-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgen-functions
More file actions
123 lines (98 loc) · 3.17 KB
/
gen-functions
File metadata and controls
123 lines (98 loc) · 3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
############################################# -*- sh -*- ##############
# Useful functions
initialize () {
local test_type="$2" file="$3"
PROJECT="$1"
DIE=0
if [ ! $test_type $file ]; then
echo "Could not find the top-level $PROJECT directory"
DIE=1
fi
if [ "x$LIBTOOL" = "x" ]; then
if [ -x "`which glibtool 2> /dev/null`" ]; then
LIBTOOL="glibtool"
LIBTOOLIZE="glibtoolize"
else
LIBTOOL="libtool"
LIBTOOLIZE="libtoolize"
fi
fi
}
check_ver () {
local ver="$1" reqver="$2" vdigit="" rdigit=""
until [ -z "$ver" ]; do
vdigit=`echo "$ver" | sed 's/[^0-9]*\([0-9]\{1,\}\).*/\1/'`
rdigit=`echo "$reqver" | sed 's/[^0-9]*\([0-9]\{1,\}\).*/\1/'`
ver=`echo "$ver" | sed 's/[^0-9]*[0-9]\{1,\}\.\{0,\}\(.*\)/\1/'`
reqver=`echo "$reqver" | sed 's/[^0-9]*[0-9]\{1,\}\.\{0,\}\(.*\)/\1/'`
if [ -z "$vdigit" ]; then vdigit="0"; fi
if [ -z "$rdigit" ]; then rdigit="0"; fi
# If the version is less, automatic fail
if [ $vdigit -lt $rdigit ]; then
DIE=1
BADVER=1
return
# If the version is greater, automatic success
elif [ $vdigit -gt $rdigit ]; then
BADVER=0
return
fi
# Otherwise it's equal, so keep checking
done
# If we're here and we haven't failed, it must be equal.
BADVER=0
}
check_prog () {
local prog="$1" vercmd="$2" ver="" reqver="$3" action="$4" url="$5"
local msg="You must have $prog $reqver to $action. Please acquire it from $url or a mirror."
if [ -z "`which $prog`" ]; then
echo $msg | fold -s
DIE=1
fi
ver="`eval $vercmd | head -n 1`"
check_ver "$ver" "$reqver"
if [ "$BADVER" = "1" ]; then
echo $msg | fold -s
DIE=1
fi
}
check_cc () {
case $CC in
*xlc | *xlc\ * | *lcc | *lcc\ *) am_opt=--include-deps;;
esac
}
checks_or_die () {
if [ "$DIE" = "1" ]; then exit 1; fi
}
generate () {
local autogen_dirs="$@"
if [ -z "$autogen_dirs" ]; then
autogen_dirs="."
fi
for i in $autogen_dirs; do
echo "Processing $i..."
# automatically generate Makefile list
MAKEFILE_LIST="`find . -mindepth 1 -name \"Makefile.am\" \
| sort | tr '\n' ' ' | sed 's+\./++g;s/\.am//g'`"
sed "s+^\(AC_CONFIG_FILES(\[\).*$+\1$MAKEFILE_LIST+" \
< configure.ac > configure.ac.tmp
if [ -z "`diff --brief configure.ac configure.ac.tmp`" ]; then
rm -f configure.ac.tmp
else
echo 'autogen: updating list of Makefiles in configure.ac'
mv configure.ac.tmp configure.ac
fi
cd $i
aclocal -I aclocal --install $ACLOCAL_FLAGS
# optionally feature autoheader
if grep AC_CONFIG_HEADERS configure.ac >/dev/null ; then
(autoheader --version) < /dev/null > /dev/null 2>&1 && autoheader
fi
# It seems that libtool 1.4.2 doesn't give call libtoolize anymore
if grep AC_PROG_LIBTOOL configure.ac >/dev/null; then
$LIBTOOLIZE --automake --force
fi
automake --add-missing $am_opt
autoconf
done
}