doc: remove IRIX from manual
[autoconf.git] / lib / m4sugar / m4sh.m4
blob9c7339699d3f7816413a1bf0a19f2981e3fe7f3f
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/> and
26 # <https://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=blob_plain;f=COPYING.EXCEPTION>.
28 # Written by Akim Demaille, Pavel Roskin, Alexandre Oliva, Lars J. Aas
29 # and many other people.
32 # We heavily use m4's diversions both for the initializations and for
33 # required macros, because in both cases we have to issue soon in
34 # output something which is discovered late.
37 # KILL is only used to suppress output.
39 # - BINSH
40 #   AC_REQUIRE'd #! /bin/sh line
41 # - HEADER-REVISION
42 #   RCS keywords etc.
43 # - HEADER-COMMENT
44 #   Purpose of the script etc.
45 # - HEADER-COPYRIGHT
46 #   Copyright notice(s)
47 # - M4SH-SANITIZE
48 #   M4sh's shell setup
49 # - M4SH-INIT-FN
50 #   M4sh initialization (shell functions)
51 # - M4SH-INIT
52 #   M4sh initialization (detection code)
53 # - BODY
54 #   The body of the script.
57 # _m4_divert(DIVERSION-NAME)
58 # --------------------------
59 # Convert a diversion name into its number.  Otherwise, return
60 # DIVERSION-NAME which is supposed to be an actual diversion number.
61 # Of course it would be nicer to use m4_case here, instead of zillions
62 # of little macros, but it then takes twice longer to run 'autoconf'!
63 # BINSH is 1, not 0, so that user code can m4_cleardivert([BINSH]) and
64 # then generate its own BINSH; m4's special treatment of diversion 0
65 # would not allow that if BINSH were 0.  Leave an undocumented gap
66 # between BINSH and HEADER-REVISION for possible future extensions.
67 m4_define([_m4_divert(BINSH)],             1)
68 m4_define([_m4_divert(HEADER-REVISION)],   3)
69 m4_define([_m4_divert(HEADER-COMMENT)],    4)
70 m4_define([_m4_divert(HEADER-COPYRIGHT)],  5)
71 m4_define([_m4_divert(M4SH-SANITIZE)],     6)
72 m4_define([_m4_divert(M4SH-INIT-FN)],      7)
73 m4_define([_m4_divert(M4SH-INIT)],         8)
74 m4_define([_m4_divert(BODY)],           1000)
76 # Aaarg.  Yet it starts with compatibility issues...  Libtool wants to
77 # use NOTICE to insert its own LIBTOOL-INIT stuff.  People should ask
78 # before diving into our internals :(
79 m4_copy([_m4_divert(M4SH-INIT)], [_m4_divert(NOTICE)])
83 ## ------------------------- ##
84 ## 1. Sanitizing the shell.  ##
85 ## ------------------------- ##
86 # Please maintain lexicographic sorting of this section, ignoring leading _.
88 # AS_BOURNE_COMPATIBLE
89 # --------------------
90 # Try to be as Bourne and/or POSIX as possible.
92 # This does not set BIN_SH, due to the problems described in
93 # <https://lists.gnu.org/archive/html/autoconf-patches/2006-03/msg00081.html>.
94 # People who need BIN_SH should set it in their environment before invoking
95 # configure; apparently this would include UnixWare, as described in
96 # <https://lists.gnu.org/archive/html/bug-autoconf/2006-06/msg00025.html>.
97 m4_define([AS_BOURNE_COMPATIBLE],
98 [# Be more Bourne compatible
99 DUALCASE=1; export DUALCASE # for MKS sh
103 # _AS_BOURNE_COMPATIBLE
104 # ---------------------
105 # This is the part of AS_BOURNE_COMPATIBLE which has to be repeated inside
106 # each instance.
107 m4_define([_AS_BOURNE_COMPATIBLE],
108 [AS_IF([test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1],
109  [emulate sh
110   NULLCMD=:
111   [#] Pre-4.2 versions of Zsh do word splitting on ${1+"$[@]"}, which
112   # contradicts POSIX and common usage.  Disable this.
113   alias -g '${1+"$[@]"}'='"$[@]"'
114   setopt NO_GLOB_SUBST],
115  [AS_CASE([`(set -o) 2>/dev/null`], [*posix*], [set -o posix])])
119 # _AS_CLEANUP
120 # -----------
121 # Expanded as the last thing before m4sugar cleanup begins.  Macros
122 # may append m4sh cleanup hooks to this as appropriate.
123 m4_define([_AS_CLEANUP],
124 [m4_divert_text([M4SH-SANITIZE], [_AS_DETECT_BETTER_SHELL])])
127 # AS_COPYRIGHT(TEXT)
128 # ------------------
129 # Emit TEXT, a copyright notice, as a shell comment near the top of the
130 # script.  TEXT is evaluated once; to accomplish that, we do not prepend
131 # '# ' but '@%:@ '.
132 m4_define([AS_COPYRIGHT],
133 [m4_divert_text([HEADER-COPYRIGHT],
134 [m4_bpatsubst([
135 $1], [^], [@%:@ ])])])
138 # _AS_DETECT_EXPAND(VAR, SET)
139 # ---------------------------
140 # Assign the contents of VAR from the contents of SET, expanded in such
141 # a manner that VAR can be passed to _AS_RUN.  In order to make
142 # _AS_LINENO_WORKS operate correctly, we must specially handle the
143 # first instance of $LINENO within any line being expanded (the first
144 # instance is important to tests using the current shell, leaving
145 # remaining instances for tests using a candidate shell).  Bash loses
146 # track of line numbers if a double quote contains a newline, hence,
147 # we must piece-meal the assignment of VAR such that $LINENO expansion
148 # occurs in a single line.
149 m4_define([_AS_DETECT_EXPAND],
150 [$1="m4_bpatsubst(m4_dquote(AS_ESCAPE(_m4_expand(m4_set_contents([$2], [
151 ])))), [\\\$LINENO\(.*\)$], [";$1=$$1$LINENO;$1=$$1"\1])"])
154 # _AS_DETECT_REQUIRED(TEST)
155 # -------------------------
156 # Refuse to execute under a shell that does not pass the given TEST.
157 # Does not do AS_REQUIRE for the better-shell detection code.
159 # M4sh should never require something not required by POSIX, although
160 # other clients are free to do so.
161 m4_defun([_AS_DETECT_REQUIRED],
162 [m4_set_add([_AS_DETECT_REQUIRED_BODY], [$1 || AS_EXIT])])
165 # _AS_DETECT_SUGGESTED(TEST)
166 # --------------------------
167 # Prefer to execute under a shell that passes the given TEST.
168 # Does not do AS_REQUIRE for the better-shell detection code.
170 # M4sh should never suggest something not required by POSIX, although
171 # other clients are free to do so.
172 m4_defun([_AS_DETECT_SUGGESTED],
173 [m4_set_add([_AS_DETECT_SUGGESTED_BODY], [$1 || AS_EXIT])])
176 # _AS_DETECT_SUGGESTED_PRUNE(TEST)
177 # --------------------------------
178 # If TEST is also a required test, remove it from the set of suggested tests.
179 m4_define([_AS_DETECT_SUGGESTED_PRUNE],
180 [m4_set_contains([_AS_DETECT_REQUIRED_BODY], [$1],
181                  [m4_set_remove([_AS_DETECT_SUGGESTED_BODY], [$1])])])
184 # _AS_DETECT_BETTER_SHELL
185 # -----------------------
186 # The real workhorse for detecting a shell with the correct
187 # features.
189 # In previous versions, we prepended /usr/posix/bin to the path, but that
190 # caused a regression on OpenServer 6.0.0
191 # <https://lists.gnu.org/archive/html/bug-autoconf/2006-06/msg00017.html>
192 # and on HP-UX 11.11, see the failure of test 120 in
193 # <https://lists.gnu.org/archive/html/bug-autoconf/2006-10/msg00003.html>
195 # FIXME: The code should test for the OSF bug described in
196 # <https://lists.gnu.org/archive/html/autoconf-patches/2006-03/msg00081.html>.
198 # This code is run outside any trap 0 context, hence we can simplify AS_EXIT.
199 m4_defun([_AS_DETECT_BETTER_SHELL],
201 dnl By default, do not force re-execution of the script just because
202 dnl the user has pre-set $CONFIG_SHELL; do so only if the m4sh client has
203 dnl defined the internal variable '_AS_FORCE_REEXEC_WITH_CONFIG_SHELL' to
204 dnl "yes".
205 dnl FIXME: This interface is acceptable for the moment, as a private,
206 dnl FIXME: internal one; but if we want to make the "always re-execute"
207 dnl FIXME: feature public, we should find a better interface!
208 [m4_if(_AS_FORCE_REEXEC_WITH_CONFIG_SHELL, [yes],
209   [# Use a proper internal environment variable to ensure we don't fall
210   # into an infinite loop, continuously re-executing ourselves.
211   if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
212     _as_can_reexec=no; export _as_can_reexec;
213     _AS_REEXEC_WITH_SHELL([$CONFIG_SHELL])
214   fi
215   # We don't want this to propagate to other subprocesses.
216   dnl This might be especially important in case an m4sh-generated script
217   dnl is used to later execute other m4sh-generated scripts.  This happens
218   dnl for example in autoconf's own testsuite (and happens *a lot* there,
219   dnl in fact).
220   AS_UNSET([_as_can_reexec])
221 ])]dnl
222 dnl Remove any tests from suggested that are also required
223 [m4_set_map([_AS_DETECT_SUGGESTED_BODY], [_AS_DETECT_SUGGESTED_PRUNE])]dnl
224 [m4_pushdef([AS_EXIT], [exit m4_default(]m4_dquote([$][1])[, 1)])]dnl
225 [if test "x$CONFIG_SHELL" = x; then
226   as_bourne_compatible="AS_ESCAPE(_m4_expand([_AS_BOURNE_COMPATIBLE]))"
227   _AS_DETECT_EXPAND([as_required], [_AS_DETECT_REQUIRED_BODY])
228   _AS_DETECT_EXPAND([as_suggested], [_AS_DETECT_SUGGESTED_BODY])
229   AS_IF([_AS_RUN(["$as_required"])],
230         [as_have_required=yes],
231         [as_have_required=no])
232   AS_IF([test x$as_have_required = xyes && _AS_RUN(["$as_suggested"])],
233     [],
234     [_AS_PATH_WALK([/bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH],
235       [case $as_dir in @%:@(
236          /*)
237            for as_base in sh bash ksh sh5; do
238              # Try only shells that exist, to save several forks.
239              as_shell=$as_dir$as_base
240              AS_IF([{ test -f "$as_shell" || test -f "$as_shell.exe"; } &&
241                     _AS_RUN(["$as_required"], ["$as_shell"])],
242                    [CONFIG_SHELL=$as_shell as_have_required=yes
243                    m4_set_empty([_AS_DETECT_SUGGESTED_BODY], [break 2],
244                      [AS_IF([_AS_RUN(["$as_suggested"], ["$as_shell"])],
245                             [break 2])])])
246            done;;
247        esac],
248       [AS_IF([{ test -f "$SHELL" || test -f "$SHELL.exe"; } &&
249               _AS_RUN(["$as_required"], ["$SHELL"])],
250              [CONFIG_SHELL=$SHELL as_have_required=yes])])
252       AS_IF([test "x$CONFIG_SHELL" != x],
253             [export CONFIG_SHELL
254              _AS_REEXEC_WITH_SHELL([$CONFIG_SHELL])])
256 dnl Unfortunately, $as_me isn't available here.
257     AS_IF([test x$as_have_required = xno],
258       [AS_ECHO(["$[]0: This script requires a shell more modern than all"])
259   AS_ECHO(["$[]0: the shells that I found on your system."])
260   if test ${ZSH_VERSION+y} ; then
261     AS_ECHO(["$[]0: In particular, zsh $ZSH_VERSION has bugs and should"])
262     AS_ECHO(["$[]0: be upgraded to zsh 4.3.4 or later."])
263   else
264     AS_ECHO("m4_text_wrap([Please tell ]_m4_defn([m4_PACKAGE_BUGREPORT])
265 m4_ifset([AC_PACKAGE_BUGREPORT], [m4_if(_m4_defn([m4_PACKAGE_BUGREPORT]),
266 _m4_defn([AC_PACKAGE_BUGREPORT]), [], [and _m4_defn([AC_PACKAGE_BUGREPORT])])])
267 [about your system, including any error possibly output before this message.
268 Then install a modern shell, or manually run the script under such a
269 shell if you do have one.], [$[]0: ], [], [62])")
270   fi
271   AS_EXIT])])
273 SHELL=${CONFIG_SHELL-/bin/sh}
274 export SHELL
275 # Unset more variables known to interfere with behavior of common tools.
276 CLICOLOR_FORCE= GREP_OPTIONS=
277 unset CLICOLOR_FORCE GREP_OPTIONS
278 _m4_popdef([AS_EXIT])])# _AS_DETECT_BETTER_SHELL
280 # _AS_REEXEC_WITH_SHELL(SHELL)
281 # ----------------------------
282 # Re-execute the current script with the given shell, trying to preserve
283 # portable settings (e.g., the 'xtrace' and 'verbose' shell flag).
284 m4_defun([_AS_REEXEC_WITH_SHELL], [dnl
285 # We cannot yet assume a decent shell, so we have to provide a
286 # neutralization value for shells without unset; and this also
287 # works around shells that cannot unset nonexistent variables.
288 # Preserve -v and -x to the replacement shell.
289 BASH_ENV=/dev/null
290 ENV=/dev/null
291 (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
292 case $- in @%:@ ((((
293   *v*x* | *x*v* ) as_opts=-vx ;;
294   *v* ) as_opts=-v ;;
295   *x* ) as_opts=-x ;;
296   * ) as_opts= ;;
297 esac
298 case [$]@%:@ in @%:@ ((
299   0) exec $1 $as_opts "$as_myself" ;;
300   *) exec $1 $as_opts "$as_myself" "$[@]" ;;
301 esac
302 # Admittedly, this is quite paranoid, since all the known shells bail
303 # out after a failed 'exec'.
304 AS_ECHO(["$[]0: could not re-execute with $1"]) >&2
305 dnl AS_EXIT cannot be used here because as_fn_exit is not yet defined;
306 dnl code inserted by AS_REQUIRE_SHELL_FN will appear _after_ this point.
307 dnl We shouldn't have to worry about any traps being active at this point.
308 exit 255])# _AS_REEXEC_WITH_SHELL
311 # _AS_ENSURE_STANDARD_FDS
312 # -----------------------
313 # Ensure that file descriptors 0, 1, and 2 are open, as a defensive
314 # measure against weird environments that run configure scripts
315 # with these descriptors closed.
316 # 'exec m>&n' fails in POSIX sh when fd N is closed, but succeeds
317 # regardless of whether fd N is open in some old shells, e.g. Solaris
318 # /bin/sh.  This is OK because those shells will be rejected by
319 # _AS_DETECT_BETTER_SHELL anyway.
320 # TODO post-2.70: use "backward" redirections when opening these fds,
321 # so we preserve their unusable state.  Needs downstream logic to
322 # stop on the first failed attempt to write to fd 1 or 2, so we don't
323 # run through an entire configure script spewing "write error"
324 # messages when fd 1 is closed.
325 m4_defun([_AS_ENSURE_STANDARD_FDS], [dnl
326 # Ensure that fds 0, 1, and 2 are open.
327 if (exec 3>&0) 2>/dev/null; then :; else exec 0</dev/null; fi
328 if (exec 3>&1) 2>/dev/null; then :; else exec 1>/dev/null; fi
329 if (exec 3>&2)            ; then :; else exec 2>/dev/null; fi
333 # _AS_PREPARE
334 # -----------
335 # This macro has a very special status.  Normal use of M4sh relies
336 # heavily on AS_REQUIRE, so that needed initializations (such as
337 # _AS_TEST_PREPARE) are performed on need, not on demand.  But
338 # Autoconf is the first client of M4sh, and for two reasons: configure
339 # and config.status.  Relying on AS_REQUIRE is of course fine for
340 # configure, but fails for config.status (which is created by
341 # configure).  So we need a means to force the inclusion of the
342 # various _AS_*_PREPARE on top of config.status.  That's basically why
343 # there are so many _AS_*_PREPARE below, and that's also why it is
344 # important not to forget some: config.status needs them.
345 # List any preparations that create shell functions first, then
346 # topologically sort the others by their dependencies.
348 # Special case: we do not need _AS_LINENO_PREPARE, because the
349 # parent will have substituted $LINENO for us when processing its
350 # own invocation of _AS_LINENO_PREPARE.
352 # Special case: the full definition of _AS_ERROR_PREPARE is not output
353 # unless AS_MESSAGE_LOG_FD is non-empty, although the value of
354 # AS_MESSAGE_LOG_FD is not relevant.
355 m4_defun([_AS_PREPARE],
356 [m4_pushdef([AS_REQUIRE])]dnl
357 [m4_pushdef([AS_REQUIRE_SHELL_FN], _m4_defn([_AS_REQUIRE_SHELL_FN])
358 )]dnl
359 [m4_pushdef([AS_MESSAGE_LOG_FD], [-1])]dnl
360 [_AS_ERROR_PREPARE
361 _m4_popdef([AS_MESSAGE_LOG_FD])]dnl
362 [_AS_EXIT_PREPARE
363 _AS_UNSET_PREPARE
364 _AS_VAR_APPEND_PREPARE
365 _AS_VAR_ARITH_PREPARE
367 _AS_EXPR_PREPARE
368 _AS_BASENAME_PREPARE
369 _AS_DIRNAME_PREPARE
370 _AS_ME_PREPARE
371 _AS_CR_PREPARE
372 _AS_LN_S_PREPARE
373 _AS_MKDIR_P_PREPARE
374 _AS_TEST_PREPARE
375 _AS_TR_CPP_PREPARE
376 _AS_TR_SH_PREPARE
377 _m4_popdef([AS_REQUIRE], [AS_REQUIRE_SHELL_FN])])
379 # AS_PREPARE
380 # ----------
381 # Output all the M4sh possible initialization into the initialization
382 # diversion.  We do not use _AS_PREPARE so that the m4_provide symbols for
383 # AS_REQUIRE and AS_REQUIRE_SHELL_FN are defined properly, and so that
384 # shell functions are placed in M4SH-INIT-FN.
385 m4_defun([AS_PREPARE],
386 [m4_divert_push([KILL])
387 m4_append_uniq([_AS_CLEANUP],
388   [m4_divert_text([M4SH-INIT-FN], [_AS_ERROR_PREPARE[]])])
389 AS_REQUIRE([_AS_EXPR_PREPARE])
390 AS_REQUIRE([_AS_BASENAME_PREPARE])
391 AS_REQUIRE([_AS_DIRNAME_PREPARE])
392 AS_REQUIRE([_AS_ME_PREPARE])
393 AS_REQUIRE([_AS_CR_PREPARE])
394 AS_REQUIRE([_AS_LINENO_PREPARE])
395 AS_REQUIRE([_AS_EXIT_PREPARE])
396 AS_REQUIRE([_AS_LN_S_PREPARE])
397 AS_REQUIRE([_AS_MKDIR_P_PREPARE])
398 AS_REQUIRE([_AS_TEST_PREPARE])
399 AS_REQUIRE([_AS_TR_CPP_PREPARE])
400 AS_REQUIRE([_AS_TR_SH_PREPARE])
401 AS_REQUIRE([_AS_UNSET_PREPARE])
402 AS_REQUIRE([_AS_VAR_APPEND_PREPARE], [], [M4SH-INIT-FN])
403 AS_REQUIRE([_AS_VAR_ARITH_PREPARE], [], [M4SH-INIT-FN])
404 m4_divert_pop[]])
407 # AS_REQUIRE(NAME-TO-CHECK, [BODY-TO-EXPAND = NAME-TO-CHECK],
408 #            [DIVERSION = M4SH-INIT])
409 # -----------------------------------------------------------
410 # BODY-TO-EXPAND is some initialization which must be expanded in the
411 # given diversion when expanded (required or not).  The expansion
412 # goes in the named diversion or an earlier one.
414 # Since $2 can be quite large, this is factored for faster execution, giving
415 # either m4_require([$1], [$2]) or m4_divert_require(desired, [$1], [$2]).
416 m4_defun([AS_REQUIRE],
417 [m4_define([_m4_divert_desired], [m4_default_quoted([$3], [M4SH-INIT])])]dnl
418 [m4_if(m4_eval(_m4_divert_dump - 0 <= _m4_divert(_m4_divert_desired, [-])),
419        1, [m4_require(],
420           [m4_divert_require(_m4_divert_desired,]) [$1], [$2])])
422 # _AS_REQUIRE_SHELL_FN(NAME-TO-CHECK, COMMENT, BODY-TO-EXPAND)
423 # ------------------------------------------------------------
424 # Core of AS_REQUIRE_SHELL_FN, but without diversion support.
425 m4_define([_AS_REQUIRE_SHELL_FN], [
426 m4_n([$2])$1 ()
429 } @%:@ $1[]])
431 # AS_REQUIRE_SHELL_FN(NAME-TO-CHECK, COMMENT, BODY-TO-EXPAND,
432 #                     [DIVERSION = M4SH-INIT-FN])
433 # -----------------------------------------------------------
434 # BODY-TO-EXPAND is the body of a shell function to be emitted in the
435 # given diversion when expanded (required or not).  Unlike other
436 # xx_REQUIRE macros, BODY-TO-EXPAND is mandatory.  If COMMENT is
437 # provided (often via AS_FUNCTION_DESCRIBE), it is listed with a
438 # newline before the function name.
439 m4_define([AS_REQUIRE_SHELL_FN],
440 [m4_provide_if([AS_SHELL_FN_$1], [],
441 [AS_REQUIRE([AS_SHELL_FN_$1],
442 [m4_provide([AS_SHELL_FN_$1])_$0($@)],
443 m4_default_quoted([$4], [M4SH-INIT-FN]))])])
446 # _AS_RUN(TEST, [SHELL])
447 # ----------------------
448 # Run TEST under the current shell (if one parameter is used)
449 # or under the given SHELL, protecting it from syntax errors.
450 # Set as_run in order to assist _AS_LINENO_WORKS.
451 m4_define([_AS_RUN],
452 [m4_ifval([$2], [as_run=a $2 -c "$as_bourne_compatible"$1],
453                 [(eval $1)]) 2>/dev/null])
456 # _AS_SHELL_FN_WORK
457 # -----------------
458 # This is a spy to detect "in the wild" shells that do not support shell
459 # functions correctly.  It is based on the m4sh.at Autotest testcases.
460 m4_define([_AS_SHELL_FN_WORK],
461 [as_fn_return () { (exit [$]1); }
462 as_fn_success () { as_fn_return 0; }
463 as_fn_failure () { as_fn_return 1; }
464 as_fn_ret_success () { return 0; }
465 as_fn_ret_failure () { return 1; }
467 exitcode=0
468 as_fn_success || { exitcode=1; echo as_fn_success failed.; }
469 as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
470 as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
471 as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
472 AS_IF([( set x; as_fn_ret_success y && test x = "[$]1" )], [],
473       [exitcode=1; echo positional parameters were not saved.])
474 test x$exitcode = x0[]])# _AS_SHELL_FN_WORK
477 # _AS_MODERN_CMDSUBST_WORKS
478 # -------------------------
479 # This is a spy to detect "in the wild" shells that do not support
480 # the newer $(...) form of command substitutions.
481 m4_define([_AS_MODERN_CMDSUBST_WORKS],
482 [blah=$(echo $(echo blah))
483 test x"$blah" = xblah])
486 # _AS_SHELL_SANITIZE
487 # ------------------
488 # This is the prolog that is emitted by AS_INIT and AS_INIT_GENERATED;
489 # it is executed prior to shell function definitions, hence the
490 # temporary redefinition of AS_EXIT.
491 m4_defun([_AS_SHELL_SANITIZE],
492 [m4_pushdef([AS_EXIT], [exit m4_default(]m4_dquote([$][1])[, 1)])]dnl
493 [m4_text_box([M4sh Initialization.])
495 AS_BOURNE_COMPATIBLE
497 # Reset variables that may have inherited troublesome values from
498 # the environment.
500 # IFS needs to be set, to space, tab, and newline, in precisely that order.
501 # (If _AS_PATH_WALK were called with IFS unset, it would have the
502 # side effect of setting IFS to empty, thus disabling word splitting.)
503 # Quoting is to prevent editors from complaining about space-tab.
504 as_nl='
506 export as_nl
507 IFS=" ""        $as_nl"
509 PS1='$ '
510 PS2='> '
511 PS4='+ '
513 # Ensure predictable behavior from utilities with locale-dependent output.
514 LC_ALL=C
515 export LC_ALL
516 LANGUAGE=C
517 export LANGUAGE
519 # We cannot yet rely on "unset" to work, but we need these variables
520 # to be unset--not just set to an empty or harmless value--now, to
521 # avoid bugs in old shells (e.g. pre-3.0 UWIN ksh).  This construct
522 # also avoids known problems related to "unset" and subshell syntax
523 # in other old shells (e.g. bash 2.01 and pdksh 5.2.14).
524 for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH
525 do eval test \${$as_var+y} \
526   && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
527 done
529 _AS_ENSURE_STANDARD_FDS
530 _AS_PATH_SEPARATOR_PREPARE
532 # Find who we are.  Look in the path if we contain no directory separator.
533 as_myself=
534 case $[0] in @%:@((
535   *[[\\/]]* ) as_myself=$[0] ;;
536   *) _AS_PATH_WALK([],
537                    [test -r "$as_dir$[0]" && as_myself=$as_dir$[0] && break])
538      ;;
539 esac
540 # We did not find ourselves, most probably we were run as 'sh COMMAND'
541 # in which case we are not to be found in the path.
542 if test "x$as_myself" = x; then
543   as_myself=$[0]
545 if test ! -f "$as_myself"; then
546   AS_ECHO(["$as_myself: error: cannot find myself; rerun with an absolute file name"]) >&2
547   AS_EXIT
550 _m4_popdef([AS_EXIT])])# _AS_SHELL_SANITIZE
553 # AS_SHELL_SANITIZE
554 # -----------------
555 # This is only needed for the sake of Libtool, which screws up royally
556 # in its usage of M4sh internals.
557 m4_define([AS_SHELL_SANITIZE],
558 [_AS_SHELL_SANITIZE
559 m4_provide_if([AS_INIT], [],
560 [m4_provide([AS_INIT])
561 _AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])
562 _AS_DETECT_REQUIRED([_AS_MODERN_CMDSUBST_WORKS])
563 _AS_DETECT_REQUIRED([_AS_TEST_X_WORKS])
564 _AS_DETECT_BETTER_SHELL
565 _AS_UNSET_PREPARE
566 ])])
569 ## ----------------------------- ##
570 ## 2. Wrappers around builtins.  ##
571 ## ----------------------------- ##
573 # This section is lexicographically sorted.
576 # AS_CASE(WORD, [PATTERN1], [IF-MATCHED1]...[DEFAULT])
577 # ----------------------------------------------------
578 # Expand into
579 # | case WORD in #(
580 # |   PATTERN1) IF-MATCHED1 ;; #(
581 # |   ...
582 # |   *) DEFAULT ;;
583 # | esac
584 # The shell comments are intentional, to work around people who don't
585 # realize the impacts of using insufficient m4 quoting.  This macro
586 # always uses : and provides a default case, to work around Solaris
587 # /bin/sh bugs regarding the exit status.
588 m4_define([_AS_CASE],
589 [ [@%:@(]
590   $1[)] :
591     $2 ;;])
592 m4_define([_AS_CASE_DEFAULT],
593 [ [@%:@(]
594   *[)] :
595     $1 ;;])
597 m4_defun([AS_CASE],
598 [case $1 in[]m4_map_args_pair([_$0], [_$0_DEFAULT],
599    m4_shift($@m4_if(m4_eval([$# & 1]), [1], [,])))
600 esac])# AS_CASE
603 # _AS_EXIT_PREPARE
604 # ----------------
605 # Ensure AS_EXIT and AS_SET_STATUS will work.
607 # We cannot simply use "exit N" because some shells (zsh and Solaris sh)
608 # will not set $? to N while running the code set by "trap 0"
609 # Some shells fork even for (exit N), so we use a helper function
610 # to set $? prior to the exit.
611 # Then there are shells that don't inherit $? correctly into the start of
612 # a shell function, so we must always be given an argument.
613 # Other shells don't use '$?' as default for 'exit', hence just repeating
614 # the exit value can only help improving portability.
615 m4_defun([_AS_EXIT_PREPARE],
616 [AS_REQUIRE_SHELL_FN([as_fn_set_status],
617   [AS_FUNCTION_DESCRIBE([as_fn_set_status], [STATUS],
618     [Set $? to STATUS, without forking.])], [  return $[]1])]dnl
619 [AS_REQUIRE_SHELL_FN([as_fn_exit],
620   [AS_FUNCTION_DESCRIBE([as_fn_exit], [STATUS],
621     [Exit the shell with STATUS, even in a "trap 0" or "set -e" context.])],
622 [  set +e
623   as_fn_set_status $[1]
624   exit $[1]])])#_AS_EXIT_PREPARE
627 # AS_EXIT([EXIT-CODE = $?])
628 # -------------------------
629 # Exit, with status set to EXIT-CODE in the way that it's seen
630 # within "trap 0", and without interference from "set -e".  If
631 # EXIT-CODE is omitted, then use $?.
632 m4_defun([AS_EXIT],
633 [AS_REQUIRE([_AS_EXIT_PREPARE])[]as_fn_exit m4_ifval([$1], [$1], [$][?])])
636 # AS_FOR(MACRO, SHELL-VAR, [LIST = "$@"], [BODY = :])
637 # ---------------------------------------------------
638 # Expand to a shell loop that assigns SHELL-VAR to each of the
639 # whitespace-separated entries in LIST (or "$@" if LIST is empty),
640 # then executes BODY.  BODY may call break to abort the loop, or
641 # continue to proceed with the next element of LIST.  Requires that
642 # IFS be set to the normal space-tab-newline.  As an optimization,
643 # BODY should access MACRO rather than $SHELL-VAR.  Normally, MACRO
644 # expands to $SHELL-VAR, but if LIST contains only a single element
645 # that needs no additional shell quoting, then MACRO will expand to
646 # that element, thus providing a direct value rather than a shell
647 # variable indirection.
649 # Only use the optimization if LIST can be used without additional
650 # shell quoting in either a literal or double-quoted context (that is,
651 # we give up on default IFS chars, parameter expansion, command
652 # substitution, shell quoting, globs, or quadrigraphs).  Inline the
653 # m4_defn for speed.
654 m4_defun([AS_FOR],
655 [m4_pushdef([$1], m4_if([$3], [], [[$$2]], m4_translit([$3], ]dnl
656 m4_dquote(_m4_defn([m4_cr_symbols2]))[[%+=:,./-]), [], [[$3]], [[$$2]]))]dnl
657 [for $2[]m4_ifval([$3], [ in $3])
658 do :
659   $4
660 done[]_m4_popdef([$1])])
663 # AS_IF(TEST1, [IF-TRUE1 = :]...[IF-FALSE = :])
664 # ---------------------------------------------
665 # Expand into
666 # | if TEST1
667 # | then
668 # |   IF-TRUE1
669 # | elif TEST2
670 # | then
671 # |   IF-TRUE2
672 # [...]
673 # | else
674 # |   IF-FALSE
675 # | fi
676 # with simplifications when IF-TRUE1 and/or IF-FALSE are empty.
678 # Note: IF-TRUEn and IF-FALSE may be nonempty but, after further
679 # macro expansion, leave no actual shell code.  We can't detect this,
680 # so surround each clause with appropriate shell syntax so that it is
681 # valid even if it is empty.  For the IF-TRUEn this can simply be ':'
682 # before the clause.  However, we can't do the same for IF-FALSE
683 # because the ':' would trash the value of $? from the conditional
684 # expression, which the IF-FALSE code might use.  Instead we use
685 # 'case e in e) IF-FALSE ;; esac' which is valid even when IF-FALSE
686 # is empty.
687 m4_define([_AS_IF],
688 [elif $1
689 then :
690   $2
692 m4_defun([_AS_IF_ELSE],
693 [m4_ifnblank([$1],
694 [else case e in @%:@(
695   e) $1 ;;
696 esac
697 ])])
699 m4_defun([AS_IF],
700 [if $1
701 then :
702   $2
703 m4_map_args_pair([_$0], [_$0_ELSE], m4_shift2($@))]dnl
704 [fi[]])# AS_IF
707 # AS_SET_STATUS(STATUS)
708 # ---------------------
709 # Set the shell status ($?) to STATUS, without forking.
710 m4_defun([AS_SET_STATUS],
711 [AS_REQUIRE([_AS_EXIT_PREPARE])[]as_fn_set_status $1])
714 # _AS_UNSET_PREPARE
715 # -----------------
716 # Define $as_unset to execute AS_UNSET, for backwards compatibility
717 # with older versions of M4sh.
718 m4_defun([_AS_UNSET_PREPARE],
719 [AS_FUNCTION_DESCRIBE([as_fn_unset], [VAR], [Portably unset VAR.])
720 as_fn_unset ()
722   AS_UNSET([$[1]])
724 as_unset=as_fn_unset
728 # AS_UNSET(VAR)
729 # -------------
730 # Unset the env VAR, working around shells that do not allow unsetting
731 # a variable that is not already set.  You should not unset MAIL and
732 # MAILCHECK, as that triggers a bug in Bash 2.01.
733 m4_defun([AS_UNSET],
734 [{ AS_LITERAL_WORD_IF([$1], [], [eval ])$1=; unset $1;}])
741 ## ------------------------------------------ ##
742 ## 3. Error and warnings at the shell level.  ##
743 ## ------------------------------------------ ##
746 # AS_MESSAGE_FD
747 # -------------
748 # Must expand to the fd where messages will be sent.  Defaults to 1,
749 # although a script may reassign this value and use exec to either
750 # copy stdout to the new fd, or open the new fd on /dev/null.
751 m4_define([AS_MESSAGE_FD], [1])
753 # AS_MESSAGE_LOG_FD
754 # -----------------
755 # Must expand to either the empty string (when no logging is
756 # performed), or to the fd of a log file.  Defaults to empty, although
757 # a script may reassign this value and use exec to open a log.  When
758 # not empty, messages to AS_MESSAGE_FD are duplicated to the log,
759 # along with a LINENO reference.
760 m4_define([AS_MESSAGE_LOG_FD])
763 # AS_ORIGINAL_STDIN_FD
764 # --------------------
765 # Must expand to the fd of the script's original stdin.  Defaults to
766 # 0, although the script may reassign this value and use exec to
767 # shuffle fd's.
768 m4_define([AS_ORIGINAL_STDIN_FD], [0])
771 # AS_ESCAPE(STRING, [CHARS = `\"$])
772 # ---------------------------------
773 # Add backslash escaping to the CHARS in STRING.  In an effort to
774 # optimize use of this macro inside double-quoted shell constructs,
775 # the behavior is intentionally undefined if CHARS is longer than 4
776 # bytes, or contains bytes outside of the set [`\"$].  However,
777 # repeated bytes within the set are permissible (AS_ESCAPE([$1], [""])
778 # being a common way to be nice to syntax highlighting).
780 # Avoid the m4_bpatsubst if there are no interesting characters to escape.
781 # _AS_ESCAPE bypasses argument defaulting.
782 m4_define([AS_ESCAPE],
783 [_$0([$1], m4_if([$2], [], [[`], [\"$]], [m4_substr([$2], [0], [1]), [$2]]))])
785 # _AS_ESCAPE(STRING, KEY, SET)
786 # ----------------------------
787 # Backslash-escape all instances of the single byte KEY or up to four
788 # bytes in SET occurring in STRING.  Although a character can occur
789 # multiple times, optimum efficiency occurs when KEY and SET are
790 # distinct, and when SET does not exceed two bytes.  These particular
791 # semantics allow for the fewest number of parses of STRING, as well
792 # as taking advantage of the optimizations in m4 1.4.13+ when
793 # m4_translit is passed SET of size 2 or smaller.
794 m4_define([_AS_ESCAPE],
795 [m4_if(m4_index(m4_translit([[$1]], [$3], [$2$2$2$2]), [$2]), [-1],
796        [$0_], [m4_bpatsubst])([$1], [[$2$3]], [\\\&])])
797 m4_define([_AS_ESCAPE_], [$1])
800 # _AS_QUOTE(STRING)
801 # -----------------
802 # If there are quoted (via backslash) backquotes, output STRING
803 # literally and warn; otherwise, output STRING with ` and " quoted.
805 # Compatibility glue between the old AS_MSG suite which did not
806 # quote anything, and the modern suite which quotes the quotes.
807 # If STRING contains '\\' or '\$', it's modern.
808 # If STRING contains '\"' or '\`', it's old.
809 # Otherwise it's modern.
811 # Profiling shows that m4_index is 5 to 8x faster than m4_bregexp.  The
812 # slower implementation used:
813 # m4_bmatch([$1],
814 #           [\\[\\$]], [$2],
815 #           [\\[`"]], [$3],
816 #           [$2])
817 # The current implementation caters to the common case of no backslashes,
818 # to minimize m4_index expansions (hence the nested if).
819 m4_define([_AS_QUOTE],
820 [m4_cond([m4_index([$1], [\])], [-1], [_AS_QUOTE_MODERN],
821          [m4_eval(m4_index(m4_translit([[$1]], [$], [\]), [\\]) >= 0)],
822 [1], [_AS_QUOTE_MODERN],
823          [m4_eval(m4_index(m4_translit([[$1]], ["], [`]), [\`]) >= 0)],dnl"
824 [1], [_AS_QUOTE_OLD],
825          [_AS_QUOTE_MODERN])([$1])])
827 m4_define([_AS_QUOTE_MODERN],
828 [_AS_ESCAPE([$1], [`], [""])])
830 m4_define([_AS_QUOTE_OLD],
831 [m4_warn([obsolete],
832    [back quotes and double quotes must not be escaped in: $1])$1])
835 # _AS_ECHO_UNQUOTED(STRING, [FD = AS_MESSAGE_FD])
836 # -----------------------------------------------
837 # Perform shell expansions on STRING and echo the string to FD.
838 m4_define([_AS_ECHO_UNQUOTED],
839 [AS_ECHO(["$1"]) >&m4_default([$2], [AS_MESSAGE_FD])])
842 # _AS_ECHO(STRING, [FD = AS_MESSAGE_FD])
843 # --------------------------------------
844 # Protect STRING from backquote expansion, echo the result to FD.
845 m4_define([_AS_ECHO],
846 [_AS_ECHO_UNQUOTED([_AS_QUOTE([$1])], [$2])])
849 # _AS_ECHO_LOG(STRING)
850 # --------------------
851 # Log the string to AS_MESSAGE_LOG_FD.
852 m4_defun_init([_AS_ECHO_LOG],
853 [AS_REQUIRE([_AS_LINENO_PREPARE])],
854 [_AS_ECHO([$as_me:${as_lineno-$LINENO}: $1], AS_MESSAGE_LOG_FD)])
857 # _AS_ECHO_N(STRING, [FD = AS_MESSAGE_FD])
858 # ----------------------------------------
859 # Same as _AS_ECHO, but echo doesn't return to a new line.
860 m4_define([_AS_ECHO_N],
861 [AS_ECHO_N(["_AS_QUOTE([$1])"]) >&m4_default([$2], [AS_MESSAGE_FD])])
864 # AS_MESSAGE(STRING, [FD = AS_MESSAGE_FD])
865 # ----------------------------------------
866 # Output "`basename $0`: STRING" to the open file FD, and if logging
867 # is enabled, copy it to the log with a reference to LINENO.
868 m4_defun_init([AS_MESSAGE],
869 [AS_REQUIRE([_AS_ME_PREPARE])],
870 [m4_ifval(AS_MESSAGE_LOG_FD,
871           [{ _AS_ECHO_LOG([$1])
872 _AS_ECHO([$as_me: $1], [$2]);}],
873           [_AS_ECHO([$as_me: $1], [$2])])[]])
876 # AS_WARN(PROBLEM)
877 # ----------------
878 # Output "`basename $0`: WARNING: PROBLEM" to stderr.
879 m4_define([AS_WARN],
880 [AS_MESSAGE([WARNING: $1], [2])])# AS_WARN
883 # _AS_ERROR_PREPARE
884 # -----------------
885 # Output the shell function used by AS_ERROR.  This is designed to be
886 # expanded during the m4_wrap cleanup.
888 # If AS_MESSAGE_LOG_FD is non-empty at the end of the script, then
889 # make this function take optional parameters that use LINENO at the
890 # points where AS_ERROR was expanded with non-empty AS_MESSAGE_LOG_FD;
891 # otherwise, assume the entire script does not do logging.
892 m4_define([_AS_ERROR_PREPARE],
893 [AS_REQUIRE_SHELL_FN([as_fn_error],
894   [AS_FUNCTION_DESCRIBE([as_fn_error], [STATUS ERROR]m4_ifval(AS_MESSAGE_LOG_FD,
895       [[ [[LINENO LOG_FD]]]]),
896     [Output "`basename @S|@0`: error: ERROR" to stderr.]
897 m4_ifval(AS_MESSAGE_LOG_FD,
898     [[If LINENO and LOG_FD are provided, also output the error to LOG_FD,
899       referencing LINENO.]])
900     [Then exit the script with STATUS, using 1 if that was 0.])],
901 [  as_status=$[1]; test $as_status -eq 0 && as_status=1
902 m4_ifval(AS_MESSAGE_LOG_FD,
903 [m4_pushdef([AS_MESSAGE_LOG_FD], [$[4]])dnl
904   if test "$[4]"; then
905     AS_LINENO_PUSH([$[3]])
906     _AS_ECHO_LOG([error: $[2]])
907   fi
908 m4_define([AS_MESSAGE_LOG_FD])], [m4_pushdef([AS_MESSAGE_LOG_FD])])dnl
909   AS_MESSAGE([error: $[2]], [2])
910 _m4_popdef([AS_MESSAGE_LOG_FD])dnl
911   AS_EXIT([$as_status])])])
913 # AS_ERROR(ERROR, [EXIT-STATUS = max($?/1)])
914 # ------------------------------------------
915 # Output "`basename $0`: error: ERROR" to stderr, then exit the
916 # script with EXIT-STATUS.
917 m4_defun_init([AS_ERROR],
918 [m4_append_uniq([_AS_CLEANUP],
919   [m4_divert_text([M4SH-INIT-FN], [_AS_ERROR_PREPARE[]])])],
920 [as_fn_error m4_default([$2], [$?]) "_AS_QUOTE([$1])"m4_ifval(AS_MESSAGE_LOG_FD,
921   [ "$LINENO" AS_MESSAGE_LOG_FD])])
924 # AS_LINENO_PUSH([LINENO])
925 # ------------------------
926 # If this is the outermost call to AS_LINENO_PUSH, make sure that
927 # AS_MESSAGE will print LINENO as the line number.
928 m4_defun([AS_LINENO_PUSH],
929 [as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack])
932 # AS_LINENO_POP([LINENO])
933 # -----------------------
934 # If this is call balances the outermost call to AS_LINENO_PUSH,
935 # AS_MESSAGE will restart printing $LINENO as the line number.
937 # No need to use AS_UNSET, since as_lineno is necessarily set.
938 m4_defun([AS_LINENO_POP],
939 [eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno])
942 # as_echo
943 # -------
944 # Define the obsolete internal shell variable as_echo if necessary.
945 # It is known to be used by some third party macros.  New code should
946 # use AS_ECHO(["message"]).
948 # This macro will typically be used like
949 #   $as_echo "message"
950 # and that line of the script must not be changed by the expansion;
951 # especially, we cannot introduce whitespace between '$' and 'a'.
952 # This means we cannot use m4_require and we need to invoke
953 # _as_echo_var_prepare with call parentheses.
954 m4_defun([as_echo],
955 [m4_provide_if([_as_echo_var_prepare], [], [_as_echo_var_prepare()])]dnl
956 [as@&t@_echo])
958 # _as_echo_var_prepare
959 # --------------------
960 # The @&t@ prevents recursive expansion.
961 # Extra quoting in case 's' or 'n' are user-defined macros when this
962 # is expanded; they almost certainly aren't meant to be used here.
963 # See bug 110377.
964 m4_defun([_as_echo_var_prepare],
965 [m4_warn([obsolete],
966    [$as_echo is obsolete; use AS_ECHO(["message"]) instead])]dnl
967 [m4_divert_once([M4SH-INIT], [
968 # Provided for backward compatibility.  Change uses to AS_ECHO(["message"]).
969 as@&t@_echo='printf [%s\n]'])])
971 # as_echo_n
972 # ---------
973 # Define the obsolete internal shell variable as_echo_n if necessary.
974 # It is known to be used by some third party macros.  New code should
975 # use AS_ECHO_N(["message"]).
976 # See as_echo for implementation notes.
977 m4_defun([as_echo_n],
978 [m4_provide_if([_as_echo_n_var_prepare], [], [_as_echo_n_var_prepare()])]dnl
979 [as@&t@_echo_n])
981 # _as_echo_n_var_prepare
982 # ----------------------
983 # The @&t@ prevents recursive expansion.
984 # Extra quoting in case 's' or 'n' are user-defined macros when this
985 # is expanded; they almost certainly aren't meant to be used here.
986 # See bug 110377.
987 m4_defun([_as_echo_n_var_prepare],
988 [m4_warn([obsolete],
989    [$as_echo_n is obsolete; use AS_ECHO_N(["message"]) instead])]dnl
990 [m4_divert_once([M4SH-INIT], [
991 # Provided for backward compatibility.  Change uses to AS_ECHO_N(["message"]).
992 as@&t@_echo_n='printf [%s]'])])
996 ## -------------------------------------- ##
997 ## 4. Portable versions of common tools.  ##
998 ## -------------------------------------- ##
1000 # This section is lexicographically sorted.
1003 # AS_BASENAME(FILE-NAME)
1004 # ----------------------
1005 # Simulate the command 'basename FILE-NAME'.  Not all systems have basename.
1006 # Also see the comments for AS_DIRNAME.
1008 m4_defun([_AS_BASENAME_EXPR],
1009 [$as_expr X/[]$1 : '.*/\([[^/][^/]*]\)/*$' \| \
1010          X[]$1 : 'X\(//\)$' \| \
1011          X[]$1 : 'X\(/\)' \| .])
1013 m4_defun([_AS_BASENAME_SED],
1014 [AS_ECHO([X/[]$1]) |
1015     sed ['/^.*\/\([^/][^/]*\)\/*$/{
1016             s//\1/
1017             q
1018           }
1019           /^X\/\(\/\/\)$/{
1020             s//\1/
1021             q
1022           }
1023           /^X\/\(\/\).*/{
1024             s//\1/
1025             q
1026           }
1027           s/.*/./; q']])
1029 m4_defun_init([AS_BASENAME],
1030 [AS_REQUIRE([_$0_PREPARE])],
1031 [$as_basename -- $1 ||
1032 _AS_BASENAME_EXPR([$1]) 2>/dev/null ||
1033 _AS_BASENAME_SED([$1])])
1036 # _AS_BASENAME_PREPARE
1037 # --------------------
1038 # Avoid Solaris 9 /usr/ucb/basename, as 'basename /' outputs an empty line.
1039 # Also, traditional basename mishandles --.  Require here _AS_EXPR_PREPARE,
1040 # to avoid problems when _AS_BASENAME is called from the M4SH-INIT diversion.
1041 m4_defun([_AS_BASENAME_PREPARE],
1042 [AS_REQUIRE([_AS_EXPR_PREPARE])]dnl
1043 [if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
1044   as_basename=basename
1045 else
1046   as_basename=false
1048 ])# _AS_BASENAME_PREPARE
1051 # AS_DIRNAME(FILE-NAME)
1052 # ---------------------
1053 # Simulate the command 'dirname FILE-NAME'.  Not all systems have dirname.
1054 # This macro must be usable from inside ` `.
1056 # Prefer expr to echo|sed, since expr is usually faster and it handles
1057 # backslashes and newlines correctly.  However, older expr
1058 # implementations (e.g. SunOS 4 expr and Solaris 8 /usr/ucb/expr) have
1059 # a silly length limit that causes expr to fail if the matched
1060 # substring is longer than 120 bytes.  So fall back on echo|sed if
1061 # expr fails.
1062 m4_defun_init([_AS_DIRNAME_EXPR],
1063 [AS_REQUIRE([_AS_EXPR_PREPARE])],
1064 [$as_expr X[]$1 : 'X\(.*[[^/]]\)//*[[^/][^/]]*/*$' \| \
1065          X[]$1 : 'X\(//\)[[^/]]' \| \
1066          X[]$1 : 'X\(//\)$' \| \
1067          X[]$1 : 'X\(/\)' \| .])
1069 m4_defun([_AS_DIRNAME_SED],
1070 [AS_ECHO([X[]$1]) |
1071     sed ['/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
1072             s//\1/
1073             q
1074           }
1075           /^X\(\/\/\)[^/].*/{
1076             s//\1/
1077             q
1078           }
1079           /^X\(\/\/\)$/{
1080             s//\1/
1081             q
1082           }
1083           /^X\(\/\).*/{
1084             s//\1/
1085             q
1086           }
1087           s/.*/./; q']])
1089 m4_defun_init([AS_DIRNAME],
1090 [AS_REQUIRE([_$0_PREPARE])],
1091 [$as_dirname -- $1 ||
1092 _AS_DIRNAME_EXPR([$1]) 2>/dev/null ||
1093 _AS_DIRNAME_SED([$1])])
1096 # _AS_DIRNAME_PREPARE
1097 # -------------------
1098 m4_defun([_AS_DIRNAME_PREPARE],
1099 [AS_REQUIRE([_AS_EXPR_PREPARE])]dnl
1100 [if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
1101   as_dirname=dirname
1102 else
1103   as_dirname=false
1105 ])# _AS_DIRNAME_PREPARE
1108 # AS_ECHO(WORD)
1109 # -------------
1110 # Output WORD followed by a newline.  WORD must be a single shell word
1111 # (typically a quoted string).  The bytes of WORD are output as-is, even
1112 # if it starts with "-" or contains "\".
1113 m4_define([AS_ECHO],
1114 dnl Extra quoting in case 's' or 'n' are user-defined macros when this
1115 dnl is expanded; they almost certainly aren't meant to be used here.
1116 dnl See bug 110377.
1117 [printf '[%s\n]' $1])
1120 # AS_ECHO_N(WORD)
1121 # ---------------
1122 # Like AS_ECHO(WORD), except do not output the trailing newline.
1123 m4_define([AS_ECHO_N],
1124 dnl Extra quoting in case 's' is a user-defined macro when this
1125 dnl is expanded; it almost certainly isn't meant to be used here.
1126 dnl See bug 110377.
1127 [printf [%s] $1])
1130 # AS_TEST_X
1131 # ---------
1132 # Check whether a file has executable or search permissions.
1133 # FIXME: This macro is no longer useful; consider deleting it in 2014
1134 # after we ensure m4sh scripts can always find a shell with test -x.
1135 m4_defun_init([AS_TEST_X],
1136 [AS_REQUIRE([_AS_TEST_PREPARE])],
1137 [test -x $1[]])# AS_TEST_X
1140 # AS_EXECUTABLE_P
1141 # ---------------
1142 # Check whether a file is a regular file that has executable permissions.
1143 m4_defun_init([AS_EXECUTABLE_P],
1144 [AS_REQUIRE([_AS_TEST_PREPARE])],
1145 [as_fn_executable_p $1])# AS_EXECUTABLE_P
1148 # _AS_EXPR_PREPARE
1149 # ----------------
1150 # QNX 4.25 expr computes and issue the right result but exits with failure.
1151 # Tru64 expr mishandles leading zeros in numeric strings.
1152 # Detect these flaws.
1153 m4_defun([_AS_EXPR_PREPARE],
1154 [if expr a : '\(a\)' >/dev/null 2>&1 &&
1155    test "X`expr 00001 : '.*\(...\)'`" = X001; then
1156   as_expr=expr
1157 else
1158   as_expr=false
1160 ])# _AS_EXPR_PREPARE
1163 # _AS_ME_PREPARE
1164 # --------------
1165 # Define $as_me to the basename of the executable file's name.
1166 m4_defun([AS_ME_PREPARE], [AS_REQUIRE([_$0])])
1167 m4_defun([_AS_ME_PREPARE],
1168 [AS_REQUIRE([_AS_BASENAME_PREPARE])]dnl
1169 [as_me=`AS_BASENAME("$[0]")`
1172 # _AS_LINENO_WORKS
1173 # ----------------
1174 # Succeed if the currently executing shell supports LINENO.
1175 # This macro does not expand to a single shell command, so be careful
1176 # when using it.  Surrounding the body of this macro with {} would
1177 # cause "bash -c '_ASLINENO_WORKS'" to fail (with Bash 2.05, anyway),
1178 # but that bug is irrelevant to our use of LINENO.  We can't use
1179 # AS_VAR_ARITH, as this is expanded prior to shell functions.
1181 # Testing for LINENO support is hard; we use _AS_LINENO_WORKS inside
1182 # _AS_RUN, which sometimes eval's its argument (pdksh gives false
1183 # negatives if $LINENO is expanded by eval), and sometimes passes the
1184 # argument to another shell (if the current shell supports LINENO,
1185 # then expanding $LINENO prior to the string leads to false
1186 # positives).  Hence, we perform two tests, and coordinate with
1187 # _AS_DETECT_EXPAND (which ensures that only the first of two LINENO
1188 # is expanded in advance) and _AS_RUN (which sets $as_run to 'a' when
1189 # handing the test to another shell), so that we know which test to
1190 # trust.
1191 m4_define([_AS_LINENO_WORKS],
1192 [  as_lineno_1=$LINENO as_lineno_1a=$LINENO
1193   as_lineno_2=$LINENO as_lineno_2a=$LINENO
1194   eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
1195   test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"'])
1198 # _AS_LINENO_PREPARE
1199 # ------------------
1200 # If LINENO is not supported by the shell, produce a version of this
1201 # script where LINENO is hard coded.
1202 # Comparing LINENO against _oline_ is not a good solution, since in
1203 # the case of embedded executables (such as config.status within
1204 # configure) you'd compare LINENO wrt config.status vs. _oline_ wrt
1205 # configure.
1207 # AS_ERROR normally uses LINENO if logging, but AS_LINENO_PREPARE uses
1208 # AS_ERROR.  Besides, if the logging fd is open, we don't want to use
1209 # $LINENO in the log complaining about broken LINENO.  We break the
1210 # circular require by changing AS_ERROR and AS_MESSAGE_LOG_FD.
1211 m4_defun([AS_LINENO_PREPARE], [AS_REQUIRE([_$0])])
1212 m4_defun([_AS_LINENO_PREPARE],
1213 [AS_REQUIRE([_AS_CR_PREPARE])]dnl
1214 [AS_REQUIRE([_AS_ME_PREPARE])]dnl
1215 [_AS_DETECT_SUGGESTED([_AS_LINENO_WORKS])]dnl
1216 [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl
1217 [m4_pushdef([AS_ERROR],
1218   [{ AS_MESSAGE(]m4_dquote([error: $][1])[, [2]); AS_EXIT([1]); }])]dnl
1219 dnl Create $as_me.lineno as a copy of $as_myself, but with $LINENO
1220 dnl uniformly replaced by the line number.  The first 'sed' inserts a
1221 dnl line-number line after each line using $LINENO; the second 'sed'
1222 dnl does the real work.  The second script uses 'N' to pair each
1223 dnl line-number line with the line containing $LINENO, and appends
1224 dnl trailing '-' during substitution so that $LINENO is not a special
1225 dnl case at line end.  (Raja R Harinath suggested sed '=', and Paul
1226 dnl Eggert wrote the scripts with optimization help from Paolo Bonzini).
1227 [_AS_LINENO_WORKS || {
1228 [  # Blame Lee E. McMahon (1931-1989) for sed's syntax.  :-)
1229   sed -n '
1230     p
1231     /[$]LINENO/=
1232   ' <$as_myself |
1233     sed '
1234       t clear
1235       :clear
1236       s/[$]LINENO.*/&-/
1237       t lineno
1238       b
1239       :lineno
1240       N
1241       :loop
1242       s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
1243       t loop
1244       s/-\n.*//
1245     ' >$as_me.lineno &&
1246   chmod +x "$as_me.lineno"] ||
1247     AS_ERROR([cannot create $as_me.lineno; rerun with a POSIX shell])
1249   # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
1250   # already done that, so ensure we don't try to do so again and fall
1251   # in an infinite loop.  This has already happened in practice.
1252   _as_can_reexec=no; export _as_can_reexec
1253   # Don't try to exec as it changes $[0], causing all sort of problems
1254   # (the dirname of $[0] is not the place where we might find the
1255   # original and so on.  Autoconf is especially sensitive to this).
1256   . "./$as_me.lineno"
1257   # Exit status is that of the last command.
1258   exit
1260 _m4_popdef([AS_MESSAGE_LOG_FD], [AS_ERROR])])# _AS_LINENO_PREPARE
1263 # _AS_LN_S_PREPARE
1264 # ----------------
1265 # Don't use conftest.sym to avoid file name issues on DJGPP, where this
1266 # would yield conftest.sym.exe for DJGPP < 2.04.  And don't use 'conftest'
1267 # as base name to avoid prohibiting concurrency (e.g., concurrent
1268 # config.statuses).  On read-only media, assume 'cp -pR' and hope we
1269 # are just running --help anyway.
1270 m4_defun([_AS_LN_S_PREPARE],
1271 [rm -f conf$$ conf$$.exe conf$$.file
1272 if test -d conf$$.dir; then
1273   rm -f conf$$.dir/conf$$.file
1274 else
1275   rm -f conf$$.dir
1276   mkdir conf$$.dir 2>/dev/null
1278 if (echo >conf$$.file) 2>/dev/null; then
1279   if ln -s conf$$.file conf$$ 2>/dev/null; then
1280     as_ln_s='ln -s'
1281     # ... but there are two gotchas:
1282     # 1) On MSYS, both 'ln -s file dir' and 'ln file dir' fail.
1283     # 2) DJGPP < 2.04 has no symlinks; 'ln -s' creates a wrapper executable.
1284     # In both cases, we have to default to 'cp -pR'.
1285     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
1286       as_ln_s='cp -pR'
1287   elif ln conf$$.file conf$$ 2>/dev/null; then
1288     as_ln_s=ln
1289   else
1290     as_ln_s='cp -pR'
1291   fi
1292 else
1293   as_ln_s='cp -pR'
1295 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
1296 rmdir conf$$.dir 2>/dev/null
1297 ])# _AS_LN_S_PREPARE
1300 # AS_LN_S(FILE, LINK)
1301 # -------------------
1302 # FIXME: Should we add the glue code to handle properly relative symlinks
1303 # simulated with 'ln' or 'cp'?
1304 m4_defun_init([AS_LN_S],
1305 [AS_REQUIRE([_AS_LN_S_PREPARE])],
1306 [$as_ln_s $1 $2])
1309 # _AS_MKDIR_P
1310 # -----------
1311 # Emit code that can be used to emulate 'mkdir -p' with plain 'mkdir';
1312 # the code assumes that "$as_dir" contains the directory to create.
1313 # $as_dir is normalized, so there is no need to worry about using --.
1314 m4_define([_AS_MKDIR_P],
1315 [case $as_dir in #(
1316   -*) as_dir=./$as_dir;;
1317   esac
1318   test -d "$as_dir" || eval $as_mkdir_p || {
1319     as_dirs=
1320     while :; do
1321       case $as_dir in #(
1322       *\'*) as_qdir=`AS_ECHO(["$as_dir"]) | sed "s/'/'\\\\\\\\''/g"`;; #'(
1323       *) as_qdir=$as_dir;;
1324       esac
1325       as_dirs="'$as_qdir' $as_dirs"
1326       as_dir=`AS_DIRNAME("$as_dir")`
1327       test -d "$as_dir" && break
1328     done
1329     test -z "$as_dirs" || eval "mkdir $as_dirs"
1330   } || test -d "$as_dir" || AS_ERROR([cannot create directory $as_dir])
1333 # AS_MKDIR_P(DIR)
1334 # ---------------
1335 # Emulate 'mkdir -p' with plain 'mkdir' if needed.
1336 m4_defun_init([AS_MKDIR_P],
1337 [AS_REQUIRE([_$0_PREPARE])],
1338 [as_dir=$1; as_fn_mkdir_p])# AS_MKDIR_P
1341 # _AS_MKDIR_P_PREPARE
1342 # -------------------
1343 m4_defun([_AS_MKDIR_P_PREPARE],
1344 [AS_REQUIRE_SHELL_FN([as_fn_mkdir_p],
1345   [AS_FUNCTION_DESCRIBE([as_fn_mkdir_p], [],
1346     [Create "$as_dir" as a directory, including parents if necessary.])],
1348   _AS_MKDIR_P
1349 ])]dnl
1350 [if mkdir -p . 2>/dev/null; then
1351   as_mkdir_p='mkdir -p "$as_dir"'
1352 else
1353   test -d ./-p && rmdir ./-p
1354   as_mkdir_p=false
1356 ])# _AS_MKDIR_P_PREPARE
1359 # _AS_PATH_SEPARATOR_PREPARE
1360 # --------------------------
1361 # Compute the path separator.
1362 m4_defun([_AS_PATH_SEPARATOR_PREPARE],
1363 [# The user is always right.
1364 if ${PATH_SEPARATOR+false} :; then
1365   PATH_SEPARATOR=:
1366   (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
1367     (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
1368       PATH_SEPARATOR=';'
1369   }
1371 ])# _AS_PATH_SEPARATOR_PREPARE
1374 # _AS_PATH_WALK([PATH = $PATH], BODY, [IF-NOT-FOUND])
1375 # ---------------------------------------------------
1376 # Walk through PATH running BODY for each 'as_dir', with a trailing slash
1377 # already present.  If BODY never does a 'break', evaluate IF-NOT-FOUND.
1379 # Still very private as its interface looks quite bad.
1381 # '$as_dummy' forces splitting on constant user-supplied paths.
1382 # POSIX.2 field splitting is done only on the result of word
1383 # expansions, not on literal text.  This closes a longstanding sh security
1384 # hole.  Optimize it away when not needed, i.e., if there are no literal
1385 # path separators.
1386 m4_defun_init([_AS_PATH_WALK],
1387 [AS_REQUIRE([_AS_PATH_SEPARATOR_PREPARE])],
1388 [as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
1389 m4_ifvaln([$3], [as_found=false])dnl
1390 m4_if([$1], m4_translit([[$1]], [:;]),
1391 [for as_dir in m4_default([$1], [$PATH])],
1392 [as_dummy="$1"
1393 for as_dir in $as_dummy])
1395   IFS=$as_save_IFS
1396   case $as_dir in @%:@(((
1397     '') as_dir=./ ;;
1398     */) ;;
1399     *) as_dir=$as_dir/ ;;
1400   esac
1401   m4_ifvaln([$3], [as_found=:])dnl
1402   $2
1403   m4_ifvaln([$3], [as_found=false])dnl
1404 done
1405 IFS=$as_save_IFS
1406 m4_ifvaln([$3], [AS_IF([$as_found], [], [$3])])dnl
1410 # AS_SET_CATFILE(VAR, DIR-NAME, FILE-NAME)
1411 # ----------------------------------------
1412 # Set VAR to DIR-NAME/FILE-NAME.
1413 # Optimize the common case where $2 or $3 is '.'.
1414 m4_define([AS_SET_CATFILE],
1415 [case $2 in @%:@((
1416 .) AS_VAR_SET([$1], [$3]);;
1418   case $3 in @%:@(((
1419   .) AS_VAR_SET([$1], [$2]);;
1420   [[\\/]]* | ?:[[\\/]]* ) AS_VAR_SET([$1], [$3]);;
1421   *) AS_VAR_SET([$1], [$2/$3]);;
1422   esac;;
1423 esac[]])# AS_SET_CATFILE
1426 # _AS_TEST_X_WORKS
1427 # ----------------
1428 # These days, we require that 'test -x' works.
1429 m4_define([_AS_TEST_X_WORKS], [test -x /])
1431 # _AS_TEST_PREPARE
1432 # ----------------
1433 # Provide back-compat to people that hooked into our undocumented
1434 # internals (here's looking at you, libtool).
1435 m4_defun([_AS_TEST_PREPARE],
1436 [AS_REQUIRE_SHELL_FN([as_fn_executable_p],
1437   [AS_FUNCTION_DESCRIBE([as_fn_executable_p], [FILE],
1438     [Test if FILE is an executable regular file.])],
1439   [  test -f "$[]1" && test -x "$[]1"])]dnl
1440 [as_test_x='test -x'
1441 as_executable_p=as_fn_executable_p
1442 ])# _AS_TEST_PREPARE
1447 ## ------------------ ##
1448 ## 5. Common idioms.  ##
1449 ## ------------------ ##
1451 # This section is lexicographically sorted.
1454 # AS_BOX(MESSAGE, [FRAME-CHARACTER = '-'])
1455 # ----------------------------------------
1456 # Output MESSAGE, a single line text, framed with FRAME-CHARACTER (which
1457 # must not be '/').
1458 m4_define([AS_BOX],
1459 [_$0(m4_expand([$1]), [$2])])
1461 m4_define([_AS_BOX],
1462 [m4_if(m4_index(m4_translit([[$1]], [`\"], [$$$]), [$]),
1463   [-1], [$0_LITERAL], [$0_INDIR])($@)])
1466 # _AS_BOX_LITERAL(MESSAGE, [FRAME-CHARACTER = '-'])
1467 # -------------------------------------------------
1468 m4_define([_AS_BOX_LITERAL],
1469 [AS_ECHO(["_AS_ESCAPE(m4_dquote(m4_expand([m4_text_box($@)])), [`], [\"$])"])])
1472 # _AS_BOX_INDIR(MESSAGE, [FRAME-CHARACTER = '-'])
1473 # -----------------------------------------------
1474 m4_define([_AS_BOX_INDIR],
1475 [sed 'h;s/./m4_default([$2], [-])/g;s/^.../@%:@@%:@ /;s/...$/ @%:@@%:@/;p;x;p;x' <<_ASBOX
1476 @%:@@%:@ $1 @%:@@%:@
1477 _ASBOX])
1480 # _AS_CLEAN_DIR(DIR)
1481 # ------------------
1482 # Remove all contents from within DIR, including any unwritable
1483 # subdirectories, but leave DIR itself untouched.
1484 m4_define([_AS_CLEAN_DIR],
1485 [if test -d $1
1486 then
1487   find $1 -type d ! -perm -700 -exec chmod u+rwx {} \;
1488   rm -fr $1/* $1/.[[!.]] $1/.??*
1489 fi])
1492 # AS_FUNCTION_DESCRIBE(NAME, [ARGS], DESCRIPTION, [WRAP-COLUMN = 79])
1493 # -------------------------------------------------------------------
1494 # Output a shell comment describing NAME and its arguments ARGS, then
1495 # a separator line, then the DESCRIPTION wrapped at WRAP-COLUMN.
1496 # The output resembles:
1497 #  # NAME ARGS
1498 #  # ---------
1499 #  # Wrapped DESCRIPTION text
1500 # NAME and ARGS are expanded, while DESCRIPTION is treated as a
1501 # whitespace-separated list of strings that are not expanded.
1502 m4_define([AS_FUNCTION_DESCRIBE],
1503 [@%:@ $1[]m4_ifval([$2], [ $2])
1504 @%:@ m4_translit(m4_format([%*s],
1505            m4_decr(m4_qlen(_m4_expand([$1[]m4_ifval([$2], [ $2])
1506 ]))), []), [ ], [-])
1507 m4_text_wrap([$3], [@%:@ ], [], [$4])])
1510 # AS_HELP_STRING(LHS, RHS, [INDENT-COLUMN = 26], [WRAP-COLUMN = 79])
1511 # ------------------------------------------------------------------
1513 # Format a help string so that it looks pretty when the user executes
1514 # "script --help".  This macro takes up to four arguments, a
1515 # "left hand side" (LHS), a "right hand side" (RHS),
1516 # INDENT-COLUMN which is the column where wrapped lines should begin
1517 # (the default of 26 is recommended), and WRAP-COLUMN which is
1518 # the column where lines should wrap (the default of 79 is recommended).
1519 # LHS is expanded, RHS is not.
1521 # For backwards compatibility not documented in the manual, INDENT-COLUMN
1522 # can also be specified as a string of white spaces, whose width
1523 # determines the indentation column.  Using TABs in INDENT-COLUMN is not
1524 # recommended, since screen width of TAB is not computed.
1526 # The resulting string is suitable for use in other macros that require
1527 # a help string (e.g. AC_ARG_WITH).
1529 # Here is the sample string from the Autoconf manual (Node: External
1530 # Software) which shows the proper spacing for help strings.
1532 #    --with-readline         support fancy command line editing
1533 #  ^ ^                       ^
1534 #  | |                       |
1535 #  | column 2                column 26
1536 #  |
1537 #  column 0
1539 # A help string is made up of a "left hand side" (LHS) and a "right
1540 # hand side" (RHS).  In the example above, the LHS is
1541 # "--with-readline", while the RHS is "support fancy command line
1542 # editing".
1544 # If the LHS contains more than (INDENT-COLUMN - 3) characters, then the
1545 # LHS is terminated with a newline so that the RHS starts on a line of its
1546 # own beginning at INDENT-COLUMN.  In the default case, this corresponds to an
1547 # LHS with more than 23 characters.
1549 # Therefore, in the example, if the LHS were instead
1550 # "--with-readline-blah-blah-blah", then the AS_HELP_STRING macro would
1551 # expand into:
1554 #    --with-readline-blah-blah-blah
1555 #  ^ ^                       support fancy command line editing
1556 #  | |                       ^
1557 #  | column 2                |
1558 #  column 0                  column 26
1561 # m4_text_wrap hacks^Wworks around the fact that m4_format does not
1562 # know quadrigraphs.
1564 m4_define([AS_HELP_STRING],
1565 [m4_text_wrap([$2], m4_cond([[$3]], [], [                          ],
1566                             [m4_eval([$3]+0)], [0], [[$3]],
1567                             [m4_format([[%*s]], [$3], [])]),
1568               m4_expand([  $1 ]), [$4])])# AS_HELP_STRING
1571 # AS_IDENTIFIER_IF(EXPRESSION, IF-IDENT, IF-NOT-IDENT)
1572 # ----------------------------------------------------
1573 # If EXPRESSION serves as an identifier (ie, after removal of @&t@, it
1574 # matches the regex '^[a-zA-Z_][a-zA-Z_0-9]*$'), execute IF-IDENT,
1575 # otherwise IF-NOT-IDENT.
1577 # This is generally faster than the alternative:
1578 #   m4_bmatch(m4_bpatsubst([[$1]], [@&t@]), ^m4_defn([m4_re_word])$,
1579 #             [$2], [$3])
1581 # Rather than expand m4_defn every time AS_IDENTIFIER_IF is expanded, we
1582 # inline its expansion up front.  Only use a regular expression if we
1583 # detect a potential quadrigraph.
1585 # First, check if the entire string matches m4_cr_symbol2.  Only then do
1586 # we worry if the first character also matches m4_cr_symbol1 (ie. does not
1587 # match m4_cr_digit).
1588 m4_define([AS_IDENTIFIER_IF],
1589 [m4_if(_$0(m4_if(m4_index([$1], [@]), [-1],
1590   [[$1]], [m4_bpatsubst([[$1]], [@&t@])])), [-], [$2], [$3])])
1592 m4_define([_AS_IDENTIFIER_IF],
1593 [m4_cond([[$1]], [], [],
1594          [m4_eval(m4_len(m4_translit([[$1]], ]]dnl
1595 m4_dquote(m4_dquote(m4_defn([m4_cr_symbols2])))[[)) > 0)], [1], [],
1596          [m4_len(m4_translit(m4_format([[%.1s]], [$1]), ]]dnl
1597 m4_dquote(m4_dquote(m4_defn([m4_cr_symbols1])))[[))], [0], [-])])
1600 # AS_LITERAL_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL,
1601 #               [IF-SIMPLE-REF = IF-NOT-LITERAL])
1602 # -----------------------------------------------------
1603 # If EXPRESSION has no shell indirections ($var or `expr`), expand
1604 # IF-LITERAL, else IF-NOT-LITERAL.  In some cases, IF-NOT-LITERAL
1605 # must be complex to safely deal with ``, while a simpler
1606 # expression IF-SIMPLE-REF can be used if the indirection
1607 # involves only shell variable expansion (as in ${varname}).
1609 # EXPRESSION is treated as a literal if it results in the same
1610 # interpretation whether it is unquoted or contained within double
1611 # quotes, with the exception that whitespace is ignored (on the
1612 # assumption that it will be flattened to _).  Therefore, neither '\$'
1613 # nor 'a''b' is a literal, since both backslash and single quotes have
1614 # different quoting behavior in the two contexts; and 'a*' is not a
1615 # literal, because it has different globbing.  Note, however, that
1616 # while '${a+b}' is neither a literal nor a simple ref, 'a+b' is a
1617 # literal.  This macro is an *approximation*: it is possible that
1618 # there are some EXPRESSIONs which the shell would treat as literals,
1619 # but which this macro does not recognize.
1621 # Why do we reject EXPRESSION expanding with '[' or ']' as a literal?
1622 # Because AS_TR_SH is MUCH faster if it can use m4_translit on literals
1623 # instead of m4_bpatsubst; but m4_translit is much tougher to do safely
1624 # if '[' is translated.  That, and file globbing matters.
1626 # Note that the quadrigraph @S|@ can result in non-literals, but outright
1627 # rejecting all @ would make AC_INIT complain on its bug report address.
1629 # We used to use m4_bmatch(m4_quote($1), [[`$]], [$3], [$2]), but
1630 # profiling shows that it is faster to use m4_translit.
1632 # Because the translit is stripping quotes, it must also neutralize
1633 # anything that might be in a macro name, as well as comments, commas,
1634 # or unbalanced parentheses.  Valid shell variable characters and
1635 # unambiguous literal characters are deleted ('a.b'), and remaining
1636 # characters are normalized into '$' if they can form simple refs
1637 # (${a}), '+' if they can potentially form literals (a+b), '`' if they
1638 # can interfere with m4 parsing, or left alone otherwise.  If both '$'
1639 # and '+' are left, it is treated as a complex reference (${a+b}),
1640 # even though it could technically be a simple reference (${a}+b).
1641 # _AS_LITERAL_IF_ only has to check for an empty string after removing
1642 # one of the two normalized characters.
1644 # Rather than expand m4_defn every time AS_LITERAL_IF is expanded, we
1645 # inline its expansion up front.  _AS_LITERAL_IF expands to the name
1646 # of a macro that takes three arguments: IF-SIMPLE-REF,
1647 # IF-NOT-LITERAL, IF-LITERAL.  It also takes an optional argument of
1648 # any additional characters to allow as literals (useful for AS_TR_SH
1649 # and AS_TR_CPP to perform inline conversion of whitespace to _).  The
1650 # order of the arguments allows reuse of m4_default.
1651 m4_define([AS_LITERAL_IF],
1652 [_$0(m4_expand([$1]), [  ][
1653 ])([$4], [$3], [$2])])
1655 m4_define([_AS_LITERAL_IF],
1656 [m4_if(m4_index([$1], [@S|@]), [-1], [$0_(m4_translit([$1],
1657   [-:=%/@{}[]#(),.$2]]]m4_dquote(m4_dquote(m4_defn([m4_cr_symbols2])))[[,
1658   [++++++$$`````]))], [$0_NO])])
1660 m4_define([_AS_LITERAL_IF_],
1661 [m4_if(m4_translit([$1], [+]), [], [$0YES],
1662        m4_translit([$1], [$]), [], [m4_default], [$0NO])])
1664 m4_define([_AS_LITERAL_IF_YES], [$3])
1665 m4_define([_AS_LITERAL_IF_NO], [$2])
1667 # AS_LITERAL_WORD_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL,
1668 #                    [IF-SIMPLE-REF = IF-NOT-LITERAL])
1669 # ----------------------------------------------------------
1670 # Like AS_LITERAL_IF, except that spaces and tabs in EXPRESSION
1671 # are treated as non-literal.
1672 m4_define([AS_LITERAL_WORD_IF],
1673 [_AS_LITERAL_IF(m4_expand([$1]))([$4], [$3], [$2])])
1675 # AS_LITERAL_HEREDOC_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL)
1676 # -------------------------------------------------------------
1677 # Like AS_LITERAL_IF, except that a string is considered literal
1678 # if it results in the same output in both quoted and unquoted
1679 # here-documents.
1680 m4_define([AS_LITERAL_HEREDOC_IF],
1681 [_$0(m4_expand([$1]))([$2], [$3])])
1683 m4_define([_AS_LITERAL_HEREDOC_IF],
1684 [m4_if(m4_index([$1], [@S|@]), [-1],
1685   [m4_if(m4_index(m4_translit([[$1]], [\`], [$]), [$]), [-1],
1686     [$0_YES], [$0_NO])],
1687   [$0_NO])])
1689 m4_define([_AS_LITERAL_HEREDOC_IF_YES], [$1])
1690 m4_define([_AS_LITERAL_HEREDOC_IF_NO], [$2])
1693 # AS_TMPDIR(PREFIX, [DIRECTORY = $TMPDIR [= /tmp]])
1694 # -------------------------------------------------
1695 # Create as safely as possible a temporary directory in DIRECTORY
1696 # which name is inspired by PREFIX (should be 2-4 chars max).
1698 # Even though $tmp does not fit our normal naming scheme of $as_*,
1699 # it is a documented part of the public API and must not be changed.
1700 m4_define([AS_TMPDIR],
1701 [# Create a (secure) tmp directory for tmp files.
1702 m4_if([$2], [], [: "${TMPDIR:=/tmp}"])
1704   tmp=`(umask 077 && mktemp -d "m4_default([$2],
1705     [$TMPDIR])/$1XXXXXX") 2>/dev/null` &&
1706   test -d "$tmp"
1707 }  ||
1709   tmp=m4_default([$2], [$TMPDIR])/$1$$-$RANDOM
1710   (umask 077 && mkdir "$tmp")
1711 } || AS_ERROR([cannot create a temporary directory in m4_default([$2],
1712               [$TMPDIR])])])# AS_TMPDIR
1715 # AS_UNAME
1716 # --------
1717 # Try to describe this machine.  Meant for logs.
1718 m4_define([AS_UNAME],
1720 cat <<_ASUNAME
1721 m4_text_box([Platform.])
1723 hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
1724 uname -m = `(uname -m) 2>/dev/null || echo unknown`
1725 uname -r = `(uname -r) 2>/dev/null || echo unknown`
1726 uname -s = `(uname -s) 2>/dev/null || echo unknown`
1727 uname -v = `(uname -v) 2>/dev/null || echo unknown`
1729 /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
1730 /bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
1732 /bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
1733 /usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
1734 /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
1735 /usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`
1736 /bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
1737 /usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
1738 /bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
1740 _ASUNAME
1742 _AS_PATH_WALK([$PATH], [AS_ECHO(["PATH: $as_dir"])])
1746 # _AS_VERSION_COMPARE_PREPARE
1747 # ---------------------------
1748 # Output variables for comparing version numbers.
1749 m4_defun([_AS_VERSION_COMPARE_PREPARE],
1750 [[as_awk_strverscmp='
1751   # Use only awk features that work with 7th edition Unix awk (1978).
1752   # My, what an old awk you have, Mr. Solaris!
1753   END {
1754     while (length(v1) && length(v2)) {
1755       # Set d1 to be the next thing to compare from v1, and likewise for d2.
1756       # Normally this is a single character, but if v1 and v2 contain digits,
1757       # compare them as integers and fractions as strverscmp does.
1758       if (v1 ~ /^[0-9]/ && v2 ~ /^[0-9]/) {
1759         # Split v1 and v2 into their leading digit string components d1 and d2,
1760         # and advance v1 and v2 past the leading digit strings.
1761         for (len1 = 1; substr(v1, len1 + 1) ~ /^[0-9]/; len1++) continue
1762         for (len2 = 1; substr(v2, len2 + 1) ~ /^[0-9]/; len2++) continue
1763         d1 = substr(v1, 1, len1); v1 = substr(v1, len1 + 1)
1764         d2 = substr(v2, 1, len2); v2 = substr(v2, len2 + 1)
1765         if (d1 ~ /^0/) {
1766           if (d2 ~ /^0/) {
1767             # Compare two fractions.
1768             while (d1 ~ /^0/ && d2 ~ /^0/) {
1769               d1 = substr(d1, 2); len1--
1770               d2 = substr(d2, 2); len2--
1771             }
1772             if (len1 != len2 && ! (len1 && len2 && substr(d1, 1, 1) == substr(d2, 1, 1))) {
1773               # The two components differ in length, and the common prefix
1774               # contains only leading zeros.  Consider the longer to be less.
1775               d1 = -len1
1776               d2 = -len2
1777             } else {
1778               # Otherwise, compare as strings.
1779               d1 = "x" d1
1780               d2 = "x" d2
1781             }
1782           } else {
1783             # A fraction is less than an integer.
1784             exit 1
1785           }
1786         } else {
1787           if (d2 ~ /^0/) {
1788             # An integer is greater than a fraction.
1789             exit 2
1790           } else {
1791             # Compare two integers.
1792             d1 += 0
1793             d2 += 0
1794           }
1795         }
1796       } else {
1797         # The normal case, without worrying about digits.
1798         d1 = substr(v1, 1, 1); v1 = substr(v1, 2)
1799         d2 = substr(v2, 1, 1); v2 = substr(v2, 2)
1800       }
1801       if (d1 < d2) exit 1
1802       if (d1 > d2) exit 2
1803     }
1804     # Beware Solaris /usr/xgp4/bin/awk (at least through Solaris 10),
1805     # which mishandles some comparisons of empty strings to integers.
1806     if (length(v2)) exit 1
1807     if (length(v1)) exit 2
1808   }
1809 ']])# _AS_VERSION_COMPARE_PREPARE
1812 # AS_VERSION_COMPARE(VERSION-1, VERSION-2,
1813 #                    [ACTION-IF-LESS], [ACTION-IF-EQUAL], [ACTION-IF-GREATER])
1814 # ----------------------------------------------------------------------------
1815 # Compare two strings possibly containing shell variables as version strings.
1817 # This usage is portable even to ancient awk,
1818 # so don't worry about finding a "nice" awk version.
1819 m4_defun_init([AS_VERSION_COMPARE],
1820 [AS_REQUIRE([_$0_PREPARE])],
1821 [as_arg_v1=$1
1822 as_arg_v2=$2
1823 awk "$as_awk_strverscmp" v1="$as_arg_v1" v2="$as_arg_v2" /dev/null
1824 AS_CASE([$?],
1825         [1], [$3],
1826         [0], [$4],
1827         [2], [$5])])# AS_VERSION_COMPARE
1831 ## --------------------------------------- ##
1832 ## 6. Common m4/sh character translation.  ##
1833 ## --------------------------------------- ##
1835 # The point of this section is to provide high level macros comparable
1836 # to m4's 'translit' primitive, but m4/sh polymorphic.
1837 # Transliteration of literal strings should be handled by m4, while
1838 # shell variables' content will be translated at runtime (tr or sed).
1841 # _AS_CR_PREPARE
1842 # --------------
1843 # Output variables defining common character ranges.
1844 # See m4_cr_letters etc.
1845 m4_defun([_AS_CR_PREPARE],
1846 [# Avoid depending upon Character Ranges.
1847 as_cr_letters='abcdefghijklmnopqrstuvwxyz'
1848 as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
1849 as_cr_Letters=$as_cr_letters$as_cr_LETTERS
1850 as_cr_digits='0123456789'
1851 as_cr_alnum=$as_cr_Letters$as_cr_digits
1855 # _AS_TR_SH_PREPARE
1856 # -----------------
1857 m4_defun([_AS_TR_SH_PREPARE],
1858 [AS_REQUIRE([_AS_CR_PREPARE])]dnl
1859 [# Sed expression to map a string onto a valid variable name.
1860 as_sed_sh="y%*+%pp%;s%[[^_$as_cr_alnum]]%_%g"
1861 as_tr_sh="eval sed '$as_sed_sh'" # deprecated
1865 # AS_TR_SH(EXPRESSION)
1866 # --------------------
1867 # Transform EXPRESSION into a valid shell variable name.
1868 # sh/m4 polymorphic.
1869 # Be sure to update the definition of '$as_sed_sh' if you change this.
1871 # AS_LITERAL_IF guarantees that a literal does not have any nested quotes,
1872 # once $1 is expanded.  m4_translit silently uses only the first occurrence
1873 # of a character that appears multiple times in argument 2, since we know
1874 # that m4_cr_not_symbols2 also contains [ and ].  m4_translit also silently
1875 # ignores characters in argument 3 that do not match argument 2; we use this
1876 # fact to skip worrying about the length of m4_cr_not_symbols2.
1878 # For speed, we inline the literal definitions that can be computed up front.
1879 m4_defun_init([AS_TR_SH],
1880 [AS_REQUIRE([_$0_PREPARE])],
1881 [_$0(m4_expand([$1]))])
1883 m4_define([_AS_TR_SH],
1884 [_AS_LITERAL_IF([$1], [*][       ][
1885 ])([], [$0_INDIR], [$0_LITERAL])([$1])])
1887 m4_define([_AS_TR_SH_LITERAL],
1888 [m4_translit([[$1]],
1889   [*+[]]]m4_dquote(m4_defn([m4_cr_not_symbols2]))[,
1890   [pp[]]]m4_dquote(m4_for(,1,255,,[[_]]))[)])
1892 m4_define([_AS_TR_SH_INDIR],
1893 [`AS_ECHO(["_AS_ESCAPE([[$1]], [`], [\])"]) | sed "$as_sed_sh"`])
1896 # _AS_TR_CPP_PREPARE
1897 # ------------------
1898 m4_defun([_AS_TR_CPP_PREPARE],
1899 [AS_REQUIRE([_AS_CR_PREPARE])]dnl
1900 [# Sed expression to map a string onto a valid CPP name.
1901 as_sed_cpp="y%*$as_cr_letters%P$as_cr_LETTERS%;s%[[^_$as_cr_alnum]]%_%g"
1902 as_tr_cpp="eval sed '$as_sed_cpp'" # deprecated
1906 # AS_TR_CPP(EXPRESSION)
1907 # ---------------------
1908 # Map EXPRESSION to an upper case string which is valid as rhs for a
1909 # '#define'.  sh/m4 polymorphic.  Be sure to update the definition
1910 # of '$as_sed_cpp' if you change this.
1912 # See implementation comments in AS_TR_SH.
1913 m4_defun_init([AS_TR_CPP],
1914 [AS_REQUIRE([_$0_PREPARE])],
1915 [_$0(m4_expand([$1]))])
1917 m4_define([_AS_TR_CPP],
1918 [_AS_LITERAL_IF([$1], [*][       ][
1919 ])([], [$0_INDIR], [$0_LITERAL])([$1])])
1921 m4_define([_AS_TR_CPP_LITERAL],
1922 [m4_translit([[$1]],
1923   [*[]]]m4_dquote(m4_defn([m4_cr_letters])m4_defn([m4_cr_not_symbols2]))[,
1924   [P[]]]m4_dquote(m4_defn([m4_cr_LETTERS])m4_for(,1,255,,[[_]]))[)])
1926 m4_define([_AS_TR_CPP_INDIR],
1927 [`AS_ECHO(["_AS_ESCAPE([[$1]], [`], [\])"]) | sed "$as_sed_cpp"`])
1930 # _AS_TR_PREPARE
1931 # --------------
1932 m4_defun([_AS_TR_PREPARE],
1933 [AS_REQUIRE([_AS_TR_SH_PREPARE])AS_REQUIRE([_AS_TR_CPP_PREPARE])])
1938 ## ------------------------------------------------------ ##
1939 ## 7. Common m4/sh handling of variables (indirections).  ##
1940 ## ------------------------------------------------------ ##
1943 # The purpose of this section is to provide a uniform API for
1944 # reading/setting sh variables with or without indirection.
1945 # Typically, one can write
1946 #   AS_VAR_SET(var, val)
1947 # or
1948 #   AS_VAR_SET(as_$var, val)
1949 # and expect the right thing to happen.  In the descriptions below,
1950 # a literal name matches the regex [a-zA-Z_][a-zA-Z0-9_]*, an
1951 # indirect name is a shell expression that produces a literal name
1952 # when passed through eval, and a polymorphic name is either type.
1955 # _AS_VAR_APPEND_PREPARE
1956 # ----------------------
1957 # Define as_fn_append to the optimum definition for the current
1958 # shell (bash and zsh provide the += assignment operator to avoid
1959 # quadratic append growth over repeated appends).
1960 m4_defun([_AS_VAR_APPEND_PREPARE],
1961 [AS_FUNCTION_DESCRIBE([as_fn_append], [VAR VALUE],
1962 [Append the text in VALUE to the end of the definition contained in
1963 VAR.  Take advantage of any shell optimizations that allow amortized
1964 linear growth over repeated appends, instead of the typical quadratic
1965 growth present in naive implementations.])
1966 AS_IF([_AS_RUN(["AS_ESCAPE(m4_quote(_AS_VAR_APPEND_WORKS))"])],
1967 [eval 'as_fn_append ()
1968   {
1969     eval $[]1+=\$[]2
1970   }'],
1971 [as_fn_append ()
1972   {
1973     eval $[]1=\$$[]1\$[]2
1974   }]) # as_fn_append
1977 # _AS_VAR_APPEND_WORKS
1978 # --------------------
1979 # Output a shell test to discover whether += works.
1980 m4_define([_AS_VAR_APPEND_WORKS],
1981 [as_var=1; as_var+=2; test x$as_var = x12])
1983 # AS_VAR_APPEND(VAR, VALUE)
1984 # -------------------------
1985 # Append the shell expansion of VALUE to the end of the existing
1986 # contents of the polymorphic shell variable VAR, taking advantage of
1987 # any shell optimizations that allow repeated appends to result in
1988 # amortized linear scaling rather than quadratic behavior.  This macro
1989 # is not worth the overhead unless the expected final size of the
1990 # contents of VAR outweigh the typical VALUE size of repeated appends.
1991 # Note that unlike AS_VAR_SET, VALUE must be properly quoted to avoid
1992 # field splitting and file name expansion.
1993 m4_defun_init([AS_VAR_APPEND],
1994 [AS_REQUIRE([_AS_VAR_APPEND_PREPARE], [], [M4SH-INIT-FN])],
1995 [as_fn_append $1 $2])
1998 # _AS_VAR_ARITH_PREPARE
1999 # ---------------------
2000 # Define as_fn_arith to the optimum definition for the current
2001 # shell (using POSIX $(()) where supported).
2002 m4_defun([_AS_VAR_ARITH_PREPARE],
2003 [AS_FUNCTION_DESCRIBE([as_fn_arith], [ARG...],
2004 [Perform arithmetic evaluation on the ARGs, and store the result in
2005 the global $as_val.  Take advantage of shells that can avoid forks.
2006 The arguments must be portable across $(()) and expr.])
2007 AS_IF([_AS_RUN(["AS_ESCAPE(m4_quote(_AS_VAR_ARITH_WORKS))"])],
2008 [eval 'as_fn_arith ()
2009   {
2010     as_val=$(( $[]* ))
2011   }'],
2012 [as_fn_arith ()
2013   {
2014     as_val=`expr "$[]@" || test $? -eq 1`
2015   }]) # as_fn_arith
2018 # _AS_VAR_ARITH_WORKS
2019 # -------------------
2020 # Output a shell test to discover whether $(()) works.
2021 m4_define([_AS_VAR_ARITH_WORKS],
2022 [test $(( 1 + 1 )) = 2])
2024 # AS_VAR_ARITH(VAR, EXPR)
2025 # -----------------------
2026 # Perform the arithmetic evaluation of the arguments in EXPR, and set
2027 # contents of the polymorphic shell variable VAR to the result, taking
2028 # advantage of any shell optimizations that perform arithmetic without
2029 # forks.  Because EXPR might be evaluated via either $((...)) or the
2030 # 'expr' command, EXPR's syntax is limited; see the Autoconf manual.
2031 m4_defun_init([AS_VAR_ARITH],
2032 [_AS_DETECT_SUGGESTED([_AS_VAR_ARITH_WORKS])]dnl
2033 [AS_REQUIRE([_AS_VAR_ARITH_PREPARE], [], [M4SH-INIT-FN])],
2034 [as_fn_arith $2 && AS_VAR_SET([$1], [$as_val])])
2037 # AS_VAR_COPY(DEST, SOURCE)
2038 # -------------------------
2039 # Set the polymorphic shell variable DEST to the contents of the polymorphic
2040 # shell variable SOURCE.
2041 m4_define([AS_VAR_COPY],
2042 [AS_LITERAL_WORD_IF([$1[]$2], [$1=$$2], [eval $1=\$$2])])
2045 # AS_VAR_GET(VARIABLE)
2046 # --------------------
2047 # Get the value of the shell VARIABLE.
2048 # Evaluates to $VARIABLE if there is no indirection in VARIABLE,
2049 # else to the appropriate 'eval' sequence.
2050 # This macro is deprecated because it sometimes mishandles trailing newlines;
2051 # use AS_VAR_COPY instead.
2052 m4_define([AS_VAR_GET],
2053 [AS_LITERAL_WORD_IF([$1],
2054                [$$1],
2055   [`eval 'as_val=${'_AS_ESCAPE([[$1]], [`], [\])'};printf "[%s\\n]" "$as_val"'`])])
2058 # AS_VAR_IF(VARIABLE, VALUE, IF-TRUE, IF-FALSE)
2059 # ---------------------------------------------
2060 # Implement a shell 'if test $VARIABLE = VALUE; then-else'.
2061 # Polymorphic, and avoids sh expansion error upon interrupt or term signal.
2062 m4_define([AS_VAR_IF],
2063 [AS_LITERAL_WORD_IF([$1],
2064   [AS_IF(m4_ifval([$2], [[test "x$$1" = x[]$2]], [[${$1:+false} :]])],
2065   [AS_VAR_COPY([as_val], [$1])
2066    AS_IF(m4_ifval([$2], [[test "x$as_val" = x[]$2]], [[${as_val:+false} :]])],
2067   [AS_IF(m4_ifval([$2],
2068     [[eval test \"x\$"$1"\" = x"_AS_ESCAPE([$2], [`], [\"$])"]],
2069     [[eval \${$1:+false} :]])]),
2070 [$3], [$4])])
2073 # AS_VAR_PUSHDEF and AS_VAR_POPDEF
2074 # --------------------------------
2077 # Sometimes we may have to handle literals (e.g. 'stdlib.h'), while at
2078 # other moments, the same code may have to get the value from a
2079 # variable (e.g., 'ac_header').  To have a uniform handling of both
2080 # cases, when a new value is about to be processed, declare a local
2081 # variable, e.g.:
2083 #   AS_VAR_PUSHDEF([header], [ac_cv_header_$1])
2085 # and then in the body of the macro, use 'header' as is.  It is of
2086 # first importance to use 'AS_VAR_*' to access this variable.
2088 # If the value '$1' was a literal (e.g. 'stdlib.h'), then 'header' is
2089 # in fact the value 'ac_cv_header_stdlib_h'.  If '$1' was indirect,
2090 # then the value of 'header' in m4 is in fact '$as_header', the shell
2091 # variable that holds all of the magic to get the expansion right.
2093 # At the end of the block, free the variable with
2095 #   AS_VAR_POPDEF([header])
2098 # AS_VAR_POPDEF(VARNAME)
2099 # ----------------------
2100 # Free the shell variable accessor VARNAME.  To be dnl'ed.
2101 m4_define([AS_VAR_POPDEF],
2102 [m4_popdef([$1])])
2105 # AS_VAR_PUSHDEF(VARNAME, VALUE)
2106 # ------------------------------
2107 # Define the m4 macro VARNAME to an accessor to the shell variable
2108 # named VALUE.  VALUE does not need to be a valid shell variable name:
2109 # the transliteration is handled here.  To be dnl'ed.
2111 # AS_TR_SH attempts to play with diversions if _AS_TR_SH_PREPARE has
2112 # not been expanded.  However, users are expected to do subsequent
2113 # calls that trigger AS_LITERAL_IF([VARNAME]), and that macro performs
2114 # expansion inside an argument collection context, where diversions
2115 # don't work.  Therefore, we must require the preparation ourselves.
2116 m4_defun_init([AS_VAR_PUSHDEF],
2117 [AS_REQUIRE([_AS_TR_SH_PREPARE])],
2118 [_$0([$1], m4_expand([$2]))])
2120 m4_define([_AS_VAR_PUSHDEF],
2121 [_AS_LITERAL_IF([$2], [  ][
2122 ])([], [as_$1=_AS_TR_SH_INDIR([$2])
2123 m4_pushdef([$1], [$as_[$1]])],
2124 [m4_pushdef([$1], [_AS_TR_SH_LITERAL([$2])])])])
2127 # AS_VAR_SET(VARIABLE, VALUE)
2128 # ---------------------------
2129 # Set the contents of the polymorphic shell VARIABLE to the shell
2130 # expansion of VALUE.  VALUE is immune to field splitting and file
2131 # name expansion.
2132 m4_define([AS_VAR_SET],
2133 [AS_LITERAL_WORD_IF([$1],
2134                [$1=$2],
2135                [eval "$1=_AS_ESCAPE([$2], [`], [\"$])"])])
2138 # AS_VAR_SET_IF(VARIABLE, IF-TRUE, IF-FALSE)
2139 # ------------------------------------------
2140 # Implement a shell 'if-then-else' depending whether VARIABLE is set
2141 # or not.  Polymorphic.
2142 m4_define([AS_VAR_SET_IF],
2143 [AS_IF([AS_VAR_TEST_SET([$1])], [$2], [$3])])
2146 # AS_VAR_TEST_SET(VARIABLE)
2147 # -------------------------
2148 # Expands into an expression which is true if VARIABLE
2149 # is set.  Polymorphic.
2150 m4_define([AS_VAR_TEST_SET],
2151 [AS_LITERAL_WORD_IF([$1],
2152   [test ${$1+y}],
2153   [{ as_var=$1; eval test \${$as_var+y}; }],
2154   [eval test \${$1+y}])])
2157 ## -------------------- ##
2158 ## 8. Setting M4sh up.  ##
2159 ## -------------------- ##
2162 # AS_INIT_GENERATED(FILE, [COMMENT])
2163 # ----------------------------------
2164 # Generate a child script FILE with all initialization necessary to
2165 # reuse the environment learned by the parent script, and make the
2166 # file executable.  If COMMENT is supplied, it is inserted after the
2167 # '#!' sequence but before initialization text begins.  After this
2168 # macro, additional text can be appended to FILE to form the body of
2169 # the child script.  The macro ends with non-zero status if the
2170 # file could not be fully written (such as if the disk is full).
2171 m4_defun([AS_INIT_GENERATED],
2172 [m4_require([AS_PREPARE])]dnl
2173 [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl
2174 [as_write_fail=0
2175 cat >$1 <<_ASEOF || as_write_fail=1
2176 #! $SHELL
2177 # Generated by $as_me.
2179 SHELL=\${CONFIG_SHELL-$SHELL}
2180 export SHELL
2181 _ASEOF
2182 cat >>$1 <<\_ASEOF || as_write_fail=1
2183 _AS_SHELL_SANITIZE
2184 _AS_PREPARE
2185 m4_if(AS_MESSAGE_FD, [1], [], [exec AS_MESSAGE_FD>&1
2186 ])]dnl
2187 [m4_text_box([Main body of $1 script.])
2188 _ASEOF
2189 test $as_write_fail = 0 && chmod +x $1[]dnl
2190 _m4_popdef([AS_MESSAGE_LOG_FD])])# AS_INIT_GENERATED
2193 # AS_INIT
2194 # -------
2195 # Initialize m4sh.
2196 m4_define([AS_INIT],
2197 [# Wrap our cleanup prior to m4sugar's cleanup.
2198 m4_wrap([_AS_CLEANUP])
2199 m4_init
2200 m4_provide([AS_INIT])
2202 # Forbidden tokens and exceptions.
2203 m4_pattern_forbid([^_?AS_])
2205 # Bangshe and minimal initialization.
2206 # Put only the basename of __file__ into HEADER-COMMENT, so that the
2207 # path to the source directory is not embedded in the output file.
2208 m4_divert_text([BINSH], [@%:@! /bin/sh])
2209 m4_divert_text([HEADER-COMMENT],
2210                [@%:@ Generated from m4_bpatsubst(__file__,[^.*/\([^/]*\)$],[[\1]]) by m4_PACKAGE_STRING.])
2211 m4_divert_text([M4SH-SANITIZE], [_AS_SHELL_SANITIZE])
2212 m4_divert_text([M4SH-INIT-FN], [m4_text_box([M4sh Shell Functions.])])
2214 # Let's go!
2215 m4_divert([BODY])dnl
2216 m4_text_box([Main body of script.])
2217 _AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])dnl
2218 _AS_DETECT_REQUIRED([_AS_MODERN_CMDSUBST_WORKS])dnl
2219 _AS_DETECT_REQUIRED([_AS_TEST_X_WORKS])dnl
2220 AS_REQUIRE([_AS_UNSET_PREPARE], [], [M4SH-INIT-FN])dnl