# -*- 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 63512 2010-02-06 19:43:08Z blair@macports.org $

PortSystem 1.0
PortGroup  muniversal 1.0

name			db47
version			4.7.25
revision        1
set branch		[join [lrange [split ${version} .] 0 1] {}]
categories		databases
maintainers		mcalhoun openmaintainer
platforms		darwin
description		The Berkeley DB package, version 4.7
long_description	\
    Version 4.7 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/database/berkeley-db/index.html
master_sites    \
    http://download-west.oracle.com/berkeley-db/ \
    http://download-east.oracle.com/berkeley-db/ \
    http://download-uk.oracle.com/berkeley-db/
patch_sites     http://www.oracle.com/technology/products/berkeley-db/db/update/${version}/
patchfiles \
    patch.${version}.1 \
    patch.${version}.2 \
    patch.${version}.3

distname		db-${version}
patch.dir		${workpath}/${distname}

checksums		\
    ${distname}${extract.suffix} \
    md5     ec2b87e833779681a0c3a814aa71359e \
    sha1    957c10358df1211e1dc37ea997aadef42117d6a5 \
    rmd160  9a5d8149d61452906c3f1c36f2859a2033c8bc3b \
    patch.${version}.1 \
    md5     5fdf101259e5164dea1c8c86214fde38 \
    sha1    3ae3c02fb541dc8f8dee903a75450d2dbc0736a7 \
    rmd160  89c58f5235f95e82e65bab447d1b9019bf26ed25 \
    patch.${version}.2 \
    md5     bd410a11c71fee52fddb6aa2d8d4f80c \
    sha1    e3d56ad6e4a9bc092495f62c40c0cdf11ab2443c \
    rmd160  097a6bc3e8efd43fe5bd0fd77a4b793cd0d6bc18 \
    patch.${version}.3 \
    md5     6fcd69f64f5b34bfe8f0a63cc2e402c1 \
    sha1    1f707e6c65c8ebe9fa7b36333c6de76f2d480cf5 \
    rmd160  a0ef673d8127be825444aaa12711dcf75b7fda1a

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

configure.cmd		../dist/configure
configure.args		\
    --enable-cxx \
    --enable-java \
    --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}
	}
}

variant no_java description {don't build the Java API} {
    configure.args-delete  --enable-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/technology/documentation/berkeley-db/db/ref/changelog/[join [lrange [split ${version} .] 0 1] .].html
livecheck.regex {Berkeley DB (\d+(?:\.\d+)*)}
