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

name                lapack
if {${subport} eq ${name}} {
    PortGroup           compilers 1.0
    compilers.choose    cc fc f77 f90
    compilers.setup     require_fortran -clang

    PortGroup           cmake 1.0
    cmake.out_of_source yes
}
version             3.8.0
categories          math devel science
platforms           darwin
license             BSD
maintainers         {takeshi @tenomoto} openmaintainer
description         Linear Algebra PACKage
long_description \
    LAPACK is written in Fortran 90 and provides routines \
    for solving systems of simultaneous linear equations, \
    least-squares solutions of linear systems of equations, \
    eigenvalue problems, and singular value problems.
homepage            http://www.netlib.org/${name}/
master_sites        ${homepage}

checksums           rmd160  ff306181c4c125e7594c57c1eeece8b0aa8f8523 \
                    sha256  deb22cc4a6120bff72621155a9917f485f96ef8319ac074a7afbc68aab88bcf6

configure.cppflags-append \
                    -DADD_
# remove MACOSX_DEPLOYMENT_TARGET #53565
macosx_deployment_target
configure.args-delete \
                    -DCMAKE_INSTALL_RPATH=${prefix}/lib \
                    -DCMAKE_INSTALL_NAME_DIR=${prefix}/lib

configure.args-append \
                    -DBUILD_SHARED_LIBS=ON \
                    -DCBLAS=ON \
                    -DLAPACKE=ON \
                    -DCMAKE_INSTALL_INCLUDEDIR=${prefix}/include/${name} \
                    -DCMAKE_INSTALL_LIBDIR=${prefix}/lib/${name} \
                    -DCMAKE_INSTALL_RPATH=${prefix}/lib/${name} \
                    -DCMAKE_INSTALL_NAME_DIR=${prefix}/lib/${name}

if {${subport} eq ${name}} {
    variant accelerate description {use BLAS in Accelerate.framework} {
        depends_lib-append          port:vecLibFort
        configure.args-append       -DUSE_OPTIMIZED_BLAS=ON
        configure.ldflags-append    -lvecLibFort
    }
}

notes "C headers are installed in ${prefix}/include/${name}."

subport ${name}-manpages {
    supported_archs     noarch
    description         LAPACK manpages
    long_description    ${description}

    depends_build       bin:doxygen:doxygen

    use_configure       no
    build.cmd           doxygen
    build.target        DOCS/Doxyfile_man

    destroot            {
        foreach f [glob ${worksrcpath}/DOCS/man/man3/*] {
            xinstall -m 444 ${f} ${destroot}${prefix}/share/man/man3
        }
    }
}