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.4.1.tar.gz" sha256 "891e314e8f5d856ef71d8bbce5d255a18b0c8f227628748bb0e1e19473273cc1" bottle do sha256 "0e5128fa677354c723a15b8d82a74a28ff6585efefa0c334e64798eee4ce2964" => :sierra sha256 "2e8e2cbb8a5f109cafc0ad0e0231a91420d72c2f7a9eba5ef5f2ece66c1910c8" => :el_capitan sha256 "144c6a6415dd42759190bf00b72bee3a7c7577db7a5d08f061bfbf8e2aa184e1" => :yosemite end devel do url "http://www.swi-prolog.org/download/devel/src/swipl-7.5.2.tar.gz" sha256 "e16a5e74af16b1830d6a6f9950e56e2039b73e9dc70313603557a85d5490dafe" 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 # The archive package hard-codes a check for MacPort libarchive # Replace this with a check for Homebrew's libarchive, or nowhere if build.with? "libarchive" inreplace "packages/archive/configure.in", "/opt/local", 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.undent test :- write('Homebrew'). EOS assert_equal "Homebrew", shell_output("#{bin}/swipl -s #{testpath}/test.pl -g test -t halt") end end