1#! /bin/sh
2cd `dirname $0`
3
4if test "$1" = "clean"; then
5	UNAME=`uname`
6	if test $UNAME = OpenBSD || test $UNAME = Darwin ; then
7		ARGS="-0"
8	else
9		ARGS="-r0"
10	fi
11
12	find . -name Makefile.in -print0 | xargs $ARGS rm -f
13	find . -path ./tools/texpaint -prune -o -name config.h.in -print0 | xargs $ARGS rm -f
14	find . \( -path ./vc2005 -o -path ./vc2008 \) -prune -o -name config.h -print0 | xargs $ARGS rm -f
15	find . -name stamp-h1 -print0 | xargs $ARGS rm -f
16	find . -name '*~' -type f -print0 | xargs $ARGS rm -f
17	find . -name '*.rej' -type f -print0 | xargs $ARGS rm -f
18	find . -name '*.orig' -type f -print0 | xargs $ARGS rm -f
19	rm -f aclocal.m4 build-stamp changelog-stamp config.cache config.log \
20		  config.status configure configure-stamp install-sh libtool missing \
21		  mkinstalldirs quakeforge-config quakeforge.lsm
22	rm -f compile config.guess config.sub depcomp ltmain.sh ylwrap
23	rm -rf autom4te.cache
24	rm -f m4/libtool.m4 m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 \
25		  m4/lt~obsolete.m4
26
27	cd -
28	find . \( -path ./tools/gas2masm -o -path ./tools/quaketoascii \) -prune -o -name Makefile -print0 | xargs $ARGS rm -f
29	find . -name core -print0 | xargs $ARGS rm -f
30	rm -f RPM/build_rpm RPM/quakeforge.conf RPM/quakeforge.spec RPM/rpmmacros
31	find . -name '*.o' -type f -print0 | xargs $ARGS rm -f
32	find . -name '*.lo' -type f -print0 | xargs $ARGS rm -f
33	find . -name '*.qfo' -type f -print0 | xargs $ARGS rm -f
34	find . -name '.libs' -type d -print0 | xargs $ARGS rm -rf
35	find . -name '.deps' -type d -print0 | xargs $ARGS rm -rf
36	find . -name '*.a' -type f -print0 | xargs $ARGS rm -f
37	find . -name '*.dat*' -type f -print0 | xargs $ARGS rm -f
38	find . -name '*.sym*' -type f -print0 | xargs $ARGS rm -f
39	exit 0
40fi
41# Check libtoolize version, fix for Debian/Woody
42if test x`uname` = xDarwin ; then
43	libtoolize=glibtoolize
44else
45	libtoolize=libtoolize
46fi
47lt=`which $libtoolize`
48if test -n "$lt" ; then
49	if test -x "$lt" ; then
50		LTIZE_VER=`$libtoolize --version | head -1 | sed 's/.* \([1-9][0-9]*\(\.[1-9][0-9]*\)\(\.[1-9][0-9]*\)*\).*/\1/'`
51		LTIZE_VER_MAJOR=`echo $LTIZE_VER | cut -f1 -d'.'`
52		LTIZE_VER_MINOR=`echo $LTIZE_VER | cut -f2 -d'.' | sed -e 's/[^0-9]//g'`
53
54		if test "$LTIZE_VER_MAJOR" -lt "1"; then
55			errors="Libtool 1.5 or greater needed to build configure.\n$errors"
56		fi
57		if test "$LTIZE_VER_MAJOR" -eq "1" -a "$LTIZE_VER_MINOR" -lt "5" ; then
58			errors="Libtool 1.5 or greater needed to build configure.\n$errors"
59		fi
60	fi
61else
62	errors="Libtool not found. QuakeForge git requires libtool to bootstrap itself.\n$errors"
63fi
64
65# Check Autoconf version
66ac=`which autoconf`
67if test -n "$ac" ; then
68	if test -x "$ac" ; then
69		AC_VER=`autoconf --version | head -1 | sed 's/^[^0-9]*//'`
70		AC_VER_MAJOR=`echo $AC_VER | cut -f1 -d'.'`
71		AC_VER_MINOR=`echo $AC_VER | cut -f2 -d'.' | sed 's/[^0-9]*$//'`
72
73		if test "$AC_VER_MAJOR" -lt "2" ; then
74			errors="Autoconf 2.61 or greater needed to build configure.\n$errors"
75		fi
76
77		if test "$AC_VER_MAJOR" -eq "2" -a "$AC_VER_MINOR" -lt "61" ; then
78			errors="Autoconf 2.61 or greater needed to build configure.\n$errors"
79		fi
80	fi
81else
82	errors="Autoconf not found. QuakeForge git requires autoconf to bootstrap itself.\n$errors"
83fi
84
85am=`which automake`
86if test -n "$am" ; then
87	if test -x "$am" ; then
88		AM_VER=`automake --version | head -1 | sed -e 's/automake (GNU automake) //' -e 's/\-p.*$//'`
89		AM_VER_MAJOR=`echo $AM_VER | cut -f1 -d.`
90		AM_VER_MINOR=`echo $AM_VER | cut -f2 -d.`
91		if test "$AM_VER_MAJOR" -lt "1"; then
92			errors="Automake 1.10 or greater needed to build makefiles.\n$errors"
93		fi
94		if test "$AM_VER_MAJOR" -eq "1" -a "$AM_VER_MINOR" -lt "10"; then
95			errors="Automake 1.10 or greater needed to build makefiles.\n$errors"
96		fi
97	fi
98else
99	errors="Automake not found. QuakeForge git requires automake to bootstrap itself.\n$errors"
100fi
101
102if test -n "$errors" ; then
103	echo -e $errors
104	exit 1
105fi
106
107aclocal -I m4 && autoheader && $libtoolize --automake && automake --add-missing && autoconf
108