1 # helper functions for autogen.sh
4 # print out a debug message if DEBUG is a defined variable
13 # check the version of a package
14 # first argument : package name (executable)
15 # second argument : optional path where to look for it instead
16 # third argument : source download url
17 # rest of arguments : major, minor, micro version
18 # all consecutive ones : suggestions for binaries to use
19 # (if not specified in second argument)
28 # for backwards compatibility, we let PKG_PATH=PACKAGE when PKG_PATH null
29 if test -z "$PKG_PATH"; then PKG_PATH=$PACKAGE; fi
30 debug "major $MAJOR minor $MINOR micro $MICRO"
32 if test ! -z "$MINOR"; then VERSION=$VERSION.$MINOR; else MINOR=0; fi
33 if test ! -z "$MICRO"; then VERSION=$VERSION.$MICRO; else MICRO=0; fi
35 debug "major $MAJOR minor $MINOR micro $MICRO"
37 for SUGGESTION in $PKG_PATH; do
40 # don't check if asked not to
41 test -z "$NOCHECK" && {
42 echo -n " checking for $COMMAND >= $VERSION ... "
44 # we set a var with the same name as the package, but stripped of
46 VAR=`echo $PACKAGE | sed 's/-//g'`
52 debug "checking version with $COMMAND"
53 ($COMMAND --version) < /dev/null > /dev/null 2>&1 ||
58 # strip everything that's not a digit, then use cut to get the first field
59 pkg_version=`$COMMAND --version|head -n 1|sed 's/^[^0-9]*//'|cut -d' ' -f1`
60 debug "pkg_version $pkg_version"
61 # remove any non-digit characters from the version numbers to permit numeric
63 pkg_major=`echo $pkg_version | cut -d. -f1 | sed s/[a-zA-Z\-].*//g`
64 pkg_minor=`echo $pkg_version | cut -d. -f2 | sed s/[a-zA-Z\-].*//g`
65 pkg_micro=`echo $pkg_version | cut -d. -f3 | sed s/[a-zA-Z\-].*//g`
66 test -z "$pkg_major" && pkg_major=0
67 test -z "$pkg_minor" && pkg_minor=0
68 test -z "$pkg_micro" && pkg_micro=0
69 debug "found major $pkg_major minor $pkg_minor micro $pkg_micro"
71 #start checking the version
77 if [ ! "$pkg_major" -gt "$MAJOR" ]; then
78 debug "major: $pkg_major <= $MAJOR"
79 if [ "$pkg_major" -lt "$MAJOR" ]; then
80 debug "major: $pkg_major < $MAJOR"
82 elif [ ! "$pkg_minor" -gt "$MINOR" ]; then
83 debug "minor: $pkg_minor <= $MINOR"
84 if [ "$pkg_minor" -lt "$MINOR" ]; then
85 debug "minor: $pkg_minor < $MINOR"
87 elif [ "$pkg_micro" -lt "$MICRO" ]; then
88 debug "micro: $pkg_micro < $MICRO"
94 if test ! -z "$WRONG"; then
95 echo "found $pkg_version, not ok !"
98 echo "found $pkg_version, ok."
99 # we set a var with the same name as the package, but stripped of
101 VAR=`echo $PACKAGE | sed 's/-//g'`
109 echo "You must have $PACKAGE installed to compile $package."
110 echo "Download the appropriate package for your distribution,"
111 echo "or get the source tarball at $URL"
117 # normally aclocal is part of automake
118 # so we expect it to be in the same place as automake
119 # so if a different automake is supplied, we need to adapt as well
120 # so how's about replacing automake with aclocal in the set var,
121 # and saving that in $aclocal ?
122 # note, this will fail if the actual automake isn't called automake*
123 # or if part of the path before it contains it
124 if [ -z "$automake" ]; then
125 echo "Error: no automake variable set !"
128 aclocal=`echo $automake | sed s/automake/aclocal/`
129 debug "aclocal: $aclocal"
130 if [ "$aclocal" != "aclocal" ];
132 CONFIGURE_DEF_OPT="$CONFIGURE_DEF_OPT --with-aclocal=$aclocal"
134 if [ ! -x `which $aclocal` ]; then
135 echo "Error: cannot execute $aclocal !"
143 # same here - autoheader is part of autoconf
144 # use the same voodoo
145 if [ -z "$autoconf" ]; then
146 echo "Error: no autoconf variable set !"
149 autoheader=`echo $autoconf | sed s/autoconf/autoheader/`
150 debug "autoheader: $autoheader"
151 if [ "$autoheader" != "autoheader" ];
153 CONFIGURE_DEF_OPT="$CONFIGURE_DEF_OPT --with-autoheader=$autoheader"
155 if [ ! -x `which $autoheader` ]; then
156 echo "Error: cannot execute $autoheader !"
162 autoconf_2_52d_check ()
164 # autoconf 2.52d has a weird issue involving a yes:no error
165 # so don't allow it's use
166 test -z "$NOCHECK" && {
167 ac_version=`$autoconf --version|head -n 1|sed 's/^[a-zA-Z\.\ ()]*//;s/ .*$//'`
168 if test "$ac_version" = "2.52d"; then
169 echo "autoconf 2.52d has an issue with our current build."
170 echo "We don't know who's to blame however. So until we do, get a"
171 echo "regular version. RPM's of a working version are on the gstreamer site."
181 # if set to 1, we need to print something helpful then die
183 if test "x$DIE" = "x1";
186 echo "- Please get the right tools before proceeding."
187 echo "- Alternatively, if you're sure we're wrong, run with --nocheck."
194 if test "x$1" = "x"; then
198 while test "x$1" != "x" ; do
199 optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
203 AUTOGEN_EXT_OPT="$AUTOGEN_EXT_OPT --noconfigure"
204 echo "+ configure run disabled"
208 AUTOGEN_EXT_OPT="$AUTOGEN_EXT_OPT --nocheck"
210 echo "+ autotools version check disabled"
215 AUTOGEN_EXT_OPT="$AUTOGEN_EXT_OPT --debug"
216 echo "+ debug output enabled"
220 CONFIGURE_EXT_OPT="$CONFIGURE_EXT_OPT --prefix=$optarg"
221 echo "+ passing --prefix=$optarg to configure"
227 CONFIGURE_EXT_OPT="$CONFIGURE_EXT_OPT --prefix=$1"
228 echo "+ passing --prefix=$1 to configure"
233 echo "autogen.sh (autogen options) -- (configure options)"
234 echo "autogen.sh help options: "
235 echo " --noconfigure don't run the configure script"
236 echo " --nocheck don't do version checks"
237 echo " --debug debug the autogen process"
238 echo " --prefix will be passed on to configure"
240 echo " --with-autoconf PATH use autoconf in PATH"
241 echo " --with-automake PATH use automake in PATH"
243 echo "to pass options to configure, put them as arguments after -- "
248 echo "+ using alternate automake in $optarg"
249 CONFIGURE_DEF_OPT="$CONFIGURE_DEF_OPT --with-automake=$AUTOMAKE"
254 echo "+ using alternate autoconf in $optarg"
255 CONFIGURE_DEF_OPT="$CONFIGURE_DEF_OPT --with-autoconf=$AUTOCONF"
258 --disable*|--enable*|--with*)
259 echo "+ passing option $1 to configure"
260 CONFIGURE_EXT_OPT="$CONFIGURE_EXT_OPT $1"
264 *) echo "- ignoring unknown autogen.sh argument $1"; shift ;;
268 # a silly hack that generates autoregen.sh but it's handy
269 echo "#!/bin/sh" > autoregen.sh
270 echo "./autogen.sh $@ \$@" >> autoregen.sh
271 chmod +x autoregen.sh
274 for arg do CONFIGURE_EXT_OPT="$CONFIGURE_EXT_OPT $arg"; done
275 if test ! -z "$CONFIGURE_EXT_OPT"
277 echo "+ options passed to configure: $CONFIGURE_EXT_OPT"
284 test -f $srcfile || {
285 echo "You must run this script in the top-level $package directory"
296 echo "+ running $tool $options..."