# $Id: Portfile 38762 2008-07-30 18:32:43Z pmq@macports.org $

PortSystem 1.0

name			vsftpd
version			2.0.7
categories		net
platforms		darwin
maintainers		pmq openmaintainer

description		Secure FTP server for UNIX systems
long_description	vsftpd is an FTP server, or daemon. The 'vs' stands for \
			Very Secure. Obviously this is not a guarantee, but a \
			reflection that it is written with security in mind, and \
			carefully designed to be resilient to attack.

homepage		http://vsftpd.beasts.org
master_sites		ftp://vsftpd.beasts.org/users/cevans/
checksums		sha1 760afe849d1ebe10592ef29032b6e00e7f1bbf79 \
			rmd160 8947c7ae00214fb30c9d7d2cfba5116643e1d8c7

patchfiles		patch-sysdeputil.c.diff \
			patch-vsf_findlibs.sh.diff \
			patch-vsftpd.conf.diff \
			patch-Makefile.diff

configure {
	reinplace "s|/etc/|${prefix}/etc/|g" \
		${worksrcpath}/Makefile \
		${worksrcpath}/defs.h \
		${worksrcpath}/tunables.c \
		${worksrcpath}/vsftpd.8 \
		${worksrcpath}/vsftpd.conf
	reinplace "s|/var/|${prefix}/var/|g" \
		${worksrcpath}/tunables.c \
		${worksrcpath}/vsftpd.conf.5 \
		${worksrcpath}/vsftpd.conf
	reinplace "s|/usr/share/empty|${prefix}/var/empty|g" \
		${worksrcpath}/tunables.c
	reinplace "s|/usr/share/ssl/|${prefix}/share/ssl/|g" \
		${worksrcpath}/tunables.c
	reinplace "s|/etc/vsftpd|${prefix}/etc/vsftpd|g" \
		${worksrcpath}/vsftpd.conf.5

	reinplace "s|/usr/local/man|${destroot}${prefix}/share/man|g" \
		${worksrcpath}/Makefile
	reinplace "s|/usr/local|${destroot}${prefix}|g" \
		${worksrcpath}/Makefile
}

build.target

post-destroot {
    xinstall ${worksrcpath}/vsftpd.conf ${destroot}${prefix}/etc/vsftpd.conf.sample
    set docdir ${destroot}${prefix}/share/doc/${name}-${version}
    xinstall -d ${docdir}
    xinstall -m 644 -W ${worksrcpath} AUDIT BENCHMARKS BUGS COPYING FAQ LICENSE \
        README README.security README.ssl SIZE SPEED TODO TUNING \
        ${docdir}
    file copy ${worksrcpath}/EXAMPLE ${docdir}
    file copy ${worksrcpath}/SECURITY ${docdir}
}

destroot.keepdirs	"${destroot}${prefix}/var/empty/" \
			"${destroot}${prefix}/var/log/"

variant ssl description "Enable SSL support" {
    depends_lib-append	port:openssl

    post-configure {
        reinplace "s|#undef VSF_BUILD_SSL|#define VSF_BUILD_SSL|" \
	    ${worksrcpath}/builddefs.h
    }

    build.env-append	LDFLAGS=${configure.ldflags}
}
