# $Id: Portfile 85862 2011-10-17 02:59:03Z jmr@macports.org $

PortSystem 1.0

name                mod_perl
version             1.30
categories          www
license             Apache-1.1
platforms           darwin
maintainers         nomaintainer
description         Embeds a Perl interpreter in the Apache 1.3 server
long_description	${description}
homepage            http://perl.apache.org/
master_sites       	http://perl.apache.org/dist/ \
					http://apache.mirror.digitalspace.net/perl/ \
					http://www.apache.inetcosmos.org/dist/perl/ \
					http://www.rge.com/pub/infosystems/apache/perl/ \
					http://mirrors.ccs.neu.edu/Apache/dist/perl/
checksums			md5 bfd6f6cff1ab1cc3dbb58a236701d169
depends_lib         path:bin/perl:perl5 port:apache

worksrcdir			${name}-${version}

configure.env	LANG=C \
				LC_ALL=C
configure.pre_args
configure {
	if { [variant_isset apache_layout] } {
		set APXS ${prefix}/apache/bin/apxs
	} else {
		set APXS ${prefix}/sbin/apxs
	}

	system "cd ${workpath}/${worksrcdir} && \
		perl Makefile.PL USE_APXS=1 \
		PREFIX=${prefix} \
		WITH_APXS={APXS} EVERYTHING=1 \
		PERL_EXTRA_CFLAGS='-DDEFAULT_PATH=\"/bin:/usr/bin:${prefix}/bin\"'"
}

destroot.target	all pure_install doc_install

post-destroot {
	if { [variant_isset apache_layout] } {
		xinstall -m 755 -d ${destroot}${prefix}/apache/include/modules/perl \
			${destroot}${prefix}/apache/libexec
		system "install -m 755 ${worksrcpath}/src/modules/perl/*.h \
    	        ${destroot}${prefix}/apache/include/modules/perl"

		xinstall -m 755 ${worksrcpath}/apaci/libperl.so \
			${destroot}${prefix}/apache/libexec/
	} else {
		xinstall -m 755 -d ${destroot}${prefix}/include/apache/modules/perl \
			${destroot}${prefix}/libexec/apache
		system "install -m 755 ${worksrcpath}/src/modules/perl/*.h \
			${destroot}${prefix}/include/apache/modules/perl"
		xinstall -m 755 ${worksrcpath}/apaci/libperl.so \
			${destroot}${prefix}/libexec/apache/
	}
	system "cd ${destroot}${prefix}/lib/perl5/site_perl/5.*/darwin-*2level/auto/mod_perl/ \
		&& cat .packlist | sed s#${destroot}/#\/#g >.packlist.new \
		&& mv .packlist.new .packlist"
}

post-install {
	ui_msg "\nIf this your first install, you might want"
	ui_msg " * enable mod_perl in apache :\n"
	if { [variant_isset apache_layout] } {
		ui_msg "cd ${prefix}/apache/libexec"
	} else {
		ui_msg "cd ${prefix}/libexec/apache"
	}
	ui_msg "apxs -a -e -n \"perl\" libperl.so\n"
	ui_msg " * And then relaunch apache \n"
	ui_msg "apachectl graceful\n"
}
