# -*- 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 119779 2014-05-06 18:51:19Z pixilla@macports.org $

PortSystem          1.0

name                terra
version             0.7
revision            1

categories          gis science
maintainers         gmail.com:tlockhart1976 openmaintainer

description         Generate polygonal approximations of terrains and other height fields.

long_description \
Generate polygonal approximations of terrains and other height fields. \
Terra is based on algorithms described in: \
Fast Polygonal Approximation of Terrains and Height Fields \
by Michael Garland and Paul Heckbert (Technical Report CMU-CS-95-181).

license             Public Domain
platforms           darwin

homepage            http://mgarland.org/software/scape.html
master_sites        http://mgarland.org/dist/

checksums           rmd160  885639282ffe5244f5289ef3f453390c8acdb30f \
                    sha256  22470e13e1f0659d23dbf7e0ecbfd8f6490bcd1d0a953537c1dfec18f4df3bd7

depends_lib         port:freeglut

worksrcdir          ${name}
patch.pre_args      -p1
patchfiles          patch-compiler.diff patch-opengl.diff

post-patch {
    reinplace -E "s,@CC@,${configure.cc},g" ${worksrcpath}/Makefile
    reinplace -E "s,@CXX@,${configure.cxx},g" ${worksrcpath}/Makefile
    reinplace -E "s,@OPTFLAGS@,${configure.optflags},g" ${worksrcpath}/Makefile
    reinplace -E "s,@PREFIX@,${prefix},g" ${worksrcpath}/Makefile
}

use_configure       no

destroot {
    xinstall -m 755 ${worksrcpath}/terra ${destroot}${prefix}/bin/terra
    xinstall -m 755 ${worksrcpath}/xterra ${destroot}${prefix}/bin/xterra

    # documentation
    xinstall -m 755 -d ${destroot}${prefix}/share/${name}
    xinstall -m 644 ${worksrcpath}/README.html ${destroot}${prefix}/share/${name}
    xinstall -m 644 ${worksrcpath}/crater.pgm ${destroot}${prefix}/share/${name}
}
