# -*- 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
PortGroup           cmake 1.1
PortGroup           github 1.0

github.setup        qhull qhull 2020.2
github.tarball_from archive
revision            1

categories          math
platforms           darwin
maintainers         nomaintainer
license             Permissive

description         Programs and library for computing convex hulls.
long_description    \
    Qhull computes the convex hull, Delaunay triangulation, Voronoi \
    diagram, halfspace intersection about a point, furthest-site \
    Delaunay triangulation, and furthest-site Voronoi diagram. The \
    software runs in 2-d, 3-d, 4-d, and higher dimensions. Qhull \
    implements the Quickhull algorithm for computing the convex hull. \
    It handles roundoff errors from floating point arithmetic. Qhull \
    also computes volumes, surface areas, and approximations to the \
    convex hull.

homepage            https://www.qhull.org

checksums           rmd160  5cb0fa2126f6ce7b278ef52d1be820da72a45db4 \
                    sha256  59356b229b768e6e2b09a701448bfa222c37b797a84f87f864f97462d8dbc7c5 \
                    size    1307213

variant native description {Build with best native support for local CPU capabilities} {
    if {${os.arch} eq "arm"} {
        # M1 Support
        configure.optflags  -O3 -pipe -mcpu=apple-m1
    } else {
        # Intel
        configure.optflags  -O3 -pipe -march=native
    }
}

compiler.cxx_standard   2011

configure.args-append   -DBIN_INSTALL_DIR=${prefix}/bin \
                        -DLIB_INSTALL_DIR=${prefix}/lib \
                        -DINCLUDE_INSTALL_DIR=${prefix}/include \
                        -DDOC_INSTALL_DIR=${prefix}/share/doc/qhull \
                        -DMAN_INSTALL_DIR=${prefix}/share/man/man1

configure.cxxflags-append \
                        -std=c++11

post-destroot {
    ln -s ${prefix}/include/libqhull ${destroot}${prefix}/include/qhull
    ln -s ${prefix}/include/libqhull/libqhull.h ${destroot}${prefix}/include/libqhull/qhull.h
    ln -s ${prefix}/lib/libqhullstatic.a ${destroot}${prefix}/lib/libqhull.a
}

test.run  yes
