# $Id: Portfile 66638 2010-04-18 15:43:45Z elelay@macports.org $

PortSystem      1.0

name            avahi
version         0.6.25
revision	2
categories      net devel
maintainers     nomaintainer
platforms       darwin
description     A system which facilitates service discovery on a local network

long_description \
    Avahi is a system which facilitates service discovery on a local \
    network. This means that you can plug your laptop or computer into \
    a network and instantly be able to view other people who you can \
    chat with, find printers to print to or find files being shared. \
    This kind of technology is already found in Mac OS X (branded \
    Rendezvous, Bonjour and sometimes Zeroconf) and is very convenient. \
    Avahi is mainly based on Lennart Poettering's flexmdns mDNS \
    implementation for Linux which has been discontinued in favour \
    of Avahi.

homepage        http://avahi.org/
master_sites    ${homepage}download/

checksums       md5     a83155a6e29e3988f07e5eea3287b21e \
                sha1    7ce8ed5a494d72401dd81f64594fda59d2ec91fd \
                rmd160  3025f774360a8ea3b9de87e2df0b00387569aaf2

patchfiles      patch-avahi-utils-Makefile.in-nls.diff \
                patch-avahi-daemon-Makefile.in-nls.diff \
                patch-avahi-dnsconfd-Makefile.in-nls.diff \
                patch-initscript_darwin_org.freedesktop.avahi-daemon.plist.in \
                patch-initscript_darwin_org.freedesktop.avahi-dnsconfd.plist.in

post-patch {
    # This preprocessor macro causes a lot of things to be undefined inside netinet/in.h system header.
    reinplace "s/-D_XOPEN_SOURCE=500//" ${worksrcpath}/configure

    reinplace "s|/System|${destroot}|g" ${worksrcpath}/initscript/darwin/Makefile.in
}

depends_build   port:pkgconfig

depends_run     port:intltool

depends_lib     port:libdaemon \
                port:libglade2 \
                port:dbus-python26 \
                port:expat \
                port:gdbm \
                port:py26-gtk \
                port:gettext

configure.args  --disable-autoipd \
                --disable-qt3 \
                --disable-qt4 \
                --disable-mono \
                --disable-monodoc \
                --with-distro=darwin \
                --enable-compat-libdns_sd

configure.cppflags-append   -L${prefix}/lib
configure.python            ${prefix}/bin/python2.6

test.run        yes
test.target     check

pre-test {
    if {![variant_isset test]} {
        error "test variant must be enabled to run the tests."
    }
}

pre-activate {
    addgroup avahi
    adduser avahi gid=[existsgroup avahi] realname=Avahi Service
}

post-activate {
    if {[file exists /System/Library/LaunchDaemons/org.freedesktop.avahi-dnsconfd.plist]} {
        ui_debug "Removing cruft from versions prior to 0.6.17_2..."
        delete \
            /System/Library/LaunchDaemons/org.freedesktop.avahi-dnsconfd.plist \
            /System/Library/LaunchDaemons/org.freedesktop.avahi-daemon.plist
    }
}

variant mono description {Enable Mono support} {
    depends_build-append    port:monodoc

    depends_lib-append      port:mono \
                            port:gtk-sharp2

    configure.args-delete   --disable-mono \
                            --disable-monodoc

    post-patch {
        reinplace {s/\.so\.0/.0.dylib/} ${worksrcpath}/avahi-ui-sharp/avahi-ui-sharp.dll.config.in
    }

    post-build {
        # TODO This shouldn't be needed, we need to fix Mono dllmap library path.
        reinplace -E "s|(target=\")|\\1${prefix}/lib/|" \
            ${worksrcpath}/avahi-sharp/avahi-sharp.dll.config \
            ${worksrcpath}/avahi-ui-sharp/avahi-ui-sharp.dll.config
    }
}

variant test description {Build tests} {
    configure.args-append   --enable-tests
}

livecheck.type  regex
livecheck.url   [lindex ${master_sites} 0]
livecheck.regex ${name}-(\[0-9.\]+)\\.tar
