# -*- 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
PortSystem		1.0

name			triangle
version			1.6
revision                7
categories		science
license			Noncommercial Copyleft
maintainers		nomaintainer
description		A Two-Dimensional Quality Mesh Generator and Delaunay Triangulator
long_description	Triangle generates exact Delaunay triangulations, \
    constrained Delaunay triangulations, conforming Delaunay \
    triangulations, Voronoi diagrams, and high-quality triangular \
    meshes. The latter can be generated with no small or large \
    angles, and are thus suitable for finite element analysis.

platforms		darwin

homepage		http://www.cs.cmu.edu/~quake/triangle.html
master_sites		http://www.netlib.org/voronoi/
distname		${name}

checksums           rmd160  12be39ae4e34fc14ef3f9982e28a242abe200307 \
                    sha256  1766327add038495fa3499e9b7cc642179229750f7201b94f8e1b7bee76f8480

use_zip			yes

extract.mkdir		yes

patchfiles-append  patch-makefile.diff

post-patch  {
    reinplace "s|__MACPORTS_CC__|${configure.cc}|g" ${worksrcpath}/makefile
    reinplace "s|__MACPORTS_PREFIX__|${prefix}|g" ${worksrcpath}/makefile
    reinplace "s|__MACPORTS_CPPFLAGS__|${configure.cppflags}|g" ${worksrcpath}/makefile
    reinplace "s|__MACPORTS_CFLAGS__|${configure.cflags} [get_canonical_archflags cc]|g" ${worksrcpath}/makefile
    reinplace "s|__MACPORTS_LDFLAGS__|${configure.ldflags} [get_canonical_archflags ld]|g" ${worksrcpath}/makefile
}

build.target trilibrary triangle

use_configure		no

variant universal {}

destroot	{
    xinstall -d ${destroot}${prefix}/share/doc/${name}
    xinstall -W ${worksrcpath} triangle ${destroot}${prefix}/bin
    if {[variant_isset showme]} {
        xinstall -W ${worksrcpath} showme ${destroot}${prefix}/bin
    }
    xinstall -d ${destroot}${prefix}/share/${name}
    # The port ncarg needs the triangle source files; see http://trac.macports.org/ticket/34706
    xinstall -m 644 -W ${worksrcpath} triangle.h triangle.c ${destroot}${prefix}/share/${name}
    xinstall -m 644 -W ${worksrcpath} README ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath} triangle.h ${destroot}${prefix}/include
    xinstall -m 755 -W ${worksrcpath} libtriangle.dylib ${destroot}${prefix}/lib
    xinstall -m 644 -W ${worksrcpath} libtriangle.a ${destroot}${prefix}/lib
}

variant showme description {Install Show Me, a display program for meshes and more} {
    depends_lib-append port:xorg-libX11
    build.target-append showme
}

livecheck.type	regex
livecheck.url	${homepage}
livecheck.regex	Version (1\.\[0-9\]+)
