# $Id: Portfile 45610 2009-01-18 22:00:27Z blb@macports.org $

PortSystem 1.0

name              grass
version           6.3.0
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/grass63/source/

checksums         md5 7dce50a076e2481733148ba34cbebc07

depends_lib       port:fftw \
                  port:freetype \
                  port:gdal \
                  port:geos \
                  port:jpeg \
                  port:libpng \
                  port:openmotif \
                  port:proj \
                  port:tk

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 -framework OpenGL
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
#    --enable-macosx-app

#--with-glw \
#--with-glw-includes=/Developer/SDKs/MacOSX10.5.sdk/usr/X11/include \
#--with-glw-libs=/Developer/SDKs/MacOSX10.5.sdk/usr/X11/lib
#-Wl,-dylib_file,/Developer/SDKs/MacOSX10.5.sdk/usr/X11/lib/libGLw.dylib:\
#                /Developer/SDKs/MacOSX10.5.sdk/usr/X11/lib/libGLw.dylib

platform darwin 9 {
configure.ldflags-append \
    -Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:\
    /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib
}
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    port: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
}

