# $Id: Portfile 78784 2011-05-22 00:10:41Z ryandesign@macports.org $

PortSystem 1.0

name				commons-daemon
version				1.0.2
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     a6c68eed204bc9f1ef3b77488edfcfeb \
                    sha1    a4e7e267c6accfeae5226f3a64ad2d7bd19993d1 \
                    rmd160  afad8e7608f342ea576efde374511e50d269ae84

patchfiles			patch-native-dso-dyld.c

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}
