autogen.sh 2.6 KB
Newer Older
1
#!/usr/bin/env bash
Aaron Bockover's avatar
Aaron Bockover committed
2

3
PROJECT=banshee
Aaron Bockover's avatar
Aaron Bockover committed
4

5 6 7 8
function error () {
	echo "Error: $1" 1>&2
	exit 1
}
Aaron Bockover's avatar
Aaron Bockover committed
9

10 11 12 13 14 15 16 17
function check_autotool_version () {
	which $1 &>/dev/null || {
		error "$1 is not installed, and is required to configure $PACKAGE"
	}

	version=$($1 --version | head -n 1 | cut -f4 -d' ')
	major=$(echo $version | cut -f1 -d.)
	minor=$(echo $version | cut -f2 -d.)
18
	rev=$(echo $version | cut -f3 -d. | sed 's/[^0-9].*$//')
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
	major_check=$(echo $2 | cut -f1 -d.)
	minor_check=$(echo $2 | cut -f2 -d.)
	rev_check=$(echo $2 | cut -f3 -d.)

	if [ $major -lt $major_check ]; then
		do_bail=yes
	elif [[ $minor -lt $minor_check && $major = $major_check ]]; then
		do_bail=yes
	elif [[ $rev -lt $rev_check && $minor = $minor_check && $major = $major_check ]]; then
		do_bail=yes
	fi

	if [ x"$do_bail" = x"yes" ]; then
		error "$1 version $2 or better is required to configure $PROJECT"
	fi
Aaron Bockover's avatar
Aaron Bockover committed
34 35
}

36
function run () {
37 38 39
	which $1 >/dev/null || {
		error "Could not find '$1', which is required to configure $PROJECT"
	}
40 41 42 43
	echo "Running $@ ..."
	$@ 2>.autogen.log || {
		cat .autogen.log 1>&2
		rm .autogen.log
44
		error "There were errors when running '$1', a step that is required to configure $PROJECT"
45 46
	}
	rm .autogen.log
Aaron Bockover's avatar
Aaron Bockover committed
47 48
}

49 50 51 52 53
srcdir=$(dirname $0)
test -z "$srcdir" && srcdir=.

(test -f $srcdir/configure.ac) || {
	error "Directory \"$srcdir\" does not look like the top-level $PROJECT directory"
Aaron Bockover's avatar
Aaron Bockover committed
54
}
Aaron Bockover's avatar
Aaron Bockover committed
55

56 57
builddir=`pwd`
cd "$srcdir"
58 59 60 61

# in case there are binaries from a previous compilation
make distclean 2>/dev/null

62
# MacPorts on OS X only seems to have glibtoolize
63 64 65 66 67
WHICHLIBTOOLIZE=$(which libtoolize || which glibtoolize)
if [ x"$WHICHLIBTOOLIZE" == x"" ]; then
	error "libtool is required to configure $PROJECT"
fi
LIBTOOLIZE=$(basename $WHICHLIBTOOLIZE)
68

69
check_autotool_version aclocal 1.9
70
check_autotool_version automake 1.10
71
check_autotool_version autoconf 2.53
72
check_autotool_version $LIBTOOLIZE 1.4.3
73
check_autotool_version intltoolize 0.35.0
74 75
check_autotool_version pkg-config 0.14.0

76
if git --help &>/dev/null; then
77
	git submodule update --init
78 79
fi

80
run intltoolize --force --copy
81
run $LIBTOOLIZE --force --copy --automake
82
run aclocal -I build/m4/banshee -I build/m4/shamrock -I build/m4/shave $ACLOCAL_FLAGS
83 84
run autoconf
run autoheader
Gabriel Burt's avatar
Gabriel Burt committed
85

86 87 88
test -f config.h.in && touch config.h.in
run automake --gnu --add-missing --force --copy \
	-Wno-portability -Wno-portability
Aaron Bockover's avatar
Aaron Bockover committed
89

90 91 92 93 94
if [ ! -z "$NOCONFIGURE" ]; then
	echo "Done. ./configure skipped."
	exit $?
fi

95 96
if [ $# = 0 ]; then
	echo "WARNING: I am going to run configure without any arguments."
97
fi
Aaron Bockover's avatar
Aaron Bockover committed
98

99
cd "$builddir"
100

101 102
{ cat <<EOF
#!/usr/bin/env bash
103
./autogen.sh $@ \$@
104 105
EOF
} > reautogen.sh
106
chmod +x reautogen.sh
107

108
run "$srcdir/configure" $@