#! /bin/sh


die() {
   echo "$@". Aborted.
   exit 1
}


cd "`dirname $0`"/../..
[ -f configure ] || die "I do not see \`configure' script in `pwd`"

patch < modules/pcgi2/configure.patch || exit 1

./configure --with-module=pcgi2:pcgi2/mod_pcgi2.c "$@" || exit 1

cd modules/pcgi2
sed -e '1,2d' -e 's/^static = mod_pcgi2.la.*$/static = mod_pcgi2.la/' \
   modules.mk >_tmp || exit 1
mv _tmp modules.mk

make || exit 1

cd ../..
exec make
