#!/bin/sh
# Copyright (C) 2004 Alex Kirhenshtein <alk@alk.lv>
#  
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without 
# modifications, as long as this notice is preserved.
# 
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# Remove possibly incorrect build tag files
rm -f ./netxms-build-tag.h
rm -f ./build/netxms-build-tag.*

autoreconf -fi -W none,obsolete,syntax
exit $?

ACLOCAL=aclocal
AUTOCONF=autoconf
AUTOHEADER=autoheader
AUTOMAKE=automake
if test -x "`which libtoolize`"; then
	LIBTOOLIZE=libtoolize
fi
if test -x "`which glibtoolize`"; then
	LIBTOOLIZE=glibtoolize
fi

mkdir -p config
touch README

echo \*\*\* ACLOCAL: `which $ACLOCAL`
echo \*\*\* AUTOCONF: `which $AUTOCONF`
echo \*\*\* AUTOHEADER: `which $AUTOHEADER`
echo \*\*\* AUTOMAKE: `which $AUTOMAKE`
echo \*\*\* LIBTOOLIZE: `which $LIBTOOLIZE`

rm -f config.cache &&
[ ! -f config/ltmain.sh ] && $LIBTOOLIZE
echo "- aclocal." &&
$ACLOCAL -I m4 &&
echo "- autoconf." &&
$AUTOCONF &&
echo "- autoheader." &&
$AUTOHEADER &&
echo "- automake." &&
$AUTOMAKE -a &&
chmod 755 configure

if test -d src/private; then
	FILES=`cat src/private/configure.files`
	for file in $FILES; do
		echo "Processing $file"
		$AUTOMAKE $file
	done
fi

exit $?
