# $Id: Portfile,v 1.49 2005/10/18 20:20:30 mww Exp $

PortSystem 1.0
name                apache
version             1.3.34
categories          www
platforms           darwin freebsd
maintainers         michaelm@opendarwin.org
description         The extremely popular Apache http server
long_description \
  Apache is an HTTP server designed as a plug-in replacement for \
  the NCSA server version 1.3 (or 1.4). It fixes numerous bugs in \
  the NCSA server and includes many frequently requested new \
  features, and has an API which allows it to be extended to meet \
  users' needs more easily.
homepage            http://httpd.apache.org/
master_sites        apache:httpd/ \
                    http://archive.apache.org/dist/httpd/old/

distname            ${name}_${version}
checksums           md5 9978cc552b423f0015c1052d23ab619e

variant darwin {
	if { ![variant_isset apache_layout] } {
		configure.args-append	--with-layout=FreeBSD  --logfiledir=${prefix}/var/log/httpd --runtimedir=${prefix}/run
	} 
}

variant apache_layout {
	configure.pre_args	--prefix=${prefix}/apache
	configure.args-append   --with-layout=Apache --logfiledir=${prefix}/apache/var/log/httpd --runtimedir=${prefix}/apache/var/run
}

set stdargs "--server-uid=www --server-gid=www  --enable-module=most --enable-shared=max --disable-rule=expat"

configure.pre_args  --prefix=${prefix} --datadir=${prefix}/var/www/data --cgidir=${prefix}/var/www/cgi-bin --iconsdir=${prefix}/var/www/icons --mandir=${prefix}/share/man

configure.args		${stdargs}

destroot.args		root=${destroot}

startupitem.create	yes
if { [variant_isset apache_layout] } { 
	startupitem.init	\
		"CTL=${prefix}/apache/bin/apachectl\nPID=${prefix}/apache/run/httpd.pid"
} else {
	startupitem.init	\
		"CTL=${prefix}/sbin/apachectl\nPID=${prefix}/var/run/httpd.pid"
}
startupitem.start	\
"\[ -x \${CTL} \] && \${CTL} start >/dev/null"
startupitem.stop	\
"\[ -r \${PID} \] && \${CTL} stop >/dev/null"
startupitem.restart	\
"\[ -x \${CTL} \] && \${CTL} restart >/dev/null"

post-destroot      {
	if { [variant_isset apache_layout] } { 
		 xinstall -m 755 -d ${destroot}${prefix}/apache/log \
			${destroot}${prefix}/apache/run
		 destroot.keepdirs ${destroot}${prefix}/apache/log \
			${destroot}${prefix}/apache/run
	} else {
        	xinstall -m 755 -d ${destroot}${prefix}/var/log/httpd \
				${destroot}${prefix}/var/run
        	destroot.keepdirs ${destroot}${prefix}/var/log/httpd \
				${destroot}${prefix}/var/run
	}
}

