diff --git a/Formula/guile-config.rb b/Formula/guile-config.rb new file mode 100644 index 0000000..3c5c6c8 --- /dev/null +++ b/Formula/guile-config.rb @@ -0,0 +1,48 @@ +class GuileConfig < Formula + desc "Module for handling application configuration in a declarative way" + homepage "https://gitlab.com/a-sassmannshausen/guile-config/" + url "https://gitlab.com/api/v4/projects/7016362/repository/archive?sha=8a4f6442ac42084b00713dde3181c3538d52edbf" + sha256 "6e5099475e23dcab4253f8c59b113c1cf0cb250fb9709582af7a5b2902999698" + version "main" + + depends_on "autoconf" => :build + depends_on "automake" => :build + depends_on "pkg-config" => :build + depends_on "texinfo" => :build + depends_on "guile-next" + + def install + ENV["GUILE_AUTO_COMPILE"] = "0" + # We need this so we can find other modules. + ENV["GUILE_LOAD_PATH"] = HOMEBREW_PREFIX/"share/guile/site/3.0" + ENV["GUILE_LOAD_COMPILED_PATH"] = HOMEBREW_PREFIX/"lib/guile/3.0/site-ccache" + ENV["GUILE_SYSTEM_EXTENSIONS_PATH"] = HOMEBREW_PREFIX/"lib/guile/3.0/extensions" + + system "autoreconf", "-vif" + system "./configure", "--prefix=#{prefix}" + system "make", "install" + end + + def caveats + <<~EOS + Remember to add the following to your .bashrc or equivalent in order to use this module: + export GUILE_LOAD_PATH="#{HOMEBREW_PREFIX}/share/guile/site/3.0" + export GUILE_LOAD_COMPILED_PATH="#{HOMEBREW_PREFIX}/lib/guile/3.0/site-ccache" + export GUILE_SYSTEM_EXTENSIONS_PATH="#{HOMEBREW_PREFIX}/lib/guile/3.0/extensions" + EOS + end + + test do + config = testpath/"config.scm" + config.write <<~EOS + (use-modules (config)) + EOS + + ENV["GUILE_AUTO_COMPILE"] = "0" + ENV["GUILE_LOAD_PATH"] = HOMEBREW_PREFIX/"share/guile/site/3.0" + ENV["GUILE_LOAD_COMPILED_PATH"] = HOMEBREW_PREFIX/"lib/guile/3.0/site-ccache" + ENV["GUILE_SYSTEM_EXTENSIONS_PATH"] = HOMEBREW_PREFIX/"lib/guile/3.0/extensions" + + system "guile", config + end +end diff --git a/Formula/guile-hall.rb b/Formula/guile-hall.rb index 0e8bba0..66e7a53 100644 --- a/Formula/guile-hall.rb +++ b/Formula/guile-hall.rb @@ -3,12 +3,12 @@ class GuileHall < Formula homepage "https://gitlab.com/a-sassmannshausen/guile-hall/" url "https://gitlab.com/api/v4/projects/7016408/repository/archive?sha=cc0c9016220de42084f9b61f7353edeb62dbff82" sha256 "997331e60cd009be93fd7d6d3dacaa4eec87499cd6345ee14602ae323318ae62" - + depends_on "autoconf" => :build depends_on "automake" => :build depends_on "pkg-config" => :build depends_on "texinfo" => :build - depends_on "guile" + depends_on "guile-next" depends_on "guile-lib" depends_on "guile-config" diff --git a/Formula/guile-next.rb b/Formula/guile-next.rb new file mode 100644 index 0000000..7d62228 --- /dev/null +++ b/Formula/guile-next.rb @@ -0,0 +1,94 @@ +class GuileNext < Formula + desc "GNU Ubiquitous Intelligent Language for Extensions" + homepage "https://www.gnu.org/software/guile/" + url "https://git.savannah.gnu.org/git/guile.git", revision: "bce91cebedda016b479972655c680acc6706e539" + version "3.0.10" + license "LGPL-3.0-or-later" + # Credit goes to aconchillo + + depends_on "autoconf" => :build + depends_on "automake" => :build + depends_on "gettext" => :build + depends_on "gnu-sed" => :build + depends_on "bdw-gc" + depends_on "gmp" + depends_on "libtool" + depends_on "libunistring" + depends_on "pkg-config" # guile-config is a wrapper around pkg-config. + depends_on "readline" + + uses_from_macos "flex" => :build + uses_from_macos "gperf" + uses_from_macos "libffi", since: :catalina + uses_from_macos "libxcrypt" + + on_system :linux, macos: :ventura_or_newer do + depends_on "texinfo" => :build + end + + def install + # Avoid superenv shim + inreplace "meta/guile-config.in", "@PKG_CONFIG@", Formula["pkg-config"].opt_bin/"pkg-config" + + system "./autogen.sh" + + system "./configure", *std_configure_args, + "--with-libreadline-prefix=#{Formula["readline"].opt_prefix}", + "--with-libgmp-prefix=#{Formula["gmp"].opt_prefix}", + "--disable-nls" + system "make", "install" + + # A really messed up workaround required on macOS --mkhl + Pathname.glob("#{lib}/*.dylib") do |dylib| + lib.install_symlink dylib.basename => "#{dylib.basename(".dylib")}.so" + end + + # This is either a solid argument for guile including options for + # --with-xyz-prefix= for libffi and bdw-gc or a solid argument for + # Homebrew automatically removing Cellar paths from .pc files in favour + # of opt_prefix usage everywhere. + inreplace lib/"pkgconfig/guile-3.0.pc" do |s| + s.gsub! Formula["bdw-gc"].prefix.realpath, Formula["bdw-gc"].opt_prefix + s.gsub! Formula["libffi"].prefix.realpath, Formula["libffi"].opt_prefix if !OS.mac? || MacOS.version < :catalina + end + + (share/"gdb/auto-load").install Dir["#{lib}/*-gdb.scm"] + end + + def post_install + # Create directories so installed modules can create links inside. + (HOMEBREW_PREFIX/"lib/guile/3.0/site-ccache").mkpath + (HOMEBREW_PREFIX/"lib/guile/3.0/extensions").mkpath + (HOMEBREW_PREFIX/"share/guile/site/3.0").mkpath + end + + def caveats + <<~EOS + To use `guile-next` you need to unlink `guile` and then link `guile-next`: + brew unlink guile + brew link guile-next + + Guile libraries can now be installed here: + Source files: #{HOMEBREW_PREFIX}/share/guile/site/3.0 + Compiled files: #{HOMEBREW_PREFIX}/lib/guile/3.0/site-ccache + Extensions: #{HOMEBREW_PREFIX}/lib/guile/3.0/extensions + + Add the following to your .bashrc or equivalent: + export GUILE_LOAD_PATH="#{HOMEBREW_PREFIX}/share/guile/site/3.0" + export GUILE_LOAD_COMPILED_PATH="#{HOMEBREW_PREFIX}/lib/guile/3.0/site-ccache" + export GUILE_SYSTEM_EXTENSIONS_PATH="#{HOMEBREW_PREFIX}/lib/guile/3.0/extensions" + EOS + end + + test do + hello = testpath/"hello.scm" + hello.write <<~EOS + (display "Hello World") + (newline) + EOS + + ENV["GUILE_AUTO_COMPILE"] = "0" + + system bin/"guile", hello + end +end