>From 99fab0b28b2d685c186dbfacafa6e745ccf98cbc Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Fri, 30 Jan 2015 13:52:08 +0100 Subject: [PATCH] autoconf: warn about late AC_CONFIG_AUX_DIR call Some macros explicitly call (require) AC_CONFIG_AUX_DIR_DEFAULT. When such macro was called _before_ AC_CONFIG_AUX_DIR, the check for install-sh script would then most probably fail (as the install-sh script probably resided in re-defined aux directory). See automake bug #19539. * lib/autoconf/general.m4(AC_CONFIG_AUX_DIR): Call AC_BEFORE to warn about bad macro order. Put AC_BEFORE _before_ actual call to internal AC_CONFIG_AUX_DIRS as it provides AC_CONFIG_AUX_DIR_DEFAULT. * doc/autoconf.texi (AC_CONFIG_AUX_DIR): Document why AC_CONFIG_AUX_DIR should be called early. * tests/tools.at (autoconf: AC_CONFIG_AUX_DIR): New testcase. --- doc/autoconf.texi | 11 +++++++++++ lib/autoconf/general.m4 | 4 +++- tests/tools.at | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/doc/autoconf.texi b/doc/autoconf.texi index d9e833d..65233fd 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -2096,6 +2096,17 @@ name is obsolete because some @command{make} have a rule that creates The auxiliary directory is commonly named @file{build-aux}. If you need portability to DOS variants, do not name the auxiliary directory @file{aux}. @xref{File System Conventions}. + +Call to @code{AC_CONFIG_AUX_DIR} should be done as soon as possible after the address@hidden because there are several macros requiring properly defined +auxiliary directory (e.g., @code{AC_PROG_INSTALL}). If you use such macro +together with @code{AC_CONFIG_AUX_DIR} you must make sure address@hidden is called before such macro. + +Also note that if you use Automake (in version 1.13.3 and above), Automake +redefines Autoconf's @code{AC_PROG_CC} macro the way it also depends on aux +directory. Thus, @code{AC_CONFIG_AUX_DIR} must be called before address@hidden or any other macro requiring it. @end defmac @defmac AC_REQUIRE_AUX_FILE (@var{file}) diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index 2d1a291..4f9b877 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -1681,7 +1681,9 @@ program_transform_name=`AS_ECHO(["$program_transform_name"]) | sed "$ac_script"` # in directory DIR. These are auxiliary files used in configuration. # DIR can be either absolute or relative to $srcdir. AC_DEFUN([AC_CONFIG_AUX_DIR], -[AC_CONFIG_AUX_DIRS($1 "$srcdir"/$1)]) +[AC_BEFORE([$0], [AC_CONFIG_AUX_DIR_DEFAULT]) +AC_CONFIG_AUX_DIRS($1 "$srcdir"/$1)dnl +]) # AC_CONFIG_AUX_DIR_DEFAULT diff --git a/tests/tools.at b/tests/tools.at index 24173c9..889375b 100644 --- a/tests/tools.at +++ b/tests/tools.at @@ -605,6 +605,47 @@ AT_CHECK([[grep 'version ]]AT_PACKAGE_VERSION[[ version' configure]], AT_CLEANUP +# autoconf: AC_CONFIG_AUX_DIR +# --------------------------- +# Check that calling AC_PROG_INSTALL before AC_CONFIG_AUX_DIR warns user. + +AT_SETUP([autoconf: AC_CONFIG_AUX_DIR]) +AT_DATA([configure.ac], +[[AC_INIT +AC_PROG_INSTALL +AC_CONFIG_AUX_DIR([build-aux]) +AC_OUTPUT +]]) + +AT_DATA([stderr], +[[ohohoo +]]) + +mkdir build-aux +touch build-aux/install-sh +chmod a+x build-aux/install-sh + +AT_CHECK_AUTOCONF([], [0], [ignore], [stderr]) +AT_CHECK([dnl +grep -c 'AC_CONFIG_AUX_DIR_DEFAULT was called before AC_CONFIG_AUX_DIR' stderr], +[0], [1 +]) + +AT_CHECK_CONFIGURE([], [1], [ignore], [stderr]) +AT_CHECK([grep -c 'cannot find install-sh' stderr], [0], [1 +]) + +AT_DATA([configure.ac], +[[AC_INIT +AC_CONFIG_AUX_DIR([build-aux]) +AC_PROG_INSTALL +AC_OUTPUT +]]) + +AT_CHECK_AUTOCONF([], [0]) + +AT_CLEANUP + # autoconf: AC_PRESERVE_HELP_ORDER # -------------------------------- -- 2.1.0