# -*- 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           cmake           1.1
PortGroup           github          1.0
PortGroup           legacysupport   1.0
PortGroup           openssl         1.0

github.setup        cwida duckdb 1.2.1 v
github.tarball_from archive
revision            0

homepage            https://www.duckdb.org

description         \
    DuckDB is an embeddable SQL OLAP Database Management System

long_description    \
    DuckDB is an embedded database designed to execute analytical SQL queries \
    fast while embedded in another process. It is designed to be easy to \
    install and easy to use. DuckDB has no external dependencies. DuckDB has \
    bindings for C/C++, Python and R. DuckDB is developed by the Database \
    Architectures group of the CWI.

categories          databases
license             MIT
maintainers         {gmail.com:herby.gillot @herbygillot} \
                    openmaintainer

checksums           rmd160  4185c60f520b0db86bc600daac1650dc67733b3b \
                    sha256  481a05d59cb8eaf4d78e5495ab0c99ed53e3b41e84aeaf24eef4144f2c60d1cc \
                    size    89810599

patchfiles-append   no-ccache.patch

set python_version  312
set python_branch   \
    [string index ${python_version} 0].[string range ${python_version} 1 end]

configure.args-append \
                    -DBUILD_EXTENSIONS='autocomplete\;icu\;parquet\;json' \
                    -DENABLE_EXTENSION_AUTOLOADING=1 \
                    -DENABLE_EXTENSION_AUTOINSTALL=1 \
                    -DOVERRIDE_GIT_DESCRIBE=v${version} \
                    -DPython3_EXECUTABLE=${prefix}/bin/python${python_branch}

compiler.cxx_standard 2011

depends_build-append \
                    port:pkgconfig \
                    port:python${python_version} \
                    port:zstd

if {[string match *gcc* ${configure.compiler}]} {
    # Without the following setting, the build fails miserably at linking with every possible symbol undefined.
    # Undefined symbols: __ZNK6duckdb5Value14GetValueUnsafeItEET_v, __ZN6duckdb11LogicalType3MAPES0_S0_ etc.
    configure.args-append \
                    -DEXTENSION_STATIC_BUILD=TRUE
    configure.ldflags-append \
                    -latomic
}