]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Catch even more common AC_CACHE_VAL mistakes.
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Fri, 28 Sep 2007 04:14:06 +0000 (22:14 -0600)
committerEric Blake <ebb9@byu.net>
Fri, 28 Sep 2007 04:18:28 +0000 (22:18 -0600)
* lib/autoconf/general.m4 (AC_CACHE_VAL): Warn if cache variable
lacks '_cv_', or if AC_SUBST appears in body.
* tests/base.at (AC_CACHE_CHECK): Test this change.

ChangeLog
lib/autoconf/general.m4
tests/base.at

index ea29d1bd5dc01cdf3585f3e64000748f56b38549..63278cf31ec1aa66bec76cc2a9f6d33777c5e561 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-09-27  Eric Blake  <ebb9@byu.net>
+       and Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
+
+       Catch even more common AC_CACHE_VAL mistakes.
+       * lib/autoconf/general.m4 (AC_CACHE_VAL): Warn if cache variable
+       lacks '_cv_', or if AC_SUBST appears in body.
+       * tests/base.at (AC_CACHE_CHECK): Test this change.
+
 2007-09-27  Stepan Kasal  <kasal@ucw.cz>
        and Eric Blake  <ebb9@byu.net>
 
index 81f3a9579971796514f492171659d8f1d7ff26be..a0f473aff5c76deccf0e5913d146866c7998eb97 100644 (file)
@@ -1950,9 +1950,15 @@ rm -f confcache[]dnl
 # The name of shell var CACHE-ID must contain `_cv_' in order to get saved.
 # Should be dnl'ed.  Try to catch common mistakes.
 m4_defun([AC_CACHE_VAL],
-[m4_bmatch([$2], [AC_DEFINE],
+[AS_LITERAL_IF([$1], [m4_bmatch(m4_quote($1), [_cv_], [],
+                               [AC_DIAGNOSE([syntax],
+[$0($1, ...): suspicious cache-id, must contain _cv_ to be cached])])])dnl
+m4_bmatch([$2], [AC_DEFINE],
           [AC_DIAGNOSE([syntax],
 [$0($1, ...): suspicious presence of an AC_DEFINE in the second argument, ]dnl
+[where no actions should be taken])],
+          [AC_SUBST], [AC_DIAGNOSE([syntax],
+[$0($1, ...): suspicious presence of an AC_SUBST in the second argument, ]dnl
 [where no actions should be taken])])dnl
 AS_VAR_SET_IF([$1],
              [_AS_ECHO_N([(cached) ])],
index 0acabe7d75e69311cbfd018a1d4bcdf0a0f89cbe..f7e9ecf65dde9e4b83d3b4aecebe07a03a1fc3fb 100644 (file)
@@ -2,7 +2,8 @@
 
 AT_BANNER([Autoconf base layer.])
 
-# Copyright (C) 2000, 2001, 2003, 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2001, 2003, 2005, 2006, 2007 Free Software
+# Foundation, Inc.
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -202,16 +203,29 @@ AT_CLEANUP
 ## ---------------- ##
 
 # Make sure AC_CACHE_CHECK is silent with -q.
+# Also make sure we warn about cache id's not named with `_cv_'.
 
 AT_SETUP([AC_CACHE_CHECK])
 
 AT_DATA([configure.ac],
 [[AC_INIT
+# m4_define([ac_nothing], [ac_cv_absolutely_nothing])
 AC_CACHE_CHECK([for nothing],
               [ac_nothing],
               [ac_nothing=found])
 ]])
 
+AT_CHECK_AUTOCONF([], [], [], [stderr])
+AT_CHECK([grep 'must contain _cv_ to be cached' stderr], [], [ignore])
+
+# Do not warn about defines:
+sed 's/^# //' configure.ac > t
+mv -f t configure.ac
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([-q])
+
+sed '/m4_define/d; s/ac_nothing/ac_cv_nothing/' configure.ac > t
+mv -f t configure.ac
 AT_CHECK_AUTOCONF
 AT_CHECK_CONFIGURE([-q])