set -e

tar zxf apache_2.0a4.tar.gz
cd apache_2.0a4/src

# NOTE: some minor tweaks ...
#	lib/apr/file_io/unix/pipe.c, no mkfifo
#	main/util.c, workaround problem in find_fqdn
#	lib/pcre/pcre.in, dllimport not needed
#	support/logresolve.c, h_errno
#	Makefile.in, helpers/install.sh, lib/pcre/Makefile.in, install/.exe
patch -p2 <../../apache.patch

# NOTE: buildconf requires autoconf and libtool
#	autoconf can be downloaded from cygutils.netpedia.net
#	libtool you'll need to build yourself
./buildconf

# NOTE: autoheader fails when it tries to rename an open file
if [ -f autoh* ]
then
    mv autoh* include/ap_config_auto.h.in
    mv lib/apr/autoh* lib/apr/include/apr_private.h.in
fi

# NOTE: tweak configure's mmap test
#	fix "test: ==: unknown operand" with s/==/=/ (ash v. bash)
patch <../../apache.conf.patch

./configure --prefix=/usr/local/apache --with-mpm=prefork

make

make install

