# -*- 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           clang_dependency 1.0

name                gdbm
version             1.26
revision            0

categories          databases
license             GPL-3+
maintainers         nomaintainer

description         The GNU database manager
long_description    The GNU `dbm' is a library of database functions \
                    that use extendible hashing and works similar to \
                    the standard UNIX `dbm' functions. These routines \
                    are provided to a programmer needing to create and \
                    manipulate a hashed database.
homepage            https://www.gnu.org/software/gdbm/gdbm.html

depends_build       port:gettext

depends_lib         port:gettext-runtime \
                    port:readline

master_sites        gnu

checksums           rmd160  8a023fcc0c74686a16a2dd4cd2bb53889b527a6e \
                    sha256  6a24504a14de4a744103dcb936be976df6fbe88ccff26065e54c1c47946f4a5e \
                    size    1226591

if {${os.platform} eq "darwin" && ${os.major} < 11 && ${cxx_stdlib} eq "libc++"} {
    # This port is in the dependency chain for clang 3.7 and later
    clang_dependency.extra_versions 3.7
}

# https://trac.macports.org/ticket/63393
patchfiles-append   patch-gdbm.h-tiger-stdio-no-offt.diff

configure.ccache    no

configure.args      --disable-silent-rules \
                    ac_cv_prog_AWK=awk

post-install {
    # gdbm @1.8.3_1 installed files outside the destroot; remove them if found
    foreach file {share/info/gdbm.info share/man/man3/gdbm.3} {
        set filepath ${prefix}/${file}
        if {[file exists ${filepath}] && [registry_file_registered ${filepath}] == "0"} {
            if {[catch {delete ${filepath}}]} {
                ui_warn "Cannot delete ${filepath}; please remove it manually"
            }
        }
    }
}

test.run        yes
test.target     check

variant compat description {Install dbm/ndbm compatibility files} {
    configure.args-append --enable-libgdbm-compat
}

livecheck.regex     ${name}-(\\d+(?:\\.\\d+)*)\\.tar
