# -*- 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 79922 2011-06-29 11:03:45Z afb@macports.org $

PortSystem 1.0
PortGroup  muniversal 1.0

name			db52
version			5.2.28
set branch		[join [lrange [split ${version} .] 0 1] {}]
categories		databases
license			Sleepycat
maintainers		afb openmaintainer
platforms		darwin
description		The Berkeley DB package, version 5.2
long_description	\
    Version 5.2 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/
master_sites    \
    http://download-west.oracle.com/berkeley-db/ \
    http://download-east.oracle.com/berkeley-db/ \
    http://download-uk.oracle.com/berkeley-db/

distname		db-${version}

checksums		\
    md5     c0130828427d7ab179027185d09fda66 \
    sha1    e6572e3356cf8bc998da4e889db3b12638833435 \
    rmd160  b54918e88cfea6584dbe2e4994aa16ec24f04a83

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

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

use_parallel_build	yes

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}
	}
	if { ![variant_isset no_sql] } {
		move ${destroot}${prefix}/bin/dbsql \
			${destroot}${prefix}/bin/db${branch}sql
	}
}

variant no_java description {don't build the Java API} {
    configure.args-delete  --enable-java
}

variant no_sql description {don't build the SQL API} {
    configure.args-delete  --enable-sql
}

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  regexm
livecheck.url   http://www.oracle.com/technetwork/database/berkeleydb/downloads/index.html
livecheck.regex {Berkeley\s+DB\s+(5\.2(?:\.\d+)*)\.tar\.gz}
