# $Id: Portfile 68089 2010-05-26 15:15:03Z macsforever2000@macports.org $

PortSystem 1.0

name              grass
version           6.4.0RC6
maintainers       nomaintainer
categories        gis
platforms         darwin

description       GRASS
long_description  GRASS is a Geographic Information System (GIS) used for \
                  geospatial data management and analysis.

homepage          http://grass.osgeo.org
master_sites      http://grass.osgeo.org/grass64/source/

checksums         md5     cbb98b579155f8e9864b4e98e4423568 \
                  sha1    4e82d7211ac85dbefa15ff27397d896d1955db64 \
                  rmd160  6c8a0cd56b72b11395cf97953bc74672939225f3

depends_lib       port:fftw-3 \
                  port:freetype \
                  port:gdal \
                  port:geos \
                  port:jpeg \
                  port:libpng \
                  port:openmotif \
                  port:proj \
                  port:tk \
                  port:cairo \
                  port:readline

use_parallel_build yes

patchfiles \
    patch-Makefile.diff \
    patch-configure.diff \
    patch-macosx_Makefile.diff

post-patch {
   reinplace "s|@@APPLICATIONS_DIR@@|${applications_dir}|" \
      ${worksrcpath}/configure
}

configure.ldflags-append -framework OpenGL -framework Accelerate
configure.args \
    --with-fftw-includes=${prefix}/include \
    --with-fftw-libs=${prefix}/lib \
    --with-freetype \
    --with-freetype-includes=${prefix}/include/freetype2 \
    --with-freetype-libs=${prefix}/lib \
    --with-gdal=${prefix}/bin/gdal-config \
    --with-jpeg-includes=${prefix}/include \
    --with-jpeg-libs=${prefix}/lib \
    --with-motif \
    --with-motif-includes=${prefix}/include \
    --with-motif-libs=${prefix}/lib \
    --with-png-includes=${prefix}/include \
    --with-png-libs=${prefix}/lib \
    --with-proj-includes=${prefix}/include \
    --with-proj-libs=${prefix}/lib \
    --with-proj-share=${prefix}/share/proj \
    --with-tcltk-includes=${prefix}/include \
    --with-tcltk-libs=${prefix}/lib \
    --with-cxx \
    --with-x \
    --without-postgres \
    --enable-largefile \
    --with-cairo \
    --with-cairo-includes=${prefix}/include/cairo \
    --with-cairo-libs=${prefix}/lib \
    --with-blas \
    --with-lapack \
    --with-readline \
    --with-readline-includes=${prefix}/include/readline \
    --with-readline-libs=${prefix}/lib \
    --with-regex-includes=/usr/include \
    --with-regex-lib=/usr/lib

build.target    default

# installs into /opt/local/grass-6.3.0
#destroot.violate_mtree  yes

variant mysql5 description "Install grass with mysql 5 support" {
    depends_lib-append    path:bin/mysql_config5:mysql5
    configure.args-append --with-mysql
    configure.args-append --with-mysql-includes=${prefix}/include/mysql5/mysql
    configure.args-append --with-mysql-libs=${prefix}/lib/mysql5/mysql
    configure.env-append MYSQLD_CONFIG=${prefix}/lib/mysql5/bin/mysql_config
}

variant postgresql83 description "Install grass with postgresql 8.3 support" {
    depends_lib-append    port:postgresql83
    configure.args-delete --without-postgres
    configure.args-append --with-postgres
    configure.args-append --with-postgres-includes=${prefix}/include/postgresql83
    configure.args-append --with-postgres-libs=${prefix}/lib/postgresql83
}

variant sqlite3 description "Install grass with sqlite 3 support" {
    depends_lib-append    port:sqlite3
    configure.args-append --with-sqlite
    configure.args-append --with-sqlite-includes=${prefix}/include
    configure.args-append --with-sqlite-libs=${prefix}/lib
}

variant ffmpeg description {Install grass with ffmpeg suport} {
    depends_lib-append    port:ffmpeg
    configure.args-append --with-ffmpeg \
                          --with-ffmpeg-includes=\"${prefix}/include/libavcodec  \
                                                   ${prefix}/include/libavformat \
                                                   ${prefix}/include/libswscale\" \
                          --with-ffmpeglibs=${prefix}/lib
}
