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

name                sprng
version             1.0
revision            1
categories          math
license             CC-BY-SA-4
platforms           darwin
maintainers         nomaintainer
description         Scalable Parallel Random Number Generators
long_description    ${description}

homepage            http://www.sprng.org
master_sites        http://ftp.mcs.anl.gov/pub/petsc/externalpackages

checksums           rmd160  56869960903151ca58be796713f47a73d2d426c1 \
                    sha256  a305343059fa8d42e4479e9e54a9e25e45bc3fb9094e457839fb457230da65e7

# petsc expects this to be built with mpi
mpi.setup           require

use_configure       no
use_parallel_build  no

patch.pre_args-replace  -p0 -p1
patchfiles-append   patch-makefile.diff patch-shared.diff

configure.cflags    -fPIC -Wall -Wwrite-strings -Wno-strict-aliasing -O3 -mtune=native

build.pre_args      -C SRC

post-patch {
    reinplace "s|@@PREFIX@@|${prefix}|" ${worksrcpath}/SRC/make.PETSC
    reinplace "s|@@CC@@|${configure.cc}|" ${worksrcpath}/SRC/make.PETSC
    reinplace "s|@@FC@@|${configure.fc}|" ${worksrcpath}/SRC/make.PETSC
    reinplace "s|@@CPP@@|${configure.cpp}|" ${worksrcpath}/SRC/make.PETSC
    reinplace "s|@@CFLAGS@@|${configure.cflags}|" ${worksrcpath}/SRC/make.PETSC
    reinplace "s|@@FFLAGS@@|${configure.fflags}|" ${worksrcpath}/SRC/make.PETSC
    reinplace "s|@@MPICC@@|${mpi.cc}|" ${worksrcpath}/SRC/make.PETSC
    reinplace "s|@@MPIFC@@|${mpi.fc}|" ${worksrcpath}/SRC/make.PETSC
    reinplace "s|@@SHAREDFLAGS@@|-dynamiclib -Wl,-headerpad_max_install_names,-multiply_defined,suppress,-commons,use_dylibs,-search_paths_first|" ${worksrcpath}/SRC/make.PETSC
}

destroot {
    xinstall -m 644 {*}[glob ${worksrcpath}/include/*.h] ${destroot}${prefix}/include
    xinstall -m 644 {*}[glob ${worksrcpath}/lib/*.a] ${destroot}${prefix}/lib
    xinstall -m 644 {*}[glob ${worksrcpath}/lib/*.dylib] ${destroot}${prefix}/lib
}

livecheck.type      none
