1 # This file is part of Autoconf. -*- Autoconf -*-
2 # M4 sugar for common shell constructs.
3 # Requires GNU M4 and M4sugar.
5 # Copyright (C) 2000-2017, 2020-2024 Free Software Foundation, Inc.
7 # This file is part of Autoconf. This program is free
8 # software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the
10 # Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # Under Section 7 of GPL version 3, you are granted additional
19 # permissions described in the Autoconf Configure Script Exception,
20 # version 3.0, as published by the Free Software Foundation.
22 # You should have received a copy of the GNU General Public License
23 # and a copy of the Autoconf Configure Script Exception along with
24 # this program; see the files COPYINGv3 and COPYING.EXCEPTION
25 # respectively. If not, see <https://www.gnu.org/licenses/>.
27 # Written by Akim Demaille, Pavel Roskin, Alexandre Oliva, Lars J. Aas
28 # and many other people.
31 # We heavily use m4's diversions both for the initializations and for
32 # required macros, because in both cases we have to issue soon in
33 # output something which is discovered late.
36 # KILL is only used to suppress output.
39 # AC_REQUIRE'd #! /bin/sh line
43 # Purpose of the script etc.
49 # M4sh initialization (shell functions)
51 # M4sh initialization (detection code)
53 # The body of the script.
56 # _m4_divert(DIVERSION-NAME)
57 # --------------------------
58 # Convert a diversion name into its number. Otherwise, return
59 # DIVERSION-NAME which is supposed to be an actual diversion number.
60 # Of course it would be nicer to use m4_case here, instead of zillions
61 # of little macros, but it then takes twice longer to run 'autoconf'!
62 # BINSH is 1, not 0, so that user code can m4_cleardivert([BINSH]) and
63 # then generate its own BINSH; m4's special treatment of diversion 0
64 # would not allow that if BINSH were 0. Leave an undocumented gap
65 # between BINSH and HEADER-REVISION for possible future extensions.
66 m4_define([_m4_divert(BINSH)], 1)
67 m4_define([_m4_divert(HEADER-REVISION)], 3)
68 m4_define([_m4_divert(HEADER-COMMENT)], 4)
69 m4_define([_m4_divert(HEADER-COPYRIGHT)], 5)
70 m4_define([_m4_divert(M4SH-SANITIZE)], 6)
71 m4_define([_m4_divert(M4SH-INIT-FN)], 7)
72 m4_define([_m4_divert(M4SH-INIT)], 8)
73 m4_define([_m4_divert(BODY)], 1000)
75 # Aaarg. Yet it starts with compatibility issues... Libtool wants to
76 # use NOTICE to insert its own LIBTOOL-INIT stuff. People should ask
77 # before diving into our internals :(
78 m4_copy([_m4_divert(M4SH-INIT)], [_m4_divert(NOTICE)])
82 ## ------------------------- ##
83 ## 1. Sanitizing the shell. ##
84 ## ------------------------- ##
85 # Please maintain lexicographic sorting of this section, ignoring leading _.
87 # AS_BOURNE_COMPATIBLE
88 # --------------------
89 # Try to be as Bourne and/or POSIX as possible.
91 # This does not set BIN_SH, due to the problems described in
92 # <https://lists.gnu.org/archive/html/autoconf-patches/2006-03/msg00081.html>.
93 # People who need BIN_SH should set it in their environment before invoking
94 # configure; apparently this would include UnixWare, as described in
95 # <https://lists.gnu.org/archive/html/bug-autoconf/2006-06/msg00025.html>.
96 m4_define([AS_BOURNE_COMPATIBLE],
97 [# Be more Bourne compatible
98 DUALCASE=1; export DUALCASE # for MKS sh
102 # _AS_BOURNE_COMPATIBLE
103 # ---------------------
104 # This is the part of AS_BOURNE_COMPATIBLE which has to be repeated inside
106 m4_define([_AS_BOURNE_COMPATIBLE],
107 [AS_IF([test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1],
110 [#] Pre-4.2 versions of Zsh do word splitting on ${1+"$[@]"}, which
111 # contradicts POSIX and common usage. Disable this.
112 alias -g '${1+"$[@]"}'='"$[@]"'
113 setopt NO_GLOB_SUBST],
114 [AS_CASE([`(set -o) 2>/dev/null`], [*posix*], [set -o posix])])
120 # Expanded as the last thing before m4sugar cleanup begins. Macros
121 # may append m4sh cleanup hooks to this as appropriate.
122 m4_define([_AS_CLEANUP],
123 [m4_divert_text([M4SH-SANITIZE], [_AS_DETECT_BETTER_SHELL])])
128 # Emit TEXT, a copyright notice, as a shell comment near the top of the
129 # script. TEXT is evaluated once; to accomplish that, we do not prepend
131 m4_define([AS_COPYRIGHT],
132 [m4_divert_text([HEADER-COPYRIGHT],
134 $1], [^], [@%:@ ])])])
137 # _AS_DETECT_EXPAND(VAR, SET)
138 # ---------------------------
139 # Assign the contents of VAR from the contents of SET, expanded in such
140 # a manner that VAR can be passed to _AS_RUN. In order to make
141 # _AS_LINENO_WORKS operate correctly, we must specially handle the
142 # first instance of $LINENO within any line being expanded (the first
143 # instance is important to tests using the current shell, leaving
144 # remaining instances for tests using a candidate shell). Bash loses
145 # track of line numbers if a double quote contains a newline, hence,
146 # we must piece-meal the assignment of VAR such that $LINENO expansion
147 # occurs in a single line.
148 m4_define([_AS_DETECT_EXPAND],
149 [$1="m4_bpatsubst(m4_dquote(AS_ESCAPE(_m4_expand(m4_set_contents([$2], [
150 ])))), [\\\$LINENO\(.*\)$], [";$1=$$1$LINENO;$1=$$1"\1])"])
153 # _AS_DETECT_REQUIRED(TEST)
154 # -------------------------
155 # Refuse to execute under a shell that does not pass the given TEST.
156 # Does not do AS_REQUIRE for the better-shell detection code.
158 # M4sh should never require something not required by POSIX, although
159 # other clients are free to do so.
160 m4_defun([_AS_DETECT_REQUIRED],
161 [m4_set_add([_AS_DETECT_REQUIRED_BODY], [$1 || AS_EXIT])])
164 # _AS_DETECT_SUGGESTED(TEST)
165 # --------------------------
166 # Prefer to execute under a shell that passes the given TEST.
167 # Does not do AS_REQUIRE for the better-shell detection code.
169 # M4sh should never suggest something not required by POSIX, although
170 # other clients are free to do so.
171 m4_defun([_AS_DETECT_SUGGESTED],
172 [m4_set_add([_AS_DETECT_SUGGESTED_BODY], [$1 || AS_EXIT])])
175 # _AS_DETECT_SUGGESTED_PRUNE(TEST)
176 # --------------------------------
177 # If TEST is also a required test, remove it from the set of suggested tests.
178 m4_define([_AS_DETECT_SUGGESTED_PRUNE],
179 [m4_set_contains([_AS_DETECT_REQUIRED_BODY], [$1],
180 [m4_set_remove([_AS_DETECT_SUGGESTED_BODY], [$1])])])
183 # _AS_DETECT_BETTER_SHELL
184 # -----------------------
185 # The real workhorse for detecting a shell with the correct
188 # In previous versions, we prepended /usr/posix/bin to the path, but that
189 # caused a regression on OpenServer 6.0.0
190 # <https://lists.gnu.org/archive/html/bug-autoconf/2006-06/msg00017.html>
191 # and on HP-UX 11.11, see the failure of test 120 in
192 # <https://lists.gnu.org/archive/html/bug-autoconf/2006-10/msg00003.html>
194 # FIXME: The code should test for the OSF bug described in
195 # <https://lists.gnu.org/archive/html/autoconf-patches/2006-03/msg00081.html>.
197 # This code is run outside any trap 0 context, hence we can simplify AS_EXIT.
198 m4_defun([_AS_DETECT_BETTER_SHELL],
200 dnl By default, do not force re-execution of the script just because
201 dnl the user has pre-set $CONFIG_SHELL; do so only if the m4sh client has
202 dnl defined the internal variable '_AS_FORCE_REEXEC_WITH_CONFIG_SHELL' to
204 dnl FIXME: This interface is acceptable for the moment, as a private,
205 dnl FIXME: internal one; but if we want to make the "always re-execute"
206 dnl FIXME: feature public, we should find a better interface!
207 [m4_if(_AS_FORCE_REEXEC_WITH_CONFIG_SHELL, [yes],
208 [# Use a proper internal environment variable to ensure we don't fall
209 # into an infinite loop, continuously re-executing ourselves.
210 if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
211 _as_can_reexec=no; export _as_can_reexec;
212 _AS_REEXEC_WITH_SHELL([$CONFIG_SHELL])
214 # We don't want this to propagate to other subprocesses.
215 dnl This might be especially important in case an m4sh-generated script
216 dnl is used to later execute other m4sh-generated scripts. This happens
217 dnl for example in autoconf's own testsuite (and happens *a lot* there,
219 AS_UNSET([_as_can_reexec])
221 dnl Remove any tests from suggested that are also required
222 [m4_set_map([_AS_DETECT_SUGGESTED_BODY], [_AS_DETECT_SUGGESTED_PRUNE])]dnl
223 [m4_pushdef([AS_EXIT], [exit m4_default(]m4_dquote([$][1])[, 1)])]dnl
224 [if test "x$CONFIG_SHELL" = x; then
225 as_bourne_compatible="AS_ESCAPE(_m4_expand([_AS_BOURNE_COMPATIBLE]))"
226 _AS_DETECT_EXPAND([as_required], [_AS_DETECT_REQUIRED_BODY])
227 _AS_DETECT_EXPAND([as_suggested], [_AS_DETECT_SUGGESTED_BODY])
228 AS_IF([_AS_RUN(["$as_required"])],
229 [as_have_required=yes],
230 [as_have_required=no])
231 AS_IF([test x$as_have_required = xyes && _AS_RUN(["$as_suggested"])],
233 [_AS_PATH_WALK([/bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH],
234 [case $as_dir in @%:@(
236 for as_base in sh bash ksh sh5; do
237 # Try only shells that exist, to save several forks.
238 as_shell=$as_dir$as_base
239 AS_IF([{ test -f "$as_shell" || test -f "$as_shell.exe"; } &&
240 _AS_RUN(["$as_required"], ["$as_shell"])],
241 [CONFIG_SHELL=$as_shell as_have_required=yes
242 m4_set_empty([_AS_DETECT_SUGGESTED_BODY], [break 2],
243 [AS_IF([_AS_RUN(["$as_suggested"], ["$as_shell"])],
247 [AS_IF([{ test -f "$SHELL" || test -f "$SHELL.exe"; } &&
248 _AS_RUN(["$as_required"], ["$SHELL"])],
249 [CONFIG_SHELL=$SHELL as_have_required=yes])])
251 AS_IF([test "x$CONFIG_SHELL" != x],
253 _AS_REEXEC_WITH_SHELL([$CONFIG_SHELL])])
255 dnl Unfortunately, $as_me isn't available here.
256 AS_IF([test x$as_have_required = xno],
257 [AS_ECHO(["$[]0: This script requires a shell more modern than all"])
258 AS_ECHO(["$[]0: the shells that I found on your system."])
259 if test ${ZSH_VERSION+y} ; then
260 AS_ECHO(["$[]0: In particular, zsh $ZSH_VERSION has bugs and should"])
261 AS_ECHO(["$[]0: be upgraded to zsh 4.3.4 or later."])
263 AS_ECHO("m4_text_wrap([Please tell ]_m4_defn([m4_PACKAGE_BUGREPORT])
264 m4_ifset([AC_PACKAGE_BUGREPORT], [m4_if(_m4_defn([m4_PACKAGE_BUGREPORT]),
265 _m4_defn([AC_PACKAGE_BUGREPORT]), [], [and _m4_defn([AC_PACKAGE_BUGREPORT])])])
266 [about your system, including any error possibly output before this message.
267 Then install a modern shell, or manually run the script under such a
268 shell if you do have one.], [$[]0: ], [], [62])")
272 SHELL=${CONFIG_SHELL-/bin/sh}
274 # Unset more variables known to interfere with behavior of common tools.
275 CLICOLOR_FORCE= GREP_OPTIONS=
276 unset CLICOLOR_FORCE GREP_OPTIONS
277 _m4_popdef([AS_EXIT])])# _AS_DETECT_BETTER_SHELL
279 # _AS_REEXEC_WITH_SHELL(SHELL)
280 # ----------------------------
281 # Re-execute the current script with the given shell, trying to preserve
282 # portable settings (e.g., the 'xtrace' and 'verbose' shell flag).
283 m4_defun([_AS_REEXEC_WITH_SHELL], [dnl
284 # We cannot yet assume a decent shell, so we have to provide a
285 # neutralization value for shells without unset; and this also
286 # works around shells that cannot unset nonexistent variables.
287 # Preserve -v and -x to the replacement shell.
290 (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
292 *v*x* | *x*v* ) as_opts=-vx ;;
297 case [$]@%:@ in @%:@ ((
298 0) exec $1 $as_opts "$as_myself" ;;
299 *) exec $1 $as_opts "$as_myself" "$[@]" ;;
301 # Admittedly, this is quite paranoid, since all the known shells bail
302 # out after a failed 'exec'.
303 AS_ECHO(["$[]0: could not re-execute with $1"]) >&2
304 dnl AS_EXIT cannot be used here because as_fn_exit is not yet defined;
305 dnl code inserted by AS_REQUIRE_SHELL_FN will appear _after_ this point.
306 dnl We shouldn't have to worry about any traps being active at this point.
307 exit 255])# _AS_REEXEC_WITH_SHELL
310 # _AS_ENSURE_STANDARD_FDS
311 # -----------------------
312 # Ensure that file descriptors 0, 1, and 2 are open, as a defensive
313 # measure against weird environments that run configure scripts
314 # with these descriptors closed.
315 # 'exec m>&n' fails in POSIX sh when fd N is closed, but succeeds
316 # regardless of whether fd N is open in some old shells, e.g. Solaris
317 # /bin/sh. This is OK because those shells will be rejected by
318 # _AS_DETECT_BETTER_SHELL anyway.
319 # TODO post-2.70: use "backward" redirections when opening these fds,
320 # so we preserve their unusable state. Needs downstream logic to
321 # stop on the first failed attempt to write to fd 1 or 2, so we don't
322 # run through an entire configure script spewing "write error"
323 # messages when fd 1 is closed.
324 m4_defun([_AS_ENSURE_STANDARD_FDS], [dnl
325 # Ensure that fds 0, 1, and 2 are open.
326 if (exec 3>&0) 2>/dev/null; then :; else exec 0</dev/null; fi
327 if (exec 3>&1) 2>/dev/null; then :; else exec 1>/dev/null; fi
328 if (exec 3>&2) ; then :; else exec 2>/dev/null; fi
334 # This macro has a very special status. Normal use of M4sh relies
335 # heavily on AS_REQUIRE, so that needed initializations (such as
336 # _AS_TEST_PREPARE) are performed on need, not on demand. But
337 # Autoconf is the first client of M4sh, and for two reasons: configure
338 # and config.status. Relying on AS_REQUIRE is of course fine for
339 # configure, but fails for config.status (which is created by
340 # configure). So we need a means to force the inclusion of the
341 # various _AS_*_PREPARE on top of config.status. That's basically why
342 # there are so many _AS_*_PREPARE below, and that's also why it is
343 # important not to forget some: config.status needs them.
344 # List any preparations that create shell functions first, then
345 # topologically sort the others by their dependencies.
347 # Special case: we do not need _AS_LINENO_PREPARE, because the
348 # parent will have substituted $LINENO for us when processing its
349 # own invocation of _AS_LINENO_PREPARE.
351 # Special case: the full definition of _AS_ERROR_PREPARE is not output
352 # unless AS_MESSAGE_LOG_FD is non-empty, although the value of
353 # AS_MESSAGE_LOG_FD is not relevant.
354 m4_defun([_AS_PREPARE],
355 [m4_pushdef([AS_REQUIRE])]dnl
356 [m4_pushdef([AS_REQUIRE_SHELL_FN], _m4_defn([_AS_REQUIRE_SHELL_FN])
358 [m4_pushdef([AS_MESSAGE_LOG_FD], [-1])]dnl
360 _m4_popdef([AS_MESSAGE_LOG_FD])]dnl
363 _AS_VAR_APPEND_PREPARE
364 _AS_VAR_ARITH_PREPARE
376 _m4_popdef([AS_REQUIRE], [AS_REQUIRE_SHELL_FN])])
380 # Output all the M4sh possible initialization into the initialization
381 # diversion. We do not use _AS_PREPARE so that the m4_provide symbols for
382 # AS_REQUIRE and AS_REQUIRE_SHELL_FN are defined properly, and so that
383 # shell functions are placed in M4SH-INIT-FN.
384 m4_defun([AS_PREPARE],
385 [m4_divert_push([KILL])
386 m4_append_uniq([_AS_CLEANUP],
387 [m4_divert_text([M4SH-INIT-FN], [_AS_ERROR_PREPARE[]])])
388 AS_REQUIRE([_AS_EXPR_PREPARE])
389 AS_REQUIRE([_AS_BASENAME_PREPARE])
390 AS_REQUIRE([_AS_DIRNAME_PREPARE])
391 AS_REQUIRE([_AS_ME_PREPARE])
392 AS_REQUIRE([_AS_CR_PREPARE])
393 AS_REQUIRE([_AS_LINENO_PREPARE])
394 AS_REQUIRE([_AS_EXIT_PREPARE])
395 AS_REQUIRE([_AS_LN_S_PREPARE])
396 AS_REQUIRE([_AS_MKDIR_P_PREPARE])
397 AS_REQUIRE([_AS_TEST_PREPARE])
398 AS_REQUIRE([_AS_TR_CPP_PREPARE])
399 AS_REQUIRE([_AS_TR_SH_PREPARE])
400 AS_REQUIRE([_AS_UNSET_PREPARE])
401 AS_REQUIRE([_AS_VAR_APPEND_PREPARE], [], [M4SH-INIT-FN])
402 AS_REQUIRE([_AS_VAR_ARITH_PREPARE], [], [M4SH-INIT-FN])
406 # AS_REQUIRE(NAME-TO-CHECK, [BODY-TO-EXPAND = NAME-TO-CHECK],
407 # [DIVERSION = M4SH-INIT])
408 # -----------------------------------------------------------
409 # BODY-TO-EXPAND is some initialization which must be expanded in the
410 # given diversion when expanded (required or not). The expansion
411 # goes in the named diversion or an earlier one.
413 # Since $2 can be quite large, this is factored for faster execution, giving
414 # either m4_require([$1], [$2]) or m4_divert_require(desired, [$1], [$2]).
415 m4_defun([AS_REQUIRE],
416 [m4_define([_m4_divert_desired], [m4_default_quoted([$3], [M4SH-INIT])])]dnl
417 [m4_if(m4_eval(_m4_divert_dump - 0 <= _m4_divert(_m4_divert_desired, [-])),
419 [m4_divert_require(_m4_divert_desired,]) [$1], [$2])])
421 # _AS_REQUIRE_SHELL_FN(NAME-TO-CHECK, COMMENT, BODY-TO-EXPAND)
422 # ------------------------------------------------------------
423 # Core of AS_REQUIRE_SHELL_FN, but without diversion support.
424 m4_define([_AS_REQUIRE_SHELL_FN], [
430 # AS_REQUIRE_SHELL_FN(NAME-TO-CHECK, COMMENT, BODY-TO-EXPAND,
431 # [DIVERSION = M4SH-INIT-FN])
432 # -----------------------------------------------------------
433 # BODY-TO-EXPAND is the body of a shell function to be emitted in the
434 # given diversion when expanded (required or not). Unlike other
435 # xx_REQUIRE macros, BODY-TO-EXPAND is mandatory. If COMMENT is
436 # provided (often via AS_FUNCTION_DESCRIBE), it is listed with a
437 # newline before the function name.
438 m4_define([AS_REQUIRE_SHELL_FN],
439 [m4_provide_if([AS_SHELL_FN_$1], [],
440 [AS_REQUIRE([AS_SHELL_FN_$1],
441 [m4_provide([AS_SHELL_FN_$1])_$0($@)],
442 m4_default_quoted([$4], [M4SH-INIT-FN]))])])
445 # _AS_RUN(TEST, [SHELL])
446 # ----------------------
447 # Run TEST under the current shell (if one parameter is used)
448 # or under the given SHELL, protecting it from syntax errors.
449 # Set as_run in order to assist _AS_LINENO_WORKS.
451 [m4_ifval([$2], [as_run=a $2 -c "$as_bourne_compatible"$1],
452 [(eval $1)]) 2>/dev/null])
457 # This is a spy to detect "in the wild" shells that do not support shell
458 # functions correctly. It is based on the m4sh.at Autotest testcases.
459 m4_define([_AS_SHELL_FN_WORK],
460 [as_fn_return () { (exit [$]1); }
461 as_fn_success () { as_fn_return 0; }
462 as_fn_failure () { as_fn_return 1; }
463 as_fn_ret_success () { return 0; }
464 as_fn_ret_failure () { return 1; }
467 as_fn_success || { exitcode=1; echo as_fn_success failed.; }
468 as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
469 as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
470 as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
471 AS_IF([( set x; as_fn_ret_success y && test x = "[$]1" )], [],
472 [exitcode=1; echo positional parameters were not saved.])
473 test x$exitcode = x0[]])# _AS_SHELL_FN_WORK
476 # _AS_MODERN_CMDSUBST_WORKS
477 # -------------------------
478 # This is a spy to detect "in the wild" shells that do not support
479 # the newer $(...) form of command substitutions.
480 m4_define([_AS_MODERN_CMDSUBST_WORKS],
481 [blah=$(echo $(echo blah))
482 test x"$blah" = xblah])
487 # This is the prolog that is emitted by AS_INIT and AS_INIT_GENERATED;
488 # it is executed prior to shell function definitions, hence the
489 # temporary redefinition of AS_EXIT.
490 m4_defun([_AS_SHELL_SANITIZE],
491 [m4_pushdef([AS_EXIT], [exit m4_default(]m4_dquote([$][1])[, 1)])]dnl
492 [m4_text_box([M4sh Initialization.])
496 # Reset variables that may have inherited troublesome values from
499 # IFS needs to be set, to space, tab, and newline, in precisely that order.
500 # (If _AS_PATH_WALK were called with IFS unset, it would have the
501 # side effect of setting IFS to empty, thus disabling word splitting.)
502 # Quoting is to prevent editors from complaining about space-tab.
512 # Ensure predictable behavior from utilities with locale-dependent output.
518 # We cannot yet rely on "unset" to work, but we need these variables
519 # to be unset--not just set to an empty or harmless value--now, to
520 # avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct
521 # also avoids known problems related to "unset" and subshell syntax
522 # in other old shells (e.g. bash 2.01 and pdksh 5.2.14).
523 for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH
524 do eval test \${$as_var+y} \
525 && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
528 _AS_ENSURE_STANDARD_FDS
529 _AS_PATH_SEPARATOR_PREPARE
531 # Find who we are. Look in the path if we contain no directory separator.
534 *[[\\/]]* ) as_myself=$[0] ;;
536 [test -r "$as_dir$[0]" && as_myself=$as_dir$[0] && break])
539 # We did not find ourselves, most probably we were run as 'sh COMMAND'
540 # in which case we are not to be found in the path.
541 if test "x$as_myself" = x; then
544 if test ! -f "$as_myself"; then
545 AS_ECHO(["$as_myself: error: cannot find myself; rerun with an absolute file name"]) >&2
549 _m4_popdef([AS_EXIT])])# _AS_SHELL_SANITIZE
554 # This is only needed for the sake of Libtool, which screws up royally
555 # in its usage of M4sh internals.
556 m4_define([AS_SHELL_SANITIZE],
558 m4_provide_if([AS_INIT], [],
559 [m4_provide([AS_INIT])
560 _AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])
561 _AS_DETECT_REQUIRED([_AS_MODERN_CMDSUBST_WORKS])
562 _AS_DETECT_REQUIRED([_AS_TEST_X_WORKS])
563 _AS_DETECT_BETTER_SHELL
568 ## ----------------------------- ##
569 ## 2. Wrappers around builtins. ##
570 ## ----------------------------- ##
572 # This section is lexicographically sorted.
575 # AS_CASE(WORD, [PATTERN1], [IF-MATCHED1]...[DEFAULT])
576 # ----------------------------------------------------
579 # | PATTERN1) IF-MATCHED1 ;; #(
583 # The shell comments are intentional, to work around people who don't
584 # realize the impacts of using insufficient m4 quoting. This macro
585 # always uses : and provides a default case, to work around Solaris
586 # /bin/sh bugs regarding the exit status.
587 m4_define([_AS_CASE],
591 m4_define([_AS_CASE_DEFAULT],
597 [case $1 in[]m4_map_args_pair([_$0], [_$0_DEFAULT],
598 m4_shift($@m4_if(m4_eval([$# & 1]), [1], [,])))
604 # Ensure AS_EXIT and AS_SET_STATUS will work.
606 # We cannot simply use "exit N" because some shells (zsh and Solaris sh)
607 # will not set $? to N while running the code set by "trap 0"
608 # Some shells fork even for (exit N), so we use a helper function
609 # to set $? prior to the exit.
610 # Then there are shells that don't inherit $? correctly into the start of
611 # a shell function, so we must always be given an argument.
612 # Other shells don't use '$?' as default for 'exit', hence just repeating
613 # the exit value can only help improving portability.
614 m4_defun([_AS_EXIT_PREPARE],
615 [AS_REQUIRE_SHELL_FN([as_fn_set_status],
616 [AS_FUNCTION_DESCRIBE([as_fn_set_status], [STATUS],
617 [Set $? to STATUS, without forking.])], [ return $[]1])]dnl
618 [AS_REQUIRE_SHELL_FN([as_fn_exit],
619 [AS_FUNCTION_DESCRIBE([as_fn_exit], [STATUS],
620 [Exit the shell with STATUS, even in a "trap 0" or "set -e" context.])],
622 as_fn_set_status $[1]
623 exit $[1]])])#_AS_EXIT_PREPARE
626 # AS_EXIT([EXIT-CODE = $?])
627 # -------------------------
628 # Exit, with status set to EXIT-CODE in the way that it's seen
629 # within "trap 0", and without interference from "set -e". If
630 # EXIT-CODE is omitted, then use $?.
632 [AS_REQUIRE([_AS_EXIT_PREPARE])[]as_fn_exit m4_ifval([$1], [$1], [$][?])])
635 # AS_FOR(MACRO, SHELL-VAR, [LIST = "$@"], [BODY = :])
636 # ---------------------------------------------------
637 # Expand to a shell loop that assigns SHELL-VAR to each of the
638 # whitespace-separated entries in LIST (or "$@" if LIST is empty),
639 # then executes BODY. BODY may call break to abort the loop, or
640 # continue to proceed with the next element of LIST. Requires that
641 # IFS be set to the normal space-tab-newline. As an optimization,
642 # BODY should access MACRO rather than $SHELL-VAR. Normally, MACRO
643 # expands to $SHELL-VAR, but if LIST contains only a single element
644 # that needs no additional shell quoting, then MACRO will expand to
645 # that element, thus providing a direct value rather than a shell
646 # variable indirection.
648 # Only use the optimization if LIST can be used without additional
649 # shell quoting in either a literal or double-quoted context (that is,
650 # we give up on default IFS chars, parameter expansion, command
651 # substitution, shell quoting, globs, or quadrigraphs). Inline the
654 [m4_pushdef([$1], m4_if([$3], [], [[$$2]], m4_translit([$3], ]dnl
655 m4_dquote(_m4_defn([m4_cr_symbols2]))[[%+=:,./-]), [], [[$3]], [[$$2]]))]dnl
656 [for $2[]m4_ifval([$3], [ in $3])
659 done[]_m4_popdef([$1])])
662 # AS_IF(TEST1, [IF-TRUE1 = :]...[IF-FALSE = :])
663 # ---------------------------------------------
675 # with simplifications when IF-TRUE1 and/or IF-FALSE are empty.
677 # Note: IF-TRUEn and IF-FALSE may be nonempty but, after further
678 # macro expansion, leave no actual shell code. We can't detect this,
679 # so surround each clause with appropriate shell syntax so that it is
680 # valid even if it is empty. For the IF-TRUEn this can simply be ':'
681 # before the clause. However, we can't do the same for IF-FALSE
682 # because the ':' would trash the value of $? from the conditional
683 # expression, which the IF-FALSE code might use. Instead we use
684 # 'case e in e) IF-FALSE ;; esac' which is valid even when IF-FALSE
691 m4_defun([_AS_IF_ELSE],
693 [else case e in @%:@(
702 m4_map_args_pair([_$0], [_$0_ELSE], m4_shift2($@))]dnl
706 # AS_SET_STATUS(STATUS)
707 # ---------------------
708 # Set the shell status ($?) to STATUS, without forking.
709 m4_defun([AS_SET_STATUS],
710 [AS_REQUIRE([_AS_EXIT_PREPARE])[]as_fn_set_status $1])
715 # Define $as_unset to execute AS_UNSET, for backwards compatibility
716 # with older versions of M4sh.
717 m4_defun([_AS_UNSET_PREPARE],
718 [AS_FUNCTION_DESCRIBE([as_fn_unset], [VAR], [Portably unset VAR.])
729 # Unset the env VAR, working around shells that do not allow unsetting
730 # a variable that is not already set. You should not unset MAIL and
731 # MAILCHECK, as that triggers a bug in Bash 2.01.
733 [{ AS_LITERAL_WORD_IF([$1], [], [eval ])$1=; unset $1;}])
740 ## ------------------------------------------ ##
741 ## 3. Error and warnings at the shell level. ##
742 ## ------------------------------------------ ##
747 # Must expand to the fd where messages will be sent. Defaults to 1,
748 # although a script may reassign this value and use exec to either
749 # copy stdout to the new fd, or open the new fd on /dev/null.
750 m4_define([AS_MESSAGE_FD], [1])
754 # Must expand to either the empty string (when no logging is
755 # performed), or to the fd of a log file. Defaults to empty, although
756 # a script may reassign this value and use exec to open a log. When
757 # not empty, messages to AS_MESSAGE_FD are duplicated to the log,
758 # along with a LINENO reference.
759 m4_define([AS_MESSAGE_LOG_FD])
762 # AS_ORIGINAL_STDIN_FD
763 # --------------------
764 # Must expand to the fd of the script's original stdin. Defaults to
765 # 0, although the script may reassign this value and use exec to
767 m4_define([AS_ORIGINAL_STDIN_FD], [0])
770 # AS_ESCAPE(STRING, [CHARS = `\"$])
771 # ---------------------------------
772 # Add backslash escaping to the CHARS in STRING. In an effort to
773 # optimize use of this macro inside double-quoted shell constructs,
774 # the behavior is intentionally undefined if CHARS is longer than 4
775 # bytes, or contains bytes outside of the set [`\"$]. However,
776 # repeated bytes within the set are permissible (AS_ESCAPE([$1], [""])
777 # being a common way to be nice to syntax highlighting).
779 # Avoid the m4_bpatsubst if there are no interesting characters to escape.
780 # _AS_ESCAPE bypasses argument defaulting.
781 m4_define([AS_ESCAPE],
782 [_$0([$1], m4_if([$2], [], [[`], [\"$]], [m4_substr([$2], [0], [1]), [$2]]))])
784 # _AS_ESCAPE(STRING, KEY, SET)
785 # ----------------------------
786 # Backslash-escape all instances of the single byte KEY or up to four
787 # bytes in SET occurring in STRING. Although a character can occur
788 # multiple times, optimum efficiency occurs when KEY and SET are
789 # distinct, and when SET does not exceed two bytes. These particular
790 # semantics allow for the fewest number of parses of STRING, as well
791 # as taking advantage of the optimizations in m4 1.4.13+ when
792 # m4_translit is passed SET of size 2 or smaller.
793 m4_define([_AS_ESCAPE],
794 [m4_if(m4_index(m4_translit([[$1]], [$3], [$2$2$2$2]), [$2]), [-1],
795 [$0_], [m4_bpatsubst])([$1], [[$2$3]], [\\\&])])
796 m4_define([_AS_ESCAPE_], [$1])
801 # If there are quoted (via backslash) backquotes, output STRING
802 # literally and warn; otherwise, output STRING with ` and " quoted.
804 # Compatibility glue between the old AS_MSG suite which did not
805 # quote anything, and the modern suite which quotes the quotes.
806 # If STRING contains '\\' or '\$', it's modern.
807 # If STRING contains '\"' or '\`', it's old.
808 # Otherwise it's modern.
810 # Profiling shows that m4_index is 5 to 8x faster than m4_bregexp. The
811 # slower implementation used:
816 # The current implementation caters to the common case of no backslashes,
817 # to minimize m4_index expansions (hence the nested if).
818 m4_define([_AS_QUOTE],
819 [m4_cond([m4_index([$1], [\])], [-1], [_AS_QUOTE_MODERN],
820 [m4_eval(m4_index(m4_translit([[$1]], [$], [\]), [\\]) >= 0)],
821 [1], [_AS_QUOTE_MODERN],
822 [m4_eval(m4_index(m4_translit([[$1]], ["], [`]), [\`]) >= 0)],dnl"
823 [1], [_AS_QUOTE_OLD],
824 [_AS_QUOTE_MODERN])([$1])])
826 m4_define([_AS_QUOTE_MODERN],
827 [_AS_ESCAPE([$1], [`], [""])])
829 m4_define([_AS_QUOTE_OLD],
831 [back quotes and double quotes must not be escaped in: $1])$1])
834 # _AS_ECHO_UNQUOTED(STRING, [FD = AS_MESSAGE_FD])
835 # -----------------------------------------------
836 # Perform shell expansions on STRING and echo the string to FD.
837 m4_define([_AS_ECHO_UNQUOTED],
838 [AS_ECHO(["$1"]) >&m4_default([$2], [AS_MESSAGE_FD])])
841 # _AS_ECHO(STRING, [FD = AS_MESSAGE_FD])
842 # --------------------------------------
843 # Protect STRING from backquote expansion, echo the result to FD.
844 m4_define([_AS_ECHO],
845 [_AS_ECHO_UNQUOTED([_AS_QUOTE([$1])], [$2])])
848 # _AS_ECHO_LOG(STRING)
849 # --------------------
850 # Log the string to AS_MESSAGE_LOG_FD.
851 m4_defun_init([_AS_ECHO_LOG],
852 [AS_REQUIRE([_AS_LINENO_PREPARE])],
853 [_AS_ECHO([$as_me:${as_lineno-$LINENO}: $1], AS_MESSAGE_LOG_FD)])
856 # _AS_ECHO_N(STRING, [FD = AS_MESSAGE_FD])
857 # ----------------------------------------
858 # Same as _AS_ECHO, but echo doesn't return to a new line.
859 m4_define([_AS_ECHO_N],
860 [AS_ECHO_N(["_AS_QUOTE([$1])"]) >&m4_default([$2], [AS_MESSAGE_FD])])
863 # AS_MESSAGE(STRING, [FD = AS_MESSAGE_FD])
864 # ----------------------------------------
865 # Output "`basename $0`: STRING" to the open file FD, and if logging
866 # is enabled, copy it to the log with a reference to LINENO.
867 m4_defun_init([AS_MESSAGE],
868 [AS_REQUIRE([_AS_ME_PREPARE])],
869 [m4_ifval(AS_MESSAGE_LOG_FD,
870 [{ _AS_ECHO_LOG([$1])
871 _AS_ECHO([$as_me: $1], [$2]);}],
872 [_AS_ECHO([$as_me: $1], [$2])])[]])
877 # Output "`basename $0`: WARNING: PROBLEM" to stderr.
879 [AS_MESSAGE([WARNING: $1], [2])])# AS_WARN
884 # Output the shell function used by AS_ERROR. This is designed to be
885 # expanded during the m4_wrap cleanup.
887 # If AS_MESSAGE_LOG_FD is non-empty at the end of the script, then
888 # make this function take optional parameters that use LINENO at the
889 # points where AS_ERROR was expanded with non-empty AS_MESSAGE_LOG_FD;
890 # otherwise, assume the entire script does not do logging.
891 m4_define([_AS_ERROR_PREPARE],
892 [AS_REQUIRE_SHELL_FN([as_fn_error],
893 [AS_FUNCTION_DESCRIBE([as_fn_error], [STATUS ERROR]m4_ifval(AS_MESSAGE_LOG_FD,
894 [[ [[LINENO LOG_FD]]]]),
895 [Output "`basename @S|@0`: error: ERROR" to stderr.]
896 m4_ifval(AS_MESSAGE_LOG_FD,
897 [[If LINENO and LOG_FD are provided, also output the error to LOG_FD,
898 referencing LINENO.]])
899 [Then exit the script with STATUS, using 1 if that was 0.])],
900 [ as_status=$[1]; test $as_status -eq 0 && as_status=1
901 m4_ifval(AS_MESSAGE_LOG_FD,
902 [m4_pushdef([AS_MESSAGE_LOG_FD], [$[4]])dnl
904 AS_LINENO_PUSH([$[3]])
905 _AS_ECHO_LOG([error: $[2]])
907 m4_define([AS_MESSAGE_LOG_FD])], [m4_pushdef([AS_MESSAGE_LOG_FD])])dnl
908 AS_MESSAGE([error: $[2]], [2])
909 _m4_popdef([AS_MESSAGE_LOG_FD])dnl
910 AS_EXIT([$as_status])])])
912 # AS_ERROR(ERROR, [EXIT-STATUS = max($?/1)])
913 # ------------------------------------------
914 # Output "`basename $0`: error: ERROR" to stderr, then exit the
915 # script with EXIT-STATUS.
916 m4_defun_init([AS_ERROR],
917 [m4_append_uniq([_AS_CLEANUP],
918 [m4_divert_text([M4SH-INIT-FN], [_AS_ERROR_PREPARE[]])])],
919 [as_fn_error m4_default([$2], [$?]) "_AS_QUOTE([$1])"m4_ifval(AS_MESSAGE_LOG_FD,
920 [ "$LINENO" AS_MESSAGE_LOG_FD])])
923 # AS_LINENO_PUSH([LINENO])
924 # ------------------------
925 # If this is the outermost call to AS_LINENO_PUSH, make sure that
926 # AS_MESSAGE will print LINENO as the line number.
927 m4_defun([AS_LINENO_PUSH],
928 [as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack])
931 # AS_LINENO_POP([LINENO])
932 # -----------------------
933 # If this is call balances the outermost call to AS_LINENO_PUSH,
934 # AS_MESSAGE will restart printing $LINENO as the line number.
936 # No need to use AS_UNSET, since as_lineno is necessarily set.
937 m4_defun([AS_LINENO_POP],
938 [eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno])
943 # Define the obsolete internal shell variable as_echo if necessary.
944 # It is known to be used by some third party macros. New code should
945 # use AS_ECHO(["message"]).
947 # This macro will typically be used like
949 # and that line of the script must not be changed by the expansion;
950 # especially, we cannot introduce whitespace between '$' and 'a'.
951 # This means we cannot use m4_require and we need to invoke
952 # _as_echo_var_prepare with call parentheses.
954 [m4_provide_if([_as_echo_var_prepare], [], [_as_echo_var_prepare()])]dnl
957 # _as_echo_var_prepare
958 # --------------------
959 # The @&t@ prevents recursive expansion.
960 # Extra quoting in case 's' or 'n' are user-defined macros when this
961 # is expanded; they almost certainly aren't meant to be used here.
963 m4_defun([_as_echo_var_prepare],
965 [$as_echo is obsolete; use AS_ECHO(["message"]) instead])]dnl
966 [m4_divert_once([M4SH-INIT], [
967 # Provided for backward compatibility. Change uses to AS_ECHO(["message"]).
968 as@&t@_echo='printf [%s\n]'])])
972 # Define the obsolete internal shell variable as_echo_n if necessary.
973 # It is known to be used by some third party macros. New code should
974 # use AS_ECHO_N(["message"]).
975 # See as_echo for implementation notes.
976 m4_defun([as_echo_n],
977 [m4_provide_if([_as_echo_n_var_prepare], [], [_as_echo_n_var_prepare()])]dnl
980 # _as_echo_n_var_prepare
981 # ----------------------
982 # The @&t@ prevents recursive expansion.
983 # Extra quoting in case 's' or 'n' are user-defined macros when this
984 # is expanded; they almost certainly aren't meant to be used here.
986 m4_defun([_as_echo_n_var_prepare],
988 [$as_echo_n is obsolete; use AS_ECHO_N(["message"]) instead])]dnl
989 [m4_divert_once([M4SH-INIT], [
990 # Provided for backward compatibility. Change uses to AS_ECHO_N(["message"]).
991 as@&t@_echo_n='printf [%s]'])])
995 ## -------------------------------------- ##
996 ## 4. Portable versions of common tools. ##
997 ## -------------------------------------- ##
999 # This section is lexicographically sorted.
1002 # AS_BASENAME(FILE-NAME)
1003 # ----------------------
1004 # Simulate the command 'basename FILE-NAME'. Not all systems have basename.
1005 # Also see the comments for AS_DIRNAME.
1007 m4_defun([_AS_BASENAME_EXPR],
1008 [$as_expr X/[]$1 : '.*/\([[^/][^/]*]\)/*$' \| \
1009 X[]$1 : 'X\(//\)$' \| \
1010 X[]$1 : 'X\(/\)' \| .])
1012 m4_defun([_AS_BASENAME_SED],
1013 [AS_ECHO([X/[]$1]) |
1014 sed ['/^.*\/\([^/][^/]*\)\/*$/{
1028 m4_defun_init([AS_BASENAME],
1029 [AS_REQUIRE([_$0_PREPARE])],
1030 [$as_basename -- $1 ||
1031 _AS_BASENAME_EXPR([$1]) 2>/dev/null ||
1032 _AS_BASENAME_SED([$1])])
1035 # _AS_BASENAME_PREPARE
1036 # --------------------
1037 # Avoid Solaris 9 /usr/ucb/basename, as 'basename /' outputs an empty line.
1038 # Also, traditional basename mishandles --. Require here _AS_EXPR_PREPARE,
1039 # to avoid problems when _AS_BASENAME is called from the M4SH-INIT diversion.
1040 m4_defun([_AS_BASENAME_PREPARE],
1041 [AS_REQUIRE([_AS_EXPR_PREPARE])]dnl
1042 [if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
1043 as_basename=basename
1047 ])# _AS_BASENAME_PREPARE
1050 # AS_DIRNAME(FILE-NAME)
1051 # ---------------------
1052 # Simulate the command 'dirname FILE-NAME'. Not all systems have dirname.
1053 # This macro must be usable from inside ` `.
1055 # Prefer expr to echo|sed, since expr is usually faster and it handles
1056 # backslashes and newlines correctly. However, older expr
1057 # implementations (e.g. SunOS 4 expr and Solaris 8 /usr/ucb/expr) have
1058 # a silly length limit that causes expr to fail if the matched
1059 # substring is longer than 120 bytes. So fall back on echo|sed if
1061 m4_defun_init([_AS_DIRNAME_EXPR],
1062 [AS_REQUIRE([_AS_EXPR_PREPARE])],
1063 [$as_expr X[]$1 : 'X\(.*[[^/]]\)//*[[^/][^/]]*/*$' \| \
1064 X[]$1 : 'X\(//\)[[^/]]' \| \
1065 X[]$1 : 'X\(//\)$' \| \
1066 X[]$1 : 'X\(/\)' \| .])
1068 m4_defun([_AS_DIRNAME_SED],
1070 sed ['/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
1088 m4_defun_init([AS_DIRNAME],
1089 [AS_REQUIRE([_$0_PREPARE])],
1090 [$as_dirname -- $1 ||
1091 _AS_DIRNAME_EXPR([$1]) 2>/dev/null ||
1092 _AS_DIRNAME_SED([$1])])
1095 # _AS_DIRNAME_PREPARE
1096 # -------------------
1097 m4_defun([_AS_DIRNAME_PREPARE],
1098 [AS_REQUIRE([_AS_EXPR_PREPARE])]dnl
1099 [if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
1104 ])# _AS_DIRNAME_PREPARE
1109 # Output WORD followed by a newline. WORD must be a single shell word
1110 # (typically a quoted string). The bytes of WORD are output as-is, even
1111 # if it starts with "-" or contains "\".
1112 m4_define([AS_ECHO],
1113 dnl Extra quoting in case 's' or 'n' are user-defined macros when this
1114 dnl is expanded; they almost certainly aren't meant to be used here.
1116 [printf '[%s\n]' $1])
1121 # Like AS_ECHO(WORD), except do not output the trailing newline.
1122 m4_define([AS_ECHO_N],
1123 dnl Extra quoting in case 's' is a user-defined macro when this
1124 dnl is expanded; it almost certainly isn't meant to be used here.
1131 # Check whether a file has executable or search permissions.
1132 # FIXME: This macro is no longer useful; consider deleting it in 2014
1133 # after we ensure m4sh scripts can always find a shell with test -x.
1134 m4_defun_init([AS_TEST_X],
1135 [AS_REQUIRE([_AS_TEST_PREPARE])],
1136 [test -x $1[]])# AS_TEST_X
1141 # Check whether a file is a regular file that has executable permissions.
1142 m4_defun_init([AS_EXECUTABLE_P],
1143 [AS_REQUIRE([_AS_TEST_PREPARE])],
1144 [as_fn_executable_p $1])# AS_EXECUTABLE_P
1149 # QNX 4.25 expr computes and issue the right result but exits with failure.
1150 # Tru64 expr mishandles leading zeros in numeric strings.
1151 # Detect these flaws.
1152 m4_defun([_AS_EXPR_PREPARE],
1153 [if expr a : '\(a\)' >/dev/null 2>&1 &&
1154 test "X`expr 00001 : '.*\(...\)'`" = X001; then
1159 ])# _AS_EXPR_PREPARE
1164 # Define $as_me to the basename of the executable file's name.
1165 m4_defun([AS_ME_PREPARE], [AS_REQUIRE([_$0])])
1166 m4_defun([_AS_ME_PREPARE],
1167 [AS_REQUIRE([_AS_BASENAME_PREPARE])]dnl
1168 [as_me=`AS_BASENAME("$[0]")`
1173 # Succeed if the currently executing shell supports LINENO.
1174 # This macro does not expand to a single shell command, so be careful
1175 # when using it. Surrounding the body of this macro with {} would
1176 # cause "bash -c '_ASLINENO_WORKS'" to fail (with Bash 2.05, anyway),
1177 # but that bug is irrelevant to our use of LINENO. We can't use
1178 # AS_VAR_ARITH, as this is expanded prior to shell functions.
1180 # Testing for LINENO support is hard; we use _AS_LINENO_WORKS inside
1181 # _AS_RUN, which sometimes eval's its argument (pdksh gives false
1182 # negatives if $LINENO is expanded by eval), and sometimes passes the
1183 # argument to another shell (if the current shell supports LINENO,
1184 # then expanding $LINENO prior to the string leads to false
1185 # positives). Hence, we perform two tests, and coordinate with
1186 # _AS_DETECT_EXPAND (which ensures that only the first of two LINENO
1187 # is expanded in advance) and _AS_RUN (which sets $as_run to 'a' when
1188 # handing the test to another shell), so that we know which test to
1190 m4_define([_AS_LINENO_WORKS],
1191 [ as_lineno_1=$LINENO as_lineno_1a=$LINENO
1192 as_lineno_2=$LINENO as_lineno_2a=$LINENO
1193 eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
1194 test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"'])
1197 # _AS_LINENO_PREPARE
1198 # ------------------
1199 # If LINENO is not supported by the shell, produce a version of this
1200 # script where LINENO is hard coded.
1201 # Comparing LINENO against _oline_ is not a good solution, since in
1202 # the case of embedded executables (such as config.status within
1203 # configure) you'd compare LINENO wrt config.status vs. _oline_ wrt
1206 # AS_ERROR normally uses LINENO if logging, but AS_LINENO_PREPARE uses
1207 # AS_ERROR. Besides, if the logging fd is open, we don't want to use
1208 # $LINENO in the log complaining about broken LINENO. We break the
1209 # circular require by changing AS_ERROR and AS_MESSAGE_LOG_FD.
1210 m4_defun([AS_LINENO_PREPARE], [AS_REQUIRE([_$0])])
1211 m4_defun([_AS_LINENO_PREPARE],
1212 [AS_REQUIRE([_AS_CR_PREPARE])]dnl
1213 [AS_REQUIRE([_AS_ME_PREPARE])]dnl
1214 [_AS_DETECT_SUGGESTED([_AS_LINENO_WORKS])]dnl
1215 [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl
1216 [m4_pushdef([AS_ERROR],
1217 [{ AS_MESSAGE(]m4_dquote([error: $][1])[, [2]); AS_EXIT([1]); }])]dnl
1218 dnl Create $as_me.lineno as a copy of $as_myself, but with $LINENO
1219 dnl uniformly replaced by the line number. The first 'sed' inserts a
1220 dnl line-number line after each line using $LINENO; the second 'sed'
1221 dnl does the real work. The second script uses 'N' to pair each
1222 dnl line-number line with the line containing $LINENO, and appends
1223 dnl trailing '-' during substitution so that $LINENO is not a special
1224 dnl case at line end. (Raja R Harinath suggested sed '=', and Paul
1225 dnl Eggert wrote the scripts with optimization help from Paolo Bonzini).
1226 [_AS_LINENO_WORKS || {
1227 [ # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-)
1241 s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
1245 chmod +x "$as_me.lineno"] ||
1246 AS_ERROR([cannot create $as_me.lineno; rerun with a POSIX shell])
1248 # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
1249 # already done that, so ensure we don't try to do so again and fall
1250 # in an infinite loop. This has already happened in practice.
1251 _as_can_reexec=no; export _as_can_reexec
1252 # Don't try to exec as it changes $[0], causing all sort of problems
1253 # (the dirname of $[0] is not the place where we might find the
1254 # original and so on. Autoconf is especially sensitive to this).
1256 # Exit status is that of the last command.
1259 _m4_popdef([AS_MESSAGE_LOG_FD], [AS_ERROR])])# _AS_LINENO_PREPARE
1264 # Don't use conftest.sym to avoid file name issues on DJGPP, where this
1265 # would yield conftest.sym.exe for DJGPP < 2.04. And don't use 'conftest'
1266 # as base name to avoid prohibiting concurrency (e.g., concurrent
1267 # config.statuses). On read-only media, assume 'cp -pR' and hope we
1268 # are just running --help anyway.
1269 m4_defun([_AS_LN_S_PREPARE],
1270 [rm -f conf$$ conf$$.exe conf$$.file
1271 if test -d conf$$.dir; then
1272 rm -f conf$$.dir/conf$$.file
1275 mkdir conf$$.dir 2>/dev/null
1277 if (echo >conf$$.file) 2>/dev/null; then
1278 if ln -s conf$$.file conf$$ 2>/dev/null; then
1280 # ... but there are two gotchas:
1281 # 1) On MSYS, both 'ln -s file dir' and 'ln file dir' fail.
1282 # 2) DJGPP < 2.04 has no symlinks; 'ln -s' creates a wrapper executable.
1283 # In both cases, we have to default to 'cp -pR'.
1284 ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
1286 elif ln conf$$.file conf$$ 2>/dev/null; then
1294 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
1295 rmdir conf$$.dir 2>/dev/null
1296 ])# _AS_LN_S_PREPARE
1299 # AS_LN_S(FILE, LINK)
1300 # -------------------
1301 # FIXME: Should we add the glue code to handle properly relative symlinks
1302 # simulated with 'ln' or 'cp'?
1303 m4_defun_init([AS_LN_S],
1304 [AS_REQUIRE([_AS_LN_S_PREPARE])],
1310 # Emit code that can be used to emulate 'mkdir -p' with plain 'mkdir';
1311 # the code assumes that "$as_dir" contains the directory to create.
1312 # $as_dir is normalized, so there is no need to worry about using --.
1313 m4_define([_AS_MKDIR_P],
1315 -*) as_dir=./$as_dir;;
1317 test -d "$as_dir" || eval $as_mkdir_p || {
1321 *\'*) as_qdir=`AS_ECHO(["$as_dir"]) | sed "s/'/'\\\\\\\\''/g"`;; #'(
1322 *) as_qdir=$as_dir;;
1324 as_dirs="'$as_qdir' $as_dirs"
1325 as_dir=`AS_DIRNAME("$as_dir")`
1326 test -d "$as_dir" && break
1328 test -z "$as_dirs" || eval "mkdir $as_dirs"
1329 } || test -d "$as_dir" || AS_ERROR([cannot create directory $as_dir])
1334 # Emulate 'mkdir -p' with plain 'mkdir' if needed.
1335 m4_defun_init([AS_MKDIR_P],
1336 [AS_REQUIRE([_$0_PREPARE])],
1337 [as_dir=$1; as_fn_mkdir_p])# AS_MKDIR_P
1340 # _AS_MKDIR_P_PREPARE
1341 # -------------------
1342 m4_defun([_AS_MKDIR_P_PREPARE],
1343 [AS_REQUIRE_SHELL_FN([as_fn_mkdir_p],
1344 [AS_FUNCTION_DESCRIBE([as_fn_mkdir_p], [],
1345 [Create "$as_dir" as a directory, including parents if necessary.])],
1349 [if mkdir -p . 2>/dev/null; then
1350 as_mkdir_p='mkdir -p "$as_dir"'
1352 test -d ./-p && rmdir ./-p
1355 ])# _AS_MKDIR_P_PREPARE
1358 # _AS_PATH_SEPARATOR_PREPARE
1359 # --------------------------
1360 # Compute the path separator.
1361 m4_defun([_AS_PATH_SEPARATOR_PREPARE],
1362 [# The user is always right.
1363 if ${PATH_SEPARATOR+false} :; then
1365 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
1366 (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
1370 ])# _AS_PATH_SEPARATOR_PREPARE
1373 # _AS_PATH_WALK([PATH = $PATH], BODY, [IF-NOT-FOUND])
1374 # ---------------------------------------------------
1375 # Walk through PATH running BODY for each 'as_dir', with a trailing slash
1376 # already present. If BODY never does a 'break', evaluate IF-NOT-FOUND.
1378 # Still very private as its interface looks quite bad.
1380 # '$as_dummy' forces splitting on constant user-supplied paths.
1381 # POSIX.2 field splitting is done only on the result of word
1382 # expansions, not on literal text. This closes a longstanding sh security
1383 # hole. Optimize it away when not needed, i.e., if there are no literal
1385 m4_defun_init([_AS_PATH_WALK],
1386 [AS_REQUIRE([_AS_PATH_SEPARATOR_PREPARE])],
1387 [as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
1388 m4_ifvaln([$3], [as_found=false])dnl
1389 m4_if([$1], m4_translit([[$1]], [:;]),
1390 [for as_dir in m4_default([$1], [$PATH])],
1392 for as_dir in $as_dummy])
1395 case $as_dir in @%:@(((
1398 *) as_dir=$as_dir/ ;;
1400 m4_ifvaln([$3], [as_found=:])dnl
1402 m4_ifvaln([$3], [as_found=false])dnl
1405 m4_ifvaln([$3], [AS_IF([$as_found], [], [$3])])dnl
1409 # AS_SET_CATFILE(VAR, DIR-NAME, FILE-NAME)
1410 # ----------------------------------------
1411 # Set VAR to DIR-NAME/FILE-NAME.
1412 # Optimize the common case where $2 or $3 is '.'.
1413 m4_define([AS_SET_CATFILE],
1415 .) AS_VAR_SET([$1], [$3]);;
1418 .) AS_VAR_SET([$1], [$2]);;
1419 [[\\/]]* | ?:[[\\/]]* ) AS_VAR_SET([$1], [$3]);;
1420 *) AS_VAR_SET([$1], [$2/$3]);;
1422 esac[]])# AS_SET_CATFILE
1427 # These days, we require that 'test -x' works.
1428 m4_define([_AS_TEST_X_WORKS], [test -x /])
1432 # Provide back-compat to people that hooked into our undocumented
1433 # internals (here's looking at you, libtool).
1434 m4_defun([_AS_TEST_PREPARE],
1435 [AS_REQUIRE_SHELL_FN([as_fn_executable_p],
1436 [AS_FUNCTION_DESCRIBE([as_fn_executable_p], [FILE],
1437 [Test if FILE is an executable regular file.])],
1438 [ test -f "$[]1" && test -x "$[]1"])]dnl
1439 [as_test_x='test -x'
1440 as_executable_p=as_fn_executable_p
1441 ])# _AS_TEST_PREPARE
1446 ## ------------------ ##
1447 ## 5. Common idioms. ##
1448 ## ------------------ ##
1450 # This section is lexicographically sorted.
1453 # AS_BOX(MESSAGE, [FRAME-CHARACTER = '-'])
1454 # ----------------------------------------
1455 # Output MESSAGE, a single line text, framed with FRAME-CHARACTER (which
1458 [_$0(m4_expand([$1]), [$2])])
1460 m4_define([_AS_BOX],
1461 [m4_if(m4_index(m4_translit([[$1]], [`\"], [$$$]), [$]),
1462 [-1], [$0_LITERAL], [$0_INDIR])($@)])
1465 # _AS_BOX_LITERAL(MESSAGE, [FRAME-CHARACTER = '-'])
1466 # -------------------------------------------------
1467 m4_define([_AS_BOX_LITERAL],
1468 [AS_ECHO(["_AS_ESCAPE(m4_dquote(m4_expand([m4_text_box($@)])), [`], [\"$])"])])
1471 # _AS_BOX_INDIR(MESSAGE, [FRAME-CHARACTER = '-'])
1472 # -----------------------------------------------
1473 m4_define([_AS_BOX_INDIR],
1474 [sed 'h;s/./m4_default([$2], [-])/g;s/^.../@%:@@%:@ /;s/...$/ @%:@@%:@/;p;x;p;x' <<_ASBOX
1475 @%:@@%:@ $1 @%:@@%:@
1479 # _AS_CLEAN_DIR(DIR)
1480 # ------------------
1481 # Remove all contents from within DIR, including any unwritable
1482 # subdirectories, but leave DIR itself untouched.
1483 m4_define([_AS_CLEAN_DIR],
1486 find $1 -type d ! -perm -700 -exec chmod u+rwx {} \;
1487 rm -fr $1/* $1/.[[!.]] $1/.??*
1491 # AS_FUNCTION_DESCRIBE(NAME, [ARGS], DESCRIPTION, [WRAP-COLUMN = 79])
1492 # -------------------------------------------------------------------
1493 # Output a shell comment describing NAME and its arguments ARGS, then
1494 # a separator line, then the DESCRIPTION wrapped at WRAP-COLUMN.
1495 # The output resembles:
1498 # # Wrapped DESCRIPTION text
1499 # NAME and ARGS are expanded, while DESCRIPTION is treated as a
1500 # whitespace-separated list of strings that are not expanded.
1501 m4_define([AS_FUNCTION_DESCRIBE],
1502 [@%:@ $1[]m4_ifval([$2], [ $2])
1503 @%:@ m4_translit(m4_format([%*s],
1504 m4_decr(m4_qlen(_m4_expand([$1[]m4_ifval([$2], [ $2])
1505 ]))), []), [ ], [-])
1506 m4_text_wrap([$3], [@%:@ ], [], [$4])])
1509 # AS_HELP_STRING(LHS, RHS, [INDENT-COLUMN = 26], [WRAP-COLUMN = 79])
1510 # ------------------------------------------------------------------
1512 # Format a help string so that it looks pretty when the user executes
1513 # "script --help". This macro takes up to four arguments, a
1514 # "left hand side" (LHS), a "right hand side" (RHS),
1515 # INDENT-COLUMN which is the column where wrapped lines should begin
1516 # (the default of 26 is recommended), and WRAP-COLUMN which is
1517 # the column where lines should wrap (the default of 79 is recommended).
1518 # LHS is expanded, RHS is not.
1520 # For backwards compatibility not documented in the manual, INDENT-COLUMN
1521 # can also be specified as a string of white spaces, whose width
1522 # determines the indentation column. Using TABs in INDENT-COLUMN is not
1523 # recommended, since screen width of TAB is not computed.
1525 # The resulting string is suitable for use in other macros that require
1526 # a help string (e.g. AC_ARG_WITH).
1528 # Here is the sample string from the Autoconf manual (Node: External
1529 # Software) which shows the proper spacing for help strings.
1531 # --with-readline support fancy command line editing
1534 # | column 2 column 26
1538 # A help string is made up of a "left hand side" (LHS) and a "right
1539 # hand side" (RHS). In the example above, the LHS is
1540 # "--with-readline", while the RHS is "support fancy command line
1543 # If the LHS contains more than (INDENT-COLUMN - 3) characters, then the
1544 # LHS is terminated with a newline so that the RHS starts on a line of its
1545 # own beginning at INDENT-COLUMN. In the default case, this corresponds to an
1546 # LHS with more than 23 characters.
1548 # Therefore, in the example, if the LHS were instead
1549 # "--with-readline-blah-blah-blah", then the AS_HELP_STRING macro would
1553 # --with-readline-blah-blah-blah
1554 # ^ ^ support fancy command line editing
1557 # column 0 column 26
1560 # m4_text_wrap hacks^Wworks around the fact that m4_format does not
1561 # know quadrigraphs.
1563 m4_define([AS_HELP_STRING],
1564 [m4_text_wrap([$2], m4_cond([[$3]], [], [ ],
1565 [m4_eval([$3]+0)], [0], [[$3]],
1566 [m4_format([[%*s]], [$3], [])]),
1567 m4_expand([ $1 ]), [$4])])# AS_HELP_STRING
1570 # AS_IDENTIFIER_IF(EXPRESSION, IF-IDENT, IF-NOT-IDENT)
1571 # ----------------------------------------------------
1572 # If EXPRESSION serves as an identifier (ie, after removal of @&t@, it
1573 # matches the regex '^[a-zA-Z_][a-zA-Z_0-9]*$'), execute IF-IDENT,
1574 # otherwise IF-NOT-IDENT.
1576 # This is generally faster than the alternative:
1577 # m4_bmatch(m4_bpatsubst([[$1]], [@&t@]), ^m4_defn([m4_re_word])$,
1580 # Rather than expand m4_defn every time AS_IDENTIFIER_IF is expanded, we
1581 # inline its expansion up front. Only use a regular expression if we
1582 # detect a potential quadrigraph.
1584 # First, check if the entire string matches m4_cr_symbol2. Only then do
1585 # we worry if the first character also matches m4_cr_symbol1 (ie. does not
1586 # match m4_cr_digit).
1587 m4_define([AS_IDENTIFIER_IF],
1588 [m4_if(_$0(m4_if(m4_index([$1], [@]), [-1],
1589 [[$1]], [m4_bpatsubst([[$1]], [@&t@])])), [-], [$2], [$3])])
1591 m4_define([_AS_IDENTIFIER_IF],
1592 [m4_cond([[$1]], [], [],
1593 [m4_eval(m4_len(m4_translit([[$1]], ]]dnl
1594 m4_dquote(m4_dquote(m4_defn([m4_cr_symbols2])))[[)) > 0)], [1], [],
1595 [m4_len(m4_translit(m4_format([[%.1s]], [$1]), ]]dnl
1596 m4_dquote(m4_dquote(m4_defn([m4_cr_symbols1])))[[))], [0], [-])])
1599 # AS_LITERAL_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL,
1600 # [IF-SIMPLE-REF = IF-NOT-LITERAL])
1601 # -----------------------------------------------------
1602 # If EXPRESSION has no shell indirections ($var or `expr`), expand
1603 # IF-LITERAL, else IF-NOT-LITERAL. In some cases, IF-NOT-LITERAL
1604 # must be complex to safely deal with ``, while a simpler
1605 # expression IF-SIMPLE-REF can be used if the indirection
1606 # involves only shell variable expansion (as in ${varname}).
1608 # EXPRESSION is treated as a literal if it results in the same
1609 # interpretation whether it is unquoted or contained within double
1610 # quotes, with the exception that whitespace is ignored (on the
1611 # assumption that it will be flattened to _). Therefore, neither '\$'
1612 # nor 'a''b' is a literal, since both backslash and single quotes have
1613 # different quoting behavior in the two contexts; and 'a*' is not a
1614 # literal, because it has different globbing. Note, however, that
1615 # while '${a+b}' is neither a literal nor a simple ref, 'a+b' is a
1616 # literal. This macro is an *approximation*: it is possible that
1617 # there are some EXPRESSIONs which the shell would treat as literals,
1618 # but which this macro does not recognize.
1620 # Why do we reject EXPRESSION expanding with '[' or ']' as a literal?
1621 # Because AS_TR_SH is MUCH faster if it can use m4_translit on literals
1622 # instead of m4_bpatsubst; but m4_translit is much tougher to do safely
1623 # if '[' is translated. That, and file globbing matters.
1625 # Note that the quadrigraph @S|@ can result in non-literals, but outright
1626 # rejecting all @ would make AC_INIT complain on its bug report address.
1628 # We used to use m4_bmatch(m4_quote($1), [[`$]], [$3], [$2]), but
1629 # profiling shows that it is faster to use m4_translit.
1631 # Because the translit is stripping quotes, it must also neutralize
1632 # anything that might be in a macro name, as well as comments, commas,
1633 # or unbalanced parentheses. Valid shell variable characters and
1634 # unambiguous literal characters are deleted ('a.b'), and remaining
1635 # characters are normalized into '$' if they can form simple refs
1636 # (${a}), '+' if they can potentially form literals (a+b), '`' if they
1637 # can interfere with m4 parsing, or left alone otherwise. If both '$'
1638 # and '+' are left, it is treated as a complex reference (${a+b}),
1639 # even though it could technically be a simple reference (${a}+b).
1640 # _AS_LITERAL_IF_ only has to check for an empty string after removing
1641 # one of the two normalized characters.
1643 # Rather than expand m4_defn every time AS_LITERAL_IF is expanded, we
1644 # inline its expansion up front. _AS_LITERAL_IF expands to the name
1645 # of a macro that takes three arguments: IF-SIMPLE-REF,
1646 # IF-NOT-LITERAL, IF-LITERAL. It also takes an optional argument of
1647 # any additional characters to allow as literals (useful for AS_TR_SH
1648 # and AS_TR_CPP to perform inline conversion of whitespace to _). The
1649 # order of the arguments allows reuse of m4_default.
1650 m4_define([AS_LITERAL_IF],
1651 [_$0(m4_expand([$1]), [ ][
1652 ])([$4], [$3], [$2])])
1654 m4_define([_AS_LITERAL_IF],
1655 [m4_if(m4_index([$1], [@S|@]), [-1], [$0_(m4_translit([$1],
1656 [-:=%/@{}[]#(),.$2]]]m4_dquote(m4_dquote(m4_defn([m4_cr_symbols2])))[[,
1657 [++++++$$`````]))], [$0_NO])])
1659 m4_define([_AS_LITERAL_IF_],
1660 [m4_if(m4_translit([$1], [+]), [], [$0YES],
1661 m4_translit([$1], [$]), [], [m4_default], [$0NO])])
1663 m4_define([_AS_LITERAL_IF_YES], [$3])
1664 m4_define([_AS_LITERAL_IF_NO], [$2])
1666 # AS_LITERAL_WORD_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL,
1667 # [IF-SIMPLE-REF = IF-NOT-LITERAL])
1668 # ----------------------------------------------------------
1669 # Like AS_LITERAL_IF, except that spaces and tabs in EXPRESSION
1670 # are treated as non-literal.
1671 m4_define([AS_LITERAL_WORD_IF],
1672 [_AS_LITERAL_IF(m4_expand([$1]))([$4], [$3], [$2])])
1674 # AS_LITERAL_HEREDOC_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL)
1675 # -------------------------------------------------------------
1676 # Like AS_LITERAL_IF, except that a string is considered literal
1677 # if it results in the same output in both quoted and unquoted
1679 m4_define([AS_LITERAL_HEREDOC_IF],
1680 [_$0(m4_expand([$1]))([$2], [$3])])
1682 m4_define([_AS_LITERAL_HEREDOC_IF],
1683 [m4_if(m4_index([$1], [@S|@]), [-1],
1684 [m4_if(m4_index(m4_translit([[$1]], [\`], [$]), [$]), [-1],
1685 [$0_YES], [$0_NO])],
1688 m4_define([_AS_LITERAL_HEREDOC_IF_YES], [$1])
1689 m4_define([_AS_LITERAL_HEREDOC_IF_NO], [$2])
1692 # AS_TMPDIR(PREFIX, [DIRECTORY = $TMPDIR [= /tmp]])
1693 # -------------------------------------------------
1694 # Create as safely as possible a temporary directory in DIRECTORY
1695 # which name is inspired by PREFIX (should be 2-4 chars max).
1697 # Even though $tmp does not fit our normal naming scheme of $as_*,
1698 # it is a documented part of the public API and must not be changed.
1699 m4_define([AS_TMPDIR],
1700 [# Create a (secure) tmp directory for tmp files.
1701 m4_if([$2], [], [: "${TMPDIR:=/tmp}"])
1703 tmp=`(umask 077 && mktemp -d "m4_default([$2],
1704 [$TMPDIR])/$1XXXXXX") 2>/dev/null` &&
1708 tmp=m4_default([$2], [$TMPDIR])/$1$$-$RANDOM
1709 (umask 077 && mkdir "$tmp")
1710 } || AS_ERROR([cannot create a temporary directory in m4_default([$2],
1711 [$TMPDIR])])])# AS_TMPDIR
1716 # Try to describe this machine. Meant for logs.
1717 m4_define([AS_UNAME],
1720 m4_text_box([Platform.])
1722 hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
1723 uname -m = `(uname -m) 2>/dev/null || echo unknown`
1724 uname -r = `(uname -r) 2>/dev/null || echo unknown`
1725 uname -s = `(uname -s) 2>/dev/null || echo unknown`
1726 uname -v = `(uname -v) 2>/dev/null || echo unknown`
1728 /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
1729 /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
1731 /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
1732 /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
1733 /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
1734 /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown`
1735 /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
1736 /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
1737 /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
1741 _AS_PATH_WALK([$PATH], [AS_ECHO(["PATH: $as_dir"])])
1745 # _AS_VERSION_COMPARE_PREPARE
1746 # ---------------------------
1747 # Output variables for comparing version numbers.
1748 m4_defun([_AS_VERSION_COMPARE_PREPARE],
1749 [[as_awk_strverscmp='
1750 # Use only awk features that work with 7th edition Unix awk (1978).
1751 # My, what an old awk you have, Mr. Solaris!
1753 while (length(v1) && length(v2)) {
1754 # Set d1 to be the next thing to compare from v1, and likewise for d2.
1755 # Normally this is a single character, but if v1 and v2 contain digits,
1756 # compare them as integers and fractions as strverscmp does.
1757 if (v1 ~ /^[0-9]/ && v2 ~ /^[0-9]/) {
1758 # Split v1 and v2 into their leading digit string components d1 and d2,
1759 # and advance v1 and v2 past the leading digit strings.
1760 for (len1 = 1; substr(v1, len1 + 1) ~ /^[0-9]/; len1++) continue
1761 for (len2 = 1; substr(v2, len2 + 1) ~ /^[0-9]/; len2++) continue
1762 d1 = substr(v1, 1, len1); v1 = substr(v1, len1 + 1)
1763 d2 = substr(v2, 1, len2); v2 = substr(v2, len2 + 1)
1766 # Compare two fractions.
1767 while (d1 ~ /^0/ && d2 ~ /^0/) {
1768 d1 = substr(d1, 2); len1--
1769 d2 = substr(d2, 2); len2--
1771 if (len1 != len2 && ! (len1 && len2 && substr(d1, 1, 1) == substr(d2, 1, 1))) {
1772 # The two components differ in length, and the common prefix
1773 # contains only leading zeros. Consider the longer to be less.
1777 # Otherwise, compare as strings.
1782 # A fraction is less than an integer.
1787 # An integer is greater than a fraction.
1790 # Compare two integers.
1796 # The normal case, without worrying about digits.
1797 d1 = substr(v1, 1, 1); v1 = substr(v1, 2)
1798 d2 = substr(v2, 1, 1); v2 = substr(v2, 2)
1803 # Beware Solaris /usr/xgp4/bin/awk (at least through Solaris 10),
1804 # which mishandles some comparisons of empty strings to integers.
1805 if (length(v2)) exit 1
1806 if (length(v1)) exit 2
1808 ']])# _AS_VERSION_COMPARE_PREPARE
1811 # AS_VERSION_COMPARE(VERSION-1, VERSION-2,
1812 # [ACTION-IF-LESS], [ACTION-IF-EQUAL], [ACTION-IF-GREATER])
1813 # ----------------------------------------------------------------------------
1814 # Compare two strings possibly containing shell variables as version strings.
1816 # This usage is portable even to ancient awk,
1817 # so don't worry about finding a "nice" awk version.
1818 m4_defun_init([AS_VERSION_COMPARE],
1819 [AS_REQUIRE([_$0_PREPARE])],
1822 awk "$as_awk_strverscmp" v1="$as_arg_v1" v2="$as_arg_v2" /dev/null
1826 [2], [$5])])# AS_VERSION_COMPARE
1830 ## --------------------------------------- ##
1831 ## 6. Common m4/sh character translation. ##
1832 ## --------------------------------------- ##
1834 # The point of this section is to provide high level macros comparable
1835 # to m4's 'translit' primitive, but m4/sh polymorphic.
1836 # Transliteration of literal strings should be handled by m4, while
1837 # shell variables' content will be translated at runtime (tr or sed).
1842 # Output variables defining common character ranges.
1843 # See m4_cr_letters etc.
1844 m4_defun([_AS_CR_PREPARE],
1845 [# Avoid depending upon Character Ranges.
1846 as_cr_letters='abcdefghijklmnopqrstuvwxyz'
1847 as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
1848 as_cr_Letters=$as_cr_letters$as_cr_LETTERS
1849 as_cr_digits='0123456789'
1850 as_cr_alnum=$as_cr_Letters$as_cr_digits
1856 m4_defun([_AS_TR_SH_PREPARE],
1857 [AS_REQUIRE([_AS_CR_PREPARE])]dnl
1858 [# Sed expression to map a string onto a valid variable name.
1859 as_sed_sh="y%*+%pp%;s%[[^_$as_cr_alnum]]%_%g"
1860 as_tr_sh="eval sed '$as_sed_sh'" # deprecated
1864 # AS_TR_SH(EXPRESSION)
1865 # --------------------
1866 # Transform EXPRESSION into a valid shell variable name.
1867 # sh/m4 polymorphic.
1868 # Be sure to update the definition of '$as_sed_sh' if you change this.
1870 # AS_LITERAL_IF guarantees that a literal does not have any nested quotes,
1871 # once $1 is expanded. m4_translit silently uses only the first occurrence
1872 # of a character that appears multiple times in argument 2, since we know
1873 # that m4_cr_not_symbols2 also contains [ and ]. m4_translit also silently
1874 # ignores characters in argument 3 that do not match argument 2; we use this
1875 # fact to skip worrying about the length of m4_cr_not_symbols2.
1877 # For speed, we inline the literal definitions that can be computed up front.
1878 m4_defun_init([AS_TR_SH],
1879 [AS_REQUIRE([_$0_PREPARE])],
1880 [_$0(m4_expand([$1]))])
1882 m4_define([_AS_TR_SH],
1883 [_AS_LITERAL_IF([$1], [*][ ][
1884 ])([], [$0_INDIR], [$0_LITERAL])([$1])])
1886 m4_define([_AS_TR_SH_LITERAL],
1887 [m4_translit([[$1]],
1888 [*+[]]]m4_dquote(m4_defn([m4_cr_not_symbols2]))[,
1889 [pp[]]]m4_dquote(m4_for(,1,255,,[[_]]))[)])
1891 m4_define([_AS_TR_SH_INDIR],
1892 [`AS_ECHO(["_AS_ESCAPE([[$1]], [`], [\])"]) | sed "$as_sed_sh"`])
1895 # _AS_TR_CPP_PREPARE
1896 # ------------------
1897 m4_defun([_AS_TR_CPP_PREPARE],
1898 [AS_REQUIRE([_AS_CR_PREPARE])]dnl
1899 [# Sed expression to map a string onto a valid CPP name.
1900 as_sed_cpp="y%*$as_cr_letters%P$as_cr_LETTERS%;s%[[^_$as_cr_alnum]]%_%g"
1901 as_tr_cpp="eval sed '$as_sed_cpp'" # deprecated
1905 # AS_TR_CPP(EXPRESSION)
1906 # ---------------------
1907 # Map EXPRESSION to an upper case string which is valid as rhs for a
1908 # '#define'. sh/m4 polymorphic. Be sure to update the definition
1909 # of '$as_sed_cpp' if you change this.
1911 # See implementation comments in AS_TR_SH.
1912 m4_defun_init([AS_TR_CPP],
1913 [AS_REQUIRE([_$0_PREPARE])],
1914 [_$0(m4_expand([$1]))])
1916 m4_define([_AS_TR_CPP],
1917 [_AS_LITERAL_IF([$1], [*][ ][
1918 ])([], [$0_INDIR], [$0_LITERAL])([$1])])
1920 m4_define([_AS_TR_CPP_LITERAL],
1921 [m4_translit([[$1]],
1922 [*[]]]m4_dquote(m4_defn([m4_cr_letters])m4_defn([m4_cr_not_symbols2]))[,
1923 [P[]]]m4_dquote(m4_defn([m4_cr_LETTERS])m4_for(,1,255,,[[_]]))[)])
1925 m4_define([_AS_TR_CPP_INDIR],
1926 [`AS_ECHO(["_AS_ESCAPE([[$1]], [`], [\])"]) | sed "$as_sed_cpp"`])
1931 m4_defun([_AS_TR_PREPARE],
1932 [AS_REQUIRE([_AS_TR_SH_PREPARE])AS_REQUIRE([_AS_TR_CPP_PREPARE])])
1937 ## ------------------------------------------------------ ##
1938 ## 7. Common m4/sh handling of variables (indirections). ##
1939 ## ------------------------------------------------------ ##
1942 # The purpose of this section is to provide a uniform API for
1943 # reading/setting sh variables with or without indirection.
1944 # Typically, one can write
1945 # AS_VAR_SET(var, val)
1947 # AS_VAR_SET(as_$var, val)
1948 # and expect the right thing to happen. In the descriptions below,
1949 # a literal name matches the regex [a-zA-Z_][a-zA-Z0-9_]*, an
1950 # indirect name is a shell expression that produces a literal name
1951 # when passed through eval, and a polymorphic name is either type.
1954 # _AS_VAR_APPEND_PREPARE
1955 # ----------------------
1956 # Define as_fn_append to the optimum definition for the current
1957 # shell (bash and zsh provide the += assignment operator to avoid
1958 # quadratic append growth over repeated appends).
1959 m4_defun([_AS_VAR_APPEND_PREPARE],
1960 [AS_FUNCTION_DESCRIBE([as_fn_append], [VAR VALUE],
1961 [Append the text in VALUE to the end of the definition contained in
1962 VAR. Take advantage of any shell optimizations that allow amortized
1963 linear growth over repeated appends, instead of the typical quadratic
1964 growth present in naive implementations.])
1965 AS_IF([_AS_RUN(["AS_ESCAPE(m4_quote(_AS_VAR_APPEND_WORKS))"])],
1966 [eval 'as_fn_append ()
1972 eval $[]1=\$$[]1\$[]2
1976 # _AS_VAR_APPEND_WORKS
1977 # --------------------
1978 # Output a shell test to discover whether += works.
1979 m4_define([_AS_VAR_APPEND_WORKS],
1980 [as_var=1; as_var+=2; test x$as_var = x12])
1982 # AS_VAR_APPEND(VAR, VALUE)
1983 # -------------------------
1984 # Append the shell expansion of VALUE to the end of the existing
1985 # contents of the polymorphic shell variable VAR, taking advantage of
1986 # any shell optimizations that allow repeated appends to result in
1987 # amortized linear scaling rather than quadratic behavior. This macro
1988 # is not worth the overhead unless the expected final size of the
1989 # contents of VAR outweigh the typical VALUE size of repeated appends.
1990 # Note that unlike AS_VAR_SET, VALUE must be properly quoted to avoid
1991 # field splitting and file name expansion.
1992 m4_defun_init([AS_VAR_APPEND],
1993 [AS_REQUIRE([_AS_VAR_APPEND_PREPARE], [], [M4SH-INIT-FN])],
1994 [as_fn_append $1 $2])
1997 # _AS_VAR_ARITH_PREPARE
1998 # ---------------------
1999 # Define as_fn_arith to the optimum definition for the current
2000 # shell (using POSIX $(()) where supported).
2001 m4_defun([_AS_VAR_ARITH_PREPARE],
2002 [AS_FUNCTION_DESCRIBE([as_fn_arith], [ARG...],
2003 [Perform arithmetic evaluation on the ARGs, and store the result in
2004 the global $as_val. Take advantage of shells that can avoid forks.
2005 The arguments must be portable across $(()) and expr.])
2006 AS_IF([_AS_RUN(["AS_ESCAPE(m4_quote(_AS_VAR_ARITH_WORKS))"])],
2007 [eval 'as_fn_arith ()
2013 as_val=`expr "$[]@" || test $? -eq 1`
2017 # _AS_VAR_ARITH_WORKS
2018 # -------------------
2019 # Output a shell test to discover whether $(()) works.
2020 m4_define([_AS_VAR_ARITH_WORKS],
2021 [test $(( 1 + 1 )) = 2])
2023 # AS_VAR_ARITH(VAR, EXPR)
2024 # -----------------------
2025 # Perform the arithmetic evaluation of the arguments in EXPR, and set
2026 # contents of the polymorphic shell variable VAR to the result, taking
2027 # advantage of any shell optimizations that perform arithmetic without
2028 # forks. Because EXPR might be evaluated via either $((...)) or the
2029 # 'expr' command, EXPR's syntax is limited; see the Autoconf manual.
2030 m4_defun_init([AS_VAR_ARITH],
2031 [_AS_DETECT_SUGGESTED([_AS_VAR_ARITH_WORKS])]dnl
2032 [AS_REQUIRE([_AS_VAR_ARITH_PREPARE], [], [M4SH-INIT-FN])],
2033 [as_fn_arith $2 && AS_VAR_SET([$1], [$as_val])])
2036 # AS_VAR_COPY(DEST, SOURCE)
2037 # -------------------------
2038 # Set the polymorphic shell variable DEST to the contents of the polymorphic
2039 # shell variable SOURCE.
2040 m4_define([AS_VAR_COPY],
2041 [AS_LITERAL_WORD_IF([$1[]$2], [$1=$$2], [eval $1=\$$2])])
2044 # AS_VAR_GET(VARIABLE)
2045 # --------------------
2046 # Get the value of the shell VARIABLE.
2047 # Evaluates to $VARIABLE if there is no indirection in VARIABLE,
2048 # else to the appropriate 'eval' sequence.
2049 # This macro is deprecated because it sometimes mishandles trailing newlines;
2050 # use AS_VAR_COPY instead.
2051 m4_define([AS_VAR_GET],
2052 [AS_LITERAL_WORD_IF([$1],
2054 [`eval 'as_val=${'_AS_ESCAPE([[$1]], [`], [\])'};printf "[%s\\n]" "$as_val"'`])])
2057 # AS_VAR_IF(VARIABLE, VALUE, IF-TRUE, IF-FALSE)
2058 # ---------------------------------------------
2059 # Implement a shell 'if test $VARIABLE = VALUE; then-else'.
2060 # Polymorphic, and avoids sh expansion error upon interrupt or term signal.
2061 m4_define([AS_VAR_IF],
2062 [AS_LITERAL_WORD_IF([$1],
2063 [AS_IF(m4_ifval([$2], [[test "x$$1" = x[]$2]], [[${$1:+false} :]])],
2064 [AS_VAR_COPY([as_val], [$1])
2065 AS_IF(m4_ifval([$2], [[test "x$as_val" = x[]$2]], [[${as_val:+false} :]])],
2066 [AS_IF(m4_ifval([$2],
2067 [[eval test \"x\$"$1"\" = x"_AS_ESCAPE([$2], [`], [\"$])"]],
2068 [[eval \${$1:+false} :]])]),
2072 # AS_VAR_PUSHDEF and AS_VAR_POPDEF
2073 # --------------------------------
2076 # Sometimes we may have to handle literals (e.g. 'stdlib.h'), while at
2077 # other moments, the same code may have to get the value from a
2078 # variable (e.g., 'ac_header'). To have a uniform handling of both
2079 # cases, when a new value is about to be processed, declare a local
2082 # AS_VAR_PUSHDEF([header], [ac_cv_header_$1])
2084 # and then in the body of the macro, use 'header' as is. It is of
2085 # first importance to use 'AS_VAR_*' to access this variable.
2087 # If the value '$1' was a literal (e.g. 'stdlib.h'), then 'header' is
2088 # in fact the value 'ac_cv_header_stdlib_h'. If '$1' was indirect,
2089 # then the value of 'header' in m4 is in fact '$as_header', the shell
2090 # variable that holds all of the magic to get the expansion right.
2092 # At the end of the block, free the variable with
2094 # AS_VAR_POPDEF([header])
2097 # AS_VAR_POPDEF(VARNAME)
2098 # ----------------------
2099 # Free the shell variable accessor VARNAME. To be dnl'ed.
2100 m4_define([AS_VAR_POPDEF],
2104 # AS_VAR_PUSHDEF(VARNAME, VALUE)
2105 # ------------------------------
2106 # Define the m4 macro VARNAME to an accessor to the shell variable
2107 # named VALUE. VALUE does not need to be a valid shell variable name:
2108 # the transliteration is handled here. To be dnl'ed.
2110 # AS_TR_SH attempts to play with diversions if _AS_TR_SH_PREPARE has
2111 # not been expanded. However, users are expected to do subsequent
2112 # calls that trigger AS_LITERAL_IF([VARNAME]), and that macro performs
2113 # expansion inside an argument collection context, where diversions
2114 # don't work. Therefore, we must require the preparation ourselves.
2115 m4_defun_init([AS_VAR_PUSHDEF],
2116 [AS_REQUIRE([_AS_TR_SH_PREPARE])],
2117 [_$0([$1], m4_expand([$2]))])
2119 m4_define([_AS_VAR_PUSHDEF],
2120 [_AS_LITERAL_IF([$2], [ ][
2121 ])([], [as_$1=_AS_TR_SH_INDIR([$2])
2122 m4_pushdef([$1], [$as_[$1]])],
2123 [m4_pushdef([$1], [_AS_TR_SH_LITERAL([$2])])])])
2126 # AS_VAR_SET(VARIABLE, VALUE)
2127 # ---------------------------
2128 # Set the contents of the polymorphic shell VARIABLE to the shell
2129 # expansion of VALUE. VALUE is immune to field splitting and file
2131 m4_define([AS_VAR_SET],
2132 [AS_LITERAL_WORD_IF([$1],
2134 [eval "$1=_AS_ESCAPE([$2], [`], [\"$])"])])
2137 # AS_VAR_SET_IF(VARIABLE, IF-TRUE, IF-FALSE)
2138 # ------------------------------------------
2139 # Implement a shell 'if-then-else' depending whether VARIABLE is set
2140 # or not. Polymorphic.
2141 m4_define([AS_VAR_SET_IF],
2142 [AS_IF([AS_VAR_TEST_SET([$1])], [$2], [$3])])
2145 # AS_VAR_TEST_SET(VARIABLE)
2146 # -------------------------
2147 # Expands into an expression which is true if VARIABLE
2148 # is set. Polymorphic.
2149 m4_define([AS_VAR_TEST_SET],
2150 [AS_LITERAL_WORD_IF([$1],
2152 [{ as_var=$1; eval test \${$as_var+y}; }],
2153 [eval test \${$1+y}])])
2156 ## -------------------- ##
2157 ## 8. Setting M4sh up. ##
2158 ## -------------------- ##
2161 # AS_INIT_GENERATED(FILE, [COMMENT])
2162 # ----------------------------------
2163 # Generate a child script FILE with all initialization necessary to
2164 # reuse the environment learned by the parent script, and make the
2165 # file executable. If COMMENT is supplied, it is inserted after the
2166 # '#!' sequence but before initialization text begins. After this
2167 # macro, additional text can be appended to FILE to form the body of
2168 # the child script. The macro ends with non-zero status if the
2169 # file could not be fully written (such as if the disk is full).
2170 m4_defun([AS_INIT_GENERATED],
2171 [m4_require([AS_PREPARE])]dnl
2172 [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl
2174 cat >$1 <<_ASEOF || as_write_fail=1
2176 # Generated by $as_me.
2178 SHELL=\${CONFIG_SHELL-$SHELL}
2181 cat >>$1 <<\_ASEOF || as_write_fail=1
2184 m4_if(AS_MESSAGE_FD, [1], [], [exec AS_MESSAGE_FD>&1
2186 [m4_text_box([Main body of $1 script.])
2188 test $as_write_fail = 0 && chmod +x $1[]dnl
2189 _m4_popdef([AS_MESSAGE_LOG_FD])])# AS_INIT_GENERATED
2195 m4_define([AS_INIT],
2196 [# Wrap our cleanup prior to m4sugar's cleanup.
2197 m4_wrap([_AS_CLEANUP])
2199 m4_provide([AS_INIT])
2201 # Forbidden tokens and exceptions.
2202 m4_pattern_forbid([^_?AS_])
2204 # Bangshe and minimal initialization.
2205 # Put only the basename of __file__ into HEADER-COMMENT, so that the
2206 # path to the source directory is not embedded in the output file.
2207 m4_divert_text([BINSH], [@%:@! /bin/sh])
2208 m4_divert_text([HEADER-COMMENT],
2209 [@%:@ Generated from m4_bpatsubst(__file__,[^.*/\([^/]*\)$],[[\1]]) by m4_PACKAGE_STRING.])
2210 m4_divert_text([M4SH-SANITIZE], [_AS_SHELL_SANITIZE])
2211 m4_divert_text([M4SH-INIT-FN], [m4_text_box([M4sh Shell Functions.])])
2214 m4_divert([BODY])dnl
2215 m4_text_box([Main body of script.])
2216 _AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])dnl
2217 _AS_DETECT_REQUIRED([_AS_MODERN_CMDSUBST_WORKS])dnl
2218 _AS_DETECT_REQUIRED([_AS_TEST_X_WORKS])dnl
2219 AS_REQUIRE([_AS_UNSET_PREPARE], [], [M4SH-INIT-FN])dnl