]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
In branch-2-0 (and in time, others) ltversion.m4 has a dot
authorGary V. Vaughan <gary@gnu.org>
Sun, 27 Feb 2005 21:19:51 +0000 (21:19 +0000)
committerGary V. Vaughan <gary@gnu.org>
Sun, 27 Feb 2005 21:19:51 +0000 (21:19 +0000)
delimited serial number that didn't used to be processed
correctly by libtoolize.  This changeset fixes that, and
leverages those changes to check versions of ltmain.sh and
config.sub, config.guess before overwriting when --force is
not given:

* libtoolize.m4sh: Don't overwrite pkgaux files with --force
unless --install is given too.
(func_serial): Fix underquoting in regexp.
(func_serial_max): New function to compare serial numbers.
(func_serial_update_check): New function factored out of
func_serial_update().
(func_serial_update): Bail if SRCFILE is missing.
Don't display both 'already up to date' and 'use --force to
update' messages for the same file.
Use func_serial_max to cope with `.' delimited serial numbers.
(func_ltmain_update): Use func_serial_update_check and
func_serial_max to do version checking with $package_revision.
(func_config_update): Ditto with $timestamp.

ChangeLog
libtoolize.m4sh

index 33bd13dbeda56f6a09985b00384e375e6828f4f8..a17db56ffb51a7034323477270ebacaed42a3f9e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2005-02-27  Gary V. Vaughan  <gary@gnu.org>
+
+       In branch-2-0 (and in time, others) ltversion.m4 has a dot
+       delimited serial number that didn't used to be processed
+       correctly by libtoolize.  This changeset fixes that, and
+       leverages those changes to check versions of ltmain.sh and
+       config.sub, config.guess before overwriting when --force is
+       not given:
+
+       * libtoolize.m4sh: Don't overwrite pkgaux files with --force
+       unless --install is given too.
+       (func_serial): Fix underquoting in regexp.
+       (func_serial_max): New function to compare serial numbers.
+       (func_serial_update_check): New function factored out of
+       func_serial_update().
+       (func_serial_update): Bail if SRCFILE is missing.
+       Don't display both 'already up to date' and 'use --force to
+       update' messages for the same file.
+       Use func_serial_max to cope with `.' delimited serial numbers.
+       (func_ltmain_update): Use func_serial_update_check and
+       func_serial_max to do version checking with $package_revision.
+       (func_config_update): Ditto with $timestamp.
+
 2005-02-26  Gary V. Vaughan  <gary@gnu.org>
 
        * libltdl/Makefile.am (install-data-local):  cd to $(srcdir) before
index 07ed4e5b9ea437187f25042cdbd9dac827dabe5c..0bc5322432ce05c62856db9ab2db1388ae1d25a6 100644 (file)
@@ -538,9 +538,9 @@ func_serial ()
     $opt_debug
     my_filename="$1"
     my_macro_regex="$2"
-    my_sed_serial='/^# serial [1-9][0-9]*[     ]*'"$my_macro_regex"'[  ]*$/ {
-         s,^# serial \([1-9][0-9]*\).*$,\1,; q;
-       }; d'
+    my_sed_serial=['/^# serial [1-9][0-9.]*[   ]*'"$my_macro_regex"'[  ]*$/ {
+         s,^# serial \([1-9][0-9.]*\).*$,\1,; q;
+       }; d']
 
     # Search FILENAME and all the files it m4_includes for a serial number
     # in the file that AC_DEFUNs MACRO_REGEX.
@@ -560,6 +560,90 @@ func_serial ()
     $ECHO $my_serial
 }
 
+
+# func_serial_max serial1 serial2
+# Compare (possibly multi-part, '.' delimited) serial numbers, and
+# return the largest in $func_serial_max_result.  If they are the
+# same, func_serial_max_result will be empty.
+func_serial_max ()
+{
+    $opt_debug
+    my_serial1="$1"
+    my_serial2="$2"
+
+    my_sed_dot='s/\..*$//g'
+    my_sed_rest='s/^[[0-9]][[1-9]]*\.*//'
+    my_sed_digits='s/[[^0-9.]]//g'
+
+    # Incase they turn out to be the same, we'll set it to empty
+    func_serial_max_result=
+
+    test "X$1$2" = X`$ECHO "X$1$2" | $Xsed -e "$my_sed_digits"` || {
+      func_error "serial numbers \`$1' or \`$2' contain non-digit chars"
+      return
+    }
+
+    while test -n "$my_serial1$my_serial2"; do
+      my_serial1_part=`$ECHO "X$my_serial1" | $Xsed -e "$my_sed_dot"`
+      my_serial2_part=`$ECHO "X$my_serial2" | $Xsed -e "$my_sed_dot"`
+
+      test -z "$my_serial1_part$my_serial2_part" \
+        && break
+
+      test -z "$my_serial1_part" \
+        && { func_serial_max_result="$2"; break; }
+
+      test -z "$my_serial2_part" \
+        && { func_serial_max_result="$1"; break; }
+
+      test "$my_serial1_part" -gt "$my_serial2_part" \
+        && { func_serial_max_result="$1"; break; }
+
+      test "$my_serial2_part" -gt "$my_serial1_part" \
+        && { func_serial_max_result="$2"; break; }
+
+      my_serial1=`$ECHO "X$my_serial1" | $Xsed -e "$my_sed_rest"`
+      my_serial2=`$ECHO "X$my_serial2" | $Xsed -e "$my_sed_rest"`
+    done
+}
+
+
+# func_serial_update_check srcfile src_serial destfile dest_serial
+# Unless SRC_SERIAL is newer than DEST_SERIAL set $func_serial_update_check
+# to 'false'.
+func_serial_update_check ()
+{
+    $opt_debug
+    my_srcfile="$1"
+    my_src_serial="$2"
+    my_destfile="$3"
+    my_dest_serial="$4"
+    my_update_p=:
+
+    if test -f "$my_destfile"; then
+      test "X$my_src_serial" = "X0" && {
+        func_error "warning: no serial number on \`$my_srcfile', not copying."
+       return
+      }
+
+      # Determine whether the destination has an older serial.
+      func_serial_max "$my_src_serial" "$my_dest_serial"
+      test "X$my_src_serial" = "X$func_serial_max_result" || my_update_p=false
+
+      test "X$my_src_serial" = "X$func_serial_max_result" \
+        && func_verbose "\`$my_srcfile' is serial $my_src_serial, greater than $my_dest_serial in \`$my_destfile'"
+
+      if test "X$my_dest_serial" = "X$func_serial_max_result"; then
+        func_verbose "\`$my_srcfile' is serial $my_src_serial, less than $my_dest_serial in \`$my_destfile'"
+       $opt_force \
+         || func_error "\`$my_destfile' is newer: use \`--force' to overwrite"
+      fi
+    fi
+
+    func_serial_update_check_result="$my_update_p"
+}
+
+
 # func_serial_update filename srcdirs destdir [macro_regex] [old_macro_regex]
 # Copy the first file named FILENAME from a directory listed in the
 # ':' delimited SRCDIRS to DESTFILE provided that either FILENAME has
@@ -576,7 +660,6 @@ func_serial_update ()
     my_old_macro_regex="$5"
 
     my_return_status=1
-    my_update_p=:
     func_filename_path_search "$my_filename" "$my_srcdirs"
     my_srcfile="$func_filename_path_search_result"
     my_destfile="$my_destdir/$my_filename"
@@ -588,35 +671,21 @@ func_serial_update ()
       my_src_serial=`func_serial "$my_srcfile" "$my_macro_regex"`
       # Strictly, this libtoolize ought not to have to deal with ancient
       # serial formats, but we accept them here to be complete:
-      test "$my_src_serial" -eq 0 &&
+      test "X$my_src_serial" = "X0" &&
         my_src_serial=`func_serial "$my_srcfile" "$my_old_macro_regex"`
 
-      my_dest_serial=`func_serial "$my_destfile" "$my_macro_regex"`
-      test "$my_dest_serial" -eq 0 &&
+      test "X$my_dest_serial" = "X0" &&
         my_dest_serial=`func_serial "$my_destfile" "$my_old_macro_regex"`
 
-      test "$my_src_serial" -eq 0 && {
-        func_error "warning: no serial number on \`$my_srcfile', not copying."
-       return
-      }
-
-      # Only perform the file update if the destination has an older serial.
-      test "$my_src_serial" -gt "$my_dest_serial" || my_update_p=false
-
-      test "$my_src_serial" -gt "$my_dest_serial" \
-        && func_verbose "\`$my_srcfile' is serial $my_srcserial, greater than $my_destserial in \`$my_destfile'"
-
-      if test "$my_src_serial" -lt "$my_dest_serial"; then
-        func_error "\`$my_srcfile' is serial $my_srcserial, less than $my_destserial in \`$my_destfile'"
-       $opt_force \
-          || func_fatal_error "Use \`--force' to replace newer libtool files with this version."
-      fi
+      func_serial_update_check \
+        "$my_srcfile" "$my_src_serial" "$my_destfile" "$my_dest_serial"
+      my_update_p="$func_serial_update_check_result"
     fi
 
     if $my_update_p || $opt_force; then
       func_copy "$my_srcfile" "$my_destfile"
       my_return_status=$?
-    else
+    elif test "X$my_dest_serial" = "X$my_src_serial"; then
       $opt_quiet \
         || func_echo "\`$my_destfile' is already up to date."
     fi
@@ -625,28 +694,15 @@ func_serial_update ()
     # it has `m4_include([DESTFILE])', so the copy effectively already
     # updated `aclocal.m4'.
     $use_aclocal || if test -f aclocal.m4; then
-      test "$my_src_serial" -gt `func_serial aclocal.m4 "$my_macro_regex"` \
+      func_serial_max \
+          "$my_src_serial" `func_serial aclocal.m4 "$my_macro_regex"`
+      test "X$my_src_serial" = "X$func_serial_max_result" \
          && func_echo "You should add the contents of \'$my_destfile' to \`aclocal.m4'."
     fi
 
     return $my_return_status
 }
 
-# func_check_macros
-# Sanity check macros from aclocal.m4 against installed versions.
-func_check_macros ()
-{
-    $opt_debug
-    # Don't trace for this, we're just checking the user didn't invoke it
-    # directly from configure.ac.
-    $SED 's,[d]nl .*$,,; s,# .*$,,' "$configure_ac" | grep AC_PROG_RANLIB \
-      && func_echo "\`AC_PROG_RANLIB' is rendered obsolete by \`LT_INIT'"
-
-    $seen_libtool \
-      || func_echo "Remember to add \`LT_INIT' to \`$configure_ac'."
-
-    # FIXME: Ensure ltmain.sh, libtool.m4 and ltdl.m4 are from the same release
-}
 
 # func_ltmain_update filename srcdirs destdir
 # Copy the first file named FILENAME from a directory listed in the
@@ -663,27 +719,41 @@ func_ltmain_update ()
     func_filename_path_search "$my_filename" "$my_srcdirs"
     my_srcfile="$func_filename_path_search_result"
     my_destfile="$my_destdir/$my_filename"
-    my_sed_ltmain='
-       s,^VERSION=[[^0-9]]*\(.*\)[[    ]]*$,\1,; t
-       s,^TIMESTAMP=[[^0-9]]*\([[.0-9]]*\) .*$,\1,; t
-       d'
 
-    if test -n "$my_srcfile"; then
+    my_update_p=:
+    my_sed_ltmain=['/^package_revision=[0-9][1-9.]*/ {
+      s,^package_revision=\([0-9.]*\)[         ]*$,\1,; p;
+    }; d']
 
-      # FIXME:  check versions, and only downgrade with --force
-      cmp -s  "$my_srcfile" "$my_destfile"
-      if test "$?" -ne 0 || $opt_force; then
-        func_copy "$my_srcfile" "$my_destfile"
-      else
-        $opt_quiet \
-          || func_echo "\`$my_destfile' is already up to date."
-      fi
+    test -f "$my_srcfile" || {
+      func_error "\`$my_srcfile' does not exist."
+      return
+    }
 
-    else
-      func_error "\`$my_filename' not found in \`$my_srcdirs'."
+    if test -f "$my_destfile"; then
+      my_src_serial=`$SED -e "$my_sed_ltmain" "$my_srcfile"`
+      test -z "$my_src_serial" && {
+        func_error "warning: no serial number in \`$my_srcfile', not copying."
+       return
+      }
+
+      my_dest_serial=`$SED -e "$my_sed_ltmain" "$my_destfile"`
+      test -n "$my_dest_serial" || my_dest_serial=0
+
+      func_serial_update_check \
+         "$my_srcfile" "$my_src_serial" "$my_destfile" "$my_dest_serial"
+      my_update_p="$func_serial_update_check_result"
+    fi
+
+    if $my_update_p || $opt_force; then
+      func_copy "$my_srcfile" "$my_destfile"
+    elif test "X$my_dest_serial" = "X$my_src_serial"; then
+      $opt_quiet \
+        || func_echo "\`$my_destfile' is already up to date."
     fi
 }
 
+
 # func_config_update filename srcdirs destdir
 # Copy the first file named FILENAME from a directory listed in the
 # ':' delimited SRCDIRS to DESTFILE provided that either FILENAME has
@@ -699,25 +769,58 @@ func_config_update ()
     func_filename_path_search "$my_filename" "$my_srcdirs"
     my_srcfile="$func_filename_path_search_result"
     my_destfile="$my_destdir/$my_filename"
-    my_sed_config='s,^timestamp=[[^0-9]]*\([[.0-9-]]*\)[[^0-9]].*$,\1,; t; d'
 
-    if test -n "$my_srcfile"; then
+    my_update_p=:
+    my_sed_config=['/^timestamp='\''\?[0-9][1-9-]*'\''\?/ {
+      s,^timestamp='\''\?\([0-9-]*\)'\''\?,\1,; s/-/./g; p;
+    }; d']
 
-      # FIXME:  check versions, and only downgrade with --force
-      cmp -s  "$my_srcfile" "$my_destfile"
-      if test "$?" -ne 0 || $opt_force; then
-        func_copy "$my_srcfile" "$my_destfile"
-      else
-        $opt_quiet \
-          || func_echo "\`$my_destfile' is already up to date."
-      fi
+    test -f "$my_srcfile" || {
+      func_error "\`$my_srcfile' does not exist."
+      return
+    }
 
-    else
-      func_error "\`$my_filename' not found in \`$my_srcdirs'."
+    if test -f "$my_destfile"; then
+      my_src_serial=`$SED -e "$my_sed_config" "$my_srcfile"`
+      test -z "$my_src_serial" && {
+        func_error "warning: no serial number in \`$my_srcfile', not copying."
+       return
+      }
+
+      my_dest_serial=`$SED -e "$my_sed_config" "$my_destfile"`
+      test -n "$my_dest_serial" || my_dest_serial=0
+
+      func_serial_update_check \
+         "$my_srcfile" "$my_src_serial" "$my_destfile" "$my_dest_serial"
+      my_update_p="$func_serial_update_check_result"
+    fi
+
+    if $my_update_p || $opt_force; then
+      func_copy "$my_srcfile" "$my_destfile"
+    elif test "X$my_dest_serial" = "X$my_src_serial"; then
+      $opt_quiet \
+        || func_echo "\`$my_destfile' is already up to date."
     fi
 }
 
 
+# func_check_macros
+# Sanity check macros from aclocal.m4 against installed versions.
+func_check_macros ()
+{
+    $opt_debug
+    # Don't trace for this, we're just checking the user didn't invoke it
+    # directly from configure.ac.
+    $SED 's,[d]nl .*$,,; s,# .*$,,' "$configure_ac" | grep AC_PROG_RANLIB \
+      && func_echo "\`AC_PROG_RANLIB' is rendered obsolete by \`LT_INIT'"
+
+    $seen_libtool \
+      || func_echo "Remember to add \`LT_INIT' to \`$configure_ac'."
+
+    # FIXME: Ensure ltmain.sh, libtool.m4 and ltdl.m4 are from the same release
+}
+
+
 
 ## ----------- ##
 ##    Main.    ##
@@ -751,7 +854,7 @@ func_config_update ()
   $opt_quiet || if test "$auxdir" != .; then
     func_echo "putting files in AC_CONFIG_AUX_DIR, \`$auxdir'."
   fi
-  if $opt_install || $opt_force; then
+  if $opt_install; then
     func_copy_all_from_path . "$pkgvdatadirs" \
       "$auxdir" "$glob_exclude_pkgaux_files"
     func_config_update config.guess "$pkgvdatadirs" "$auxdir"