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

github.setup        libtom libtommath 1.3.0 v
revision            0
categories          math
maintainers         nomaintainer
license             public-domain

description         Comprehensive, modular and portable mathematical routines
long_description \
    LibTomMath provides highly optimized and portable routines \
    for a vast majority of integer based number theoretic \
    applications (including public key cryptography).
homepage            http://www.libtom.net/LibTomMath/

distname            ltm-${version}
github.tarball_from releases
use_xz              yes

checksums           rmd160  cffb19604cf2746b26b98d97af1dd865c02f0cf1 \
                    sha256  296272d93435991308eb73607600c034b558807a07e829e751142e65ccfa9d08 \
                    size    642776

patchfiles          patch-makefile.diff \
                    patch-makefile_include.mk.diff \
                    patch-pr-476.diff

worksrcdir          ${name}-${version}

use_configure       no

variant universal {}

build.args          LIBPATH=${prefix}/lib \
                    CC="${configure.cc} [get_canonical_archflags cc]"

# Disable silent rules.
build.args-append   V=1

# makefile:112: *** missing separator.  Stop.
platform darwin 8 {
    depends_build-append port:gmake
    build.cmd       ${prefix}/bin/gmake
}

destroot {
    xinstall -m 755 -d ${destroot}${prefix}/include/${name}
    xinstall -m 644 -W ${worksrcpath} tommath.h tommath_class.h \
        tommath_superclass.h ${destroot}${prefix}/include/${name}
    xinstall -m 644 -W ${worksrcpath} libtommath.a libtommath.${version}.dylib \
        ${destroot}${prefix}/lib
    ln -s libtommath.${version}.dylib ${destroot}${prefix}/lib/libtommath.0.dylib
    ln -s libtommath.${version}.dylib ${destroot}${prefix}/lib/libtommath.dylib
    copy ${worksrcpath}/libtommath.pc.in ${worksrcpath}/libtommath.pc
    reinplace -W ${worksrcpath} -- "s,^prefix=.*,prefix=${prefix}," libtommath.pc
    reinplace -W ${worksrcpath} -- "s,^includedir=.*,&/${name}," libtommath.pc
    reinplace -W ${worksrcpath} -- "s,^Version:.*,Version: ${version}," libtommath.pc
    xinstall -m 755 -d ${destroot}${prefix}/lib/pkgconfig
    xinstall -m 644 -W ${worksrcpath} libtommath.pc ${destroot}${prefix}/lib/pkgconfig

    set docdir ${destroot}${prefix}/share/doc/${name}
    xinstall -d ${docdir}
    xinstall -m 644 -W ${worksrcpath} \
        LICENSE \
        changes.txt \
        ${docdir}
}

livecheck.type      regex
livecheck.url       http://www.libtom.net/
livecheck.regex     ltm-(\[0-9.\]+)${extract.suffix}
