# -*- 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               apr
version            1.7.5
revision           0
categories         devel
maintainers        {geeklair.net:dluke @danielluke}
platforms          darwin
description        The apache group's portability library
license            Apache-2

long_description   The Apache Portable Runtime is a library of C data \
                   structures and routines, forming a system portability \
                   layer that covers as many operating systems as \
                   possible, including Unices, Win32, BeOS, and OS/2.

homepage           https://apr.apache.org/
master_sites       apache:apr

use_bzip2          yes
checksums          rmd160  db17ac3535cf706cc100e929e7ab81cc2a52ed38 \
                   sha256  cd0f5d52b9ab1704c72160c5ee3ed5d3d4ca2df4a7f8ab564e3cb352b67232f2 \
                   size    898264

# Xcode 3.x's gcc-4.0 generates bad code in apr's translation which can be caught by enabling
# debugging in apr, apr-util, and subversion with LANG="en_US.UTF-8"
# Assertion failed: (node->next == NULL), function put_xlate_handle_node, file subversion/libsvn_subr/utf.c, line 378.
if {[vercmp ${xcodeversion} 3.0] >= 0} {
    compiler.blacklist-append gcc-4.0
}

use_parallel_build yes
configure.ccache   no
#configure's tests don't work right for sed/gsed if we just set SED here
configure.env      ac_cv_prog_AWK=awk ac_cv_path_SED=sed lt_ECHO=/bin/echo lt_cv_path_SED=sed \
                   CC_FOR_BUILD=${configure.cc}
configure.args     --with-installbuilddir=${prefix}/share/apr-1/build \
                   --enable-nonportable-atomics \
                   ac_cv_func_setpgrp_void=no

patchfiles         apr_h_patch.diff

test.run           yes
test.target        check
test.env           DYLD_LIBRARY_PATH=${worksrcpath}/.libs
pre-test {
    use_parallel_build no
}

post-destroot {
    reinplace -E {s|-arch [a-z0-9_]+||g} \
        ${destroot}${prefix}/share/apr-1/build/apr_rules.mk \
        ${destroot}${prefix}/share/apr-1/build/libtool
    if {${configure.sdkroot} ne ""} {
        reinplace "s|-isysroot${configure.sdkroot}||g" \
            ${destroot}${prefix}/share/apr-1/build/apr_rules.mk \
            ${destroot}${prefix}/share/apr-1/build/libtool
        reinplace "s|-Wl,-syslibroot,${configure.sdkroot}||g" \
            ${destroot}${prefix}/share/apr-1/build/apr_rules.mk
    }
    reinplace {s|^CC=|CC ?= |} \
        ${destroot}${prefix}/share/apr-1/build/apr_rules.mk
    reinplace {s|^LTCC=.*|: ${LTCC:=/usr/bin/cc}|} \
        ${destroot}${prefix}/share/apr-1/build/libtool
    reinplace {s|^CC=.*|: ${CC:=/usr/bin/cc}|} \
        ${destroot}${prefix}/share/apr-1/build/libtool
}

livecheck.type     regex
livecheck.url      https://apr.apache.org
livecheck.regex    {APR (\d+(?:\.\d+)*), released}
