# Apache Httpd XBuild
#
#
# --- Configure section ---
#
dpx=/opt/jboss-ep-5.2/native
pfx=""
LD_LIBRARY_PATH=$RPM_ROOT_DIR$_libdir
CC=cc
CFLAGS="$HPUXCC_CFLAGS +Z"
CPPFLAGS="-I$RPM_ROOT_DIR/include"
LDFLAGS="-L$RPM_ROOT_DIR$_libdir, -Wl,+b,$RPM_BUILD_ROOT$_libdir"
LT_RUNPATH=$RPM_BUILD_ROOT$_libdir
export CC
export CFLAGS
export CPPFLAGS
export LDFLAGS
export LD_LIBRARY_PATH
export LT_RUNPATH

#
# --- Make section ---
#
pushd srclib/apr
./configure \
        --prefix=/ \
        --includedir=/include/httpd \
        --libdir=$_libdir
test $? -ne 0 && exit 1
gmake DESTDIR=$RPM_BUILD_ROOT install
test $? -ne 0 && exit 1
popd

rm -f $RPM_BUILD_ROOT$_libdir/*.la || true
rm -f $RPM_BUILD_ROOT$_libdir/*.exp || true
rm -rf $RPM_BUILD_ROOT$_libdir/pkgconfig || true

chmod 755 $RPM_BUILD_ROOT$_libdir/lib*.so* || true
chmod 644 $RPM_BUILD_ROOT$_libdir/lib*.a || true

cp srclib/apr/include/arch/unix/apr_private.h \
        $RPM_BUILD_ROOT$_includedir/httpd/apr_private.h
chmod 644 $RPM_BUILD_ROOT$_includedir/httpd/*.h || true

pushd srclib/apr
gmake clean
pfx="$RPM_ROOT_DIR"
./configure \
        --prefix=$pfx \
        --includedir=$pfx/include/httpd \
        --libdir=$pfx$_libdir
test $? -ne 0 && exit 1
gmake DESTDIR=$RPM_BUILD_ROOT/devel install
test $? -ne 0 && exit 1
popd
install -m 755 -d "$RPM_BUILD_ROOT$_libdir/httpd/build"

cp $RPM_BUILD_ROOT/devel$RPM_ROOT_DIR/bin/ap?-1-config $RPM_BUILD_ROOT$_libdir/httpd/build/
cp $RPM_BUILD_ROOT/devel$RPM_ROOT_DIR/build-1/* $RPM_BUILD_ROOT$_libdir/httpd/build/
$__perl -pi -e 's;-L/.*/\.libs;;g' $RPM_BUILD_ROOT$_libdir/httpd/build/apr_rules.mk
$__perl -pi -e 's;-I/\S*/httpd-2\S*;;g' $RPM_BUILD_ROOT$_libdir/httpd/build/apr_rules.mk

$__perl -pi -e "s;$RPM_BUILD_ROOT$_libdir;$RPM_ROOT_DIR$_libdir;g" $RPM_BUILD_ROOT$_libdir/httpd/build/apr_rules.mk
$__perl -pi -e "s;LDFLAGS=\"\";LDFLAGS=\"$HPUXCC_LDFLAGS\";g" $RPM_BUILD_ROOT$_libdir/httpd/build/apr-1-config
$__perl -pi -e "s;CFLAGS=\"\";CFLAGS=\"$HPUXCC_CFLAGS\";g" $RPM_BUILD_ROOT$_libdir/httpd/build/apr-1-config
$__perl -pi -e "s;$RPM_BUILD_ROOT$_libdir;$RPM_ROOT_DIR$_libdir;g" $RPM_BUILD_ROOT$_libdir/httpd/build/apr-1-config
$__perl -pi -e "s;/build-1;$_libdir/httpd/build;g" $RPM_BUILD_ROOT$_libdir/httpd/build/apr-1-config
$__perl -pi -e "s;/build-1;$_libdir/httpd/build;g" $RPM_BUILD_ROOT$_libdir/httpd/build//apr_rules.mk

files="$RPM_BUILD_ROOT$_libdir/*.so*"
files_doc="CHANGES README README-win32.txt LICENSE NOTICE"

files_devel="$RPM_BUILD_ROOT$_libdir/*.a $_includedir \
$_libdir/httpd/build"
files_devel_doc="CHANGES INSTALL LAYOUT LICENSE NOTICE"
