# -*- 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           compilers 1.0
PortGroup           linear_algebra 1.0

cvs.date   	        20160908

name                LORENE
version	            0.0.0~cvs${cvs.date}
revision            6

categories          science
maintainers         {thibaut @paumard} openmaintainer
description         Langage Objet pour la RElativité NumériquE
long_description    LORENE is a set of C++ classes to solve various problems \
                    arising in numerical relativity, and more generally in \
                    computational astrophysics. It provides tools to solve \
                    partial differential equations by means of multi-domain \
                    spectral methods.

license             gpl-2+
platforms           darwin

homepage            http://www.lorene.obspm.fr/
master_sites        https://people.debian.org/~thibaut/debian/pool/main/l/lorene/
distname            lorene
distfiles           ${distname}_${version}+dfsg.orig.tar.xz
use_xz              yes
checksums           rmd160  36346f8d7a50acee20a5b81051af2e7fe5f188c1 \
                    sha256  ef797abc51ed8ae27c200f5b71fd0a3824d1fa310392dac57067de2e423222ed
worksrcdir          ${distname}-${version}+dfsg

depends_lib         port:gsl \
                    port:fftw-3 \
                    port:pgplot

compilers.choose    cxx f77
compilers.setup     require_fortran
universal_variant   no

configure {
    file copy ${filespath}/local_settings ${worksrcpath}/
    reinplace -W ${worksrcpath} "s|@CXX@|${configure.cxx}|g" local_settings
    reinplace -W ${worksrcpath} "s|@F77@|${configure.f77}|g" local_settings
    reinplace -W ${worksrcpath} "s|@CXXFLAGS@|${configure.cxxflags}|g" local_settings
    reinplace -W ${worksrcpath} "s|@CXX_ARCHFLAGS@|${configure.cxx_archflags}|g" local_settings
    reinplace -W ${worksrcpath} "s|@FFLAGS@|${configure.fflags}|g" local_settings
    reinplace -W ${worksrcpath} "s|@F90_ARCHFLAGS@|${configure.f90_archflags}|g" local_settings
    reinplace -W ${worksrcpath} "s|@LDFLAGS@|${configure.ldflags}|g" local_settings
    reinplace -W ${worksrcpath} "s|@LIB_FORTRAN@|${compilers.libfortran}|g" local_settings
    reinplace -W ${worksrcpath} "s|@LIB_LAPACK@|${linalglib}|g" local_settings
}

build.env-append    HOME_LORENE=${worksrcpath}
build.target        cpp fortran export
use_parallel_build  no

destroot {
    xinstall -d ${destroot}${prefix}/lib/lorene/Lib
    xinstall {*}[glob ${worksrcpath}/Lib/*.a] ${destroot}${prefix}/lib/lorene/Lib/
    xinstall -d ${destroot}${prefix}/lib/lorene/C++/Include
    xinstall {*}[glob ${worksrcpath}/C++/Include/*.h] ${destroot}${prefix}/lib/lorene/C++/Include/
    xinstall -d ${destroot}${prefix}/lib/lorene/C++/Include/Template
    xinstall {*}[glob ${worksrcpath}/C++/Include/Template/*] ${destroot}${prefix}/lib/lorene/C++/Include/Template/
    xinstall ${worksrcpath}/local_settings ${destroot}${prefix}/lib/lorene/
    xinstall -d ${destroot}${prefix}/lib/lorene/Devel
    xinstall {*}[glob ${worksrcpath}/Devel/*] ${destroot}${prefix}/lib/lorene/Devel/
    copy ${worksrcpath}/Codes ${destroot}${prefix}/lib/lorene/
}

notes "
+--- LORENE Usage note -----------------------------------------------------
| To compile LORENE code, you should run:
|   export HOME_LORENE=${prefix}/lib/lorene
| Codes are provided in \$HOME_LORENE/Codes. To use them, copy them to some
| place were your have write access.
+---------------------------------------------------------------------------
"