# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4
# $Id: Portfile 110713 2013-09-04 14:24:51Z jmr@macports.org $

PortSystem          1.0

name                msieve
version             1.51
categories          math
license             public-domain Apache-2 zlib BSD
maintainers         nomaintainer
description         A library for factoring large integers
long_description    ${description}

platforms           darwin

homepage            http://www.boo.net/~jasonp/qs.html
master_sites        sourceforge:project/msieve/msieve/Msieve%20v${version}
distname            ${name}[strsed ${version} {g/\.//}]
worksrcdir          ${name}-${version}

checksums           sha1    91288b1b016938a4167f83b012deaaf773f1ea99 \
                    rmd160  cca48291f5e439b469989c4ad2631a09a3c067bb

depends_lib         port:gmp

patchfiles          patch-Makefile.diff

post-patch {
    reinplace "s|@CC@|${configure.cc}|g" ${worksrcpath}/Makefile
    reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/Makefile
}

use_configure       no

build.env           CFLAGS="${configure.cflags}" \
                    CPATH="${compiler.cpath}" \
                    LIBRARY_PATH="${compiler.library_path}" \
                    MACHINE_FLAGS="${configure.cc_archflags}"

destroot {
    xinstall -m 755 -d ${destroot}${prefix}/include/msieve \
        ${destroot}${prefix}/share/doc/${name} \
        ${destroot}${prefix}/share/${name}/demo
    xinstall -m 755 ${worksrcpath}/msieve ${destroot}${prefix}/bin
    eval xinstall -m 644 [glob ${worksrcpath}/libmsieve.*] ${destroot}${prefix}/lib
    ln -s ${prefix}/lib/libsieve.${version}.dylib ${destroot}${prefix}/lib/libsieve.1.dylib
    ln -s ${prefix}/lib/libsieve.${version}.dylib ${destroot}${prefix}/lib/libsieve.dylib
    eval xinstall -m 644 [glob ${worksrcpath}/include/*] \
        ${destroot}${prefix}/include/msieve
    xinstall -m 644 -W ${worksrcpath} Readme Readme.qs Readme.nfs \
        ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath} demo.c \
        ${destroot}${prefix}/share/${name}/demo
}

livecheck.type      regex
livecheck.url       http://sourceforge.net/projects/${name}/files/
livecheck.regex     {Msieve v([0-9.]+)}
