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

name                    dsfmt
github.setup            MersenneTwister-Lab dSFMT 2.2.5 v
revision                0
categories              devel math
license                 BSD
maintainers             {mcalhoun @MarcusCalhoun-Lopez} openmaintainer
description             (d)SFMT is a new variant of Mersenne Twister (MT)
long_description        SFMT is a new variant of Mersenne Twister (MT). \
                        The purpose of dSFMT is to speed up the generation \
                        by avoiding the expensive conversion of integer \
                        to double (floating point).

homepage                http://www.math.sci.hiroshima-u.ac.jp/m-mat/MT/SFMT/

checksums               rmd160  1c5df9bb2d3dfe3045148ac9e901bffcab15f8d7 \
                        sha256  b7bc498cd140b4808963b1ff9f33b42a491870f54775c1060ecad0e02bcaffb4 \
                        size    4984272
github.tarball_from     archive

use_configure           no
variant universal       {}

configure.cppflags-append \
                       -DDSFMT_MEXP=19937 \
                       -DDSFMT_DO_NOT_USE_OLD_NAMES \
                       -DNDEBUG

# from Makefile
configure.optflags-replace \
                       -Os \
                       -O3
configure.cflags-append \
                       -finline-functions \
                       -fomit-frame-pointer \
                       -fno-strict-aliasing

if {${build_arch} eq "i386" || ${build_arch} eq "x86_64"} {
    supported_archs    i386 x86_64
    configure.cflags-append \
                       -msse2
} else {
    supported_archs    ppc ppc64
    configure.cflags-append \
                       -faltivec
}

build.cmd              ${configure.cc}
build.args             -dynamiclib \
                       -current_version ${version} \
                       -compatibility_version [join [lrange [split ${version} .] 0 0] .]\
                       -install_name ${prefix}/lib/libdSFMT.2.dylib \
                       ${configure.cppflags} \
                       ${configure.cflags} \
                       ${configure.ldflags} \
                       [get_canonical_archflags cc] \
                       dSFMT.c
build.target           -o libdSFMT.2.dylib

destroot {
    xinstall -m 0755    ${worksrcpath}/libdSFMT.2.dylib ${destroot}${prefix}/lib
    xinstall -m 0644    ${worksrcpath}/dSFMT.h          ${destroot}${prefix}/include
    ln       -s         libdSFMT.2.dylib                ${destroot}${prefix}/lib/libdSFMT.dylib
}

livecheck.regex         {dSFMT-src-(\d+(?:\.\d+)*)}
