Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2006:
[Freeciv-Dev] Re: (PR#12560) autogen.sh is inflexible when selecting ins
Home

[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]
To: sini.ruohomaa@xxxxxx
Subject: [Freeciv-Dev] Re: (PR#12560) autogen.sh is inflexible when selecting installed version of automake
From: "Tommi Björkbacka" <tommibj@xxxxxxxxx>
Date: Sat, 15 Jul 2006 06:46:41 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12560 >

This transaction appears to have no content
Hi

This patch fixes problem (#12560) for me. It's far from perfect but should
work for majority of us. Current version of autogen can't find newer version
of tool (example automake) if default one is too old. After this patch
situation is little better. :)

If default tool is too old autogen tries to find a newer one. It checks
every directory from $PATH. If there are tools named like tool-a.b (a and b
integers) autogen takes tool which has biggest version number after it's
name.

There are some limitations. If tool is named like tool-1.2.3 or
tool-1.2aautogen can't find it. This patch is only tested with Ubuntu
Dapper Drake
with automake-1.4 (aclocal-1.4) and automake-1.9 (aclocal-1.9) installed.

- Tommi
Hi

This patch fixes problem (#12560) for me. It's far from perfect but should work for majority of us. Current version of autogen can't find newer version of tool (example automake) if default one is too old. After this patch situation is little better. :)

If default tool is too old autogen tries to find a newer one. It checks every directory from $PATH. If there are tools named like tool-a.b (a and b integers) autogen takes tool which has biggest version number after it's name.

There are some limitations. If tool is named like tool-1.2.3 or tool-1.2a autogen can't find it. This patch is only tested with Ubuntu Dapper Drake with automake-1.4 (aclocal-1.4) and automake-1.9 (aclocal-1.9) installed.

- Tommi


--- autogen.sh.orig     2006-07-12 23:24:43.000000000 +0300
+++ autogen.sh  2006-07-15 15:42:56.000000000 +0300
@@ -40,9 +40,90 @@
   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
+
+  real_package_name=
+  # check if given package is suitable
+  if version_check 2 $RPACKAGE $RURL $RMAJOR $RMINOR $RMICRO; then
+    version_check 1 $RPACKAGE $RURL $RMAJOR $RMINOR $RMICRO
+  else
+    # given package was too old or not available
+    # search for the newest one
+    if version_search $RPACKAGE; then
+      version_check 1 $new_pkg $RURL $RMAJOR $RMINOR $RMICRO
+    else 
+      version_check 1 $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 
+        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`
+
+        # 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
+              FOUNDNEW=1
+          elif [ "$new_s_pkg_major" -eq "$s_pkg_major" ]; then
+            if [ "$new_s_pkg_minor" -gt "$s_pkg_minor" ]; then
+              FOUNDNEW=1
+            fi
+          fi
+      
+          if [ ! -z "$FOUNDNEW" ]; then
+            new_pkg="$FOUNDPKG"
+          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')
+# first argument : silent ('2'), complain ('1') or not ('0')
 # second argument : package name (executable)
 # third argument : source download url
 # rest of arguments : major, minor, micro version
@@ -62,7 +143,9 @@
   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 $PACKAGE >= $VERSION ... " | tr -d '\n'
+  fi
 
   ($PACKAGE --version) < /dev/null > /dev/null 2>&1 || 
   {
@@ -95,7 +178,9 @@
   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."
@@ -104,7 +189,9 @@
    fi
    return 1
   else
-    echo "found $pkg_version, ok."
+    if [ "$COMPLAIN" -ne "2" ]; then
+      echo "found $pkg_version, ok."
+    fi
   fi
 }
 
@@ -120,8 +207,16 @@
 # 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
+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
+
+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
@@ -142,26 +237,26 @@
 cat m4/*.m4 > acinclude.m4
 
 echo "+ running aclocal ..."
-aclocal $ACLOCAL_FLAGS || {
+$ACLOCAL $ACLOCAL_FLAGS || {
   echo
   echo "aclocal failed - check that all needed development files are present 
on system"
   exit 1
 }
 
 echo "+ running autoheader ... "
-autoheader || {
+$AUTOHEADER || {
   echo
   echo "autoheader failed"
   exit 1
 }
 echo "+ running autoconf ... "
-autoconf || {
+$AUTOCONF || {
   echo
   echo "autoconf failed"
   exit 1
 }
 echo "+ running automake ... "
-automake -a -c || {
+$AUTOMAKE -a -c || {
   echo
   echo "automake failed"
   exit 1

[Prev in Thread] Current Thread [Next in Thread]