summaryrefslogtreecommitdiff
path: root/lib/m4sugar
Commit message (Collapse)AuthorAgeFilesLines
* make update-copyrightZack Weinberg2021-01-283-3/+3
|
* AS_ECHO(_N): Do not expand macros named ‘s’ or ‘n’ (#110377)Zack Weinberg2020-11-161-4/+13
| | | | | | | | | | | | | | | | | | | | | | | AS_ECHO expands to ‘printf "%s\n" $1’. If a configure script defines an M4 macro named ‘s’ or ‘n’ it will be expanded in the first argument to printf, which is almost certainly not what was intended. The configure script for ruby 2.7.2 uses ‘AS_VAR_PUSHDEF([s], ...)’ and breaks with 2.69d because of this. Add some extra quoting so that the ‘%s\n’ is treated as literal; similarly for AS_ECHO_N and the legacy shell variables $as_echo and $as_echo_n. For now, anyway, don’t quote the word ‘printf’; if someone does define that as a M4 macro they might well mean to affect AS_ECHO. (Whether this is something we *want* to allow, we can worry about when it comes up.) Fixes bug #110377. * lib/m4sugar/m4sh.m4 (_AS_ECHO_N_PREPARE, AS_ECHO, AS_ECHO_N): Add another layer of quoting around the first argument to printf. * tests/m4sh.at (Redefining AS_ECHO internals): New test.
* AS_IF: Handle else clause being empty after macro expansion (#110369)Zack Weinberg2020-11-151-6/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | AS_IF can emit a syntactically invalid shell if-then-else, if CONDITION then : # ... else fi when its IF-FALSE argument consists of macros that don’t produce any shell code. This was a documented limitation in AS_IF, but it’s a bad limitation to have, because macros that *used* to expand to shell commands might start expanding to nothing in future releases. For instance, this broke the libzmq configure script, which did AC_PROG_CC AX_CHECK_COMPILE_FLAG([-std=gnu11], [CFLAGS+=" -std=gnu11"], [AC_PROG_CC_C99]) Perfectly valid in 2.69, but in 2.70 AC_PROG_CC_C99 doesn’t produce any shell code and the script crashes. We had that limitation for good reason: we can’t just put ‘:’ at the beginning of the else-clause, like we do for the then-clause, because that would clobber $? and the IF-FALSE commands might want to inspect it. (This doesn’t matter for the then-clause, because $? is always zero at the beginning of a then-clause anyway.) The simplest and least inefficient shell construct I can find that works in this context is a shell function that does ‘return $?’. Due to awkward M4sh initialization ordering constraints (AS_IF gets used before we can safely use shell functions) an indirection through a shell variable is necessary. The structure of a m4sh script is now #! /bin/sh ## M4sh Initialization as_nop=: ... ## M4sh Shell Functions as_fn_nop () { return $?; } as_nop=as_fn_nop ... and AS_IF emits if CONDITION then : # ... else $as_nop # ... fi The uses of AS_IF that appear before the beginning of the M4sh Shell Functions section are all under our control and they don’t need to look at $?. If anyone has a better idea for how to make this work I will be glad to hear it. Fixes bug #110369. * lib/m4sugar/m4sh.m4 (_AS_IF_ELSE): When $1 is nonempty, invoke _AS_EMPTY_ELSE_PREPARE. Emit $as_nop at beginning of else clause. (_AS_BOURNE_COMPATIBLE): Initialize as_nop to ‘:’. (_AS_EMPTY_ELSE_PREPARE): New macro which emits a definition of as_fn_nop and resets as_nop to as_fn_nop. (AS_PREPARE, _AS_PREPARE): Invoke _AS_EMPTY_ELSE_PREPARE. (_AS_UNSET_PREPARE): Tweak white space. * tests/m4sh.at (AS_IF and AS_CASE): Test AS_IF’s IF-FALSE argument being empty after macro expansion. * doc/autoconf.texi (AS_IF): Remove warning about use with ‘run-if-false’ argument empty after macro expansion.
* m4sh: Require shell to support $(...) command substitution.Zack Weinberg2020-11-091-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As of the 2020-11-07 update, config.sub and config.guess unconditionally use $(...) command substitution; see <https://lists.gnu.org/archive/html/config-patches/2020-11/msg00011.html>. Therefore, add this to the set of required shell features, searched for by _AS_DETECT_BETTER_SHELL. On a system where /bin/sh doesn’t support $(...), $CONFIG_SHELL will be set to one that does (and the primary configure script will be re-executed using that shell). AC_CANONICAL_* use $CONFIG_SHELL to execute config.guess/sub, so they will keep working. This also means that configure scripts and third-party macros that use $(...) will quietly start working correctly on such ancient systems. The test code is simple, but sufficient to weed out Solaris 10’s /bin/sh, which doesn’t support $(...) but *does* support shell functions. I’m not going to touch any of the existing uses of `...` command substitution in Autoconf proper for now, but it might make sense to bulk upgrade them early in the 2.71 release cycle; if nothing else, it would remove a major obstacle to running shellcheck over our scripts. * lib/m4sugar/m4sh.m4 (_AS_MODERN_CMDSUBST_WORKS): New macro. (AS_INIT, AS_SHELL_SANITIZE): Call _AS_DETECT_REQUIRED for _AS_MODERN_CMDSUBST_WORKS. * NEWS: Mention the requirement for $(...).
* _AS_PATH_WALK: Use AS_IF for IF-NOT-FOUND argument.Zack Weinberg2020-10-101-1/+1
| | | | | | | | | The construct _AS_PATH_WALK was using to conditionally execute its IF-NOT-FOUND argument, was a little too fragile: relatively natural variations in usage, such as putting the final `])` on a line by itself, could cause shell syntax errors. Use AS_IF instead. * lib/m4sugar/m4sh.m4: Use AS_IF to execute IF-NOT-FOUND conditionally.
* AS_INIT: ensure fds 0, 1, 2 are openZack Weinberg2020-08-281-26/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A patch was recently proposed for GNU libc to make *all* processes start up with file descriptors 0, 1, and 2 guaranteed to be open. Part of the rationale for this patch was that configure scripts fail catastrophically if these fds are closed, even if you just want to run --help or --version, e.g. $ ./configure --version <&-; echo $? ./configure: line 555: 0: Bad file descriptor 1 configure scripts cannot rely on behavior specific to GNU libc, so whether or not that patch gets committed, it makes sense for us to make configure scripts robust against being started up with closed stdin/stdout/stderr. This patch adds code to ensure fds 0, 1, and 2 are open, early in _AS_SHELL_SANITIZE. It uses a construct, ‘(exec 3>&n)’, that’s known not to work in very old shells, but that’s OK because those shells will be rejected by _AS_DETECT_BETTER_SHELL anyway. The worst-case scenario is that the “This script requires a shell more modern than all the shells I found on your system” error message won’t get printed. When these fds are found not to be open, we open them on /dev/null, in the normal I/O direction (0 for reading, 1 and 2 for writing). There is a case for opening them in the *opposite* direction so that, for instance, writes to fd 1 will fail when fd 1 started out closed. However, that would expose latent bugs that I think should be dealt with *after* 2.70. (See Savannah bug #110300 for more detail.) I also took the opportunity to rationalize the order of operations in _AS_SHELL_SANITIZE a little. All the special shell and environment variables that we care about are dealt with immediately after AS_BOURNE_COMPATIBLE, and _AS_PATH_SEPARATOR_PREPARE happens immediately before the first use of _AS_PATH_WALK. * lib/m4sugar/m4sh.m4 (_AS_ENSURE_STANDARD_FDS): New macro. (_AS_SHELL_SANITIZE): Move the “Unset variables that we do not need” and “NLS nuisances” blocks immediately after setting IFS; merge the unsetting of CDPATH into the main unsetting loop; move invocation of _AS_PATH_SEPARATOR_PREPARE to immediately above the “Find who we are” block; invoke _AS_ENSURE_STANDARD_FDS immediately before _AS_PATH_SEPARATOR_PREPARE. * tests/base.at (configure with closed standard fds): New test. * tests/torture.at (--help and --version in unwritable directory): New test.
* AS_INIT: basename __file__Luke Mewburn2020-07-051-1/+3
| | | | | | Fix AS_INIT to encode the basename of __file__ instead of the full path to the source directory. Allows for reproducible builds.
* Consistently expand macros in whitespace-separated lists.Zack Weinberg2020-06-291-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Several of the most commonly used Autoconf macros (starting with AC_CHECK_FUNCS and AC_CHECK_HEADERS) take a whitespace-separated list of symbols as their primary argument. It would abstractly be best if this list were _not_ subject to M4 macro expansion, in case there’s a collision between a M4 macro name and something to be looked for. However, we have historically not been careful about this, and there’s been reports of configure scripts using ‘dnl’ to write comments inside the list. The AS_LITERAL_IF optimizations added to AC_CHECK_FUNCS and AC_CHECK_HEADERS since 2.69 broke some of those scripts with bizarre shell syntax errors. Also, the macro expansion behavior is not consistent among all of the macros that take whitespace-separated lists, nor is it consistent between autoconf and autoheader. Address this by introducing a new m4sugar macro, currently called ‘m4_validate_w’ (I’m open to suggestions for better names). Here’s its documentation comment: | m4_validate_w(STRING): Expands into m4_normalize(m4_expand([STRING])), | but if that is not the same as just m4_normalize([STRING]), | issue a warning. The text of the warning is | configure.ac:N: warning: whitespace-separated-list contains macros; | configure.ac:N: in a future version of Autoconf they will not be expanded If the unexpanded form of the string contains the token ‘dnl’ then there’s an additional line: | configure.ac:N: note: ‘dnl’ is a macro All of the public macros that take a whitespace-separated list of symbols are changed to pass that argument through m4_validate_w before doing anything else with it, and the test suite is updated to verify consistent behavior for every last one of them. This addresses Savannah issues #110210 and #110211, and the harmless but annoying autoheader behavior described at https://lists.gnu.org/archive/html/bug-autoconf/2018-02/msg00005.html . In order to avoid expanding relatively expensive m4sugar macros multiple times per top-level macro invocation, several of the affected Autoconf macros are restructured along the same lines as I did for AC_REPLACE_FUNCS in the previous patch. * lib/m4sugar/m4sugar.m4 (m4_validate_w): New macro. * lib/autoconf/functions.m4 (AC_CHECK_FUNCS, AC_CHECK_FUNCS_ONCE) (AC_REPLACE_FUNCS) * lib/autoconf/general.m4 (AC_CONFIG_MACRO_DIRS, AC_CHECK_FILES) * lib/autoconf/headers.m4 (AC_CHECK_HEADERS, AC_CHECK_HEADERS_ONCE) * lib/autoconf/status.m4 (AC_CONFIG_SUBDIRS): Pass $1 through m4_validate_w before use. * lib/autoconf/headers.m4 (AC_CHECK_HEADERS): Refactor with helpers _AC_CHECK_HEADERS_ONE_U, _AC_CHECK_HEADERS_ONE_S, _AC_CHECK_HEADERS_ONE_C. (AC_CHECK_HEADERS_ONCE): Eliminate _AC_CHECK_HEADERS_ONCE. (AC_CHECK_INCLUDES_DEFAULT): Don’t use _AC_CHECK_HEADERS_ONCE. * lib/autoconf/functions.m4 (AC_CHECK_FUNCS): Refactor with helpers _AC_CHECK_FUNCS_ONE_U, _AC_CHECK_FUNCS_ONE_S, _AC_CHECK_FUNCS_ONE_C. * lib/autoconf/status.m4 (_AC_CONFIG_SUBDIRS): No need to use m4_normalize. * tests/semantics.at: Add tests for expansion of M4 macros in whitespace-separated list arguments to all of the above.
* Define $as_echo and $as_echo_n for backward compatibility.Zack Weinberg2020-03-131-4/+24
| | | | | | | | | | | | | Commit 2b59b6f8a79b8bf77e178ff4e5aa0ede433d39cf removed the internal shell variables $as_echo and $as_echo_n. It turns out that these are used by several widely-used third-party m4 files (notably both gnulib-common.m4 from gnulib, and ax_pthread.m4 from the Autoconf macro archive) as well as any number of existing configure.ac’s. Restore these shell variables, unconditionally defining them to use printf. Issue -Wobsolete warnings if they are used, recommending the use of AS_ECHO and AS_ECHO_N respectively. Add a test which checks both that they do work and that they trigger warnings.
* _AS_REEXEC_WITH_SHELL: don’t use AS_EXIT.Zack Weinberg2020-03-131-1/+4
| | | | | | | | | | | | | | | | | | | | | If _AS_REEXEC_WITH_SHELL fails to exec the selected “better” shell interpreter, and that failure somehow doesn’t terminate the process, it calls AS_EXIT([255]). This expands to an invocation of as_fn_exit. However, the definition of as_fn_exit goes into the M4SH-INIT-FN diversion, whereas _AS_REEXEC_WITH_SHELL goes into the M4SH-SANITIZE diversion, so as_fn_exit won’t be defined at the point of this use. We can’t move the definition of as_fn_exit earlier, because we don’t know that the shell supports shell functions until after we get to the end of the M4SH-SANITIZE diversion. This is only a theoretical bug because, as the comments say, “all the known shells bail out after a failed exec.” However, a shell that doesn’t bail out will instead give the user a flood of nonsensical error messages (starting with “as_fn_exit: not found” and then going on to choke on the rest of the script) so I think we should fix it anyway. There shouldn’t be any problem with using a plain ‘exit’ at this point; no traps are active yet, and we are exiting with an explicit error code.
* Fix _AS_DETECT_BETTER_SHELL breakagePaul Eggert2020-03-121-1/+1
| | | | | | | | Problem reported by Zack Weinberg in: https://lists.gnu.org/r/autoconf/2020-03/msg00017.html * lib/m4sugar/m4sh.m4 (_AS_RUN): Use sh -c instead of the no-longer-existent $as_echo. This fixes a bug introduced in 2013-01-28T03:44:45Z!gary@gnu.org.
* maint: make update-copyrightJim Meyering2020-01-013-3/+3
|
* Prefer HTTPS to FTP and HTTPPaul Eggert2017-09-163-9/+9
|
* maint: update copyright dates for 2017Jim Meyering2017-01-013-3/+3
| | | | | * all files: Run "make update-copyright". * doc/autoconf.texi: Update manually.
* maint: make update-copyrightPaul Eggert2016-02-063-3/+3
|
* m4_pattern_forbid: better documentationMatěj Týč2015-04-211-2/+2
| | | | | | | | Give a more concrete description of what the m4_pattern_forbid thingy that pretends it is a macro accepts as an argument. Copyright-paper-exempt: Yes Signed-off-by: Eric Blake <eblake@redhat.com>
* lib: use shorter way to test if variable is setEric Blake2015-04-211-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Based on an idea by Bernhard Reutner-Fischer. We frequently used the idiom of 'test "${var+set}" = set' to test if $var was set to a non-empty string, but this can portably be trimmed to a more compact 'test ${var+y}' for a smaller configure file. Testing that a variable is not set can be done with '${var+false} :' (although the value of $? is not reliably 1 when the variable is set). The code for AS_VAR_TEST_SET already used the form '${var+:} false', but it is slightly longer, and does not guarantee $? of 1. Tested on coreutils, where the resulting configure file is about 1k smaller. * doc/autoconf.texi (Shell Substitutions): Prefer shorter sequence for testing if a variable is set. (Limitations of Builtins) <test (strings)>: Document it. * configure.ac: Use it. * lib/autoconf/c.m4 (_AC_PROG_CC_G, _AC_PROG_CXX_G) (_AC_PROG_OBJC_G, _AC_PROG_OBJCXX_G): Likewise. * lib/autoconf/fortran.m4 (_AC_PROG_FC_G): Likewise. * lib/autoconf/general.m4 (_AC_ENABLE_IF_ACTION, AC_CACHE_SAVE): Likewise. * lib/autoconf/lang.m4 (_AC_COMPILER_EXEEXT_DEFAULT): Likewise. * lib/autoconf/programs.m4 (AC_PROG_INSTALL, AC_PROG_MKDIR_P) (_AC_PROG_LEX_YYTEXT_DECL): Likewise. * lib/autoconf/status.m4 (_AC_OUTPUT_MAIN_LOOP): Likewise. * lib/autotest/general.m4 (AT_INIT): Likewise. * tests/base.at (AC_CACHE_CHECK): Likewise. * tests/m4sh.at (LINENO): Likewise. * lib/m4sugar/m4sh.m4 (_AS_BOURNE_COMPATIBLE) (_AS_DETECT_BETTER_SHELL, _AS_SHELL_SANITIZE) (_AS_PATH_SEPARATOR_PREPARE): Likewise. (AS_VAR_TEST_SET): Use shorter sequence. Signed-off-by: Eric Blake <eblake@redhat.com>
* m4_set_foreach: minor optimizationEric Blake2015-04-211-2/+2
| | | | | | | | | | | As a minor optimization, most macros in m4sugar.m4 try to avoid output of 'dnl' in the expansion, to reduce the number of macros that must be expanded at each call site. * lib/m4sugar/m4sugar.m4 (m4_set_foreach): Don't expand dnl in all callers. Signed-off-by: Eric Blake <eblake@redhat.com>
* m4sugar: fix pop typo in m4_set_foreachNick Bowler2015-04-201-1/+2
| | | | | * lib/m4sugar/m4sugar.m4 (m4_set_foreach): Pop macro definition. Copyright-paperwork-exempt: Yes
* maint: bump copyright to 2015Paul Eggert2015-01-023-3/+3
| | | | * all files: Run 'make update-copyright'.
* m4sh: allow trailing newlines in shell conditionsEric Blake2014-07-171-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Dimitrios Apostolou reported getting a shell syntax error for this construct in his configure.ac: AM_CONDITIONAL([HAVE_LIBXML2], [test "x$with_libxml2" != xno && test "x$ac_cv_lib_xml2_xmlFirstElementChild" = xyes] ) He analyzed it to a root cause: his trailing newline, coupled with an 'if $2; then' construct in the macro body, resulted in configure containing: if test ... xyes ; then where the semicolon is a syntax error in shell; and proposed a patch to automake to fix his use case. While that macro is not under our control, it does highlight the fact that the shell can use either ; or newline to terminate a conditional prior to the next keyword in a compound statement. If we use newline, we gain two benefits - the configure file is slightly smaller (more lines, but fewer bytes), and any user that doesn't realize that unquoted trailing newlines in a macro argument are still significant can still generate valid shell code when their argument is used in a shell compound statement. * lib/m4sugar/m4sh.m4 (AS_IF, _AS_IF, _AS_CLEAN_DIR): Prefer newline over semicolon to end user-supplied conditionals. * lib/autoconf/general.m4 (AC_CONFIG_AUX_DIRS): Likewise. * lib/autoconf/libs.m4 (AC_SEARCH_LIBS): Likewise. * lib/autoconf/programs.m4 (_AC_PATH_PROGS_FEATURE_CHECK): Likewise. * tests/m4sh.at (AS_IF and AS_CASE): Test it. Signed-off-by: Eric Blake <eblake@redhat.com>
* maint: bump copyright to 2014Eric Blake2014-01-013-3/+3
| | | | | | | Done via 'make update-copyright', since all files are effectively modified and distributed this year via public version control. * all files: Update copyright year.
* build: no more recursion for 'lib/m4sugar' subdirStefano Lattarini2013-05-061-75/+0
| | | | | | | | | | | | * lib/m4sugar/Makefile.am: Delete, its contents merged ... * lib/Makefile.am: ... in here, with proper adjustments. (SUBDIRS): Drop 'lib/m4sugar'. Other related adjustments and re-organizations. * configure.ac (AC_CONFIG_FILES): Drop 'lib/m4sugar/Makefile'. * lib/freeze.mk ($(build_libdir)/m4sugar/version.m4): Adjust recipe. Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
* m4sugar: fix AS_VAR_GET regression.Gary V. Vaughan2013-01-291-1/+1
| | | | | | | | | | | | AS_VAR_GET expands AS_ECHO inside en evaled single quoted string, which causes the single quotes in "printf '%s\n'" to expose the %s\n to the shell which expands "\n" to simply "n" before passing it to printf. * lib/m4sugar/m4sh.m4 (AS_ECHO): Use double quotes around the format string. * doc/autoconf.texi (Limitations of Shell Builtins): Show double quotes to match AS_ECHO expansion. * NEWS: Likewise.
* m4sugar: factor away _AS_ECHO_PREPARE.Gary V. Vaughan2013-01-291-53/+7
| | | | | | | | | | | | | | "printf '%s\n' ..." has been a fine replacement for plain "echo" for at least 5 years (probably more like 10), even with most museum-piece shells. * lib/m4sugar/m4sh.m4 (_AS_ECHO_PREPARE): Remove. (_AS_SHELL_SANITIZE): Keep as_nl setting originally from _AS_ECHO_PREPARE here where it more properly belongs. (AS_ECHO, AS_ECHO_N): Use printf unconditionally. * doc/autoconf.texi (Limitations of Shell Builtins): Document preference for 'printf' over working around 'echo' bugs. * NEWS: Updated. Reported by Jim Meyering.
* maint: bump copyright to 2013Eric Blake2013-01-034-4/+4
| | | | | | | Done via 'make update-copyright', since all files are effectively modified and distributed this year via public version control. * all files: Update copyright year.
* warn: allow aclocal to silence m4_require warningsStefano Lattarini2012-11-091-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | We introduce a new witness macro, m4_require_silent_probe, for use by aclocal during the Autoconf-without-aclocal-m4 language. This will let aclocal process AC_CONFIG_MACRO_DIRS without emitting spurious warnings. In fact, if aclocal doesn't suppress require warnings, then, when some macro expanded in configure.ac calls AC_REQUIRE on another macro that is defined in one of the local m4 macro dirs specified with AC_CONFIG_MACRO_DIRS, the *first* autom4te invocation issued by aclocal, not yet being able to "see" the m4 macro definitions in the local m4 dirs, will print spurious warnings like: configure.ac:4: warning: MY_BAR is m4_require'd but not m4_defun'd configure.ac:3: MY_FOO is expanded from... Expose the use of this macro in our testsuite. Originally reported by Nick Bowler; see point (4) of: <http://lists.gnu.org/archive/html/autoconf-patches/2012-11/msg00000.html> * lib/m4sugar/m4sugar.m4 (_m4_require_call): Make warnings in the -Wsyntax category depend on the witness macro. * tests/m4sugar.at (m4@&t@_require: warning message): New test. * doc/autoconf.texi (Prerequisite Macros): Document how aclocal can silence AC_REQUIRE (m4_require) warnings. Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com> Signed-off-by: Eric Blake <eblake@redhat.com>
* build: quote 'like this', not `like this'Stefano Lattarini2012-09-211-1/+1
| | | | | | | | | As per updated GCS recommendations. * Makefile.am, configure.ac, lib/m4sugar/Makefile.am, tests/Makefile.am, m4/m4.m4: Here. Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
* AC_CHECK_ALIGNOF: fix cross-compilation bug with newer gccPaul Eggert2012-09-061-2/+2
| | | | | | | | | | | | | | * doc/autoconf.texi (Default Includes, Particular Functions) (Header Portability): * lib/autoconf/c.m4 (AC_LANG_FUNC_LINK_TRY(C)): * lib/autoconf/headers.m4 (AC_HEADER_STDC): * lib/autoconf/types.m4 (_AC_CHECK_ALIGNOF): * lib/m4sugar/m4sugar.m4 (m4_require) [comment only]: Assume the existence of the C89 freestanding headers <float.h>, <limits.h>, <stdarg.h>, <stddef.h>, as that's safe nowadays. This is less likely to run into gotchas, and should fix a cross-compilation bug with newer GCC reported by Myke Frysinger in <http://lists.gnu.org/archive/html/bug-autoconf/2012-09/msg00001.html>.
* m4sh: avoid // issues in _AS_PATH_WALKEric Blake2012-07-131-9/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | As reported by Paul Keir on the cygwin lists, http://cygwin.com/ml/cygwin/2012-07/msg00263.html, some people like to stick / in their $PATH, and if we then try to probe $as_dir/progname for existence, we can end up causing cygwin to have a several-second timeout per //name probe. It is better to avoid inserting the extra slash when $as_dir is the root directory, and simpler to code by always having a trailing slash present than it is to strip a trailing slash. Thankfully, _AS_PATH_WALK is an undocumented interface, and even if someone was using it in spite of the warnings, their use of $as_dir/foo will typically only lead to odd-looking /dir//foo probes, with only the case of / in $PATH causing slowdowns, and only when // is special. There was also a minor bug where the if-not-found code of _AS_PATH_WALK could be executed with $IFS still in the wrong state. * lib/m4sugar/m4sh.m4 (_AS_PATH_WALK): Always end as_dir in /. Avoid wrong IFS during if-not-found. Minor optimization to avoid regex. (_AS_DETECT_BETTER_SHELL, _AS_SHELL_SANITIZE): Update clients. * lib/autotest/general.m4 (_AT_FINISH): Likewise. * lib/autoconf/programs.m4 (_AC_CHECK_PROG, _AC_PATH_PROG) (_AC_PATH_PROGS_FEATURE_CHECK, _AC_PATH_PROG_FLAVOR_GNU): Likewise.
* configure: don't infloop when re-executing with $CONFIG_SHELLStefano Lattarini2012-03-031-0/+4
| | | | | | | | | | It turns out our guard against infinite recursion wasn't good enough when shells without $LINENO support were involved, since the creation-and-sourcing of configure.lineno broke the guard's expectations. Reports by Tim Rice and Paul Eggert. * lib/m4sugar/m4sh.m4 (_AS_LINENO_PREPARE): Export '_as_can_reexec' to "no" before sourcing the just-created configure.lineno.
* maint: spelling fixesPaul Eggert2012-03-012-3/+3
|
* m4sh: make AS_EXECUTABLE_P publicEric Blake2012-02-241-2/+6
| | | | | | | | | | | | | In the process of making it public, factor it into a reusable function. This makes constructs like AC_CHECK_PROGRAM smaller, as well as making libtool's naughty use of $as_executable_p safer. * lib/m4sugar/m4sh.m4 (_AS_TEST_PREPARE): Add a shell function. (AS_EXECUTABLE_P): Forward to shell function. * doc/autoconf.texi (Common Shell Constructs): Document it. * NEWS: Mention this. Signed-off-by: Eric Blake <eblake@redhat.com>
* m4sh: require that 'test -x' worksEric Blake2012-02-241-35/+14
| | | | | | | | | | | | | | | | | | | 4.3BSD is no longer a reasonable portability target; and we are pretty sure that these days we can find at least one shell on any platform that supports 'test -x'. Drop a horribly unsafe use of eval as a result. :) Libtool still uses $as_executable_p without so much as calling either AS_TEST_X or AS_EXECUTABLE_P; even though the latter has existed, although undocumented, since at least 2.59; furthermore, libtool uses it in a context where filtering out directories would have been desirable. Shame on them. * lib/m4sugar/m4sh.m4 (_AS_TEST_X_WORKS): New probe. (AS_SHELL_SANITIZE, AS_INIT): Use it in shell searching. (AS_TEST_X, AS_EXECUTABLE_P): Simplify. Signed-off-by: Eric Blake <eblake@redhat.com>
* doc: fix grammar/doubled-word errorsJim Meyering2012-01-211-1/+1
| | | | | | | * doc/autoconf.texi: Remove/fix doubled-word errors. Also, s/can not/cannot/. * lib/m4sugar/m4sh.m4: Reword "if IF" comment to avoid triggering the doubled-word warning.
* maint: update copyright yearPaul Eggert2012-01-044-4/+4
| | | | All files changed to add 2012, via 'make update-copyright'.
* m4sh: allow forced re-execution with $CONFIG_SHELL, if it's setStefano Lattarini2011-12-261-0/+22
| | | | | | | | | | * lib/m4sugar/m4sh.m4 (_AS_DETECT_BETTER_SHELL): If the m4sh client has defined the macro `_AS_FORCE_REEXEC_WITH_CONFIG_SHELL' to "yes", emit code to always re-execute the current script with $CONFIG_SHELL, if that's set. * tests/m4sh.at: Add tests for the new and old semantics, in ... (Re-exec with CONFIG_SHELL, Forced re-exec with CONFIG_SHELL): ... these new test groups.
* m4sh: refactor _AS_DETECT_BETTER_SHELL, for future changesStefano Lattarini2011-12-261-15/+26
| | | | | | * lib/m4sugar/m4sh.m4 (_AS_DETECT_BETTER_SHELL): Move code to handle the re-execution of the shell ... (_AS_REEXEC_WITH_SHELL): ... in this new macro.
* AS_LN_S: fall back on 'cp -pR' (not 'cp -p') if 'ln -s' failsPaul Eggert2011-12-261-5/+5
| | | | | | | | | This works better for symlinks to directories. Problem reported by Eli Zaretskii via Werner Lemberg in <http://lists.gnu.org/archive/html/bug-autoconf/2011-12/msg00006.html>. * NEWS: * doc/autoconf.texi (Particular Programs): Document this. * lib/m4sugar/m4sh.m4 (_AS_LN_S_PREPARE): Implement this.
* AC_REQUIRE: include FAQ URL when warning about duplicate expansionMike Frysinger2011-07-151-1/+2
| | | | | | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org> 2011-07-11 Mike Frysinger <vapier@gentoo.org> * lib/m4sugar/m4sugar.m4 (_m4_require_check): Add URL to warning.
* maint: update copyright yearEric Blake2011-01-044-7/+4
| | | | | | All files changed to add 2011, via 'make update-copyright'. Signed-off-by: Eric Blake <eblake@redhat.com>
* AS_LITERAL_IF: Treat raw = as literal again.Eric Blake2010-10-081-2/+2
| | | | | | | | | | * lib/m4sugar/m4sh.m4 (_AS_LITERAL_IF): Treat = like +. * tests/m4sh.at (AS@&t@_TR_SH and AS@&t@_TR_CPP) (AS@&t@_LITERAL_IF): Expand tests. * NEWS: Document the fix. Reported via Ben Pfaff; originally http://bugs.debian.org/593838 Signed-off-by: Eric Blake <eblake@redhat.com>
* autom4te: don't filter out portions of location tracesEric Blake2010-09-201-3/+4
| | | | | | | | | | * bin/autom4te.in (_m4_warn): Pass warnings through the channels machinery as a single chunk, to avoid partial filtering. * lib/m4sugar/m4sugar.m4 (_m4_warn): Document the conventions. * tests/m4sugar.at (m4@&t@_warn): Enhance test to catch this. Reported by Bruno Haible. Signed-off-by: Eric Blake <eblake@redhat.com>
* m4sh: fix today's AS_BOX regressionEric Blake2010-09-161-1/+1
| | | | | | | * lib/m4sugar/m4sh.m4 (_AS_BOX_LITERAL): Fix underquotation. Reported by Stefano Lattarini. Signed-off-by: Eric Blake <eblake@redhat.com>
* m4sugar: fix regression in AC_MSG_ERROR expansionEric Blake2010-09-161-1/+1
| | | | | | | | | | | | | | | | | AS_ERROR Regression introduced in commit cffdc3947, but the underlying problem stems from the introduction of m4_defun_init in commit d0c5f482. * lib/m4sugar/m4sugar.m4 (m4_defun_init): Avoid macro concatenation on subsequent expansions * tests/m4sh.at (AS_WARN and AS_ERROR): New test. * tests/m4sugar.at (m4@&t@_require: one-shot initialization): Enhance test. * NEWS: Document the fix. * THANKS: Update. Reported by Adrian Bunk and and Nishio Futoshi. Signed-off-by: Eric Blake <eblake@redhat.com>
* m4sh: preserve set -vx over re-execEric Blake2010-09-081-1/+8
| | | | | | | | | | | See http://lists.gnu.org/archive/html/bug-gnulib/2010-09/msg00035.html for the motivation for this patch. * lib/m4sugar/m4sh.m4 (_AS_DETECT_BETTER_SHELL): Trace through re-exec, to make it easier to debug script startup issues. Idea from recent bug-gnulib change to init.sh. Signed-off-by: Eric Blake <eblake@redhat.com>
* m4sh: protect LINENO against stray macroEric Blake2010-08-271-5/+5
| | | | | | | | | * lib/m4sugar/m4sh.m4 (_AS_LINENO_PREPARE): Double quote entire sed script, to avoid issue uncovered by automake testsuite where 'b' was an m4 macro that broke execution on dash. Reported by Stefano Lattarini. Signed-off-by: Eric Blake <eblake@redhat.com>
* m4sh: assume ${a:-b} supportEric Blake2010-08-271-5/+9
| | | | | | | | | | | * tests/m4sh.at (Null variable substitution): New test. * doc/autoconf.texi (Shell Substitutions) <${var:-value}>: Mention that m4sh guarantees support. (Limitations of Usual Tools) <mktemp>: Use it. * lib/m4sugar/m4sh.m4 (AS_LINENO_POP, AS_VAR_IF, AS_TMPDIR): Exploit use of colon for smaller files. Signed-off-by: Eric Blake <eblake@redhat.com>
* m4sh: revert regression in AS_TMPDIREric Blake2010-08-251-4/+7
| | | | | | | | | Regression introduced in e0ac12089ea4c934029baf77741e659f0bebd653. * lib/m4sugar/m4sh.m4 (AS_TMPDIR): The previous patch trying to rename $tmp to $as_tmp was wrong; config.status relies on it. Signed-off-by: Eric Blake <eblake@redhat.com>
* m4sh: reduce size of AS_VAR_TEST_SETEric Blake2010-08-251-4/+4
| | | | | | * lib/m4sugar/m4sh.m4 (AS_VAR_TEST_SET): Make more compact. Signed-off-by: Eric Blake <eblake@redhat.com>