+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>
# 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) ])],
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
## ---------------- ##
# 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])