# -*- 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
# $Id: Portfile 105617 2013-04-27 23:42:35Z and.damore@macports.org $

PortSystem 1.0
PortGroup  muniversal 1.0
PortGroup  select 1.0

name            db48
version         4.8.30
revision        2
set branch      [join [lrange [split ${version} .] 0 1] {}]
categories      databases
license         Sleepycat
maintainers     jmr openmaintainer
platforms       darwin
description     The Berkeley DB package, version 4.8
long_description \
    Version 4.8 of the Berkeley Data Base library which \
    offers (key/value) storage with optional concurrent \
    access or transactions interface.  This port will \
    install the AES (American Encryption Standard) \
    enabled version.

homepage        http://www.oracle.com/us/products/database/berkeley-db/db/overview/index.html
master_sites    http://download.oracle.com/berkeley-db/

distname        db-${version}

checksums       md5     f80022099c5742cd179343556179aa8c \
                sha1    ab36c170dda5b2ceaad3915ced96e41c6b7e493c \
                rmd160  dd2fcd4c9b857a91e2f491fd4fadb0c51b993a9c

patchfiles      patch-dbinc_atomic.h

configure.dir   ${worksrcpath}/build_unix
build.dir       ${configure.dir}

configure.cmd   ../dist/configure
configure.args  --enable-cxx \
                --includedir=\\\${prefix}/include/db${branch} \
                --libdir=\\\${prefix}/lib/db${branch}

depends_run-append  port:db_select
select.group        db
select.file         ${filespath}/db48

destroot.destdir \
    prefix=${destroot}${prefix} \
    docdir=${destroot}${prefix}/share/doc/${name}

post-destroot {
    foreach bin [glob -tails -directory ${destroot}${prefix}/bin/ db_*] {
        set newbin [regsub {^db_} ${bin} "db${branch}_"]
        move ${destroot}${prefix}/bin/${bin} \
            ${destroot}${prefix}/bin/${newbin}
    }
}

variant java conflicts no_java description {Build the Java API} {
    configure.args-append   --enable-java
}

variant no_java conflicts java description {Legacy compatibility variant} {}
if {[variant_isset no_java]} {
    default_variants -java
} elseif {${os.subplatform} == "macosx" && ${os.major} < 11} {
    default_variants +java
}

variant tcl description {build Tcl API} {
    depends_lib-append      port:tcl
    configure.args-append   --enable-tcl --with-tcl=${prefix}/lib
}

if { [variant_isset universal] } {
    if { ${os.arch}=="i386" } {
        if { ${os.major} >= 10 } {
            set merger_configure_args(ppc) --with-mutex=Darwin/_spin_lock_try
        }
        set merger_configure_args(ppc64)   --with-mutex=Darwin/_spin_lock_try
    } else {
        set merger_configure_args(i386)    --with-mutex=x86/gcc-assembly
        set merger_configure_args(x86_64)  --with-mutex=x86_64/gcc-assembly
    }
}

livecheck.type  regex
livecheck.url   http://www.oracle.com/technetwork/database/berkeleydb/downloads/index-082944.html
livecheck.regex {(4\.8(?:\.\d+)*)\.tar\.gz}
