# -*- 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       compiler_blacklist_versions 1.0
PortGroup       github    1.0
PortGroup       perl5     1.0

github.setup    timescale timescaledb 2.15.1
revision        0
license         Apache-2
description     A time-series database that integrates with PostreSQL.
maintainers     {blair @blair} openmaintainer
categories      databases
conflicts       timescaledb1
platforms       darwin
homepage        https://www.timescaledb.com/

long_description \
                TimescaleDB is an open-source database designed to \
                make SQL scalable for time-series data. It is \
                engineered up from PostgreSQL, providing automatic \
                partitioning across time and space (partitioning key), \
                as well as full SQL support. TimescaleDB is packaged \
                as a PostgreSQL extension.

checksums       rmd160  2e1314115045077b386fe076a12958c50b6713f6 \
                sha256  d385e2b78e361f42f248c00eef2956e027bfe33f409d1d210e3f6424975288b8 \
                size    7434367

depends_build   path:bin/cmake:cmake \
                port:perl${perl5.major} \
                port:p${perl5.major}-ipc-run

variant postgresql11 conflicts postgresql12 postgresql13 postgresql14 postgresql15 postgresql16 description {Support for PostgreSQL 11.x} {
    known_fail              yes
    ui_error                "+postgresql11 variant is not supported in TimescaleDB 2.4.0 or greater"
    return -code error      "Unsupported variant +postgresql11"
}

variant postgresql12 conflicts postgresql11 postgresql13 postgresql14 postgresql15 postgresql16 description {Support for PostgreSQL 12.x} {
    depends_lib-append      port:postgresql12
    configure.env-append    PATH=${prefix}/lib/postgresql12/bin:$::env(PATH)
}

variant postgresql13 conflicts postgresql11 postgresql12 postgresql14 postgresql15 postgresql16 description {Support for PostgreSQL 13.x} {
    depends_lib-append      port:postgresql13
    configure.env-append    PATH=${prefix}/lib/postgresql13/bin:$::env(PATH)
}

variant postgresql14 conflicts postgresql11 postgresql12 postgresql13 postgresql15 postgresql16 description {Support for PostgreSQL 14.x} {
    depends_lib-append      port:postgresql14
    configure.env-append    PATH=${prefix}/lib/postgresql14/bin:$::env(PATH)
}

variant postgresql15 conflicts postgresql11 postgresql12 postgresql13 postgresql14 postgresql16 description {Support for PostgreSQL 15.x} {
    depends_lib-append      port:postgresql15
    configure.env-append    PATH=${prefix}/lib/postgresql15/bin:$::env(PATH)
}

variant postgresql16 conflicts postgresql11 postgresql12 postgresql13 postgresql14 postgresql15 description {Support for PostgreSQL 16.x} {
    depends_lib-append      port:postgresql16
    configure.env-append    PATH=${prefix}/lib/postgresql16/bin:$::env(PATH)
}

if {![variant_isset postgresql11] && \
    ![variant_isset postgresql12] && \
    ![variant_isset postgresql13] && \
    ![variant_isset postgresql14] && \
    ![variant_isset postgresql15] && \
    ![variant_isset postgresql16] } {
    default_variants +postgresql16
}

compiler.c_standard     2011
# Work around MacPorts base C11 compiler selection bug.
# https://github.com/macports/macports-base/pull/196
compiler.blacklist-append {clang < 500}

configure.cmd           ./bootstrap
configure.pre_args

# Do not remove -DAPACHE_ONLY from configure.args otherwise some
# binaries may be built that are licensed under the Timescale License
# (TSL). See https://github.com/timescale/timescaledb#timescaledb and
# https://github.com/timescale/timescaledb/blob/master/tsl/LICENSE-TIMESCALE.
# However, using +timescale_license will enable Timescale License'd code.
#
# -DLINTER=off: see https://github.com/timescale/timescaledb/issues/2889
configure.args          -DAPACHE_ONLY=1 \
                        -DLINTER=off \
                        -DPROJECT_INSTALL_METHOD=macports

build.dir               ${worksrcpath}/build

github.livecheck.regex  {([0-9.]+)}

variant timescale_license description {Enable Timescale License code, license will be Timescale License} {
    configure.args-delete   -DAPACHE_ONLY=1
    license                 {Timescale License}
}
