1
#!/usr/bin/env bash
2
3
PROJECT=f-spot
4
5
error () {
6
	echo "Error: $1" 1>&2
7
	exit 1
8
}
9
10
function 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
36
function run () {
37
	echo "Running $@ ..."
38
	$@ || {
39
		error "Could not run $1, which is required to configure $PROJECT"
40
	}
41
}
42
43
srcdir=`dirname $0`
44
test -z "$srcdir" && srcdir=.
45
46
(test -f $srcdir/configure.ac) || {
47
	error "Directory \"$srcdir\" does not look like the top-level $PROJECT directory"
48
}
49
50
# MacPorts on OS X only seems to have glibtoolize
51
WHICHLIBTOOLIZE=$(which libtoolize || which glibtoolize)
52
if [ x"$WHICHLIBTOOLIZE" == x"" ]; then
53
	error "libtool is required to configure $PROJECT"
54
fi
55
LIBTOOLIZE=$(basename $WHICHLIBTOOLIZE)
56
57
check_autotool_version aclocal 1.9
58
check_autotool_version automake 1.9
59
check_autotool_version autoconf 2.53
60
check_autotool_version $LIBTOOLIZE 1.4.3
61
check_autotool_version intltoolize 0.35.0
62
check_autotool_version pkg-config 0.14.0
63
64
run git submodule sync
65
run git submodule update --init
66
if [ $(pkg-config --modversion gnome-doc-utils 2> /dev/null) ]; then
67
    run gnome-doc-prepare --automake --force
68
else
69
    echo "gnome-doc-utils not found; user help will not be built"
70
    echo "AC_DEFUN([GNOME_DOC_INIT], [AC_MSG_NOTICE([])])" > build/m4/gnome-doc-utils.m4
71
    ACLOCAL_FLAGS="-I build/m4 $ACLOCAL_FLAGS"
72
    touch gnome-doc-utils.make
73
fi
74
75
run intltoolize --force --copy
76
run $LIBTOOLIZE --force --copy --automake
77
run aclocal -I build/m4/f-spot -I build/m4/shamrock -I build/m4/shave $ACLOCAL_FLAGS
78
run autoconf
79
run autoheader
80
test -f config.h.in && touch config.h.in
81
run automake --gnu --add-missing --force --copy \
82
	-Wno-portability
83
84
if [ ! -z "$NOCONFIGURE" ]; then
85
	echo "Done. ./configure skipped."
86
	exit $?
87
fi
88
89
if [ $# = 0 ]; then
90
	echo "WARNING: I am going to run configure without any arguments."
91
fi
92
93
run ./configure --enable-maintainer-mode $@