# -*- 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       github 1.0
PortGroup       legacysupport 1.1
PortGroup       openssl 1.0

# clock_gettime
legacysupport.newest_darwin_requires_legacy 15

github.setup    OpenPrinting cups 2.4.19 v
revision        0
categories      print devel
license         Apache-2
maintainers     nomaintainer
description     Common UNIX Printing System
long_description \
                {*}${description}

checksums       rmd160  c4179e47aec74d0378382a40c7808dbe5148731c \
                sha256  89fa632529d3e6a7cb9787ef29e39c4997be0323cc936e05cdb4c79387a35e8e \
                size    8214275
github.tarball_from archive

patchfiles      patch-kDNSServiceErr_Timeout.diff \
                patch-usb-darwin.c.diff \
                patch-client.c.diff \
                patch-environ.diff \
                patch-no-xpc.diff \
                patch-sysman.c.diff

depends_build-append \
                port:gettext \
                path:bin/pkg-config:pkgconfig

depends_lib     port:gettext-runtime \
                port:libiconv \
                port:libpaper \
                port:libusb \
                port:zlib

configure.args-append \
                --with-cups-group=cups \
                --with-cups-user=cups \
                --with-icondir=${prefix}/share/icons \
                --with-menudir=${prefix}/share/applications \
                --with-printcap=${prefix}/etc/printcap \
                --with-system-groups=wheel \
                --with-tls=openssl \
                --without-rcdir

if {${os.platform} ne "darwin" || ${os.major} < 13} {
    configure.args-append \
                --without-ondemand
}

platform darwin {
    post-patch {
        reinplace "s|/private/etc/pam\.d /etc/pam\.d|${prefix}/etc/pam\.d|" ${worksrcpath}/configure
        # Trash unsupported linker flag that breaks the build,
        # also add legacy-support linking explicitly, otherwise it fails.
        if {${os.major} < 16} {
            reinplace "s|-Wl\,-no_warn_inits|-Wl\,-lMacportsLegacySupport|" ${worksrcpath}/configure
        } else {
            reinplace "s|-Wl\,-no_warn_inits||" ${worksrcpath}/configure
        }
    }
}

# http.h:496: error: wrong number of arguments specified for ‘unavailable’ attribute
compiler.blacklist-append \
                *gcc-4.* {clang < 421}
# Just ensure we do not get C++ ABI surprises at runtime:
compiler.cxx_standard   2011
