aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/mapserver.rb
blob: 140bc91b707d8997cbf1f638196cdc0437513ee8 (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
60
61
62
63
64
65
66
67
68
69
require 'formula'

class Mapserver < Formula
  url 'http://download.osgeo.org/mapserver/mapserver-6.0.1.tar.gz'
  homepage 'http://mapserver.org/'
  md5 'b96287449dcbca9a2fcea3a64905915a'

  depends_on 'gd'
  depends_on 'proj'
  depends_on 'gdal'

  depends_on 'geos' if ARGV.include? '--with-geos'
  depends_on 'postgresql' if ARGV.include? '--with-postgresql' and not MacOS.lion?

  def options
    [
      ["--with-geos", "Build support for GEOS spatial operations"],
      ["--with-php", "Build PHP MapScript module"],
      ["--with-postgresql", "Build support for PostgreSQL as a data source"]
    ]
  end

  def configure_args
    args = [
      "--prefix=#{prefix}",
      "--with-proj",
      "--with-gdal",
      "--with-ogr",
      "--with-png=/usr/X11"
    ]

    args.push "--with-geos" if ARGV.include? '--with-geos'
    args.push "--with-php=/usr/include/php" if ARGV.include? '--with-php'

    if ARGV.include? '--with-postgresql'
      if MacOS.lion? # Lion ships with PostgreSQL libs
        args.push "--with-postgis"
      else
        args.push "--with-postgis=#{HOMEBREW_PREFIX}/bin/pg_config"
      end
    end

    args
  end

  def install
    ENV.x11
    system "./configure", *configure_args
    system "make"
    bin.install %w(mapserv shp2img legend shptree shptreevis
        shptreetst scalebar sortshp mapscriptvars tile4ms
        msencrypt mapserver-config)

    if ARGV.include? '--with-php'
      prefix.install %w(mapscript/php/php_mapscript.so)
    end
  end

  def caveats; <<-EOS.undent
    The Mapserver CGI executable is #{prefix}/mapserv

    If you built the PHP option:
      * Add the following line to php.ini:
        extension="#{prefix}/php_mapscript.so"
      * Execute "php -m"
      * You should see MapScript in the module list
    EOS
  end
end