#
# Makefile for building and installing apache
#

all::
	cd src; ${MAKE} PREFIX=@@PREFIX@@ $@
.if defined(SUEXEC)
.if !defined(HTTPD_USER)
	cd support; ${MAKE} PREFIX=@@PREFIX@@ suexec
.else
	cd support; ${MAKE} PREFIX=@@PREFIX@@ HTTPD_USER=${HTTPD_USER} suexec
.endif
.endif

configure::
	cd src; ./Configure

INSTALL_FILE=${INSTALL} -c -m 644 -o bin -g bin
MKDIR=/bin/mkdir -p

CONF_DIR=   @@PREFIX@@/etc/apache

install::
	-${MKDIR} ${CONF_DIR}
	-${MKDIR} @@PREFIX@@/www/data
	-${MKDIR} @@PREFIX@@/www/icons
	-${MKDIR} @@PREFIX@@/www/cgi-bin
	${INSTALL} -c -s -m 755 -o root src/httpd @@PREFIX@@/sbin
	${INSTALL} -c -m 644 -o nobody icons/* @@PREFIX@@/www/icons
.if defined(SUEXEC)
	${INSTALL} -c -s -m 4711 -o root support/suexec @@PREFIX@@/sbin/suexec
.endif
	for file in httpd.conf srm.conf access.conf ; do \
	    if [ ! -f ${CONF_DIR}/$$file ] ; then \
		${INSTALL_FILE} conf/$$file-dist ${CONF_DIR}/$$file ; \
	    fi ; \
	    ${INSTALL_FILE} conf/$$file-dist ${CONF_DIR} ; \
	done
	if [ ! -f ${CONF_DIR}/mime.types ] ; then \
	    ${INSTALL_FILE} conf/mime.types ${CONF_DIR} ; \
	fi
	${INSTALL_FILE} conf/mime.types ${CONF_DIR}/mime.types-dist
