if test "$GTK_INST_DIR" = ""; then
  echo "GTK_INST_DIR not set; source ../profile first" >&2
else

if test ! -h build-aux/ltmain.sh || :; then
	(cd build-aux
	for i in compile config.guess config.sub depcomp install-sh missing mkinstalldirs mdate-sh ylwrap test-driver texinfo.tex symlink-tree elisp-comp ar-lib
	do
		rm -f $i
		test -f /usr/share/automake-$GTK_AMVERSION/$i && cp -a /usr/share/automake-$GTK_AMVERSION/$i $i
	done
	for i in ltmain.sh
	do
		rm -f $i
		if test -f /usr/share/libtool/build-aux/$i; then
		     cp -a /usr/share/libtool/build-aux/$i $i
		elif test -f /usr/share/libtool/config/$i; then
		     cp -a /usr/share/libtool/config/$i $i
		else
		     echo "cannot find $i" >&2
		fi
	done
	)

	(cd m4
	for i in libtool.m4 ltoptions.m4 ltsugar.m4 ltversion.m4 lt~obsolete.m4; do
		rm -f $i
		test -f /usr/share/aclocal/$i && cp -a /usr/share/aclocal/$i $i
	done
	for i in amversion.m4 as.m4 auxdir.m4 cond.m4 depend.m4 depout.m4 init.m4 install-sh.m4 lead-dot.m4 make.m4 minuso.m4 missing.m4 mkdirp.m4 options.m4 sanity.m4 silent.m4 strip.m4 substnot.m4 tar.m4 lispdir.m4 prog-cc-c-o.m4 runlog.m4; do
		rm -f $i
		test -f /usr/share/aclocal-$GTK_AMVERSION/$i && cp -a /usr/share/aclocal-$GTK_AMVERSION/$i $i
	done
	)

	cd gettext-runtime/libasprintf &&
	 aclocal-$GTK_AMVERSION -I ../../m4 -I ../m4 -I gnulib-m4 -I ../gnulib-m4 &&
	 autoconf &&
	 autoheader &&
	 automake &&
	 rm -rf autom4te.cache &&
	cd ../..

	cd gettext-runtime &&
	 aclocal-$GTK_AMVERSION -I m4 -I ../m4 -I gnulib-m4 &&
	 autoconf &&
	 autoheader &&
	 automake &&
	 rm -rf autom4te.cache &&
	cd ..

	cd gettext-tools/examples &&
	 aclocal-$GTK_AMVERSION -I ../../gettext-runtime/m4 -I ../../m4 &&
	 autoconf &&
	 automake &&
	 rm -rf autom4te.cache &&
	cd ../..

	cd gettext-tools &&
	 aclocal-$GTK_AMVERSION -I m4 -I ../gettext-runtime/m4 -I ../m4 -I gnulib-m4 -I libgrep/gnulib-m4 -I libgettextpo/gnulib-m4 -I ../gettext-runtime/gnulib-m4 &&
	 autoconf &&
	 autoheader &&
	 automake &&
	 rm -rf autom4te.cache &&
	cd ..

	rm -f aclocal.m4 Makefile.in Makefile
	aclocal-$GTK_AMVERSION -I m4 &&
	autoconf &&
	automake
fi

rm -rf autom4te.cache
export CXXFLAGS="-pipe -W -Wall -O2 -fomit-frame-pointer"
export CFLAGS="$CXXFLAGS -Wstrict-prototypes -Wmissing-prototypes -Wdeclaration-after-statement"
./configure $GTK_INST_CONFIGUREARGS \
	--enable-shared \
	--enable-silent-rules \
	--disable-curses \
	--enable-relocatable \
	--with-included-gettext
fi
