# $Id: Portfile 94401 2012-06-17 23:21:38Z ryandesign@macports.org $

PortSystem 1.0

name                mod_perl
version             1.31
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			rmd160  296bd5e95018c313bab84ae7b21ae9f64bd4a394 \
					sha256  0bc7d2638139b7ac9742e27051513efb332504093eca84488ca15585b14860c1

depends_lib         path:bin/perl:perl5 port:apache

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/
	}
	
	fs-traverse f ${destroot}${prefix} {
		if {[file isfile ${f}]} {
			switch [file tail ${f}] {
				.packlist -
				perllocal.pod {
					delete ${f}
				}
			}
		}
	}
}

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"
}

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