@@ -26,21 +26,46 @@ class Cafeobj < Formula
2626 sha256 x86_64_linux : "779108ed08023bc358ac5276e28d7d7f0f4febc0dc99ea67ef04da3ac8d56ae2"
2727 end
2828
29- depends_on "sbcl"
29+ depends_on "sbcl" => :build
3030 depends_on "zstd"
3131
32+ # Does not build with SBCL 2.5: https://github.com/CafeOBJ/cafeobj/issues/8
33+ resource "sbcl" do
34+ url "https://downloads.sourceforge.net/project/sbcl/sbcl/2.4.11/sbcl-2.4.11-source.tar.bz2"
35+ sha256 "4f03e5846f35834c10700bbe232da41ba4bdbf81bdccacb1d4de24297657a415"
36+ end
37+
3238 def install
39+ resource ( "sbcl" ) . stage do
40+ ENV [ "SBCL_MACOSX_VERSION_MIN" ] = MacOS . version . to_s if OS . mac?
41+ system "sh" , "make.sh" , "--prefix=#{ buildpath } /sbcl" , "--with-sb-core-compression" , "--with-sb-thread"
42+ system "sh" , "install.sh"
43+ ENV . prepend_path "PATH" , buildpath /"sbcl/bin"
44+ end
45+
3346 # Exclude unrecognized options
3447 args = std_configure_args . reject { |s | s [ "--disable-debug" ] || s [ "--disable-dependency-tracking" ] }
3548
36- system "./configure" , "--with-lisp=sbcl" , "--with-lispdir=#{ share } /emacs/site-lisp/cafeobj " , *args
49+ system "./configure" , "--with-lisp=sbcl" , "--with-lispdir=#{ elisp } " , *args
3750 system "make" , "install"
51+
52+ # Work around patchelf corrupting the SBCL core which is appended to binary
53+ # TODO: Find a better way to handle this in brew, either automatically or via DSL
54+ if OS . linux? && build . bottle? && build . stable?
55+ cp lib /"cafeobj-#{ version . major_minor } /sbcl/cafeobj.sbcl" , prefix
56+ Utils ::Gzip . compress ( prefix /"cafeobj.sbcl" )
57+ end
3858 end
3959
40- test do
41- # Fails in Linux CI with "Can't find sbcl.core"
42- return if OS . linux? && ENV [ "HOMEBREW_GITHUB_ACTIONS" ]
60+ def post_install
61+ if ( prefix /"cafeobj.sbcl.gz" ) . exist?
62+ system "gunzip" , prefix /"cafeobj.sbcl.gz"
63+ ( prefix /"cafeobj.sbcl" ) . chmod ( lib /"cafeobj-#{ version . major_minor } /sbcl/cafeobj.sbcl" ) . lstat . mode
64+ ( lib /"cafeobj-#{ version . major_minor } /sbcl" ) . install prefix /"cafeobj.sbcl"
65+ end
66+ end
4367
68+ test do
4469 system bin /"cafeobj" , "-batch"
4570 end
4671end
0 commit comments