# -*- 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.45 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)   2a667dc7a4a9e84d9551274c3a4b614d869ee93d
set sha256(pcre2)   21547f3516120c75597e5b30a992e27a592a31950b5140e7b8bfde3f192033c4
set size(pcre2)     2072403
checksums           rmd160  $rmd160(${subport}) \
                    sha256  $sha256(${subport}) \
                    size    $size(${subport})

patchfiles-append   no-darwin-pthread-flag.patch

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}
