# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4
# $Id: Portfile 117475 2014-02-28 12:47:32Z vince@macports.org $

PortSystem          1.0
PortGroup           wxWidgets 1.0

name                saga
categories          gis
license             GPL
version             2.1.1
#revision            3
platforms           darwin
maintainers         vince openmaintainer

description         SAGA is a GIS oriented towards statistics and analysis

long_description    SAGA is yet another open source GIS targeted towards\
                    spatial analysis and statistics. It uses wxWidgets as\
                    a GUI.

homepage            http://www.saga-gis.org/en/index.html

master_sites        http://sourceforge.net/projects/saga-gis/files/SAGA%20-%202.1/SAGA%202.1.1
distname            saga_${version}
worksrcdir          saga-${version}

#use_zip             yes

checksums           rmd160  61a74a1ac3abb2eabe184140be217fda1e83bb40 \
                    sha256  254fb0fb885ffe73aa2a024f774e05ee0fb1625d89754f70b6020a7d34bbd2fe

patchfiles          patch-saga_cmd_cpp.diff \
                    patch-configure.diff 

wxWidgets.use       wxWidgets-3.0

depends_build       port:autoconf \
                    port:automake \
                    port:libtool

depends_lib         port:${wxWidgets.port} \
                    port:geos \
                    port:gdal \
                    port:proj47 \
                    port:jasper \
                    port:fftw-3 \
                    port:unixodbc

post-patch  {
    reinplace -E "s|wx-config|${wxWidgets.wxconfig}|" ${worksrcpath}/configure

    set mkfiles [exec find ${worksrcpath} -type f -name Makefile.in]
    foreach makefile ${mkfiles} {
        reinplace -E "s|wx-config|${wxWidgets.wxconfig}|" ${makefile}
    }
}

#use_autoreconf              yes
#autoreconf.args             -i

configure.args              --disable-openmp
configure.cppflags-append   -I${prefix}/lib/proj47/include

variant python27 {
    depends_lib-append      port:python27\
                            port:swig-python
    configure.args-append   --enable-python
}

variant postgresql92 conflicts postgresql93 {
    depends_lib-append      port:postgresql92
    configure.args-append   --with-postgresql=${prefix}/lib/postgresql92/bin/pg_config
}

variant postgresql93 conflicts postgresql92 {
    depends_lib-append      port:postgresql93
    configure.args-append   --with-postgresql=${prefix}/lib/postgresql93/bin/pg_config
}


livecheck.type              regex
livecheck.url               ${master_sites}
livecheck.regex             ${name}-(\\d+(?:\\.\\d+)*)\\.tar
