From: Ralf Wildenhues Date: Fri, 28 Sep 2007 04:14:06 +0000 (-0600) Subject: Catch even more common AC_CACHE_VAL mistakes. X-Git-Tag: v2.62~247 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=220fef66a88d8b22ff401efd8212e0c6167f3f2d;p=thirdparty%2Fautoconf.git 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. --- diff --git a/ChangeLog b/ChangeLog index ea29d1bd..63278cf3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-09-27 Eric Blake + and Ralf Wildenhues + + 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 and Eric Blake diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index 81f3a957..a0f473af 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -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) ])], diff --git a/tests/base.at b/tests/base.at index 0acabe7d..f7e9ecf6 100644 --- a/tests/base.at +++ b/tests/base.at @@ -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])