# $Id$

PortSystem 1.0

name			netatalk
version			2.0.5
revision		4
categories		net
platforms		darwin
maintainers		nomaintainer
description		file and printer server for Apple Macintosh clients
long_description	netatalk is a daemon which provides POSIX-compliant \
					Unix/BSD systems with the ability to share files and \
					printers with Apple Macintosh computers.

homepage		http://netatalk.sourceforge.net/
master_sites	sourceforge
checksums		md5 3bd8f4780abc373e0539ab7cd1f9950f
use_bzip2		yes
startupitem.create      yes
startupitem.start       "${prefix}/etc/netatalk/initscript start"
startupitem.stop        "${prefix}/etc/netatalk/initscript stop"
startupitem.restart     "${prefix}/etc/netatalk/initscript restart"

patchfiles		patch-afppasswd.c \
				patch-paths.h \
				patch-uams_randnum.c \
				patch-adv1tov2.c \
				patch-usockfd.c

depends_lib		port:db47 \
				path:lib/libssl.dylib:openssl \
				path:bin/perl:perl5 \
				port:libiconv

if {${os.platform} eq "darwin" && ${os.major} >= 10} {
    pre-patch {
        ui_msg "AppleTalk has been removed from Mac OS X 10.6+."
        ui_msg "Building without AppleTalk support."
        patchfiles-append patch-configure
        configure.args-append --disable-ddp
    }
}

post-patch	{
	reinplace "s|__PREFIX__|${prefix}|g" \
		${worksrcpath}/include/atalk/paths.h
}

configure.args	--with-bdb=${prefix} \
				--mandir=${prefix}/share/man \
				--with-logfile=${prefix}/var/log/netatalk.log \
				--with-spooldir=${prefix}/var/spool/netatalk \
				--with-ssl-dir=${prefix} \
				--with-libiconv=${prefix}

configure.cppflags-append       -I${prefix}/include/db47
configure.ldflags-append        -L${prefix}/lib/db47

post-destroot	{
	file delete -force ${destroot}${prefix}/sbin/atalkd \
		${destroot}${prefix}/share/netatalk ${destroot}/etc
	xinstall -m 755 -d ${destroot}${prefix}/var/log/ \
		${destroot}${prefix}/var/run/netatalk \
		${destroot}${prefix}/var/spool/netatalk
	xinstall -m 755 ${filespath}/initscript ${destroot}${prefix}/etc/netatalk/
	reinplace "s|MACPORTS_PREFIX|${prefix}|" ${destroot}${prefix}/etc/netatalk/initscript
	system "touch ${destroot}${prefix}/var/log/netatalk.log"
	system "touch ${destroot}${prefix}/var/run/netatalk/afpd"
	destroot.keepdirs ${destroot}${prefix}/var/spool/netatalk
}