# $Id: Portfile 89702 2012-02-07 04:49:06Z jberry@macports.org $

PortSystem 1.0

name				commons-daemon
version				1.0.8
license             Apache-2.0

categories			java
maintainers			nomaintainer
platforms			darwin

description			Jakarta Commons-Daemon
long_description	An alternative invocation mechanism for unix-daemon-like \
					java code.
homepage			http://commons.apache.org/daemon/

distname			${name}-${version}-src
master_sites		apache:commons/daemon/source/

checksums           md5     323a0bd9e2786256f02c5aed4e887fed \
                    sha1    824075ec63d6c1588e95d3e7f068683d2a80c176 \
                    rmd160  a0bc1996f098f076c2569612c3bf98fd405c1bc1

patchfiles			patch-native-dso-dyld.c \
					patch-configure.diff

depends_build		bin:ant:apache-ant
depends_lib			bin:java:kaffe \
					port:junit

configure.dir       ${worksrcpath}/src/native/unix

platform macosx {
    pre-configure {
        if {![file isfile "/System/Library/Frameworks/JavaVM.framework/Headers/jni.h"]} {
            ui_error "${name} requires the Java for Mac OS X development headers."
            if {${os.major} == 10} {
                ui_error "Download the Java Developer Package from: <https://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wa/getSoftware?bundleID=20719>"
            } elseif {${os.major} == 9} {
                ui_error "Download the Java Developer Package from: <https://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wa/getSoftware?bundleID=20720>"
            } else {
                ui_error "Make sure your Xcode installation is complete."
            }
            return -code error "missing Java headers"
        }
    }
}

build.dir           ${configure.dir}
build.target        clean all

use_parallel_build  no

pre-build {
    system "cd ${worksrcpath} && \
        ant dist -Djunit.jar=${prefix}/share/java/junit.jar"
}

destroot {
    xinstall -d ${destroot}${prefix}/share/java \
        ${destroot}${prefix}/share/doc
    xinstall -m 644 ${worksrcpath}/dist/commons-daemon-${version}.jar \
        ${destroot}${prefix}/share/java/commons-daemon.jar
    xinstall ${worksrcpath}/src/native/unix/jsvc \
        ${destroot}${prefix}/bin
    set docdir ${prefix}/share/doc/${name}
    file copy ${worksrcpath}/dist/docs ${destroot}${docdir}
    xinstall -m 644 -W ${worksrcpath} LICENSE.txt NOTICE.txt PROPOSAL.html \
        RELEASE-NOTES.txt ${destroot}${docdir}
}

livecheck.type  regex
livecheck.url   http://commons.apache.org/downloads/download_daemon.cgi
livecheck.regex {>(\d+(?:\.\d+)*)\.tar}
