#!/bin/sh

. /etc/flenv

mkdir -p $flinstpath

targetdir=`find $srcpath -maxdepth 1 -type d -name libxml2-\*`
if [ -z "$targetdir" ] || [ ! -d "$targetdir" ]; then
	echo "ERROR: target source directory not found"
	exit 1
fi

pushd $targetdir

# libxml2-2.7.7(xmllint.c) can't be compiled with --enable-shared.
# I was bothered by that, so just disabled.
#./configure --prefix=$flinstpath --enable-static --enable-shared --without-debug --without-legacy --without-modules
./configure --prefix=$flinstpath --enable-static --disable-shared --without-debug --without-legacy --without-modules --without-threads \
|| { echo "ERROR: configure failed" ; popd ; exit 1 ; }

make \
|| { echo "ERROR: make failed" ; popd; exit 1 ; }

make install \
|| { echo "ERROR: 'make install' failed" ; popd; exit 1 ; }

popd

$flpath/bin/dllxml2.sh static

echo "INFO: libxml2 is now installed"
