homebrew-core/Formula/swi-prolog.rb
2017-11-29 20:38:23 -08:00

79 lines
2.5 KiB
Ruby

class SwiProlog < Formula
desc "ISO/Edinburgh-style Prolog interpreter"
homepage "http://www.swi-prolog.org/"
url "http://www.swi-prolog.org/download/stable/src/swipl-7.6.3.tar.gz"
sha256 "9c0be513dc98e6ca420d109f7a455a6593840682cf1b0e21876d1e71e7f35d39"
bottle do
sha256 "bda74534dcb93d046b43b88675092762a498cd85ffb101816011c2de5ca51a2b" => :high_sierra
sha256 "6549e63e9b1cd04f0d6cf935dad538d08ebf672f65fb5a72485b7476e8c4ddbd" => :sierra
sha256 "fb5391ef29bac81e9e7d75bf926c6daa270998b121f707eea42bc3743c02f7c0" => :el_capitan
end
devel do
url "http://www.swi-prolog.org/download/devel/src/swipl-7.7.4.tar.gz"
sha256 "5e4ffa8aa0565c40ca0805f6e66f51f1b4e7ad3c24729a50ac0652d11d9ffd5f"
end
head do
url "https://github.com/SWI-Prolog/swipl-devel.git"
depends_on "autoconf" => :build
end
option "with-lite", "Disable all packages"
option "with-jpl", "Enable JPL (Java Prolog Bridge)"
option "with-xpce", "Enable XPCE (Prolog Native GUI Library)"
deprecated_option "lite" => "with-lite"
depends_on "pkg-config" => :build
depends_on "readline"
depends_on "gmp"
depends_on "openssl"
depends_on "libarchive" => :optional
if build.with? "xpce"
depends_on :x11
depends_on "jpeg"
end
def install
if build.with? "libarchive"
ENV["ARPREFIX"] = Formula["libarchive"].opt_prefix
else
ENV.append "DISABLE_PKGS", "archive"
end
args = ["--prefix=#{libexec}", "--mandir=#{man}"]
ENV.append "DISABLE_PKGS", "jpl" if build.without? "jpl"
ENV.append "DISABLE_PKGS", "xpce" if build.without? "xpce"
# SWI-Prolog's Makefiles don't add CPPFLAGS to the compile command, but do
# include CIFLAGS. Setting it here. Also, they clobber CFLAGS, so including
# the Homebrew-generated CFLAGS into COFLAGS here.
ENV["CIFLAGS"] = ENV.cppflags
ENV["COFLAGS"] = ENV.cflags
# Build the packages unless --with-lite option specified
args << "--with-world" if build.without? "lite"
# './prepare' prompts the user to build documentation
# (which requires other modules). '3' is the option
# to ignore documentation.
system "echo 3 | ./prepare" if build.head?
system "./configure", *args
system "make"
system "make", "install"
bin.write_exec_script Dir["#{libexec}/bin/*"]
end
test do
(testpath/"test.pl").write <<~EOS
test :-
write('Homebrew').
EOS
assert_equal "Homebrew", shell_output("#{bin}/swipl -s #{testpath}/test.pl -g test -t halt")
end
end