# -*- 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
github.setup        qorelanguage module-pgsql 3.1.1 v
github.tarball_from releases

name                qore-pgsql-module
revision            1
categories          lang
license             LGPL-2.1
maintainers         {davidnichols @davidnich} openmaintainer
description         PostgreSQL module for Qore
long_description    Module allowing communication with PostgreSQL DBs from the Qore Programming Language
use_bzip2           yes
homepage            http://qore.org
platforms           darwin
distname            qore-pgsql-module-${github.version}

checksums           rmd160 7c172d0ff0f196263804e9470e2809a6e1961616 \
                    sha256 db3cade41dda05f6e91caa455af22277529b3b3e0afe86dfb944293d0bd4a45c \
                    size 529596

variant postgresql10 conflicts postgresql11 postgresql12 postgresql13 postgresql14 description {Enable PostgreSQL Driver version 10} {}
variant postgresql11 conflicts postgresql10 postgresql12 postgresql13 postgresql14 description {Enable PostgreSQL Driver version 11} {}
variant postgresql12 conflicts postgresql10 postgresql11 postgresql13 postgresql14 description {Enable PostgreSQL Driver version 12} {}
variant postgresql13 conflicts postgresql10 postgresql11 postgresql12 postgresql14 description {Enable PostgreSQL Driver version 13} {}
variant postgresql14 conflicts postgresql10 postgresql11 postgresql12 postgresql13 description {Enable PostgreSQL Driver version 14} {}

if {![variant_isset postgresql10] && ![variant_isset postgresql11] && ![variant_isset postgresql12] && ![variant_isset postgresql13] && ![variant_isset postgresql14]} {
    default_variants +postgresql14
}

if {[variant_isset postgresql10]} {
    set postgresql_version "10"
} elseif {[variant_isset postgresql11]} {
    set postgresql_version "11"
} elseif {[variant_isset postgresql12]} {
    set postgresql_version "12"
} elseif {[variant_isset postgresql13]} {
    set postgresql_version "13"
} elseif {[variant_isset postgresql14]} {
    set postgresql_version "14"
}

depends_lib         port:qore \
                    port:postgresql${postgresql_version}

set postgresql_tmp ${workpath}/postgresql

post-extract {
    file mkdir ${postgresql_tmp}
    ln -s ${prefix}/include/postgresql${postgresql_version} ${postgresql_tmp}/include
    ln -s ${prefix}/lib/postgresql${postgresql_version} ${postgresql_tmp}/lib
}

configure.args      --disable-debug \
                    --with-pgsql=${postgresql_tmp}
configure.ldflags-append -Wl,-undefined -Wl,dynamic_lookup
