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

PortSystem      1.0
PortGroup       boost 1.0

version         ${boost.version}
revision        1
name            boost

license         Boost-1
categories      devel
maintainers     {michaelld @michaelld} \
                {mascguy @mascguy} \
                openmaintainer

description     Collection of portable C++ source libraries

long_description \
    Boost provides free portable peer-reviewed C++ \
    libraries. The emphasis is on portable libraries \
    which work well with the C++ Standard Library.

homepage        https://www.boost.org

distfiles
use_configure   no
build           {}
universal_variant yes
platform powerpc {
    # See https://trac.macports.org/ticket/66006
    universal_variant no
}

if {[vercmp ${boost.version} 1.87] >= 0} {
    subport ${name}-numpy {
        description           Boost.Numpy library
        long_description      {*}${description}
        depends_lib           port:${name}
        boost.require_numpy   yes
    }
}

long_description {*}${long_description} \
    This port is just a shim port, installing symbolic \
    links to the include area and libraries provided \
    by the [boost::depends_portname] port.

destroot {
    # Sym link to boost include dir.
    # Only need to do this for primary boost port
    if { ${subport} eq ${name} } {
        xinstall -d ${destroot}${prefix}/include
        ln -s [boost::include_dir]/boost ${destroot}${prefix}/include
    }
    # Sym link libraries
    xinstall -d ${destroot}${prefix}/lib
    if [file exists [boost::lib_dir]/cmake] {
        xinstall -d ${destroot}${prefix}/lib/cmake
    }
    fs-traverse -tails lib [list [boost::lib_dir]] {
        # Skip numpy lib if present for main boost port
        if { ${subport} ne ${name} || ![string match *numpy* $lib] } {
            set plib ${prefix}/lib/${lib}
            if {![file exists ${destroot}${plib}]} {
                if {![file isdirectory [boost::lib_dir]/${lib}] ||
                    [string match cmake/Boost-${version}.* ${lib}]} {
                        ln -s [boost::lib_dir]/${lib} ${destroot}${plib}
                } else {
                    xinstall -d ${destroot}${plib}
                }
            }
        }
    }
    # Readme explaining this port
    set readme  ${destroot}${prefix}/share/doc/${subport}/README
    xinstall -d [file dirname ${readme}]
    set f [open ${readme} "w"]
    puts  ${f} ${long_description}
    close ${f}
}

livecheck.type  none
