[Freeciv-Dev] Re: (PR#12560) autogen.sh is inflexible when selecting ins
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12560 >
Hi
Here is a new version of autogen patch. It has couple of bugs fixed
that were in previous version. There are still bugs/problems left. For
example, autogen doesn't handle broken tools correctly and error
messages in those situations aren't very helpful.
Please check this out and give some feedback. :)
- Tommi
--- autogen.sh.orig 2006-07-12 23:24:43.000000000 +0300
+++ autogen.sh 2006-07-19 14:35:52.000000000 +0300
@@ -40,19 +40,110 @@
fi
}
+real_package_name ()
+# solve a real name of suitable package
+# first argument : package name (executable)
+# second argument : source download url
+# rest of arguments : major, minor, micro version
+{
+ RPACKAGE=$1
+ RURL=$2
+ RMAJOR=$3
+ RMINOR=$4
+ RMICRO=$5
+
+ new_pkg=$RPACKAGE
+
+ # check if given package is suitable
+ if version_check 2 $RPACKAGE $RPACKAGE $RURL $RMAJOR $RMINOR $RMICRO; then
+ version_check 1 $RPACKAGE $RPACKAGE $RURL $RMAJOR $RMINOR $RMICRO
+ else
+ # given package was too old or not available
+ # search for the newest one
+ if version_search $RPACKAGE; then
+ if version_check 2 $RPACKAGE $new_pkg $RURL $RMAJOR $RMINOR $RMICRO; then
+ # suitable package found
+ version_check 1 $RPACKAGE $new_pkg $RURL $RMAJOR $RMINOR $RMICRO
+ else
+ # the newest package is not new enough or it is broken
+ version_check 1 $RPACKAGE $RPACKAGE $RURL $RMAJOR $RMINOR $RMICRO
+ return 1
+ fi
+ else
+ # no version of given package with version information
+ # in its name available
+ version_check 1 $RPACKAGE $RPACKAGE $RURL $RMAJOR $RMINOR $RMICRO
+ return 1
+ fi
+ fi
+
+ REALPKGNAME=$new_pkg
+}
+
+version_search ()
+# search the newest version of a package
+# first argument : package name (executable)
+{
+ SPACKAGE=$1
+ STOREDIFS=$IFS
+ IFS=":"
+ set -- $PATH
+ IFS=$STOREDIFS
+
+ s_pkg_major=0
+ s_pkg_minor=0
+ new_pkg=
+
+ for SEARCHDIR ; do
+ for MATCHSTUFF in `ls "$SEARCHDIR/$SPACKAGE-"* 2> /dev/null` ; do
+ for FOUNDPKG in $MATCHSTUFF; do
+ # parse version information from name
+ new_s_pkg_major=`echo $FOUNDPKG | cut -s -d- -f2 | cut -s -d. -f1`
+ new_s_pkg_minor=`echo $FOUNDPKG | cut -s -d- -f2 | cut -s -d. -f2`
+
+ CORRECT=
+ # check if version numbers are integers
+ [ ! "x$new_s_pkg_major" = "x" ] && \
+ [ "x`echo $new_s_pkg_major | sed s/[0-9]*//g`" = "x" ] && \
+ [ ! "x$new_s_pkg_minor" = "x" ] && \
+ [ "x`echo $new_s_pkg_minor | sed s/[0-9]*//g`" = "x" ] && \
+ CORRECT=1
+
+ if [ ! -z $CORRECT ]; then
+ if [ "$new_s_pkg_major" -gt "$s_pkg_major" ]; then
+ new_pkg="$FOUNDPKG"
+ elif [ "$new_s_pkg_major" -eq "$s_pkg_major" ]; then
+ if [ "$new_s_pkg_minor" -gt "$s_pkg_minor" ]; then
+ new_pkg="$FOUNDPKG"
+ fi
+ fi
+ fi
+ done
+ done
+ done
+
+ if [ -z "$new_pkg" ]; then
+ return 1
+ else
+ return 0
+ fi
+}
+
version_check ()
# check the version of a package
-# first argument : complain ('1') or not ('0')
-# second argument : package name (executable)
-# third argument : source download url
+# first argument : silent ('2'), complain ('1') or not ('0')
+# second argument : package name
+# third argument : package name (executable)
+# fourth argument : source download url
# rest of arguments : major, minor, micro version
{
COMPLAIN=$1
- PACKAGE=$2
- URL=$3
- MAJOR=$4
- MINOR=$5
- MICRO=$6
+ PACKAGEMSG=$2
+ PACKAGE=$3
+ URL=$4
+ MAJOR=$5
+ MINOR=$6
+ MICRO=$7
WRONG=
@@ -62,16 +153,21 @@
if [ ! -z "$MICRO" ]; then VERSION=$VERSION.$MICRO; else MICRO=0; fi
debug "version $VERSION"
- echo "+ checking for $PACKAGE >= $VERSION ... " | tr -d '\n'
-
+ if [ "$COMPLAIN" -ne "2" ]; then
+ echo "+ checking for $PACKAGEMSG >= $VERSION ... " | tr -d '\n'
+ fi
+
($PACKAGE --version) < /dev/null > /dev/null 2>&1 ||
{
- echo
- echo "You must have $PACKAGE installed to compile $package."
- echo "Download the appropriate package for your distribution,"
- echo "or get the source tarball at $URL"
+ if [ "$COMPLAIN" -ne "2" ]; then
+ echo
+ echo "You must have $PACKAGEMSG installed to compile $package."
+ echo "Download the appropriate package for your distribution,"
+ echo "or get the source tarball at $URL"
+ fi
return 1
}
+
# the following line is carefully crafted sed magic
pkg_version=`$PACKAGE --version|head -n 1|sed 's/([^)]*)//g;s/^[a-zA-Z\.\
\-]*//;s/ .*$//'`
debug "pkg_version $pkg_version"
@@ -95,16 +191,20 @@
fi
if [ ! -z "$WRONG" ]; then
- echo "found $pkg_version, not ok !"
+ if [ "$COMPLAIN" -ne "2" ]; then
+ echo "found $pkg_version, not ok !"
+ fi
if [ "$COMPLAIN" -eq "1" ]; then
echo
- echo "You must have $PACKAGE $VERSION or greater to compile $package."
+ echo "You must have $PACKAGEMSG $VERSION or greater to compile $package."
echo "Get the latest version from <$URL>."
echo
fi
return 1
else
- echo "found $pkg_version, ok."
+ if [ "$COMPLAIN" -ne "2" ]; then
+ echo "found $pkg_version, ok."
+ fi
fi
}
@@ -120,12 +220,22 @@
# the original autoconf 2.13 version; we must suppose 2.52 by default here
cp m4/x.252 m4/x.m4
-version_check 1 "autoconf" "ftp://ftp.gnu.org/pub/gnu/autoconf/" 2 55 || DIE=1
-version_check 1 "automake" "ftp://ftp.gnu.org/pub/gnu/automake/" 1 6 || DIE=1
+# autoconf and autoheader version numbers must be kept in sync
+real_package_name "autoconf" "ftp://ftp.gnu.org/pub/gnu/autoconf/" 2 55 ||
DIE=1
+AUTOCONF=$REALPKGNAME
+real_package_name "autoheader" "ftp://ftp.gnu.org/pub/gnu/autoconf/" 2 55 ||
DIE=1
+AUTOHEADER=$REALPKGNAME
+
+# automake and aclocal version numbers must be kept in sync
+real_package_name "automake" "ftp://ftp.gnu.org/pub/gnu/automake/" 1 6 || DIE=1
+AUTOMAKE=$REALPKGNAME
+real_package_name "aclocal" "ftp://ftp.gnu.org/pub/gnu/automake/" 1 6 || DIE=1
+ACLOCAL=$REALPKGNAME
+
if [ "$FC_USE_NLS" = "yes" ]; then
DIE2=0
- version_check 1 "xgettext" "ftp://ftp.gnu.org/pub/gnu/gettext/" 0 10 36 ||
DIE2=1
- version_check 1 "msgfmt" "ftp://ftp.gnu.org/pub/gnu/gettext/" 0 10 36 ||
DIE2=1
+ version_check 1 "xgettext" "xgettext" "ftp://ftp.gnu.org/pub/gnu/gettext/" 0
10 36 || DIE2=1
+ version_check 1 "msgfmt" "msgfmt" "ftp://ftp.gnu.org/pub/gnu/gettext/" 0 10
36 || DIE2=1
if [ "$DIE2" -eq 1 ]; then
echo
echo "You may want to use --disable-nls to disable NLS."
@@ -141,29 +251,29 @@
echo "+ creating acinclude.m4"
cat m4/*.m4 > acinclude.m4
-echo "+ running aclocal ..."
-aclocal $ACLOCAL_FLAGS || {
+echo "+ running $ACLOCAL ..."
+$ACLOCAL $ACLOCAL_FLAGS || {
echo
- echo "aclocal failed - check that all needed development files are present
on system"
+ echo "$ACLOCAL failed - check that all needed development files are present
on system"
exit 1
}
-echo "+ running autoheader ... "
-autoheader || {
+echo "+ running $AUTOHEADER ... "
+$AUTOHEADER || {
echo
- echo "autoheader failed"
+ echo "$AUTOHEADER failed"
exit 1
}
-echo "+ running autoconf ... "
-autoconf || {
+echo "+ running $AUTOCONF ... "
+$AUTOCONF || {
echo
- echo "autoconf failed"
+ echo "$AUTOCONF failed"
exit 1
}
-echo "+ running automake ... "
-automake -a -c || {
+echo "+ running $AUTOMAKE ... "
+$AUTOMAKE -a -c || {
echo
- echo "automake failed"
+ echo "$AUTOMAKE failed"
exit 1
}
|
|