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

name                pcre
if {${subport} eq ${name}} {
    version         8.45
    revision        0
}
subport pcre2 {
    PortGroup       github 1.0

    github.setup    PCRE2Project pcre2 10.47 pcre2-
    github.tarball_from releases
    revision        0

    if {${configure.build_arch} in "i386 x86_64"} {
        compiler.blacklist-append {*gcc-[3-4].*}
    }

    github.livecheck.regex  {([0-9.]+)}
}
categories          devel
license             BSD
platforms           darwin freebsd
maintainers         {larryv @larryv}

description         Perl Compatible Regular Expressions
long_description    The PCRE library is a set of functions that \
                    implement regular expression pattern matching \
                    using the same syntax and semantics as Perl 5. \
                    PCRE has its own native API, as well as a set of \
                    wrapper functions that correspond to the POSIX \
                    regular expression API.
homepage            https://www.pcre.org

depends_lib         port:bzip2 \
                    port:libedit \
                    port:zlib

master_sites-append sourceforge:project/pcre/${subport}/${version} \
                    ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre \
                    ftp://ftp.fu-berlin.de/unix/misc/pcre \
                    ftp://ftp.tin.org/pub/libs/pcre
distname            ${subport}-${version}
use_bzip2           yes

set rmd160(pcre)    9792fbed380a39be36674e74839b9a2a6a4ce65a
set sha256(pcre)    4dae6fdcd2bb0bb6c37b5f97c33c2be954da743985369cddac3546e3218bffb8
set size(pcre)      1578809
set rmd160(pcre2)   5a1ef68e1844961bebca667ae008f3b44eb0c434
set sha256(pcre2)   47fe8c99461250d42f89e6e8fdaeba9da057855d06eb7fc08d9ca03fd08d7bc7
set size(pcre2)     2145789
checksums           rmd160  $rmd160(${subport}) \
                    sha256  $sha256(${subport}) \
                    size    $size(${subport})

configure.args      --disable-silent-rules \
                    --docdir=${prefix}/share/doc/${subport} \
                    --enable-[regsub {\d$} ${subport} &-]16 \
                    --enable-[regsub {\d$} ${subport} &-]32 \
                    --enable-${subport}grep-libbz2 \
                    --enable-${subport}grep-libz \
                    --enable-${subport}test-libedit

variant universal {}
configure.args-append --enable-jit

subport pcre {
    PortGroup clang_dependency 1.0

    patchfiles-append   single_module.patch

    configure.args-append --enable-unicode-properties
}

platform darwin 8 {
    # ticket #18448
    if {[variant_isset universal]} {
        configure.ldflags-append -lncurses
    }
}

if {${subport} eq "pcre2" && ${os.platform} eq "darwin"} {
    # This is specific to Intel and libstdc++.
    # https://trac.macports.org/ticket/67477
    # https://trac.macports.org/ticket/69073
    if {${os.major} < 11 && ${configure.build_arch} in "i386 x86_64" \
        && ${configure.cxx_stdlib} ne "libc++"} {
            configure.args-replace \
                    --enable-jit --disable-jit
    }
}

test.run            yes
test.target         check

livecheck.distname  ${subport}
