PageRenderTime 39ms CodeModel.GetById 20ms app.highlight 14ms RepoModel.GetById 2ms app.codeStats 0ms

/autogen.sh

http://github.com/hbons/SparkleShare
Shell | 85 lines | 64 code | 17 blank | 4 comment | 14 complexity | b28579829ee5fc149cea7639cb452025 MD5 | raw file
 1#!/usr/bin/env bash
 2
 3PROJECT=sparkleshare
 4
 5function error () {
 6	echo "Error: $1" 1>&2
 7	exit 1
 8}
 9
10function check_autotool_version () {
11	which $1 &>/dev/null || {
12		error "$1 is not installed, and is required to configure $PACKAGE"
13	}
14
15	version=$($1 --version | head -n 1 | cut -f4 -d' ')
16	major=$(echo $version | cut -f1 -d.)
17	minor=$(echo $version | cut -f2 -d.)
18	rev=$(echo $version | cut -f3 -d. | sed 's/[^0-9].*$//')
19	major_check=$(echo $2 | cut -f1 -d.)
20	minor_check=$(echo $2 | cut -f2 -d.)
21	rev_check=$(echo $2 | cut -f3 -d.)
22
23	if [ $major -lt $major_check ]; then
24		do_bail=yes
25	elif [[ $minor -lt $minor_check && $major = $major_check ]]; then
26		do_bail=yes
27	elif [[ $rev -lt $rev_check && $minor = $minor_check && $major = $major_check ]]; then
28		do_bail=yes
29	fi
30
31	if [ x"$do_bail" = x"yes" ]; then
32		error "$1 version $2 or better is required to configure $PROJECT"
33	fi
34}
35
36function run () {
37	echo "Running $@ ..."
38	$@ 2>.autogen.log || {
39		cat .autogen.log 1>&2
40		rm .autogen.log
41		error "Could not run $1, which is required to configure $PROJECT"
42	}
43	rm .autogen.log
44}
45
46srcdir=$(dirname $0)
47test -z "$srcdir" && srcdir=.
48
49(test -f $srcdir/configure.ac) || {
50	error "Directory \"$srcdir\" does not look like the top-level $PROJECT directory"
51}
52
53# MacPorts on OS X only seems to have glibtoolize
54WHICHLIBTOOLIZE=$(which libtoolize || which glibtoolize)
55if [ x"$WHICHLIBTOOLIZE" == x"" ]; then
56	error "libtool is required to configure $PROJECT"
57fi
58LIBTOOLIZE=$(basename $WHICHLIBTOOLIZE)
59
60check_autotool_version aclocal 1.9
61check_autotool_version automake 1.9
62check_autotool_version autoconf 2.53
63check_autotool_version $LIBTOOLIZE 1.4.3
64#check_autotool_version intltoolize 0.35.0
65check_autotool_version pkg-config 0.14.0
66
67#run intltoolize --force --copy
68run $LIBTOOLIZE --force --copy --automake
69run aclocal -I build/m4/sparkleshare -I build/m4/shamrock -I build/m4/shave $ACLOCAL_FLAGS
70run autoconf
71
72run automake --gnu --add-missing --force --copy \
73	-Wno-portability -Wno-portability
74
75if [ ! -z "$NOCONFIGURE" ]; then
76	echo "Done. ./configure skipped."
77	exit $?
78fi
79
80if [ $# = 0 ]; then
81	echo "WARNING: I am going to run configure without any arguments."
82fi
83
84run ./configure --enable-maintainer-mode $@
85