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

version             0.1
revision            0
categories          databases
license             public-domain

maintainers         {yahoo.com:n_larsson @nilason} openmaintainer

description         Perl-compatible regular expression support for SQLite
long_description    {*}${description}.

homepage            https://git.altlinux.org/people/at/packages/?p=sqlite3-pcre.git

patchfiles-append   prec2_c.diff

fetch.type          git
git.url             git://git.altlinux.org/people/at/packages/sqlite3-pcre.git
git.branch          4229ecc

depends_build       port:pkgconfig

depends_lib         port:sqlite3 \
                    port:pcre2

use_configure       no

build {
    set cflags [exec ${prefix}/bin/pkg-config --cflags sqlite3 libpcre2-8]
    set libs [exec ${prefix}/bin/pkg-config --libs sqlite3 libpcre2-8]

    system -W ${worksrcpath} "${configure.cc} -fPIC -dynamiclib \
        -o pcre2.dylib ${cflags}  ${libs} \
        -current_version ${version} -compatibility_version ${version} pcre.c"
}

destroot {
    file mkdir ${destroot}${prefix}/lib/sqlite3
    file copy ${worksrcpath}/pcre2.dylib \
        ${destroot}${prefix}/lib/sqlite3/pcre2.dylib
}

test.cmd            ${filespath}/test.sh ${prefix} ${worksrcpath}/pcre2.dylib
test.run            yes

notes-append \
"Load the installed SQLite extension with\
'.load ${prefix}/lib/sqlite3/pcre2.dylib'."
