# -*- 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        Kazade kazmath 48dbc191da47880ea6708b0a7b3c7b69b6352cad
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
version             2020.06.14
revision            0
categories          devel math
license             BSD
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
description         C math library targeted at games
long_description    {*}${description}
checksums           rmd160  593c326a7460e02d1717b7720cf1f54ad29785b4 \
                    sha256  9e619025fca642c858c1d87be22e32c224c2960f1c39a34566ecafd4c7069bfb \
                    size    733408

# Upstream uses it: https://github.com/Kazade/kazmath/commit/a71a7386588ea351cfece44c47adc1c9146c335a
set py_ver          2.7
set py_ver_nodot    [string map {. {}} ${py_ver}]
depends_build-append \
                    port:python${py_ver_nodot}
depends_test-append port:python${py_ver_nodot}

post-patch {
    reinplace "s,/usr/bin/env python2,${configure.python}," ${worksrcpath}/bin/kaztest_gen
}

configure.python    ${prefix}/bin/python${py_ver}

configure.args-append \
                    -DBUILD_SHARED_LIBS=ON \
                    -DKAZMATH_BUILD_TESTS=ON \
                    -DKAZMATH_BUILD_GL_UTILS=ON \
                    -DKAZMATH_BUILD_JNI_WRAPPER=OFF \
                    -DKAZMATH_BUILD_LUA_WRAPPER=OFF

compiler.c_standard     1999
compiler.cxx_standard   2011

pre-test {
    system -W ${cmake.build_dir}/tests "install_name_tool -change ${prefix}/lib/libkazmath.1.dylib ${cmake.build_dir}/kazmath/libkazmath.1.dylib ./kazmath_tests"
}

# On PPC test.run will fail. In fact, due to a single test out of 38: https://github.com/Kazade/kazmath/issues/59
test.run            yes
