autoconf: error out if AC_OUTPUT receives more than three arguments Modified versions of Autoconf exist that expect more than three arguments to AC_OUTPUT; attempting to regenerate a configure script that uses the extra arguments, with the unmodified Autoconf, is likely to produce a broken script. The feature enabled by a fourth argument, in the case I know about (<https://invisible-island.net/autoconf/autoconf.html> - look for “simplify the way we generate the config.h file”) is potentially worth folding into our version of Autoconf, but we would need to do it with a new AC_CONFIG_something macro, instead of reverting to having AC_OUTPUT take arguments. * lib/autoconf/status.m4 (AC_OUTPUT): Error out if more than three arguments are supplied. * tests/torture.at: Add tests of AC_OUTPUT with one, three, and four arguments. Two arguments is treated as a special case of three arguments, so it doesn’t need its own test.
diff --git a/lib/autoconf/status.m4 b/lib/autoconf/status.m4 index 472c1e6..670e3e8 100644 --- a/lib/autoconf/status.m4 +++ b/lib/autoconf/status.m4
@@ -1253,7 +1253,14 @@ # Produce config.status, config.h, and links; and configure subdirs. # m4_define([AC_OUTPUT], -[dnl Dispatch the extra arguments to their native macros. +[dnl Dispatch historical arguments to their native macros. +dnl Modified versions of Autoconf exist that take more than three +dnl arguments to AC_OUTPUT; attempting to regenerate a configure +dnl script that uses the extra arguments, with this Autoconf, is +dnl likely to produce a broken script. +m4_if(m4_eval([$# >= 4]), [1], + [m4_fatal([$0 takes at most three arguments. +This configure script cannot be compiled by this version of Autoconf.])])dnl m4_ifvaln([$1], [AC_CONFIG_FILES([$1])])dnl m4_ifvaln([$2$3],
diff --git a/tests/torture.at b/tests/torture.at index 0332a08..927921f 100644 --- a/tests/torture.at +++ b/tests/torture.at
@@ -404,6 +404,110 @@ AT_CLEANUP +## ----------------------------- ## +## AC_OUTPUT with one argument. ## +## ----------------------------- ## + +AT_SETUP([AC_OUTPUT with one argument]) + +AT_DATA([Makefile.in], +[[VARIABLE = @VARIABLE@ +]]) + +AT_DATA_AUTOCONF([configure.ac], +[[AC_INIT +AC_SUBST([VARIABLE], [value]) +AC_OUTPUT([Makefile]) +]]) + +AT_CHECK_AUTOCONF([], [0], [], +[configure.ac:3: warning: AC_OUTPUT should be used without arguments. +configure.ac:3: You should run autoupdate. +]) + +AT_CHECK_CONFIGURE + +AT_CHECK([test x"`cat Makefile || echo Makefile not found`" \ + = x"VARIABLE = value"]) + +AT_CHECK_AUTOUPDATE + +AT_CHECK([[$EGREP '^AC_OUTPUT$' configure.ac]], + [0], [ignore]) +AT_CHECK([[$EGREP '^AC_CONFIG_FILES\(\[Makefile\]\)$' configure.ac]], + [0], [ignore]) + +AT_CLEANUP + + +## -------------------------------- ## +## AC_OUTPUT with three arguments. ## +## -------------------------------- ## + +AT_SETUP([AC_OUTPUT with three arguments]) + +AT_DATA([Makefile.in], +[[VARIABLE = @VARIABLE@ +]]) + +AT_DATA([strange.in], +[[VARIABLE = %VARIABLE% +]]) + +AT_DATA_AUTOCONF([configure.ac], +[[AC_INIT +AC_SUBST([VARIABLE], [value]) +AC_OUTPUT([Makefile], + [sed -e "s/%VARIABLE%/${VARIABLE}/g" < strange.in > strange], + [VARIABLE=$VARIABLE]) +]]) + +AT_CHECK_AUTOCONF([], [0], [], +[configure.ac:3: warning: AC_OUTPUT should be used without arguments. +configure.ac:3: You should run autoupdate. +]) + +AT_CHECK_CONFIGURE + +AT_CHECK([test x"`cat Makefile || echo Makefile not found`" \ + = x"VARIABLE = value"]) +AT_CHECK([test x"`cat strange || echo strange not found`" \ + = x"VARIABLE = value"]) + +AT_CHECK_AUTOUPDATE + +AT_CHECK([[$EGREP '^AC_''OUTPUT$' configure.ac]], + [0], [ignore]) +AT_CHECK([[$EGREP '^AC_''CONFIG_FILES\(\[Makefile\]\)$' configure.ac]], + [0], [ignore]) +AT_CHECK([[$EGREP '^AC_''CONFIG_COMMANDS\(\[default\]' configure.ac]], + [0], [ignore]) + +AT_CLEANUP + +## ----------------------------------- ## +## AC_OUTPUT with too many arguments. ## +## ----------------------------------- ## + +AT_SETUP([AC_OUTPUT with too many arguments]) + +AT_DATA_AUTOCONF([configure.ac], +[[AC_INIT +AC_SUBST([VARIABLE], [value]) +AC_OUTPUT([Makefile], + [sed -e "s/%VARIABLE%/${VARIABLE}/g" < strange.in > strange], + [VARIABLE=$VARIABLE], + [needs-something-extra]) +]]) + +AT_CHECK_AUTOCONF([], [1], [], +[configure.ac:3: error: AC_OUTPUT takes at most three arguments. +This configure script cannot be compiled by this version of Autoconf. +configure.ac:3: the top level +autom4te: error: m4 failed with exit status: 1 +]) + +AT_CLEANUP ## ------------------- ##