# -*- 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
# $Id: Portfile 67050 2010-04-28 02:48:50Z macsforever2000@macports.org $

PortSystem 1.0

name                 py26-mapnik
version              0.7.1
categories           python gis

maintainers          gmail.com:dbsgeo
homepage             http://mapnik.org/
platforms            darwin

master_sites         http://download.berlios.de/mapnik/ \
                     http://download2.berlios.de/mapnik/
                     
distname             mapnik-${version}
worksrcdir           mapnik-${version}
checksums            md5     8f65fda2a792518d6f6be8a85f62fc73 \
                     sha1    a1961f6dfe5d591d5a892bef05d58e66537440c4 \
                     rmd160  9e4180e901dfaf255091843869e9441d7a08209f
use_bzip2            yes

universal_variant       no
                           
description          Open Source C++/Python mapping toolkit.
long_description \
    Mapnik is a Open Source tookit for developing mapping \
    applications. It is written in C++ and there are \
    Python bindings to facilitate fast-paced agile \
    development. It can comfortably be used for both \
    desktop and web development. \
    \
    Mapnik is about making beautiful maps. It uses the \
    AGG library and offers world class anti-aliasing \
    rendering with subpixel accuracy for geographic \
    data. It is written from scratch in modern C++ and \
    does not suffer from design decisions made a decade \
    ago. When it comes to handling common software tasks \
    such as memory management, filesystem access, \
    regular expressions, parsing and so on, Mapnik \
    does not re-invent the wheel, but utilises best of \
    breed industry standard libraries from boost.org. \

depends_lib         port:boost \
                    port:libpng \
                    port:jpeg \
                    port:tiff \
                    port:icu \
                    port:zlib \
                    port:freetype \
                    port:proj \
                    port:libxml2 \
                    port:python26 \

set python  "${prefix}/bin/python2.6"

configure.pkg_config ${prefix}/bin/pkg-config

variant cairo description {Builds port with Cairo Support} {
    configure.pkg_config_path  ${prefix}/lib/pkgconfig:${prefix}/Library/Frameworks/Python.framework/Versions/2.6/lib/pkgconfig
    depends_lib-append path:lib/pkgconfig/cairomm-1.0.pc:cairomm
    depends_lib-append port:py26-cairo
    configure.args-delete  CAIRO=False
    configure.args-append  CAIRO=True
}

variant postgis description {Builds port with PostGIS plugin} {
    depends_lib-append port:postgresql84
    depends_lib-append port:postgresql84-server
    depends_lib-append port:postgis
    configure.args-append  PG_CONFIG=${prefix}/lib/postgresql84/bin/pg_config
}

variant gdal description {Builds port with GDAL/OGR plugin} {
    depends_lib-append port:gdal
    configure.args-append  GDAL_CONFIG=${prefix}/bin/gdal-config
}

variant sqlite description {Builds port with SQLite3 plugin} {
    depends_lib-append port:sqlite3
    configure.args-append  SQLITE_INCLUDES=${prefix}/include \
                       SQLITE_LIBS=${prefix}/lib
}

use_parallel_build  yes

configure.args      PREFIX=${prefix} \
                     CAIRO=False \
                     OPTIMIZATION=3 \
                     FRAMEWORK_PYTHON=False \
                     INPUT_PLUGINS=shape,raster,ogr,postgis,gdal,sqlite \
                     PYTHON=${python} \
                     FREETYPE_CONFIG=${prefix}/bin/freetype-config \
                     XML2_CONFIG=${prefix}/bin/xml2-config \
                     BOOST_INCLUDES=${prefix}/include \
                     BOOST_LIBS=${prefix}/lib \
                     SQLITE_INCLUDES=${prefix}/include \
                     SQLITE_LIBS=${prefix}/lib \
                     ICU_INCLUDES=${prefix}/include \
                     ICU_LIBS=${prefix}/lib \
                     PNG_INCLUDES=${prefix}/include \
                     PNG_LIBS=${prefix}/lib \
                     JPEG_INCLUDES=${prefix}/include \
                     JPEG_LIBS=${prefix}/lib \
                     TIFF_INCLUDES=${prefix}/include \
                     TIFF_LIBS=${prefix}/lib \
                     PROJ_INCLUDES=${prefix}/include \
                     PROJ_LIBS=${prefix}/lib \
                     DESTDIR=${destroot}

configure {
    system "cd ${worksrcpath} && ${python} scons/scons.py ${configure.args} configure"
}

build {
    system "cd ${worksrcpath} && ${python} scons/scons.py"
}

destroot {
    system "cd ${worksrcpath} && ${python} scons/scons.py install"
}
