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

legacysupport.newest_darwin_requires_legacy     13

name                skalibs
version             2.15.0.0
revision            1
categories          devel
license             ISC
maintainers         nomaintainer
description         general-purpose libraries for C system programming

long_description \
    skalibs is a package centralizing the free software / open source \
    C development files used for building all software at skarnet.org: \
    it contains essentially general-purpose libraries. skalibs can \
    also be used as a sound basic start for C development. There are a \
    lot of general-purpose libraries out there\; but if your main goal \
    is to produce small and secure C code with a focus on system \
    programming, skalibs might be for you.

homepage            https://skarnet.org/software/skalibs/
master_sites        ${homepage}

checksums           rmd160  a8b4e44e2c3680551b1884b2613c6b55967d3cf8 \
                    sha256  7fde96e8afb4191593a15328883e9c7726c96891cf071222146821e8c87f8007 \
                    size    267454

depends_build-append \
                    port:pkgconfig

configure.args-append \
                    --enable-pkgconfig

post-destroot {
    # The upstream install script sets umask 077 before creating
    # symlinks, producing lrwx------ permissions that cause other
    # build systems (e.g. CMake's file(READ_SYMLINK)) to fail.
    # Recreate all library symlinks with correct permissions.
    foreach f [glob -nocomplain -type l ${destroot}${prefix}/lib/lib*.dylib] {
        set target [file readlink ${f}]
        file delete ${f}
        file link -symbolic ${f} ${target}
    }

    set docdir ${prefix}/share/doc/${name}
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} \
        AUTHORS \
        COPYING \
        NEWS \
        README \
        ${destroot}${docdir}
    xinstall -m 0644 {*}[glob ${worksrcpath}/doc/*.html] \
        ${destroot}${docdir}
    xinstall -d ${destroot}${docdir}/libdatastruct
    xinstall -m 0644 {*}[glob ${worksrcpath}/doc/libdatastruct/*.html] \
        ${destroot}${docdir}/libdatastruct
    xinstall -d ${destroot}${docdir}/libposixplz
    xinstall -m 0644 {*}[glob ${worksrcpath}/doc/libposixplz/*.html] \
        ${destroot}${docdir}/libposixplz
    xinstall -d ${destroot}${docdir}/librandom
    xinstall -m 0644 {*}[glob ${worksrcpath}/doc/librandom/*.html] \
        ${destroot}${docdir}/librandom
    xinstall -d ${destroot}${docdir}/libstdcrypto
    xinstall -m 0644 {*}[glob ${worksrcpath}/doc/libstdcrypto/*.html] \
        ${destroot}${docdir}/libstdcrypto
    xinstall -d ${destroot}${docdir}/libstddjb
    xinstall -m 0644 {*}[glob ${worksrcpath}/doc/libstddjb/*.html] \
        ${destroot}${docdir}/libstddjb
    xinstall -d ${destroot}${docdir}/libunixonacid
    xinstall -m 0644 {*}[glob ${worksrcpath}/doc/libunixonacid/*.html] \
        ${destroot}${docdir}/libunixonacid
}
