# $Id: Portfile,v 1.2 2005/06/27 19:58:14 mww Exp $

PortSystem 1.0
name                mod_perl
version             1.29
revision			2
categories          www
platforms           darwin freebsd
maintainers         bchesneau@mac.com
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/
distname			mod_perl-1.0-current
checksums			md5 1491931790509b9af06fc037d02b0e7a
depends_lib         port:perl5.8 port:apache

worksrcdir			${name}-${version}

platform darwin 6 {
	depends_lib-append	lib:libdl.1:dlcompat
}

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.8*/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"
}
