# $Id: Portfile 85861 2011-10-17 02:58:42Z jmr@macports.org $

PortSystem 1.0

name                apache
version             1.3.41
categories          www
license             Apache-2
platforms           darwin freebsd
maintainers         ryandesign openmaintainer
use_parallel_build  yes
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        http://archive.apache.org/dist/httpd/ \
                    apache:httpd

distname            ${name}_${version}
checksums           md5     f7f00b635243f03a787ca9f4d4c85651 \
                    sha1    3bbd4c4bc648e6ad5b696bb83420533f4d23daf8 \
                    rmd160  74786c65c143af123f1d13e9d93dd5ff07e9a201

# Both apache and apache2 want to install dbmmanage.1 and other manpages.
conflicts           apache2

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

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

configure.env       LD_SHLIB=${configure.cc}

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      --server-uid=www \
                    --server-gid=www \
                    --enable-module=most \
                    --enable-shared=max \
                    --disable-rule=expat

configure.universal_args-delete	--disable-dependency-tracking

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

notes "
Apache 1 is obsolete. Please update to Apache 2 (the apache2 port).\
For information on how to update your web server configuration, please see\
http://httpd.apache.org/docs/2.0/upgrading.html
"

livecheck.type  regex
livecheck.url   ${homepage}
livecheck.regex {Apache (1\.\d+(?:\.\d+)*) Released}
