Ticket #32670: Portfile

File Portfile, 7.1 KB (added by larryv (Lawrence Velázquez), 12 years ago)
Line 
1# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2# $Id$
3
4PortSystem                  1.0
5
6name                        mapnik2
7version                     2.0.0
8categories                  gis
9platforms                   darwin
10license                     LGPL-2.1
11maintainers                 gmail.com:larry.velazquez
12description                 Open Source C++/Python mapping toolkit.
13long_description            Mapnik is a Free Toolkit for developing mapping \
14                            applications. It's written in C++ and there are \
15                            Python bindings to facilitate fast-paced agile \
16                            development. It can comfortably be used for both \
17                            desktop and web development. Mapnik2 is current \
18                            trunk and a new era of the Mapnik codebase that \
19                            uses boost features only available in boost \
20                            >=1.41, icu >=4.2, and is a testbed for \
21                            next-generation Mapnik features.
22homepage                    http://mapnik.org/
23
24conflicts                   py26-mapnik
25
26master_sites                http://cloud.github.com/downloads/mapnik/mapnik/ \
27                            http://download.berlios.de/mapnik/ \
28                            http://download2.berlios.de/mapnik/
29distname                    mapnik-${version}
30checksums                   sha1    afa49fc80ea38c7d58c940ae5b9a549ce20f5685 \
31                            rmd160  73cf94c7fb417567ee43bc9215db6e5b752a0528
32use_bzip2                   yes
33
34depends_lib-append          port:boost \
35                            port:libpng \
36                            port:jpeg \
37                            port:tiff \
38                            port:icu \
39                            port:zlib \
40                            port:freetype \
41                            port:proj \
42                            port:libxml2
43
44set python_suffixes {25 26 27}
45set python_ports {}
46foreach s ${python_suffixes} {
47    lappend python_ports python${s}
48}
49foreach s ${python_suffixes} {
50    set p python${s}
51    set v [string index ${s} 0].[string index ${s} 1]
52    set i [lsearch -exact ${python_ports} ${p}]
53    set c [lreplace ${python_ports} ${i} ${i}]
54    eval [subst {
55        variant ${p} conflicts ${c} description {Build Python bindings} {
56            depends_lib-append      port:${p}
57            configure.args-delete   BINDINGS=none
58            configure.args-append   BINDINGS=python
59            configure.args-append   PYTHON=${prefix}/bin/python${v}
60        }
61    }]
62}
63
64proc python_branch {} {
65    global python_suffixes
66    foreach s ${python_suffixes} {
67        if {[variant_isset python${s}]} { return ${s} }
68    }
69    error "Python support not enabled."
70}
71
72variant cairo description {Enable Cairo support for PDF, PostScript, and SVG} {
73    configure.args-delete   CAIRO=False
74    configure.args-append   CAIRO=True
75    depends_build-append    port:pkgconfig
76    depends_lib-append      path:lib/pkgconfig/cairomm-1.0.pc:cairomm
77    if {![catch {set s [python_branch]}]} {
78        set pf Python.framework/Versions/[string index ${s} 0].[string index ${s} 1]
79        depends_lib-append      port:py[expr {${s} == 24 ? {} : ${s}}]-cairo
80        configure.args-append   PKG_CONFIG_PATH=${frameworks_dir}/${pf}/lib/pkgconfig
81    }
82}
83
84set input_plugins {shape raster}
85
86variant geos description {Build GEOS plugin} {
87    depends_lib-append      port:geos
88    lappend input_plugins geos
89}
90
91variant gdal description {Build GDAL/OGR plugin} {
92    depends_lib-append      port:gdal
93    lappend input_plugins gdal ogr
94}
95
96variant osm description {Build OpenStreetMap plugin} {
97    depends_lib-append      port:curl
98    lappend input_plugins osm
99}
100
101variant postgis description {Build PostGIS plugin} {
102    depends_lib-append      port:postgis
103    lappend input_plugins postgis
104}
105
106variant sqlite description {Build SQLite plugin} {
107    depends_lib-append      port:sqlite3
108    lappend input_plugins sqlite
109}
110
111default_variants            +python27
112universal_variant           no
113
114configure.python            /usr/bin/python
115build.cmd                   ${configure.python} scons/scons.py
116build.pre_args
117use_parallel_build          yes
118
119configure.cmd               ${build.cmd}
120configure.pre_args          configure --help
121configure.args              CXX=${configure.cxx} \
122                            CC=${configure.cc} \
123                            PREFIX=${prefix} \
124                            DESTDIR=${destroot} \
125                            CAIRO=False \
126                            FRAMEWORK_PYTHON=False \
127                            BINDINGS=none \
128                            JOBS=${build.jobs}
129foreach lib {BOOST ICU PNG JPEG TIFF PROJ CAIRO SQLITE} {
130    configure.args-append   ${lib}_INCLUDES=${prefix}/include
131    configure.args-append   ${lib}_LIBS=${prefix}/lib
132}
133
134destroot.destdir
135
136pre-configure {
137    # Hack to check for correct boost variant
138    if {![catch {set pys [python_branch]}]} {
139        set boost_py ${prefix}/lib/libboost_python-mt.dylib
140        if {![file exists ${boost_py}]} {
141            ui_error "
142****
143**** Your current boost does not have Python support. Please reinstall
144**** boost before trying ${name} +python${pys} again:
145****
146****     sudo port install boost +python${pys}
147****
148"
149            return -code error "Boost.Python missing"
150        }
151        regexp {Python\.framework/Versions/([[:digit:]]\.[[:digit:]])} \
152          [exec /usr/bin/otool -L ${boost_py}] foo bpv
153        if {[set bps [string replace ${bpv} 1 1]] != ${pys}} {
154            if {${bps} ni ${python_suffixes}} {
155                ui_error "
156****
157**** Your current boost is incompatible with ${name} +python${pys}.
158**** Please install the boost variant that matches ${name}:
159****
160****     sudo port install boost +python${pys}
161****
162"
163                return -code error "Incompatible Boost.Python"
164            }
165            ui_error "
166****
167**** ${name} +python${pys} is incompatible with your current boost.
168**** Please install the ${name} variant that matches boost +python${bps}:
169****
170****     sudo port install ${name} +python${bps}
171****
172**** or install the boost variant that matches ${name} +python${pys}:
173****
174****     sudo port install boost +python${pys}
175****
176"
177            return -code error "Incompatible Boost.Python"
178        }
179    }
180   
181    # Must be evaluated after the variants
182    configure.args-append           INPUT_PLUGINS=[join ${input_plugins} ","]
183    if {[variant_isset postgis]} {
184        regexp {postgresql[[:digit:]]+} [glob ${prefix}/lib/postgresql*/postgis*.so] pg
185        configure.args-append       PG_CONFIG=${prefix}/lib/${pg}/bin/pg_config
186        if {[variant_isset sqlite]} {
187            configure.args-append   PGSQL2SQLITE=True
188        }
189    }
190}
191
192post-destroot {
193    set docdir ${destroot}${prefix}/share/doc/${name}
194    xinstall -d -m 755 ${docdir}/ogcserver
195    xinstall -m 644 ${worksrcpath}/docs/ogcserver/readme.txt ${docdir}/ogcserver
196    xinstall -m 644 -W ${worksrcpath} AUTHORS CHANGELOG COPYING README ${docdir}
197    xinstall -d -m 755 ${destroot}${prefix}/share/examples/${name}
198    copy ${worksrcpath}/demo ${destroot}${prefix}/share/examples/${name}
199}