autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Autoupdating AC_PREREQ


From: Akim Demaille
Subject: Autoupdating AC_PREREQ
Date: 20 Oct 2000 15:38:24 +0200
User-agent: Gnus/5.0807 (Gnus v5.8.7) XEmacs/21.1 (Channel Islands)

People have been wanting this for a long time.  I had to move
_AC_VERSION_* into m4sugar.m4, otherwise it is not active when
autoupdate is run.  And anyway it's better like this: it is not
really related to Autoconf.

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        Let autoupdate change AC_PREREQ to require the current version of
        Autoconf.

        * acgeneral.m4 (_AC_VERSION_UNLETTER, _AC_VERSION_COMPARE): Move
        to...
        * libm4.m4 (m4_version_unletter, m4_version_compare): here.
        Adjust dependencies.
        * acgeneral.m4 (AU::AC_PREREQ): New macro.
        * autoupdate.sh: Fail when `m4 input.m4' fails.

Index: acgeneral.m4
===================================================================
RCS file: /cvs/autoconf/acgeneral.m4,v
retrieving revision 1.581
diff -u -r1.581 acgeneral.m4
--- acgeneral.m4 2000/10/18 17:16:10 1.581
+++ acgeneral.m4 2000/10/20 13:28:20
@@ -1221,43 +1221,28 @@
 ## ---------------------------------------- ##
 
 
-# _AC_VERSION_UNLETTER(VERSION)
-# -----------------------------
-# Normalize beta version numbers with letters to numbers only for comparison.
+# AU::AC_PREREQ(VERSION)
+# ----------------------
+# Update this `AC_PREREQ' statement to require the current version of
+# Autoconf.  But fail if ever this autoupdate is too old.
 #
-#   Nl -> (N+1).-1.(l#)
-#
-#i.e., 2.14a -> 2.15.-1.1, 2.14b -> 2.15.-1.2, etc.
-# This macro is absolutely not robust to active macro, it expects
-# reasonable version numbers and is valid up to `z', no double letters.
-define([_AC_VERSION_UNLETTER],
-[translit(patsubst(patsubst(patsubst([$1],
-                                     [\([0-9]+\)\([abcdefghi]\)],
-                                     [m4_eval(\1 + 1).-1.\2]),
-                            [\([0-9]+\)\([jklmnopqrs]\)],
-                            [m4_eval(\1 + 1).-1.1\2]),
-          [\([0-9]+\)\([tuvwxyz]\)],
-          [m4_eval(\1 + 1).-1.2\2]),
-          abcdefghijklmnopqrstuvwxyz,
-          12345678901234567890123456)])
-
-
-# _AC_VERSION_COMPARE(VERSION-1, VERSION-2)
-# -----------------------------------------
-# Compare the two version numbers and expand into
-#  -1 if VERSION-1 < VERSION-2
-#   0 if           =
-#   1 if           >
-define([_AC_VERSION_COMPARE],
-[m4_list_cmp((m4_split(_AC_VERSION_UNLETTER([$1]), [\.])),
-             (m4_split(_AC_VERSION_UNLETTER([$2]), [\.])))])
+# Note that `defn([AC_ACVERSION])' below are expanded before calling
+# `AU_DEFUN', i.e., it is hard coded.  Otherwise it would be quite
+# complex for autoupdate to import the value of `AC_ACVERSION'.  We
+# could `AU_DEFUN' `AC_ACVERSION', but this would replace all its
+# occurrences with the current version of Autoconf, which is certainly
+# not what mean the user.
+AU_DEFUN([AC_PREREQ],
+[ifelse(m4_version_compare(]defn([AC_ACVERSION])[, [$1]), -1,
+    [m4_fatal([Autoconf version $1 or higher is required for this script])])dnl
+[AC_PREREQ(]]defn([AC_ACVERSION])[[)]])
 
 
 # AC_PREREQ(VERSION)
 # ------------------
 # Complain and exit if the Autoconf version is less than VERSION.
 define([AC_PREREQ],
-[ifelse(_AC_VERSION_COMPARE(AC_ACVERSION, [$1]), -1,
+[ifelse(m4_version_compare(defn([AC_ACVERSION]), [$1]), -1,
      [AC_FATAL([Autoconf version $1 or higher is required for this script])])])
 
 
Index: autoupdate.sh
===================================================================
RCS file: /cvs/autoconf/autoupdate.sh,v
retrieving revision 1.34
diff -u -r1.34 autoupdate.sh
--- autoupdate.sh 2000/10/17 07:55:45 1.34
+++ autoupdate.sh 2000/10/20 13:28:21
@@ -268,6 +268,7 @@
 # Run m4 on each input file.
 for file
 do
+  filename=$file
   # We need an actual file.
   if test "x$file" = x-; then
     file=$tmp/stdin
@@ -375,7 +376,11 @@
   $sed -f $tmp/quote.sed $file >>$tmp/input.m4
 
   # Now ask m4 to perform the update.
-  $M4 $tmp/input.m4 >$tmp/updated
+  $M4 $tmp/input.m4 >$tmp/updated ||
+    {
+      echo "$me: cannot update \`$filename'" >&2
+      exit 1
+    }
 
   if test $file = $tmp/stdin; then
     cat $tmp/updated
@@ -388,7 +393,7 @@
         mv $tmp/updated $file; then
        echo "$me: \`$file' is updated" >&2
     else
-       echo "$me: could not update \`$file'" >&2
+       echo "$me: cannot update \`$file'" >&2
     fi
   fi
 done
Index: libm4.m4
===================================================================
RCS file: /cvs/autoconf/libm4.m4,v
retrieving revision 1.26
diff -u -r1.26 libm4.m4
--- libm4.m4 2000/10/17 08:08:00 1.26
+++ libm4.m4 2000/10/20 13:28:21
@@ -616,6 +616,44 @@
 
 
 
+## -------------------- ##
+## Version processing.  ##
+## -------------------- ##
+
+
+# m4_version_unletter(VERSION)
+# ----------------------------
+# Normalize beta version numbers with letters to numbers only for comparison.
+#
+#   Nl -> (N+1).-1.(l#)
+#
+#i.e., 2.14a -> 2.15.-1.1, 2.14b -> 2.15.-1.2, etc.
+# This macro is absolutely not robust to active macro, it expects
+# reasonable version numbers and is valid up to `z', no double letters.
+define([m4_version_unletter],
+[translit(patsubst(patsubst(patsubst([$1],
+                                     [\([0-9]+\)\([abcdefghi]\)],
+                                     [m4_eval(\1 + 1).-1.\2]),
+                            [\([0-9]+\)\([jklmnopqrs]\)],
+                            [m4_eval(\1 + 1).-1.1\2]),
+          [\([0-9]+\)\([tuvwxyz]\)],
+          [m4_eval(\1 + 1).-1.2\2]),
+          abcdefghijklmnopqrstuvwxyz,
+          12345678901234567890123456)])
+
+
+# m4_version_compare(VERSION-1, VERSION-2)
+# ----------------------------------------
+# Compare the two version numbers and expand into
+#  -1 if VERSION-1 < VERSION-2
+#   0 if           =
+#   1 if           >
+define([m4_version_compare],
+[m4_list_cmp((m4_split(m4_version_unletter([$1]), [\.])),
+             (m4_split(m4_version_unletter([$2]), [\.])))])
+
+
+
 ## ----------------------------------- ##
 ## Helping macros to display strings.  ##
 ## ----------------------------------- ##



reply via email to

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