aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/swi-prolog.rb
blob: 4db103f0b8dfd340c383e01a323b7bee31969374 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
require 'formula'

class SwiProlog < Formula
  homepage 'http://www.swi-prolog.org/'
  url 'http://www.swi-prolog.org/download/stable/src/pl-6.0.2.tar.gz'
  sha256 '9dbc4d3aef399204263f168583e54468078528bff75c48c7895ae3efe5499b75'

  head 'git://www.swi-prolog.org/home/pl/git/pl.git'

  option 'lite', "Don't install any packages"
  option 'without-jpl', "Don't include JPL, the Java-Prolog Bridge"

  depends_on 'pkg-config' => :build
  depends_on 'readline'
  depends_on 'gmp'
  depends_on 'jpeg'
  depends_on 'mcrypt'
  depends_on 'gawk'
  depends_on :x11 if MacOS::X11.installed?

  # 10.5 versions of these are too old
  if MacOS.leopard?
    depends_on 'fontconfig'
    depends_on 'expat'
  end

  fails_with :llvm do
    build 2335
    cause "Exported procedure chr_translate:chr_translate_line_info/3 is not defined"
  end

  def install
    args = ["--prefix=#{prefix}", "--mandir=#{man}"]
    ENV.append 'DISABLE_PKGS', "jpl" if build.include? "without-jpl"

    unless MacOS::X11.installed?
      # SWI-Prolog requires X11 for XPCE
      opoo "It appears that X11 is not installed. The XPCE packages will not be built."
      ENV.append 'DISABLE_PKGS', "xpce"
    end

    # 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 --lite option specified
    args << "--with-world" unless build.include? "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"
  end
end