1 # a silly hack that generates autoregen.sh but it's handy
2 # Remove the old autoregen.sh first to create a new file,
3 # as the current one may be being read by the shell executing
5 if [ -f "autoregen.sh" ]; then
8 echo "#!/bin/sh" > autoregen.sh
9 echo "./autogen.sh $@ \$@" >> autoregen.sh
12 # helper functions for autogen.sh
15 # print out a debug message if DEBUG is a defined variable
24 # based on the command's version output, set variables
25 # _MAJOR, _MINOR, _MICRO, _VERSION, using the given prefix as variable prefix
27 # arg 1: command binary name
28 # arg 2: (uppercased) variable name prefix
33 # strip everything that's not a digit, then use cut to get the first field
34 pkg_version=`$COMMAND --version|head -n 1|sed 's/^.*)[^0-9]*//'|cut -d' ' -f1`
35 debug "pkg_version $pkg_version"
36 # remove any non-digit characters from the version numbers to permit numeric
38 pkg_major=`echo $pkg_version | cut -d. -f1 | sed s/[a-zA-Z\-].*//g`
39 pkg_minor=`echo $pkg_version | cut -d. -f2 | sed s/[a-zA-Z\-].*//g`
40 pkg_micro=`echo $pkg_version | cut -d. -f3 | sed s/[a-zA-Z\-].*//g`
41 test -z "$pkg_major" && pkg_major=0
42 test -z "$pkg_minor" && pkg_minor=0
43 test -z "$pkg_micro" && pkg_micro=0
44 debug "found major $pkg_major minor $pkg_minor micro $pkg_micro"
45 eval `echo ${VARPREFIX}`_MAJOR=$pkg_major
46 eval `echo ${VARPREFIX}`_MINOR=$pkg_minor
47 eval `echo ${VARPREFIX}`_MICRO=$pkg_micro
48 eval `echo ${VARPREFIX}`_VERSION=$pkg_version
52 # Checks whether the version of VARPREFIX is equal to or
53 # newer than the requested version
64 pkg_major=$(eval echo $`echo ${VARPREFIX}`_MAJOR);
65 pkg_minor=$(eval echo $`echo ${VARPREFIX}`_MINOR);
66 pkg_micro=$(eval echo $`echo ${VARPREFIX}`_MICRO);
68 #start checking the version
69 debug "version_compare: $VARPREFIX against $MAJOR.$MINOR.$MICRO"
74 if [ ! "$pkg_major" -gt "$MAJOR" ]; then
75 debug "major: $pkg_major <= $MAJOR"
76 if [ "$pkg_major" -lt "$MAJOR" ]; then
77 debug "major: $pkg_major < $MAJOR"
79 elif [ ! "$pkg_minor" -gt "$MINOR" ]; then
80 debug "minor: $pkg_minor <= $MINOR"
81 if [ "$pkg_minor" -lt "$MINOR" ]; then
82 debug "minor: $pkg_minor < $MINOR"
84 elif [ "$pkg_micro" -lt "$MICRO" ]; then
85 debug "micro: $pkg_micro < $MICRO"
90 if test ! -z "$WRONG"; then
91 debug "version_compare: $VARPREFIX older than $MAJOR.$MINOR.$MICRO"
94 debug "version_compare: $VARPREFIX equal to/newer than $MAJOR.$MINOR.$MICRO"
100 # check the version of a package
101 # first argument : package name (executable)
102 # second argument : optional path where to look for it instead
103 # third argument : source download url
104 # rest of arguments : major, minor, micro version
105 # all consecutive ones : suggestions for binaries to use
106 # (if not specified in second argument)
115 # for backwards compatibility, we let PKG_PATH=PACKAGE when PKG_PATH null
116 if test -z "$PKG_PATH"; then PKG_PATH=$PACKAGE; fi
117 debug "major $MAJOR minor $MINOR micro $MICRO"
119 if test ! -z "$MINOR"; then VERSION=$VERSION.$MINOR; else MINOR=0; fi
120 if test ! -z "$MICRO"; then VERSION=$VERSION.$MICRO; else MICRO=0; fi
122 debug "major $MAJOR minor $MINOR micro $MICRO"
124 for SUGGESTION in $PKG_PATH; do
125 COMMAND="$SUGGESTION"
127 # don't check if asked not to
128 test -z "$NOCHECK" && {
129 echo -n " checking for $COMMAND >= $VERSION ... "
131 # we set a var with the same name as the package, but stripped of
133 VAR=`echo $PACKAGE | sed 's/-//g'`
139 which $COMMAND > /dev/null 2>&1
142 debug "$COMMAND not found"
146 VARPREFIX=`echo $COMMAND | sed 's/-//g' | tr [:lower:] [:upper:]`
147 version_get $COMMAND $VARPREFIX
149 version_compare $VARPREFIX $MAJOR $MINOR $MICRO
150 if test $? -ne 0; then
151 echo "found $pkg_version, not ok !"
154 echo "found $pkg_version, ok."
155 # we set a var with the same name as the package, but stripped of
157 VAR=`echo $PACKAGE | sed 's/-//g'`
164 echo "$PACKAGE not found !"
165 echo "You must have $PACKAGE installed to compile $package."
166 echo "Download the appropriate package for your distribution,"
167 echo "or get the source tarball at $URL"
173 # normally aclocal is part of automake
174 # so we expect it to be in the same place as automake
175 # so if a different automake is supplied, we need to adapt as well
176 # so how's about replacing automake with aclocal in the set var,
177 # and saving that in $aclocal ?
178 # note, this will fail if the actual automake isn't called automake*
179 # or if part of the path before it contains it
180 if [ -z "$automake" ]; then
181 echo "Error: no automake variable set !"
184 aclocal=`echo $automake | sed s/automake/aclocal/`
185 debug "aclocal: $aclocal"
186 if [ "$aclocal" != "aclocal" ];
188 CONFIGURE_DEF_OPT="$CONFIGURE_DEF_OPT --with-aclocal=$aclocal"
190 if [ ! -x `which $aclocal` ]; then
191 echo "Error: cannot execute $aclocal !"
199 # same here - autoheader is part of autoconf
200 # use the same voodoo
201 if [ -z "$autoconf" ]; then
202 echo "Error: no autoconf variable set !"
205 autoheader=`echo $autoconf | sed s/autoconf/autoheader/`
206 debug "autoheader: $autoheader"
207 if [ "$autoheader" != "autoheader" ];
209 CONFIGURE_DEF_OPT="$CONFIGURE_DEF_OPT --with-autoheader=$autoheader"
211 if [ ! -x `which $autoheader` ]; then
212 echo "Error: cannot execute $autoheader !"
219 autoconf_2_52d_check ()
221 # autoconf 2.52d has a weird issue involving a yes:no error
222 # so don't allow it's use
223 test -z "$NOCHECK" && {
224 ac_version=`$autoconf --version|head -n 1|sed 's/^[a-zA-Z\.\ ()]*//;s/ .*$//'`
225 if test "$ac_version" = "2.52d"; then
226 echo "autoconf 2.52d has an issue with our current build."
227 echo "We don't know who's to blame however. So until we do, get a"
228 echo "regular version. RPM's of a working version are on the gstreamer site."
234 libtool_2_2_gettext_check ()
236 # libtool 2.2 needs autopoint 0.17 or higher
237 version_compare LIBTOOLIZE 2 2 0
240 version_compare AUTOPOINT 0 17 0
243 echo "libtool 2.2 requires autopoint 0.17 or higher"
254 # if set to 1, we need to print something helpful then die
256 if test "x$DIE" = "x1";
259 echo "- Please get the right tools before proceeding."
260 echo "- Alternatively, if you're sure we're wrong, run with --nocheck."
267 if test "x$1" = "x"; then
271 while test "x$1" != "x" ; do
272 optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
276 AUTOGEN_EXT_OPT="$AUTOGEN_EXT_OPT --noconfigure"
277 echo "+ configure run disabled"
281 AUTOGEN_EXT_OPT="$AUTOGEN_EXT_OPT --nocheck"
283 echo "+ autotools version check disabled"
288 AUTOGEN_EXT_OPT="$AUTOGEN_EXT_OPT --debug"
289 echo "+ debug output enabled"
293 echo "autogen.sh (autogen options) -- (configure options)"
294 echo "autogen.sh help options: "
295 echo " --noconfigure don't run the configure script"
296 echo " --nocheck don't do version checks"
297 echo " --debug debug the autogen process"
299 echo " --with-autoconf PATH use autoconf in PATH"
300 echo " --with-automake PATH use automake in PATH"
302 echo "Any argument either not in the above list or after a '--' will be "
303 echo "passed to ./configure."
308 echo "+ using alternate automake in $optarg"
309 CONFIGURE_DEF_OPT="$CONFIGURE_DEF_OPT --with-automake=$AUTOMAKE"
314 echo "+ using alternate autoconf in $optarg"
315 CONFIGURE_DEF_OPT="$CONFIGURE_DEF_OPT --with-autoconf=$AUTOCONF"
320 echo "+ passing argument $1 to configure"
321 CONFIGURE_EXT_OPT="$CONFIGURE_EXT_OPT $1"
327 for arg do CONFIGURE_EXT_OPT="$CONFIGURE_EXT_OPT $arg"; done
328 if test ! -z "$CONFIGURE_EXT_OPT"
330 echo "+ options passed to configure: $CONFIGURE_EXT_OPT"
337 test -f $srcfile || {
338 echo "You must run this script in the top-level $package directory"
348 echo "+ running $tool $options..."
359 if test -d .git; then
360 # install pre-commit hook for doing clean commits
361 for hook in pre-commit; do
362 if test ! \( -x .git/hooks/$hook -a -L .git/hooks/$hook \); then
363 echo "+ Installing git $hook hook"
364 rm -f .git/hooks/$hook
365 ln -s ../../common/hooks/$hook.hook .git/hooks/$hook || {
366 # if we couldn't create a symbolic link, try doing a plain cp
367 if cp common/hooks/pre-commit.hook .git/hooks/pre-commit; then
368 chmod +x .git/hooks/pre-commit;
370 echo "********** Couldn't install git $hook hook **********";