]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Test that the macros respect the user variable name space.
authorAkim Demaille <akim@epita.fr>
Mon, 7 Feb 2000 13:25:35 +0000 (13:25 +0000)
committerAkim Demaille <akim@epita.fr>
Mon, 7 Feb 2000 13:25:35 +0000 (13:25 +0000)
* acgeneral.m4 (AC_CANONICAL_THING): define, not AC_DEFUN.
Don't AC_PROVIDE, there is no need.
When calling `config.sub`, also || exit 1, to catch failures from
config.sub.
* acspecific.m4 (AC_SYS_LONG_FILE_NAMES): Use ac_val, not val.
(AC_EXEEXT): Use ac_file, not file.
* tests/actest.m4: New file, holding extra Autoconf macros used
during the testing.
(AC_ENV_SAVE): New macro, save the sh variables in a file.
* tests/suite.m4 (AT_TEST_MACRO, Generation of configure.in):
include actest.m4, and call twice AC_ENV_SAVE to compare the
variables before and after the macro.
* tests/Makefile.am (macro.m4): Don't test macros that are
required: they will be tested somewhere else.

ChangeLog
acgeneral.m4
acspecific.m4
lib/autoconf/general.m4
lib/autoconf/specific.m4
tests/Makefile.am
tests/actest.m4 [new file with mode: 0644]
tests/suite.m4
tests/syntax.m4

index ceb462d9094b5537c4fb23881c95a78ff214aac8..7954e510c822bdee627d64d17cde38ade8f7865f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2000-02-07  Akim Demaille  <akim@epita.fr>
+
+       Test that the macros respect the user variable name space.
+
+       * acgeneral.m4 (AC_CANONICAL_THING): define, not AC_DEFUN.
+       Don't AC_PROVIDE, there is no need.
+       When calling `config.sub`, also || exit 1, to catch failures from
+       config.sub.
+       * acspecific.m4 (AC_SYS_LONG_FILE_NAMES): Use ac_val, not val.
+       (AC_EXEEXT): Use ac_file, not file.
+       * tests/actest.m4: New file, holding extra Autoconf macros used
+       during the testing.
+       (AC_ENV_SAVE): New macro, save the sh variables in a file.
+       * tests/suite.m4 (AT_TEST_MACRO, Generation of configure.in):
+       include actest.m4, and call twice AC_ENV_SAVE to compare the
+       variables before and after the macro.
+       * tests/Makefile.am (macro.m4): Don't test macros that are
+       required: they will be tested somewhere else.
+
 2000-02-07  Akim Demaille  <akim@epita.fr>
 
        * acgeneral.m4(AC_CONFIG_PRE_COMMANDS, AC_CONFIG_POST_COMMANDS):
index 4e383eb7f6e7c5fa3ba929e126306711870f5bf2..b65e531674a0f1496eb28b31691bcb39ed6d74d3 100644 (file)
@@ -1729,26 +1729,25 @@ test "$host_alias" != "$target_alias" &&
 ])
 
 
+
 dnl Subroutines of AC_CANONICAL_SYSTEM.
 
+dnl AC_CANONICAL_THING(THING)
+dnl -------------------------
 dnl Worker routine for AC_CANONICAL_{HOST TARGET BUILD}.  THING is one of
 dnl `host', `target', or `build'.  Canonicalize the appropriate thing,
 dnl generating the variables THING, THING_{alias cpu vendor os}, and the
 dnl associated cache entries.  We also redo the cache entries if the user
 dnl specifies something different from ac_cv_$THING_alias on the command line.
-
-dnl AC_CANONICAL_THING(THING)
-dnl -------------------------
-AC_DEFUN(AC_CANONICAL_THING,
+define(AC_CANONICAL_THING,
 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
-
 ifelse([$1], [host], , [AC_REQUIRE([AC_CANONICAL_HOST])])dnl
 AC_MSG_CHECKING([$1 system type])
 if test "x$ac_cv_$1" = "x" || (test "x$$1" != "xNONE" && test "x$$1" != "x$ac_cv_$1_alias"); then
 
-# Make sure we can run config.sub.
-  if $ac_config_sub sun4 >/dev/null 2>&1; then :
-    else AC_MSG_ERROR(cannot run $ac_config_sub)
+  # Make sure we can run config.sub.
+  if $ac_config_sub sun4 >/dev/null 2>&1; then :; else
+    AC_MSG_ERROR(cannot run $ac_config_sub)
   fi
 
 dnl Set $1_alias.
@@ -1767,8 +1766,8 @@ ifelse([$1], [host],[dnl
     esac ;;
   esac
 
-dnl Set the other $[1] vars.
-  ac_cv_$1=`$ac_config_sub $ac_cv_$1_alias`
+dnl Set the other $[1] vars.  Propagate the failures of config.sub.
+  ac_cv_$1=`$ac_config_sub $ac_cv_$1_alias` || exit 1
   ac_cv_$1_cpu=`echo $ac_cv_$1 | sed 's/^\([[^-]]*\)-\([[^-]]*\)-\(.*\)$/\1/'`
   ac_cv_$1_vendor=`echo $ac_cv_$1 | sed 's/^\([[^-]]*\)-\([[^-]]*\)-\(.*\)$/\2/'`
   ac_cv_$1_os=`echo $ac_cv_$1 | sed 's/^\([[^-]]*\)-\([[^-]]*\)-\(.*\)$/\3/'`
@@ -1783,14 +1782,11 @@ $1_alias=$ac_cv_$1_alias
 $1_cpu=$ac_cv_$1_cpu
 $1_vendor=$ac_cv_$1_vendor
 $1_os=$ac_cv_$1_os
-
 AC_SUBST($1)dnl
 AC_SUBST($1_alias)dnl
 AC_SUBST($1_cpu)dnl
 AC_SUBST($1_vendor)dnl
 AC_SUBST($1_os)dnl
-
-AC_PROVIDE([$0])
 ])dnl AC_CANONICAL_THING
 
 AC_DEFUN(AC_CANONICAL_HOST, [AC_CANONICAL_THING([host])])
@@ -3361,21 +3357,19 @@ changequote(, )dnl
 changequote([, ])dnl
 fi
 
-trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
-
 ifset([AC_LIST_HEADERS], [DEFS=-DHAVE_CONFIG_H], [AC_OUTPUT_MAKE_DEFS()])
 
 dnl Commands to run before creating config.status.
-AC_OUTPUT_PRE_COMMANDS()dnl
+AC_OUTPUT_COMMANDS_PRE()dnl
 
-# Without the "./", some shells look in PATH for config.status.
 : ${CONFIG_STATUS=./config.status}
+trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
 AC_OUTPUT_CONFIG_STATUS()dnl
 rm -fr confdefs* $ac_clean_files
 trap 'exit 1' 1 2 15
 
 dnl Commands to run after config.status was created
-AC_OUTPUT_POST_COMMANDS()dnl
+AC_OUTPUT_COMMANDS_POST()dnl
 
 test "$no_create" = yes || $SHELL $CONFIG_STATUS || exit 1
 dnl config.status should not do recursion.
index 7604649cf1e96e78150eae8cf5a62e46aad5a6ba..73e21f7a191df6092e28f8e1808984224d11782a 100644 (file)
@@ -3009,10 +3009,10 @@ dnl Be optimistic at first.
 dnl ### Checks for operating system services
 
 
+dnl AC_SYS_INTERPRETER
+dnl ------------------
 AC_DEFUN(AC_SYS_INTERPRETER,
-[# Pull the hash mark out of the macro call to avoid m4 problems.
-ac_msg="whether #! works in shell scripts"
-AC_CACHE_CHECK($ac_msg, ac_cv_sys_interpreter,
+[AC_CACHE_CHECK(whether @PND@! works in shell scripts, ac_cv_sys_interpreter,
 [echo '#! /bin/cat
 exit 69
 ' >conftest
@@ -3055,8 +3055,8 @@ for ac_dir in  . $ac_tmpdirs `eval echo $prefix/lib $exec_prefix/lib` ; do
   test -w $ac_dir || continue # It is less confusing to not echo anything here.
   (echo 1 >$ac_dir/conftest9012345) 2>/dev/null
   (echo 2 >$ac_dir/conftest9012346) 2>/dev/null
-  val=`cat $ac_dir/conftest9012345 2>/dev/null`
-  if test ! -f $ac_dir/conftest9012345 || test "$val" != 1; then
+  ac_val=`cat $ac_dir/conftest9012345 2>/dev/null`
+  if test ! -f $ac_dir/conftest9012345 || test "$ac_val" != 1; then
     ac_cv_sys_long_file_names=no
     rm -f $ac_dir/conftest9012345 $ac_dir/conftest9012346 2>/dev/null
     break
@@ -3479,10 +3479,10 @@ else
   echo 'int main () { return 0; }' >conftest.$ac_ext
   ac_cv_exeext=
   if AC_TRY_EVAL(ac_link); then
-    for file in conftest.*; do
-      case $file in
+    for ac_file in conftest.*; do
+      case $ac_file in
       *.c | *.C | *.o | *.obj | *.xcoff) ;;
-      *) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;;
+      *) ac_cv_exeext=`echo $ac_file | sed -e s/conftest//` ;;
       esac
     done
   else
index 4e383eb7f6e7c5fa3ba929e126306711870f5bf2..b65e531674a0f1496eb28b31691bcb39ed6d74d3 100644 (file)
@@ -1729,26 +1729,25 @@ test "$host_alias" != "$target_alias" &&
 ])
 
 
+
 dnl Subroutines of AC_CANONICAL_SYSTEM.
 
+dnl AC_CANONICAL_THING(THING)
+dnl -------------------------
 dnl Worker routine for AC_CANONICAL_{HOST TARGET BUILD}.  THING is one of
 dnl `host', `target', or `build'.  Canonicalize the appropriate thing,
 dnl generating the variables THING, THING_{alias cpu vendor os}, and the
 dnl associated cache entries.  We also redo the cache entries if the user
 dnl specifies something different from ac_cv_$THING_alias on the command line.
-
-dnl AC_CANONICAL_THING(THING)
-dnl -------------------------
-AC_DEFUN(AC_CANONICAL_THING,
+define(AC_CANONICAL_THING,
 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
-
 ifelse([$1], [host], , [AC_REQUIRE([AC_CANONICAL_HOST])])dnl
 AC_MSG_CHECKING([$1 system type])
 if test "x$ac_cv_$1" = "x" || (test "x$$1" != "xNONE" && test "x$$1" != "x$ac_cv_$1_alias"); then
 
-# Make sure we can run config.sub.
-  if $ac_config_sub sun4 >/dev/null 2>&1; then :
-    else AC_MSG_ERROR(cannot run $ac_config_sub)
+  # Make sure we can run config.sub.
+  if $ac_config_sub sun4 >/dev/null 2>&1; then :; else
+    AC_MSG_ERROR(cannot run $ac_config_sub)
   fi
 
 dnl Set $1_alias.
@@ -1767,8 +1766,8 @@ ifelse([$1], [host],[dnl
     esac ;;
   esac
 
-dnl Set the other $[1] vars.
-  ac_cv_$1=`$ac_config_sub $ac_cv_$1_alias`
+dnl Set the other $[1] vars.  Propagate the failures of config.sub.
+  ac_cv_$1=`$ac_config_sub $ac_cv_$1_alias` || exit 1
   ac_cv_$1_cpu=`echo $ac_cv_$1 | sed 's/^\([[^-]]*\)-\([[^-]]*\)-\(.*\)$/\1/'`
   ac_cv_$1_vendor=`echo $ac_cv_$1 | sed 's/^\([[^-]]*\)-\([[^-]]*\)-\(.*\)$/\2/'`
   ac_cv_$1_os=`echo $ac_cv_$1 | sed 's/^\([[^-]]*\)-\([[^-]]*\)-\(.*\)$/\3/'`
@@ -1783,14 +1782,11 @@ $1_alias=$ac_cv_$1_alias
 $1_cpu=$ac_cv_$1_cpu
 $1_vendor=$ac_cv_$1_vendor
 $1_os=$ac_cv_$1_os
-
 AC_SUBST($1)dnl
 AC_SUBST($1_alias)dnl
 AC_SUBST($1_cpu)dnl
 AC_SUBST($1_vendor)dnl
 AC_SUBST($1_os)dnl
-
-AC_PROVIDE([$0])
 ])dnl AC_CANONICAL_THING
 
 AC_DEFUN(AC_CANONICAL_HOST, [AC_CANONICAL_THING([host])])
@@ -3361,21 +3357,19 @@ changequote(, )dnl
 changequote([, ])dnl
 fi
 
-trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
-
 ifset([AC_LIST_HEADERS], [DEFS=-DHAVE_CONFIG_H], [AC_OUTPUT_MAKE_DEFS()])
 
 dnl Commands to run before creating config.status.
-AC_OUTPUT_PRE_COMMANDS()dnl
+AC_OUTPUT_COMMANDS_PRE()dnl
 
-# Without the "./", some shells look in PATH for config.status.
 : ${CONFIG_STATUS=./config.status}
+trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
 AC_OUTPUT_CONFIG_STATUS()dnl
 rm -fr confdefs* $ac_clean_files
 trap 'exit 1' 1 2 15
 
 dnl Commands to run after config.status was created
-AC_OUTPUT_POST_COMMANDS()dnl
+AC_OUTPUT_COMMANDS_POST()dnl
 
 test "$no_create" = yes || $SHELL $CONFIG_STATUS || exit 1
 dnl config.status should not do recursion.
index 7604649cf1e96e78150eae8cf5a62e46aad5a6ba..73e21f7a191df6092e28f8e1808984224d11782a 100644 (file)
@@ -3009,10 +3009,10 @@ dnl Be optimistic at first.
 dnl ### Checks for operating system services
 
 
+dnl AC_SYS_INTERPRETER
+dnl ------------------
 AC_DEFUN(AC_SYS_INTERPRETER,
-[# Pull the hash mark out of the macro call to avoid m4 problems.
-ac_msg="whether #! works in shell scripts"
-AC_CACHE_CHECK($ac_msg, ac_cv_sys_interpreter,
+[AC_CACHE_CHECK(whether @PND@! works in shell scripts, ac_cv_sys_interpreter,
 [echo '#! /bin/cat
 exit 69
 ' >conftest
@@ -3055,8 +3055,8 @@ for ac_dir in  . $ac_tmpdirs `eval echo $prefix/lib $exec_prefix/lib` ; do
   test -w $ac_dir || continue # It is less confusing to not echo anything here.
   (echo 1 >$ac_dir/conftest9012345) 2>/dev/null
   (echo 2 >$ac_dir/conftest9012346) 2>/dev/null
-  val=`cat $ac_dir/conftest9012345 2>/dev/null`
-  if test ! -f $ac_dir/conftest9012345 || test "$val" != 1; then
+  ac_val=`cat $ac_dir/conftest9012345 2>/dev/null`
+  if test ! -f $ac_dir/conftest9012345 || test "$ac_val" != 1; then
     ac_cv_sys_long_file_names=no
     rm -f $ac_dir/conftest9012345 $ac_dir/conftest9012346 2>/dev/null
     break
@@ -3479,10 +3479,10 @@ else
   echo 'int main () { return 0; }' >conftest.$ac_ext
   ac_cv_exeext=
   if AC_TRY_EVAL(ac_link); then
-    for file in conftest.*; do
-      case $file in
+    for ac_file in conftest.*; do
+      case $ac_file in
       *.c | *.C | *.o | *.obj | *.xcoff) ;;
-      *) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;;
+      *) ac_cv_exeext=`echo $ac_file | sed -e s/conftest//` ;;
       esac
     done
   else
index bf58a95a336dc9d464e9b6d68ff04c1fb4b63b26..90e7db0903a75b08de2d8912c831d5f2998e2f9b 100644 (file)
@@ -24,13 +24,13 @@ SUITE = syntax.m4 semantics.m4
 
 # We don't actually distribute the testsuite, since one only
 # needs m4 to build it, m4 being required anyway to install Autoconf.
-EXTRA_DIST = atgeneral.m4 suite.m4 macros.m4 $(SUITE)
+EXTRA_DIST = atgeneral.m4 suite.m4 macros.m4 actest.m4 $(SUITE)
 
 PERL = perl
 
-all-local: atconfig testsuite macros.m4
+all-local: atconfig testsuite
 
-check-local: atconfig testsuite macros.m4
+check-local: atconfig testsuite
        $(SHELL) testsuite
 
 testsuite: atgeneral.m4 suite.m4 macros.m4 $(SUITE)
@@ -41,12 +41,19 @@ testsuite: atgeneral.m4 suite.m4 macros.m4 $(SUITE)
 macros.m4: $(top_srcdir)/acspecific.m4 $(srcdir)/Makefile.am
        cat $(top_srcdir)/acgeneral.m4 $(top_srcdir)/acspecific.m4 | \
          sed -ne 's/^AC_DEFUN(\[*\([^],]*\).*/\1/p' | \
-         sort >macros
-       rm -f $@-t
-       for macro in `cat macros`; do \
-         echo "TEST_MACRO([$$macro])" >>$@-t; \
+         sort >defuns
+# Get the list of macros that are required: there is little interest
+# in testing them since they will be run but the guy who requires
+# them.
+       cat $(top_srcdir)/acgeneral.m4 $(top_srcdir)/acspecific.m4 | \
+         sed -ne 's/dnl.*//;s/.*AC_REQUIRE(\[*\([a-zA-Z0-9_]*\).*$$/\1/p' | \
+         sort | uniq >requires
+       for macro in `cat defuns`; do \
+         if fgrep "$$macro" requires >/dev/null 2>&1; then :; else \
+           echo "TEST_MACRO([$$macro])" >>$@-t; \
+         fi; \
        done
-       rm macros
+       rm defuns requires
        mv $@-t $@
 
 CLEANFILES = debug-*.sh macro configure configure.in config.status \
diff --git a/tests/actest.m4 b/tests/actest.m4
new file mode 100644 (file)
index 0000000..1c02742
--- /dev/null
@@ -0,0 +1,30 @@
+dnl actest.m4                                              -*- autoconf -*-
+dnl Additional Autoconf macros to ease testing.
+
+
+# AC_ENV_SAVE(FILE)
+# ------------------
+# Save the environment, but the variables we are allowed to touch.
+# This is to check no test touches the user name space.
+# FIXME: There are surely better ways.  Explore for instance if
+# we can ask help from AC_SUBST.  We have the right to touch what
+# is AC_SUBST.
+AC_DEFUN(AC_ENV_SAVE,
+[(set) 2>&1 |
+  grep -v '^ac_' |
+  # Some variables we are allowed to touch
+  egrep -v '^(CC|CFLAGS|CPP|GCC|CXX|CXXFLAGS|CXXCPP|GXX|LIBS|LIBOBJS|LDFLAGS)=' |
+  egrep -v '^(AWK|LEX|LEXLIB|LEX_OUTPUT_ROOT|LN_S|M4|RANLIB|SET_MAKE|YACC)=' |
+  egrep -v '^INSTALL(_(DATA|PROGRAM|SCRIPT))?=' |
+  egrep -v '^(CYGWIN|ISC|MINGW32|MINIX|EMXOS2|EXEEXT|OBJEXT)=' |
+  egrep -v '^(NEED_SETGID)=' |
+  egrep -v '^(X_(CFLAGS|LIBS|PRE_LIBS)|x_(includes|libraries)|have_x)=' |
+  egrep -v '^(host|build|target)(_(alias|cpu|vendor|os))?=' |
+  egrep -v '^(cross_compiling)=' |
+  egrep -v '^(interpval)=' |
+  # Some variables some shells use and change
+  egrep -v '^(_|PIPESTATUS|OLDPWD)=' |
+  # There maybe variables spread on several lines, eg IFS, remove the dead
+  # lines
+  fgrep = >$1
+])
index df271f791e94682c5d4af42c9b63382f5e660afc..ce87e282c79bf034c82fac726dedd1e7aa3661cc 100644 (file)
@@ -15,13 +15,16 @@ dnl Create a minimalist configure.in running the macro named
 dnl NAME-OF-THE-MACRO, check that autoconf runs on that script,
 dnl and that the shell runs correctly the configure.
 AT_DEFINE(AT_TEST_MACRO,
-[AT_SETUP($1)
+[AT_SETUP([$1])
 
-# An extremely simple configure.in
+dnl Produce the configure.in
 AT_DATA(configure.in,
-[AC_INIT
+[AC_INCLUDE(actest.m4)
+AC_INIT
 AC_CONFIG_HEADER(config.h)
+AC_ENV_SAVE(expout)
 ifelse([$2],,[$1], [$2])
+AC_ENV_SAVE(env-after)
 AC_OUTPUT
 ])
 
@@ -29,11 +32,12 @@ AC_OUTPUT
 # Maybe some day we could be more precise and filter out warnings.
 # The problem is that currently some warnings are spread on several
 # lines, so grepping -v warning is not enough.
-AT_CHECK([../autoconf -m ..], 0,, ignore)
-AT_CHECK([../autoheader -m ..], 0,, ignore)
+AT_CHECK([../autoconf -m .. -l $at_srcdir], 0,, ignore)
+AT_CHECK([../autoheader -m .. -l $at_srcdir], 0,, ignore)
 AT_CHECK([./configure], 0, ignore, ignore)
+AT_CHECK([cat env-after], 0, expout)
 $3
-AT_CLEANUP(configure config.status config.log config.cache config.h.in config.h)dnl
+AT_CLEANUP(configure config.status config.log config.cache config.h.in config.h env-after)dnl
 ])dnl AT_TEST_MACRO
 
 
index b5f9e98322ebeaa5bb38e9192db670d95dcd03d5..30222ffb74809a8641826fea68a69d04e768cbd5 100644 (file)
@@ -16,6 +16,7 @@ AT_DEFINE(TEST_MACRO,
         [$1], [AC_CONFIG_AUX_DIR],,
         [$1], [AC_CONFIG_AUX_DIRS],,
         [$1], [AC_INIT],,
+        [$1], [AC_INIT_PARSE_ARGS],,
         [$1], [AC_LINKER_OPTION],,
         [$1], [AC_LINK_FILES],,
         [$1], [AC_LIST_MEMBER_OF],,