m4sh: fix today's AS_BOX regression
[autoconf.git] / lib / m4sugar / m4sh.m4
blob13ad849238506db23184419178bd3f753124b994
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, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
6 # 2009, 2010 Free Software Foundation, Inc.
8 # This file is part of Autoconf.  This program is free
9 # software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the
11 # Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
19 # Under Section 7 of GPL version 3, you are granted additional
20 # permissions described in the Autoconf Configure Script Exception,
21 # version 3.0, as published by the Free Software Foundation.
23 # You should have received a copy of the GNU General Public License
24 # and a copy of the Autoconf Configure Script Exception along with
25 # this program; see the files COPYINGv3 and COPYING.EXCEPTION
26 # respectively.  If not, see <http://www.gnu.org/licenses/>.
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 m4_define([_m4_divert(BINSH)],             0)
64 m4_define([_m4_divert(HEADER-REVISION)],   1)
65 m4_define([_m4_divert(HEADER-COMMENT)],    2)
66 m4_define([_m4_divert(HEADER-COPYRIGHT)],  3)
67 m4_define([_m4_divert(M4SH-SANITIZE)],     4)
68 m4_define([_m4_divert(M4SH-INIT-FN)],      5)
69 m4_define([_m4_divert(M4SH-INIT)],         6)
70 m4_define([_m4_divert(BODY)],           1000)
72 # Aaarg.  Yet it starts with compatibility issues...  Libtool wants to
73 # use NOTICE to insert its own LIBTOOL-INIT stuff.  People should ask
74 # before diving into our internals :(
75 m4_copy([_m4_divert(M4SH-INIT)], [_m4_divert(NOTICE)])
79 ## ------------------------- ##
80 ## 1. Sanitizing the shell.  ##
81 ## ------------------------- ##
82 # Please maintain lexicographic sorting of this section, ignoring leading _.
84 # AS_BOURNE_COMPATIBLE
85 # --------------------
86 # Try to be as Bourne and/or POSIX as possible.
88 # This does not set BIN_SH, due to the problems described in
89 # <http://lists.gnu.org/archive/html/autoconf-patches/2006-03/msg00081.html>.
90 # People who need BIN_SH should set it in their environment before invoking
91 # configure; apparently this would include UnixWare, as described in
92 # <http://lists.gnu.org/archive/html/bug-autoconf/2006-06/msg00025.html>.
93 m4_define([AS_BOURNE_COMPATIBLE],
94 [# Be more Bourne compatible
95 DUALCASE=1; export DUALCASE # for MKS sh
96 _$0
99 # _AS_BOURNE_COMPATIBLE
100 # ---------------------
101 # This is the part of AS_BOURNE_COMPATIBLE which has to be repeated inside
102 # each instance.
103 m4_define([_AS_BOURNE_COMPATIBLE],
104 [AS_IF([test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1],
105  [emulate sh
106   NULLCMD=:
107   [#] Pre-4.2 versions of Zsh do word splitting on ${1+"$[@]"}, which
108   # is contrary to our usage.  Disable this feature.
109   alias -g '${1+"$[@]"}'='"$[@]"'
110   setopt NO_GLOB_SUBST],
111  [AS_CASE([`(set -o) 2>/dev/null`], [*posix*], [set -o posix])])
115 # _AS_CLEANUP
116 # -----------
117 # Expanded as the last thing before m4sugar cleanup begins.  Macros
118 # may append m4sh cleanup hooks to this as appropriate.
119 m4_define([_AS_CLEANUP],
120 [m4_divert_text([M4SH-SANITIZE], [_AS_DETECT_BETTER_SHELL])])
123 # AS_COPYRIGHT(TEXT)
124 # ------------------
125 # Emit TEXT, a copyright notice, as a shell comment near the top of the
126 # script.  TEXT is evaluated once; to accomplish that, we do not prepend
127 # `# ' but `@%:@ '.
128 m4_define([AS_COPYRIGHT],
129 [m4_divert_text([HEADER-COPYRIGHT],
130 [m4_bpatsubst([
131 $1], [^], [@%:@ ])])])
134 # _AS_DETECT_EXPAND(VAR, SET)
135 # ---------------------------
136 # Assign the contents of VAR from the contents of SET, expanded in such
137 # a manner that VAR can be passed to _AS_RUN.  In order to make
138 # _AS_LINENO_WORKS operate correctly, we must specially handle the
139 # first instance of $LINENO within any line being expanded (the first
140 # instance is important to tests using the current shell, leaving
141 # remaining instances for tests using a candidate shell).  Bash loses
142 # track of line numbers if a double quote contains a newline, hence,
143 # we must piece-meal the assignment of VAR such that $LINENO expansion
144 # occurs in a single line.
145 m4_define([_AS_DETECT_EXPAND],
146 [$1="m4_bpatsubst(m4_dquote(AS_ESCAPE(_m4_expand(m4_set_contents([$2], [
147 ])))), [\\\$LINENO\(.*\)$], [";$1=$$1$LINENO;$1=$$1"\1])"])
150 # _AS_DETECT_REQUIRED(TEST)
151 # -------------------------
152 # Refuse to execute under a shell that does not pass the given TEST.
153 # Does not do AS_REQUIRE for the better-shell detection code.
155 # M4sh should never require something not required by POSIX, although
156 # other clients are free to do so.
157 m4_defun([_AS_DETECT_REQUIRED],
158 [m4_set_add([_AS_DETECT_REQUIRED_BODY], [$1 || AS_EXIT])])
161 # _AS_DETECT_SUGGESTED(TEST)
162 # --------------------------
163 # Prefer to execute under a shell that passes the given TEST.
164 # Does not do AS_REQUIRE for the better-shell detection code.
166 # M4sh should never suggest something not required by POSIX, although
167 # other clients are free to do so.
168 m4_defun([_AS_DETECT_SUGGESTED],
169 [m4_set_add([_AS_DETECT_SUGGESTED_BODY], [$1 || AS_EXIT])])
172 # _AS_DETECT_SUGGESTED_PRUNE(TEST)
173 # --------------------------------
174 # If TEST is also a required test, remove it from the set of suggested tests.
175 m4_define([_AS_DETECT_SUGGESTED_PRUNE],
176 [m4_set_contains([_AS_DETECT_REQUIRED_BODY], [$1],
177                  [m4_set_remove([_AS_DETECT_SUGGESTED_BODY], [$1])])])
180 # _AS_DETECT_BETTER_SHELL
181 # -----------------------
182 # The real workhorse for detecting a shell with the correct
183 # features.
185 # In previous versions, we prepended /usr/posix/bin to the path, but that
186 # caused a regression on OpenServer 6.0.0
187 # <http://lists.gnu.org/archive/html/bug-autoconf/2006-06/msg00017.html>
188 # and on HP-UX 11.11, see the failure of test 120 in
189 # <http://lists.gnu.org/archive/html/bug-autoconf/2006-10/msg00003.html>
191 # FIXME: The code should test for the OSF bug described in
192 # <http://lists.gnu.org/archive/html/autoconf-patches/2006-03/msg00081.html>.
194 # This code is run outside any trap 0 context, hence we can simplify AS_EXIT.
195 m4_defun([_AS_DETECT_BETTER_SHELL],
196 dnl Remove any tests from suggested that are also required
197 [m4_set_map([_AS_DETECT_SUGGESTED_BODY], [_AS_DETECT_SUGGESTED_PRUNE])]dnl
198 [m4_pushdef([AS_EXIT], [exit m4_default(]m4_dquote([$][1])[, 1)])]dnl
199 [if test "x$CONFIG_SHELL" = x; then
200   as_bourne_compatible="AS_ESCAPE(_m4_expand([_AS_BOURNE_COMPATIBLE]))"
201   _AS_DETECT_EXPAND([as_required], [_AS_DETECT_REQUIRED_BODY])
202   _AS_DETECT_EXPAND([as_suggested], [_AS_DETECT_SUGGESTED_BODY])
203   AS_IF([_AS_RUN(["$as_required"])],
204         [as_have_required=yes],
205         [as_have_required=no])
206   AS_IF([test x$as_have_required = xyes && _AS_RUN(["$as_suggested"])],
207     [],
208     [_AS_PATH_WALK([/bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH],
209       [case $as_dir in @%:@(
210          /*)
211            for as_base in sh bash ksh sh5; do
212              # Try only shells that exist, to save several forks.
213              as_shell=$as_dir/$as_base
214              AS_IF([{ test -f "$as_shell" || test -f "$as_shell.exe"; } &&
215                     _AS_RUN(["$as_required"], ["$as_shell"])],
216                    [CONFIG_SHELL=$as_shell as_have_required=yes
217                    m4_set_empty([_AS_DETECT_SUGGESTED_BODY], [break 2],
218                      [AS_IF([_AS_RUN(["$as_suggested"], ["$as_shell"])],
219                             [break 2])])])
220            done;;
221        esac],
222       [AS_IF([{ test -f "$SHELL" || test -f "$SHELL.exe"; } &&
223               _AS_RUN(["$as_required"], ["$SHELL"])],
224              [CONFIG_SHELL=$SHELL as_have_required=yes])])
226       AS_IF([test "x$CONFIG_SHELL" != x],
227         [# We cannot yet assume a decent shell, so we have to provide a
228         # neutralization value for shells without unset; and this also
229         # works around shells that cannot unset nonexistent variables.
230         # Preserve -v and -x to the replacement shell.
231         BASH_ENV=/dev/null
232         ENV=/dev/null
233         (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
234         export CONFIG_SHELL
235         case $- in @%:@ ((((
236           *v*x* | *x*v* ) as_opts=-vx ;;
237           *v* ) as_opts=-v ;;
238           *x* ) as_opts=-x ;;
239           * ) as_opts= ;;
240         esac
241         exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$[@]"}])
243 dnl Unfortunately, $as_me isn't available here.
244     AS_IF([test x$as_have_required = xno],
245       [AS_ECHO(["$[]0: This script requires a shell more modern than all"])
246   AS_ECHO(["$[]0: the shells that I found on your system."])
247   if test x${ZSH_VERSION+set} = xset ; then
248     AS_ECHO(["$[]0: In particular, zsh $ZSH_VERSION has bugs and should"])
249     AS_ECHO(["$[]0: be upgraded to zsh 4.3.4 or later."])
250   else
251     AS_ECHO("m4_text_wrap([Please tell ]_m4_defn([m4_PACKAGE_BUGREPORT])
252 m4_ifset([AC_PACKAGE_BUGREPORT], [m4_if(_m4_defn([m4_PACKAGE_BUGREPORT]),
253 _m4_defn([AC_PACKAGE_BUGREPORT]), [], [and _m4_defn([AC_PACKAGE_BUGREPORT])])])
254 [about your system, including any error possibly output before this message.
255 Then install a modern shell, or manually run the script under such a
256 shell if you do have one.], [$[]0: ], [], [62])")
257   fi
258   AS_EXIT])])
260 SHELL=${CONFIG_SHELL-/bin/sh}
261 export SHELL
262 # Unset more variables known to interfere with behavior of common tools.
263 CLICOLOR_FORCE= GREP_OPTIONS=
264 unset CLICOLOR_FORCE GREP_OPTIONS
265 _m4_popdef([AS_EXIT])])# _AS_DETECT_BETTER_SHELL
268 # _AS_PREPARE
269 # -----------
270 # This macro has a very special status.  Normal use of M4sh relies
271 # heavily on AS_REQUIRE, so that needed initializations (such as
272 # _AS_TEST_PREPARE) are performed on need, not on demand.  But
273 # Autoconf is the first client of M4sh, and for two reasons: configure
274 # and config.status.  Relying on AS_REQUIRE is of course fine for
275 # configure, but fails for config.status (which is created by
276 # configure).  So we need a means to force the inclusion of the
277 # various _AS_*_PREPARE on top of config.status.  That's basically why
278 # there are so many _AS_*_PREPARE below, and that's also why it is
279 # important not to forget some: config.status needs them.
280 # List any preparations that create shell functions first, then
281 # topologically sort the others by their dependencies.
283 # Special case: we do not need _AS_LINENO_PREPARE, because the
284 # parent will have substituted $LINENO for us when processing its
285 # own invocation of _AS_LINENO_PREPARE.
287 # Special case: the full definition of _AS_ERROR_PREPARE is not output
288 # unless AS_MESSAGE_LOG_FD is non-empty, although the value of
289 # AS_MESSAGE_LOG_FD is not relevant.
290 m4_defun([_AS_PREPARE],
291 [m4_pushdef([AS_REQUIRE])]dnl
292 [m4_pushdef([AS_REQUIRE_SHELL_FN], _m4_defn([_AS_REQUIRE_SHELL_FN])
293 )]dnl
294 [m4_pushdef([AS_MESSAGE_LOG_FD], [-1])]dnl
295 [_AS_ERROR_PREPARE
296 _m4_popdef([AS_MESSAGE_LOG_FD])]dnl
297 [_AS_EXIT_PREPARE
298 _AS_UNSET_PREPARE
299 _AS_VAR_APPEND_PREPARE
300 _AS_VAR_ARITH_PREPARE
302 _AS_EXPR_PREPARE
303 _AS_BASENAME_PREPARE
304 _AS_DIRNAME_PREPARE
305 _AS_ME_PREPARE
306 _AS_CR_PREPARE
307 _AS_ECHO_N_PREPARE
308 _AS_LN_S_PREPARE
309 _AS_MKDIR_P_PREPARE
310 _AS_TEST_PREPARE
311 _AS_TR_CPP_PREPARE
312 _AS_TR_SH_PREPARE
313 _m4_popdef([AS_REQUIRE], [AS_REQUIRE_SHELL_FN])])
315 # AS_PREPARE
316 # ----------
317 # Output all the M4sh possible initialization into the initialization
318 # diversion.  We do not use _AS_PREPARE so that the m4_provide symbols for
319 # AS_REQUIRE and AS_REQUIRE_SHELL_FN are defined properly, and so that
320 # shell functions are placed in M4SH-INIT-FN.
321 m4_defun([AS_PREPARE],
322 [m4_divert_push([KILL])
323 m4_append_uniq([_AS_CLEANUP],
324   [m4_divert_text([M4SH-INIT-FN], [_AS_ERROR_PREPARE[]])])
325 AS_REQUIRE([_AS_EXPR_PREPARE])
326 AS_REQUIRE([_AS_BASENAME_PREPARE])
327 AS_REQUIRE([_AS_DIRNAME_PREPARE])
328 AS_REQUIRE([_AS_ME_PREPARE])
329 AS_REQUIRE([_AS_CR_PREPARE])
330 AS_REQUIRE([_AS_LINENO_PREPARE])
331 AS_REQUIRE([_AS_ECHO_N_PREPARE])
332 AS_REQUIRE([_AS_EXIT_PREPARE])
333 AS_REQUIRE([_AS_LN_S_PREPARE])
334 AS_REQUIRE([_AS_MKDIR_P_PREPARE])
335 AS_REQUIRE([_AS_TEST_PREPARE])
336 AS_REQUIRE([_AS_TR_CPP_PREPARE])
337 AS_REQUIRE([_AS_TR_SH_PREPARE])
338 AS_REQUIRE([_AS_UNSET_PREPARE])
339 AS_REQUIRE([_AS_VAR_APPEND_PREPARE], [], [M4SH-INIT-FN])
340 AS_REQUIRE([_AS_VAR_ARITH_PREPARE], [], [M4SH-INIT-FN])
341 m4_divert_pop[]])
344 # AS_REQUIRE(NAME-TO-CHECK, [BODY-TO-EXPAND = NAME-TO-CHECK],
345 #            [DIVERSION = M4SH-INIT])
346 # -----------------------------------------------------------
347 # BODY-TO-EXPAND is some initialization which must be expanded in the
348 # given diversion when expanded (required or not).  The expansion
349 # goes in the named diversion or an earlier one.
351 # Since $2 can be quite large, this is factored for faster execution, giving
352 # either m4_require([$1], [$2]) or m4_divert_require(desired, [$1], [$2]).
353 m4_defun([AS_REQUIRE],
354 [m4_define([_m4_divert_desired], [m4_default_quoted([$3], [M4SH-INIT])])]dnl
355 [m4_if(m4_eval(_m4_divert_dump - 0 <= _m4_divert(_m4_divert_desired, [-])),
356        1, [m4_require(],
357           [m4_divert_require(_m4_divert_desired,]) [$1], [$2])])
359 # _AS_REQUIRE_SHELL_FN(NAME-TO-CHECK, COMMENT, BODY-TO-EXPAND)
360 # ------------------------------------------------------------
361 # Core of AS_REQUIRE_SHELL_FN, but without diversion support.
362 m4_define([_AS_REQUIRE_SHELL_FN], [
363 m4_n([$2])$1 ()
366 } @%:@ $1[]])
368 # AS_REQUIRE_SHELL_FN(NAME-TO-CHECK, COMMENT, BODY-TO-EXPAND,
369 #                     [DIVERSION = M4SH-INIT-FN])
370 # -----------------------------------------------------------
371 # BODY-TO-EXPAND is the body of a shell function to be emitted in the
372 # given diversion when expanded (required or not).  Unlike other
373 # xx_REQUIRE macros, BODY-TO-EXPAND is mandatory.  If COMMENT is
374 # provided (often via AS_FUNCTION_DESCRIBE), it is listed with a
375 # newline before the function name.
376 m4_define([AS_REQUIRE_SHELL_FN],
377 [m4_provide_if([AS_SHELL_FN_$1], [],
378 [AS_REQUIRE([AS_SHELL_FN_$1],
379 [m4_provide([AS_SHELL_FN_$1])_$0($@)],
380 m4_default_quoted([$4], [M4SH-INIT-FN]))])])
383 # _AS_RUN(TEST, [SHELL])
384 # ----------------------
385 # Run TEST under the current shell (if one parameter is used)
386 # or under the given SHELL, protecting it from syntax errors.
387 # Set as_run in order to assist _AS_LINENO_WORKS.
388 m4_define([_AS_RUN],
389 [m4_ifval([$2], [{ $as_echo "$as_bourne_compatible"$1 | as_run=a $2; }],
390                 [(eval $1)]) 2>/dev/null])
393 # _AS_SHELL_FN_WORK
394 # -----------------
395 # This is a spy to detect "in the wild" shells that do not support shell
396 # functions correctly.  It is based on the m4sh.at Autotest testcases.
397 m4_define([_AS_SHELL_FN_WORK],
398 [as_fn_return () { (exit [$]1); }
399 as_fn_success () { as_fn_return 0; }
400 as_fn_failure () { as_fn_return 1; }
401 as_fn_ret_success () { return 0; }
402 as_fn_ret_failure () { return 1; }
404 exitcode=0
405 as_fn_success || { exitcode=1; echo as_fn_success failed.; }
406 as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
407 as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
408 as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
409 AS_IF([( set x; as_fn_ret_success y && test x = "[$]1" )], [],
410       [exitcode=1; echo positional parameters were not saved.])
411 test x$exitcode = x0[]])# _AS_SHELL_FN_WORK
414 # _AS_SHELL_SANITIZE
415 # ------------------
416 # This is the prolog that is emitted by AS_INIT and AS_INIT_GENERATED;
417 # it is executed prior to shell function definitions, hence the
418 # temporary redefinition of AS_EXIT.
419 m4_defun([_AS_SHELL_SANITIZE],
420 [m4_pushdef([AS_EXIT], [exit m4_default(]m4_dquote([$][1])[, 1)])]dnl
421 [m4_text_box([M4sh Initialization.])
423 AS_BOURNE_COMPATIBLE
424 _AS_ECHO_PREPARE
425 _AS_PATH_SEPARATOR_PREPARE
427 # IFS
428 # We need space, tab and new line, in precisely that order.  Quoting is
429 # there to prevent editors from complaining about space-tab.
430 # (If _AS_PATH_WALK were called with IFS unset, it would disable word
431 # splitting by setting IFS to empty value.)
432 IFS=" ""        $as_nl"
434 # Find who we are.  Look in the path if we contain no directory separator.
435 as_myself=
436 case $[0] in @%:@((
437   *[[\\/]]* ) as_myself=$[0] ;;
438   *) _AS_PATH_WALK([],
439                    [test -r "$as_dir/$[0]" && as_myself=$as_dir/$[0] && break])
440      ;;
441 esac
442 # We did not find ourselves, most probably we were run as `sh COMMAND'
443 # in which case we are not to be found in the path.
444 if test "x$as_myself" = x; then
445   as_myself=$[0]
447 if test ! -f "$as_myself"; then
448   AS_ECHO(["$as_myself: error: cannot find myself; rerun with an absolute file name"]) >&2
449   AS_EXIT
452 # Unset variables that we do not need and which cause bugs (e.g. in
453 # pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
454 # suppresses any "Segmentation fault" message there.  '((' could
455 # trigger a bug in pdksh 5.2.14.
456 for as_var in BASH_ENV ENV MAIL MAILPATH
457 do eval test x\${$as_var+set} = xset \
458   && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
459 done
460 PS1='$ '
461 PS2='> '
462 PS4='+ '
464 # NLS nuisances.
465 LC_ALL=C
466 export LC_ALL
467 LANGUAGE=C
468 export LANGUAGE
470 # CDPATH.
471 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
472 _m4_popdef([AS_EXIT])])# _AS_SHELL_SANITIZE
475 # AS_SHELL_SANITIZE
476 # -----------------
477 # This is only needed for the sake of Libtool, which screws up royally
478 # in its usage of M4sh internals.
479 m4_define([AS_SHELL_SANITIZE],
480 [_AS_SHELL_SANITIZE
481 m4_provide_if([AS_INIT], [],
482 [m4_provide([AS_INIT])
483 _AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])
484 _AS_DETECT_BETTER_SHELL
485 _AS_UNSET_PREPARE
486 ])])
489 ## ----------------------------- ##
490 ## 2. Wrappers around builtins.  ##
491 ## ----------------------------- ##
493 # This section is lexicographically sorted.
496 # AS_CASE(WORD, [PATTERN1], [IF-MATCHED1]...[DEFAULT])
497 # ----------------------------------------------------
498 # Expand into
499 # | case WORD in #(
500 # |   PATTERN1) IF-MATCHED1 ;; #(
501 # |   ...
502 # |   *) DEFAULT ;;
503 # | esac
504 # The shell comments are intentional, to work around people who don't
505 # realize the impacts of using insufficient m4 quoting.  This macro
506 # always uses : and provides a default case, to work around Solaris
507 # /bin/sh bugs regarding the exit status.
508 m4_define([_AS_CASE],
509 [ [@%:@(]
510   $1[)] :
511     $2 ;;])
512 m4_define([_AS_CASE_DEFAULT],
513 [ [@%:@(]
514   *[)] :
515     $1 ;;])
517 m4_defun([AS_CASE],
518 [case $1 in[]m4_map_args_pair([_$0], [_$0_DEFAULT],
519    m4_shift($@m4_if(m4_eval([$# & 1]), [1], [,])))
520 esac])# AS_CASE
523 # _AS_EXIT_PREPARE
524 # ----------------
525 # Ensure AS_EXIT and AS_SET_STATUS will work.
527 # We cannot simply use "exit N" because some shells (zsh and Solaris sh)
528 # will not set $? to N while running the code set by "trap 0"
529 # Some shells fork even for (exit N), so we use a helper function
530 # to set $? prior to the exit.
531 # Then there are shells that don't inherit $? correctly into the start of
532 # a shell function, so we must always be given an argument.
533 # Other shells don't use `$?' as default for `exit', hence just repeating
534 # the exit value can only help improving portability.
535 m4_defun([_AS_EXIT_PREPARE],
536 [AS_REQUIRE_SHELL_FN([as_fn_set_status],
537   [AS_FUNCTION_DESCRIBE([as_fn_set_status], [STATUS],
538     [Set $? to STATUS, without forking.])], [  return $[]1])]dnl
539 [AS_REQUIRE_SHELL_FN([as_fn_exit],
540   [AS_FUNCTION_DESCRIBE([as_fn_exit], [STATUS],
541     [Exit the shell with STATUS, even in a "trap 0" or "set -e" context.])],
542 [  set +e
543   as_fn_set_status $[1]
544   exit $[1]])])#_AS_EXIT_PREPARE
547 # AS_EXIT([EXIT-CODE = $?])
548 # -------------------------
549 # Exit, with status set to EXIT-CODE in the way that it's seen
550 # within "trap 0", and without interference from "set -e".  If
551 # EXIT-CODE is omitted, then use $?.
552 m4_defun([AS_EXIT],
553 [AS_REQUIRE([_AS_EXIT_PREPARE])[]as_fn_exit m4_ifval([$1], [$1], [$][?])])
556 # AS_FOR(MACRO, SHELL-VAR, [LIST = "$@"], [BODY = :])
557 # ---------------------------------------------------
558 # Expand to a shell loop that assigns SHELL-VAR to each of the
559 # whitespace-separated entries in LIST (or "$@" if LIST is empty),
560 # then executes BODY.  BODY may call break to abort the loop, or
561 # continue to proceed with the next element of LIST.  Requires that
562 # IFS be set to the normal space-tab-newline.  As an optimization,
563 # BODY should access MACRO rather than $SHELL-VAR.  Normally, MACRO
564 # expands to $SHELL-VAR, but if LIST contains only a single element
565 # that needs no additional shell quoting, then MACRO will expand to
566 # that element, thus providing a direct value rather than a shell
567 # variable indirection.
569 # Only use the optimization if LIST can be used without additional
570 # shell quoting in either a literal or double-quoted context (that is,
571 # we give up on default IFS chars, parameter expansion, command
572 # substitution, shell quoting, globs, or quadrigraphs).  Inline the
573 # m4_defn for speed.
574 m4_defun([AS_FOR],
575 [m4_pushdef([$1], m4_if([$3], [], [[$$2]], m4_translit([$3], ]dnl
576 m4_dquote(_m4_defn([m4_cr_symbols2]))[[%+=:,./-]), [], [[$3]], [[$$2]]))]dnl
577 [for $2[]m4_ifval([$3], [ in $3])
578 do :
579   $4
580 done[]_m4_popdef([$1])])
583 # AS_IF(TEST1, [IF-TRUE1 = :]...[IF-FALSE = :])
584 # ---------------------------------------------
585 # Expand into
586 # | if TEST1; then
587 # |   IF-TRUE1
588 # | elif TEST2; then
589 # |   IF-TRUE2
590 # [...]
591 # | else
592 # |   IF-FALSE
593 # | fi
594 # with simplifications if IF-TRUE1 and/or IF-FALSE is empty.
596 m4_define([_AS_IF],
597 [elif $1; then :
598   $2
600 m4_define([_AS_IF_ELSE],
601 [m4_ifnblank([$1],
602 [else
603   $1
604 ])])
606 m4_defun([AS_IF],
607 [if $1; then :
608   $2
609 m4_map_args_pair([_$0], [_$0_ELSE], m4_shift2($@))]dnl
610 [fi[]])# AS_IF
613 # AS_SET_STATUS(STATUS)
614 # ---------------------
615 # Set the shell status ($?) to STATUS, without forking.
616 m4_defun([AS_SET_STATUS],
617 [AS_REQUIRE([_AS_EXIT_PREPARE])[]as_fn_set_status $1])
620 # _AS_UNSET_PREPARE
621 # -----------------
622 # Define $as_unset to execute AS_UNSET, for backwards compatibility
623 # with older versions of M4sh.
624 m4_defun([_AS_UNSET_PREPARE],
625 [AS_FUNCTION_DESCRIBE([as_fn_unset], [VAR], [Portably unset VAR.])
626 as_fn_unset ()
628   AS_UNSET([$[1]])
630 as_unset=as_fn_unset])
633 # AS_UNSET(VAR)
634 # -------------
635 # Unset the env VAR, working around shells that do not allow unsetting
636 # a variable that is not already set.  You should not unset MAIL and
637 # MAILCHECK, as that triggers a bug in Bash 2.01.
638 m4_defun([AS_UNSET],
639 [{ AS_LITERAL_WORD_IF([$1], [], [eval ])$1=; unset $1;}])
646 ## ------------------------------------------ ##
647 ## 3. Error and warnings at the shell level.  ##
648 ## ------------------------------------------ ##
651 # AS_MESSAGE_FD
652 # -------------
653 # Must expand to the fd where messages will be sent.  Defaults to 1,
654 # although a script may reassign this value and use exec to either
655 # copy stdout to the new fd, or open the new fd on /dev/null.
656 m4_define([AS_MESSAGE_FD], [1])
658 # AS_MESSAGE_LOG_FD
659 # -----------------
660 # Must expand to either the empty string (when no logging is
661 # performed), or to the fd of a log file.  Defaults to empty, although
662 # a script may reassign this value and use exec to open a log.  When
663 # not empty, messages to AS_MESSAGE_FD are duplicated to the log,
664 # along with a LINENO reference.
665 m4_define([AS_MESSAGE_LOG_FD])
668 # AS_ORIGINAL_STDIN_FD
669 # --------------------
670 # Must expand to the fd of the script's original stdin.  Defaults to
671 # 0, although the script may reassign this value and use exec to
672 # shuffle fd's.
673 m4_define([AS_ORIGINAL_STDIN_FD], [0])
676 # AS_ESCAPE(STRING, [CHARS = `\"$])
677 # ---------------------------------
678 # Add backslash escaping to the CHARS in STRING.  In an effort to
679 # optimize use of this macro inside double-quoted shell constructs,
680 # the behavior is intentionally undefined if CHARS is longer than 4
681 # bytes, or contains bytes outside of the set [`\"$].  However,
682 # repeated bytes within the set are permissible (AS_ESCAPE([$1], [""])
683 # being a common way to be nice to syntax highlighting).
685 # Avoid the m4_bpatsubst if there are no interesting characters to escape.
686 # _AS_ESCAPE bypasses argument defaulting.
687 m4_define([AS_ESCAPE],
688 [_$0([$1], m4_if([$2], [], [[`], [\"$]], [m4_substr([$2], [0], [1]), [$2]]))])
690 # _AS_ESCAPE(STRING, KEY, SET)
691 # ----------------------------
692 # Backslash-escape all instances of the single byte KEY or up to four
693 # bytes in SET occurring in STRING.  Although a character can occur
694 # multiple times, optimum efficiency occurs when KEY and SET are
695 # distinct, and when SET does not exceed two bytes.  These particular
696 # semantics allow for the fewest number of parses of STRING, as well
697 # as taking advantage of the optimizations in m4 1.4.13+ when
698 # m4_translit is passed SET of size 2 or smaller.
699 m4_define([_AS_ESCAPE],
700 [m4_if(m4_index(m4_translit([[$1]], [$3], [$2$2$2$2]), [$2]), [-1],
701        [$0_], [m4_bpatsubst])([$1], [[$2$3]], [\\\&])])
702 m4_define([_AS_ESCAPE_], [$1])
705 # _AS_QUOTE(STRING)
706 # -----------------
707 # If there are quoted (via backslash) backquotes, output STRING
708 # literally and warn; otherwise, output STRING with ` and " quoted.
710 # Compatibility glue between the old AS_MSG suite which did not
711 # quote anything, and the modern suite which quotes the quotes.
712 # If STRING contains `\\' or `\$', it's modern.
713 # If STRING contains `\"' or `\`', it's old.
714 # Otherwise it's modern.
716 # Profiling shows that m4_index is 5 to 8x faster than m4_bregexp.  The
717 # slower implementation used:
718 # m4_bmatch([$1],
719 #           [\\[\\$]], [$2],
720 #           [\\[`"]], [$3],
721 #           [$2])
722 # The current implementation caters to the common case of no backslashes,
723 # to minimize m4_index expansions (hence the nested if).
724 m4_define([_AS_QUOTE],
725 [m4_cond([m4_index([$1], [\])], [-1], [_AS_QUOTE_MODERN],
726          [m4_eval(m4_index(m4_translit([[$1]], [$], [\]), [\\]) >= 0)],
727 [1], [_AS_QUOTE_MODERN],
728          [m4_eval(m4_index(m4_translit([[$1]], ["], [`]), [\`]) >= 0)],dnl"
729 [1], [_AS_QUOTE_OLD],
730          [_AS_QUOTE_MODERN])([$1])])
732 m4_define([_AS_QUOTE_MODERN],
733 [_AS_ESCAPE([$1], [`], [""])])
735 m4_define([_AS_QUOTE_OLD],
736 [m4_warn([obsolete],
737    [back quotes and double quotes must not be escaped in: $1])$1])
740 # _AS_ECHO_UNQUOTED(STRING, [FD = AS_MESSAGE_FD])
741 # -----------------------------------------------
742 # Perform shell expansions on STRING and echo the string to FD.
743 m4_define([_AS_ECHO_UNQUOTED],
744 [AS_ECHO(["$1"]) >&m4_default([$2], [AS_MESSAGE_FD])])
747 # _AS_ECHO(STRING, [FD = AS_MESSAGE_FD])
748 # --------------------------------------
749 # Protect STRING from backquote expansion, echo the result to FD.
750 m4_define([_AS_ECHO],
751 [_AS_ECHO_UNQUOTED([_AS_QUOTE([$1])], [$2])])
754 # _AS_ECHO_LOG(STRING)
755 # --------------------
756 # Log the string to AS_MESSAGE_LOG_FD.
757 m4_defun_init([_AS_ECHO_LOG],
758 [AS_REQUIRE([_AS_LINENO_PREPARE])],
759 [_AS_ECHO([$as_me:${as_lineno-$LINENO}: $1], AS_MESSAGE_LOG_FD)])
762 # _AS_ECHO_N_PREPARE
763 # ------------------
764 # Check whether to use -n, \c, or newline-tab to separate
765 # checking messages from result messages.
766 # Don't try to cache, since the results of this macro are needed to
767 # display the checking message.  In addition, caching something used once
768 # has little interest.
769 # Idea borrowed from dist 3.0.  Use `*c*,', not `*c,' because if `\c'
770 # failed there is also a newline to match.  Use `xy' because `\c' echoed
771 # in a command substitution prints only the first character of the output
772 # with ksh version M-11/16/88f on AIX 6.1; it needs to be reset by another
773 # backquoted echo.
774 m4_defun([_AS_ECHO_N_PREPARE],
775 [ECHO_C= ECHO_N= ECHO_T=
776 case `echo -n x` in @%:@(((((
777 -n*)
778   case `echo 'xy\c'` in
779   *c*) ECHO_T=' ';;     # ECHO_T is single tab character.
780   xy)  ECHO_C='\c';;
781   *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
782        ECHO_T=' ';;
783   esac;;
785   ECHO_N='-n';;
786 esac
787 ])# _AS_ECHO_N_PREPARE
790 # _AS_ECHO_N(STRING, [FD = AS_MESSAGE_FD])
791 # ----------------------------------------
792 # Same as _AS_ECHO, but echo doesn't return to a new line.
793 m4_define([_AS_ECHO_N],
794 [AS_ECHO_N(["_AS_QUOTE([$1])"]) >&m4_default([$2], [AS_MESSAGE_FD])])
797 # AS_MESSAGE(STRING, [FD = AS_MESSAGE_FD])
798 # ----------------------------------------
799 # Output "`basename $0`: STRING" to the open file FD, and if logging
800 # is enabled, copy it to the log with a reference to LINENO.
801 m4_defun_init([AS_MESSAGE],
802 [AS_REQUIRE([_AS_ME_PREPARE])],
803 [m4_ifval(AS_MESSAGE_LOG_FD,
804           [{ _AS_ECHO_LOG([$1])
805 _AS_ECHO([$as_me: $1], [$2]);}],
806           [_AS_ECHO([$as_me: $1], [$2])])[]])
809 # AS_WARN(PROBLEM)
810 # ----------------
811 # Output "`basename $0`: WARNING: PROBLEM" to stderr.
812 m4_define([AS_WARN],
813 [AS_MESSAGE([WARNING: $1], [2])])# AS_WARN
816 # _AS_ERROR_PREPARE
817 # -----------------
818 # Output the shell function used by AS_ERROR.  This is designed to be
819 # expanded during the m4_wrap cleanup.
821 # If AS_MESSAGE_LOG_FD is non-empty at the end of the script, then
822 # make this function take optional parameters that use LINENO at the
823 # points where AS_ERROR was expanded with non-empty AS_MESSAGE_LOG_FD;
824 # otherwise, assume the entire script does not do logging.
825 m4_define([_AS_ERROR_PREPARE],
826 [AS_REQUIRE_SHELL_FN([as_fn_error],
827   [AS_FUNCTION_DESCRIBE([as_fn_error], [STATUS ERROR]m4_ifval(AS_MESSAGE_LOG_FD,
828       [[ [[LINENO LOG_FD]]]]),
829     [Output "`basename @S|@0`: error: ERROR" to stderr.]
830 m4_ifval(AS_MESSAGE_LOG_FD,
831     [[If LINENO and LOG_FD are provided, also output the error to LOG_FD,
832       referencing LINENO.]])
833     [Then exit the script with STATUS, using 1 if that was 0.])],
834 [  as_status=$[1]; test $as_status -eq 0 && as_status=1
835 m4_ifval(AS_MESSAGE_LOG_FD,
836 [m4_pushdef([AS_MESSAGE_LOG_FD], [$[4]])dnl
837   if test "$[4]"; then
838     AS_LINENO_PUSH([$[3]])
839     _AS_ECHO_LOG([error: $[2]])
840   fi
841 m4_define([AS_MESSAGE_LOG_FD])], [m4_pushdef([AS_MESSAGE_LOG_FD])])dnl
842   AS_MESSAGE([error: $[2]], [2])
843 _m4_popdef([AS_MESSAGE_LOG_FD])dnl
844   AS_EXIT([$as_status])])])
846 # AS_ERROR(ERROR, [EXIT-STATUS = max($?/1)])
847 # ------------------------------------------
848 # Output "`basename $0`: error: ERROR" to stderr, then exit the
849 # script with EXIT-STATUS.
850 m4_defun_init([AS_ERROR],
851 [m4_append_uniq([_AS_CLEANUP],
852   [m4_divert_text([M4SH-INIT-FN], [_AS_ERROR_PREPARE[]])])],
853 [as_fn_error m4_default([$2], [$?]) "_AS_QUOTE([$1])"m4_ifval(AS_MESSAGE_LOG_FD,
854   [ "$LINENO" AS_MESSAGE_LOG_FD])])
857 # AS_LINENO_PUSH([LINENO])
858 # ------------------------
859 # If this is the outermost call to AS_LINENO_PUSH, make sure that
860 # AS_MESSAGE will print LINENO as the line number.
861 m4_defun([AS_LINENO_PUSH],
862 [as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack])
865 # AS_LINENO_POP([LINENO])
866 # -----------------------
867 # If this is call balances the outermost call to AS_LINENO_PUSH,
868 # AS_MESSAGE will restart printing $LINENO as the line number.
870 # No need to use AS_UNSET, since as_lineno is necessarily set.
871 m4_defun([AS_LINENO_POP],
872 [eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno])
876 ## -------------------------------------- ##
877 ## 4. Portable versions of common tools.  ##
878 ## -------------------------------------- ##
880 # This section is lexicographically sorted.
883 # AS_BASENAME(FILE-NAME)
884 # ----------------------
885 # Simulate the command 'basename FILE-NAME'.  Not all systems have basename.
886 # Also see the comments for AS_DIRNAME.
888 m4_defun([_AS_BASENAME_EXPR],
889 [$as_expr X/[]$1 : '.*/\([[^/][^/]*]\)/*$' \| \
890          X[]$1 : 'X\(//\)$' \| \
891          X[]$1 : 'X\(/\)' \| .])
893 m4_defun([_AS_BASENAME_SED],
894 [AS_ECHO([X/[]$1]) |
895     sed ['/^.*\/\([^/][^/]*\)\/*$/{
896             s//\1/
897             q
898           }
899           /^X\/\(\/\/\)$/{
900             s//\1/
901             q
902           }
903           /^X\/\(\/\).*/{
904             s//\1/
905             q
906           }
907           s/.*/./; q']])
909 m4_defun_init([AS_BASENAME],
910 [AS_REQUIRE([_$0_PREPARE])],
911 [$as_basename -- $1 ||
912 _AS_BASENAME_EXPR([$1]) 2>/dev/null ||
913 _AS_BASENAME_SED([$1])])
916 # _AS_BASENAME_PREPARE
917 # --------------------
918 # Avoid Solaris 9 /usr/ucb/basename, as `basename /' outputs an empty line.
919 # Also, traditional basename mishandles --.  Require here _AS_EXPR_PREPARE,
920 # to avoid problems when _AS_BASENAME is called from the M4SH-INIT diversion.
921 m4_defun([_AS_BASENAME_PREPARE],
922 [AS_REQUIRE([_AS_EXPR_PREPARE])]dnl
923 [if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
924   as_basename=basename
925 else
926   as_basename=false
928 ])# _AS_BASENAME_PREPARE
931 # AS_DIRNAME(FILE-NAME)
932 # ---------------------
933 # Simulate the command 'dirname FILE-NAME'.  Not all systems have dirname.
934 # This macro must be usable from inside ` `.
936 # Prefer expr to echo|sed, since expr is usually faster and it handles
937 # backslashes and newlines correctly.  However, older expr
938 # implementations (e.g. SunOS 4 expr and Solaris 8 /usr/ucb/expr) have
939 # a silly length limit that causes expr to fail if the matched
940 # substring is longer than 120 bytes.  So fall back on echo|sed if
941 # expr fails.
942 m4_defun_init([_AS_DIRNAME_EXPR],
943 [AS_REQUIRE([_AS_EXPR_PREPARE])],
944 [$as_expr X[]$1 : 'X\(.*[[^/]]\)//*[[^/][^/]]*/*$' \| \
945          X[]$1 : 'X\(//\)[[^/]]' \| \
946          X[]$1 : 'X\(//\)$' \| \
947          X[]$1 : 'X\(/\)' \| .])
949 m4_defun([_AS_DIRNAME_SED],
950 [AS_ECHO([X[]$1]) |
951     sed ['/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
952             s//\1/
953             q
954           }
955           /^X\(\/\/\)[^/].*/{
956             s//\1/
957             q
958           }
959           /^X\(\/\/\)$/{
960             s//\1/
961             q
962           }
963           /^X\(\/\).*/{
964             s//\1/
965             q
966           }
967           s/.*/./; q']])
969 m4_defun_init([AS_DIRNAME],
970 [AS_REQUIRE([_$0_PREPARE])],
971 [$as_dirname -- $1 ||
972 _AS_DIRNAME_EXPR([$1]) 2>/dev/null ||
973 _AS_DIRNAME_SED([$1])])
976 # _AS_DIRNAME_PREPARE
977 # -------------------
978 m4_defun([_AS_DIRNAME_PREPARE],
979 [AS_REQUIRE([_AS_EXPR_PREPARE])]dnl
980 [if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
981   as_dirname=dirname
982 else
983   as_dirname=false
985 ])# _AS_DIRNAME_PREPARE
988 # AS_ECHO(WORD)
989 # -------------
990 # Output WORD followed by a newline.  WORD must be a single shell word
991 # (typically a quoted string).  The bytes of WORD are output as-is, even
992 # if it starts with "-" or contains "\".
993 m4_defun_init([AS_ECHO],
994 [AS_REQUIRE([_$0_PREPARE])],
995 [$as_echo $1])
998 # AS_ECHO_N(WORD)
999 # ---------------
1000 # Like AS_ECHO(WORD), except do not output the trailing newline.
1001 m4_defun_init([AS_ECHO_N],
1002 [AS_REQUIRE([_AS_ECHO_PREPARE])],
1003 [$as_echo_n $1])
1006 # _AS_ECHO_PREPARE
1007 # ----------------
1008 # Arrange for $as_echo 'FOO' to echo FOO without escape-interpretation;
1009 # and similarly for $as_echo_n, which omits the trailing newline.
1010 # 'FOO' is an optional single argument; a missing FOO is treated as empty.
1011 m4_defun([_AS_ECHO_PREPARE],
1012 [[as_nl='
1014 export as_nl
1015 # Printing a long string crashes Solaris 7 /usr/bin/printf.
1016 as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
1017 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
1018 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
1019 # Prefer a ksh shell builtin over an external printf program on Solaris,
1020 # but without wasting forks for bash or zsh.
1021 if test -z "$BASH_VERSION$ZSH_VERSION" \
1022     && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
1023   as_echo='print -r --'
1024   as_echo_n='print -rn --'
1025 elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
1026   as_echo='printf %s\n'
1027   as_echo_n='printf %s'
1028 else
1029   if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
1030     as_echo_body='eval /usr/ucb/echo -n "$][1$as_nl"'
1031     as_echo_n='/usr/ucb/echo -n'
1032   else
1033     as_echo_body='eval expr "X$][1" : "X\\(.*\\)"'
1034     as_echo_n_body='eval
1035       arg=$][1;
1036       case $arg in @%:@(
1037       *"$as_nl"*)
1038         expr "X$arg" : "X\\(.*\\)$as_nl";
1039         arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
1040       esac;
1041       expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
1042     '
1043     export as_echo_n_body
1044     as_echo_n='sh -c $as_echo_n_body as_echo'
1045   fi
1046   export as_echo_body
1047   as_echo='sh -c $as_echo_body as_echo'
1049 ]])# _AS_ECHO_PREPARE
1052 # AS_TEST_X
1053 # ---------
1054 # Check whether a file has executable or search permissions.
1055 m4_defun_init([AS_TEST_X],
1056 [AS_REQUIRE([_AS_TEST_PREPARE])],
1057 [$as_test_x $1[]])# AS_TEST_X
1060 # AS_EXECUTABLE_P
1061 # ---------------
1062 # Check whether a file is a regular file that has executable permissions.
1063 m4_defun_init([AS_EXECUTABLE_P],
1064 [AS_REQUIRE([_AS_TEST_PREPARE])],
1065 [{ test -f $1 && AS_TEST_X([$1]); }])# AS_EXECUTABLE_P
1068 # _AS_EXPR_PREPARE
1069 # ----------------
1070 # QNX 4.25 expr computes and issue the right result but exits with failure.
1071 # Tru64 expr mishandles leading zeros in numeric strings.
1072 # Detect these flaws.
1073 m4_defun([_AS_EXPR_PREPARE],
1074 [if expr a : '\(a\)' >/dev/null 2>&1 &&
1075    test "X`expr 00001 : '.*\(...\)'`" = X001; then
1076   as_expr=expr
1077 else
1078   as_expr=false
1080 ])# _AS_EXPR_PREPARE
1083 # _AS_ME_PREPARE
1084 # --------------
1085 # Define $as_me to the basename of the executable file's name.
1086 m4_defun([AS_ME_PREPARE], [AS_REQUIRE([_$0])])
1087 m4_defun([_AS_ME_PREPARE],
1088 [AS_REQUIRE([_AS_BASENAME_PREPARE])]dnl
1089 [as_me=`AS_BASENAME("$[0]")`
1092 # _AS_LINENO_WORKS
1093 # ----------------
1094 # Succeed if the currently executing shell supports LINENO.
1095 # This macro does not expand to a single shell command, so be careful
1096 # when using it.  Surrounding the body of this macro with {} would
1097 # cause "bash -c '_ASLINENO_WORKS'" to fail (with Bash 2.05, anyway),
1098 # but that bug is irrelevant to our use of LINENO.  We can't use
1099 # AS_VAR_ARITH, as this is expanded prior to shell functions.
1101 # Testing for LINENO support is hard; we use _AS_LINENO_WORKS inside
1102 # _AS_RUN, which sometimes eval's its argument (pdksh gives false
1103 # negatives if $LINENO is expanded by eval), and sometimes passes the
1104 # argument to another shell (if the current shell supports LINENO,
1105 # then expanding $LINENO prior to the string leads to false
1106 # positives).  Hence, we perform two tests, and coordinate with
1107 # _AS_DETECT_EXPAND (which ensures that only the first of two LINENO
1108 # is expanded in advance) and _AS_RUN (which sets $as_run to 'a' when
1109 # handing the test to another shell), so that we know which test to
1110 # trust.
1111 m4_define([_AS_LINENO_WORKS],
1112 [  as_lineno_1=$LINENO as_lineno_1a=$LINENO
1113   as_lineno_2=$LINENO as_lineno_2a=$LINENO
1114   eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
1115   test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"'])
1118 # _AS_LINENO_PREPARE
1119 # ------------------
1120 # If LINENO is not supported by the shell, produce a version of this
1121 # script where LINENO is hard coded.
1122 # Comparing LINENO against _oline_ is not a good solution, since in
1123 # the case of embedded executables (such as config.status within
1124 # configure) you'd compare LINENO wrt config.status vs. _oline_ wrt
1125 # configure.
1127 # AS_ERROR normally uses LINENO if logging, but AS_LINENO_PREPARE uses
1128 # AS_ERROR.  Besides, if the logging fd is open, we don't want to use
1129 # $LINENO in the log complaining about broken LINENO.  We break the
1130 # circular require by changing AS_ERROR and AS_MESSAGE_LOG_FD.
1131 m4_defun([AS_LINENO_PREPARE], [AS_REQUIRE([_$0])])
1132 m4_defun([_AS_LINENO_PREPARE],
1133 [AS_REQUIRE([_AS_CR_PREPARE])]dnl
1134 [AS_REQUIRE([_AS_ME_PREPARE])]dnl
1135 [_AS_DETECT_SUGGESTED([_AS_LINENO_WORKS])]dnl
1136 [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl
1137 [m4_pushdef([AS_ERROR],
1138   [{ AS_MESSAGE(]m4_dquote([error: $][1])[, [2]); AS_EXIT([1]); }])]dnl
1139 dnl Create $as_me.lineno as a copy of $as_myself, but with $LINENO
1140 dnl uniformly replaced by the line number.  The first 'sed' inserts a
1141 dnl line-number line after each line using $LINENO; the second 'sed'
1142 dnl does the real work.  The second script uses 'N' to pair each
1143 dnl line-number line with the line containing $LINENO, and appends
1144 dnl trailing '-' during substitution so that $LINENO is not a special
1145 dnl case at line end.  (Raja R Harinath suggested sed '=', and Paul
1146 dnl Eggert wrote the scripts with optimization help from Paolo Bonzini).
1147 [_AS_LINENO_WORKS || {
1148 [  # Blame Lee E. McMahon (1931-1989) for sed's syntax.  :-)
1149   sed -n '
1150     p
1151     /[$]LINENO/=
1152   ' <$as_myself |
1153     sed '
1154       s/[$]LINENO.*/&-/
1155       t lineno
1156       b
1157       :lineno
1158       N
1159       :loop
1160       s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
1161       t loop
1162       s/-\n.*//
1163     ' >$as_me.lineno &&
1164   chmod +x "$as_me.lineno"] ||
1165     AS_ERROR([cannot create $as_me.lineno; rerun with a POSIX shell])
1167   # Don't try to exec as it changes $[0], causing all sort of problems
1168   # (the dirname of $[0] is not the place where we might find the
1169   # original and so on.  Autoconf is especially sensitive to this).
1170   . "./$as_me.lineno"
1171   # Exit status is that of the last command.
1172   exit
1174 _m4_popdef([AS_MESSAGE_LOG_FD], [AS_ERROR])])# _AS_LINENO_PREPARE
1177 # _AS_LN_S_PREPARE
1178 # ----------------
1179 # Don't use conftest.sym to avoid file name issues on DJGPP, where this
1180 # would yield conftest.sym.exe for DJGPP < 2.04.  And don't use `conftest'
1181 # as base name to avoid prohibiting concurrency (e.g., concurrent
1182 # config.statuses).  On read-only media, assume 'cp -p' and hope we
1183 # are just running --help anyway.
1184 m4_defun([_AS_LN_S_PREPARE],
1185 [rm -f conf$$ conf$$.exe conf$$.file
1186 if test -d conf$$.dir; then
1187   rm -f conf$$.dir/conf$$.file
1188 else
1189   rm -f conf$$.dir
1190   mkdir conf$$.dir 2>/dev/null
1192 if (echo >conf$$.file) 2>/dev/null; then
1193   if ln -s conf$$.file conf$$ 2>/dev/null; then
1194     as_ln_s='ln -s'
1195     # ... but there are two gotchas:
1196     # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
1197     # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
1198     # In both cases, we have to default to `cp -p'.
1199     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
1200       as_ln_s='cp -p'
1201   elif ln conf$$.file conf$$ 2>/dev/null; then
1202     as_ln_s=ln
1203   else
1204     as_ln_s='cp -p'
1205   fi
1206 else
1207   as_ln_s='cp -p'
1209 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
1210 rmdir conf$$.dir 2>/dev/null
1211 ])# _AS_LN_S_PREPARE
1214 # AS_LN_S(FILE, LINK)
1215 # -------------------
1216 # FIXME: Should we add the glue code to handle properly relative symlinks
1217 # simulated with `ln' or `cp'?
1218 m4_defun_init([AS_LN_S],
1219 [AS_REQUIRE([_AS_LN_S_PREPARE])],
1220 [$as_ln_s $1 $2])
1223 # _AS_MKDIR_P
1224 # -----------
1225 # Emit code that can be used to emulate `mkdir -p` with plain `mkdir';
1226 # the code assumes that "$as_dir" contains the directory to create.
1227 # $as_dir is normalized, so there is no need to worry about using --.
1228 m4_define([_AS_MKDIR_P],
1229 [case $as_dir in #(
1230   -*) as_dir=./$as_dir;;
1231   esac
1232   test -d "$as_dir" || eval $as_mkdir_p || {
1233     as_dirs=
1234     while :; do
1235       case $as_dir in #(
1236       *\'*) as_qdir=`AS_ECHO(["$as_dir"]) | sed "s/'/'\\\\\\\\''/g"`;; #'(
1237       *) as_qdir=$as_dir;;
1238       esac
1239       as_dirs="'$as_qdir' $as_dirs"
1240       as_dir=`AS_DIRNAME("$as_dir")`
1241       test -d "$as_dir" && break
1242     done
1243     test -z "$as_dirs" || eval "mkdir $as_dirs"
1244   } || test -d "$as_dir" || AS_ERROR([cannot create directory $as_dir])
1247 # AS_MKDIR_P(DIR)
1248 # ---------------
1249 # Emulate `mkdir -p' with plain `mkdir' if needed.
1250 m4_defun_init([AS_MKDIR_P],
1251 [AS_REQUIRE([_$0_PREPARE])],
1252 [as_dir=$1; as_fn_mkdir_p])# AS_MKDIR_P
1255 # _AS_MKDIR_P_PREPARE
1256 # -------------------
1257 m4_defun([_AS_MKDIR_P_PREPARE],
1258 [AS_REQUIRE_SHELL_FN([as_fn_mkdir_p],
1259   [AS_FUNCTION_DESCRIBE([as_fn_mkdir_p], [],
1260     [Create "$as_dir" as a directory, including parents if necessary.])],
1262   _AS_MKDIR_P
1263 ])]dnl
1264 [if mkdir -p . 2>/dev/null; then
1265   as_mkdir_p='mkdir -p "$as_dir"'
1266 else
1267   test -d ./-p && rmdir ./-p
1268   as_mkdir_p=false
1270 ])# _AS_MKDIR_P_PREPARE
1273 # _AS_PATH_SEPARATOR_PREPARE
1274 # --------------------------
1275 # Compute the path separator.
1276 m4_defun([_AS_PATH_SEPARATOR_PREPARE],
1277 [# The user is always right.
1278 if test "${PATH_SEPARATOR+set}" != set; then
1279   PATH_SEPARATOR=:
1280   (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
1281     (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
1282       PATH_SEPARATOR=';'
1283   }
1285 ])# _AS_PATH_SEPARATOR_PREPARE
1288 # _AS_PATH_WALK([PATH = $PATH], BODY, [IF-NOT-FOUND])
1289 # ---------------------------------------------------
1290 # Walk through PATH running BODY for each `as_dir'.  If BODY never does a
1291 # `break', evaluate IF-NOT-FOUND.
1293 # Still very private as its interface looks quite bad.
1295 # `$as_dummy' forces splitting on constant user-supplied paths.
1296 # POSIX.2 field splitting is done only on the result of word
1297 # expansions, not on literal text.  This closes a longstanding sh security
1298 # hole.  Optimize it away when not needed, i.e., if there are no literal
1299 # path separators.
1300 m4_defun_init([_AS_PATH_WALK],
1301 [AS_REQUIRE([_AS_PATH_SEPARATOR_PREPARE])],
1302 [as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
1303 m4_ifvaln([$3], [as_found=false])dnl
1304 m4_bmatch([$1], [[:;]],
1305 [as_dummy="$1"
1306 for as_dir in $as_dummy],
1307 [for as_dir in m4_default([$1], [$PATH])])
1309   IFS=$as_save_IFS
1310   test -z "$as_dir" && as_dir=.
1311   m4_ifvaln([$3], [as_found=:])dnl
1312   $2
1313   m4_ifvaln([$3], [as_found=false])dnl
1314 done
1315 m4_ifvaln([$3], [$as_found || { $3; }])dnl
1316 IFS=$as_save_IFS
1320 # AS_SET_CATFILE(VAR, DIR-NAME, FILE-NAME)
1321 # ----------------------------------------
1322 # Set VAR to DIR-NAME/FILE-NAME.
1323 # Optimize the common case where $2 or $3 is '.'.
1324 m4_define([AS_SET_CATFILE],
1325 [case $2 in @%:@((
1326 .) AS_VAR_SET([$1], [$3]);;
1328   case $3 in @%:@(((
1329   .) AS_VAR_SET([$1], [$2]);;
1330   [[\\/]]* | ?:[[\\/]]* ) AS_VAR_SET([$1], [$3]);;
1331   *) AS_VAR_SET([$1], [$2/$3]);;
1332   esac;;
1333 esac[]])# AS_SET_CATFILE
1336 # _AS_TEST_PREPARE
1337 # ----------------
1338 # Find out whether `test -x' works.  If not, prepare a substitute
1339 # that should work well enough for most scripts.
1341 # Here are some of the problems with the substitute.
1342 # The 'ls' tests whether the owner, not the current user, can execute/search.
1343 # The eval means '*', '?', and '[' cause inadvertent file name globbing
1344 # after the 'eval', so jam together as many tokens as we can to minimize
1345 # the likelihood that the inadvertent globbing will actually do anything.
1346 # Luckily, this gorp is needed only on really ancient hosts.
1348 m4_defun([_AS_TEST_PREPARE],
1349 [if test -x / >/dev/null 2>&1; then
1350   as_test_x='test -x'
1351 else
1352   if ls -dL / >/dev/null 2>&1; then
1353     as_ls_L_option=L
1354   else
1355     as_ls_L_option=
1356   fi
1357   as_test_x='
1358     eval sh -c '\''
1359       if test -d "$[]1"; then
1360         test -d "$[]1/.";
1361       else
1362         case $[]1 in @%:@(
1363         -*)set "./$[]1";;
1364         esac;
1365         case `ls -ld'$as_ls_L_option' "$[]1" 2>/dev/null` in @%:@((
1366         ???[[sx]]*):;;*)false;;esac;fi
1367     '\'' sh
1368   '
1370 dnl as_executable_p is present for backward compatibility with Libtool
1371 dnl 1.5.22, but it should go away at some point.
1372 as_executable_p=$as_test_x
1373 ])# _AS_TEST_PREPARE
1378 ## ------------------ ##
1379 ## 5. Common idioms.  ##
1380 ## ------------------ ##
1382 # This section is lexicographically sorted.
1385 # AS_BOX(MESSAGE, [FRAME-CHARACTER = `-'])
1386 # ----------------------------------------
1387 # Output MESSAGE, a single line text, framed with FRAME-CHARACTER (which
1388 # must not be `/').
1389 m4_define([AS_BOX],
1390 [_$0(m4_expand([$1]), [$2])])
1392 m4_define([_AS_BOX],
1393 [m4_if(m4_index(m4_translit([[$1]], [`\"], [$$$]), [$]),
1394   [-1], [$0_LITERAL], [$0_INDIR])($@)])
1397 # _AS_BOX_LITERAL(MESSAGE, [FRAME-CHARACTER = `-'])
1398 # -------------------------------------------------
1399 m4_define([_AS_BOX_LITERAL],
1400 [AS_ECHO(["_AS_ESCAPE(m4_dquote(m4_expand([m4_text_box($@)])), [`], [\"$])"])])
1403 # _AS_BOX_INDIR(MESSAGE, [FRAME-CHARACTER = `-'])
1404 # -----------------------------------------------
1405 m4_define([_AS_BOX_INDIR],
1406 [sed 'h;s/./m4_default([$2], [-])/g;s/^.../@%:@@%:@ /;s/...$/ @%:@@%:@/;p;x;p;x' <<_ASBOX
1407 @%:@@%:@ $1 @%:@@%:@
1408 _ASBOX])
1411 # _AS_CLEAN_DIR(DIR)
1412 # ------------------
1413 # Remove all contents from within DIR, including any unwritable
1414 # subdirectories, but leave DIR itself untouched.
1415 m4_define([_AS_CLEAN_DIR],
1416 [if test -d $1; then
1417   find $1 -type d ! -perm -700 -exec chmod u+rwx {} \;
1418   rm -fr $1/* $1/.[[!.]] $1/.??*
1419 fi])
1422 # AS_FUNCTION_DESCRIBE(NAME, [ARGS], DESCRIPTION, [WRAP-COLUMN = 79])
1423 # -------------------------------------------------------------------
1424 # Output a shell comment describing NAME and its arguments ARGS, then
1425 # a separator line, then the DESCRIPTION wrapped at a decimal
1426 # WRAP-COLUMN.  The output resembles:
1427 #  # NAME ARGS
1428 #  # ---------
1429 #  # Wrapped DESCRIPTION text
1430 # NAME and ARGS are expanded, while DESCRIPTION is treated as a
1431 # whitespace-separated list of strings that are not expanded.
1432 m4_define([AS_FUNCTION_DESCRIBE],
1433 [@%:@ $1[]m4_ifval([$2], [ $2])
1434 @%:@ m4_translit(m4_format([%*s],
1435            m4_decr(m4_qlen(_m4_expand([$1[]m4_ifval([$2], [ $2])
1436 ]))), []), [ ], [-])
1437 m4_text_wrap([$3], [@%:@ ], [], [$4])])
1440 # AS_HELP_STRING(LHS, RHS, [INDENT-COLUMN = 26], [WRAP-COLUMN = 79])
1441 # ------------------------------------------------------------------
1443 # Format a help string so that it looks pretty when the user executes
1444 # "script --help".  This macro takes up to four arguments, a
1445 # "left hand side" (LHS), a "right hand side" (RHS), a decimal
1446 # INDENT-COLUMN which is the column where wrapped lines should begin
1447 # (the default of 26 is recommended), and a decimal WRAP-COLUMN which is
1448 # the column where lines should wrap (the default of 79 is recommended).
1449 # LHS is expanded, RHS is not.
1451 # For backwards compatibility not documented in the manual, INDENT-COLUMN
1452 # can also be specified as a string of white spaces, whose width
1453 # determines the indentation column.  Using TABs in INDENT-COLUMN is not
1454 # recommended, since screen width of TAB is not computed.
1456 # The resulting string is suitable for use in other macros that require
1457 # a help string (e.g. AC_ARG_WITH).
1459 # Here is the sample string from the Autoconf manual (Node: External
1460 # Software) which shows the proper spacing for help strings.
1462 #    --with-readline         support fancy command line editing
1463 #  ^ ^                       ^
1464 #  | |                       |
1465 #  | column 2                column 26
1466 #  |
1467 #  column 0
1469 # A help string is made up of a "left hand side" (LHS) and a "right
1470 # hand side" (RHS).  In the example above, the LHS is
1471 # "--with-readline", while the RHS is "support fancy command line
1472 # editing".
1474 # If the LHS contains more than (INDENT-COLUMN - 3) characters, then the
1475 # LHS is terminated with a newline so that the RHS starts on a line of its
1476 # own beginning at INDENT-COLUMN.  In the default case, this corresponds to an
1477 # LHS with more than 23 characters.
1479 # Therefore, in the example, if the LHS were instead
1480 # "--with-readline-blah-blah-blah", then the AS_HELP_STRING macro would
1481 # expand into:
1484 #    --with-readline-blah-blah-blah
1485 #  ^ ^                       support fancy command line editing
1486 #  | |                       ^
1487 #  | column 2                |
1488 #  column 0                  column 26
1491 # m4_text_wrap hacks^Wworks around the fact that m4_format does not
1492 # know quadrigraphs.
1494 m4_define([AS_HELP_STRING],
1495 [m4_text_wrap([$2], m4_cond([[$3]], [], [                          ],
1496                             [m4_eval([$3]+0)], [0], [[$3]],
1497                             [m4_format([[%*s]], [$3], [])]),
1498               m4_expand([  $1 ]), [$4])])# AS_HELP_STRING
1501 # AS_IDENTIFIER_IF(EXPRESSION, IF-IDENT, IF-NOT-IDENT)
1502 # ----------------------------------------------------
1503 # If EXPRESSION serves as an identifier (ie, after removal of @&t@, it
1504 # matches the regex `^[a-zA-Z_][a-zA-Z_0-9]*$'), execute IF-IDENT,
1505 # otherwise IF-NOT-IDENT.
1507 # This is generally faster than the alternative:
1508 #   m4_bmatch(m4_bpatsubst([[$1]], [@&t@]), ^m4_defn([m4_re_word])$,
1509 #             [$2], [$3])
1511 # Rather than expand m4_defn every time AS_IDENTIFIER_IF is expanded, we
1512 # inline its expansion up front.  Only use a regular expression if we
1513 # detect a potential quadrigraph.
1515 # First, check if the entire string matches m4_cr_symbol2.  Only then do
1516 # we worry if the first character also matches m4_cr_symbol1 (ie. does not
1517 # match m4_cr_digit).
1518 m4_define([AS_IDENTIFIER_IF],
1519 [m4_if(_$0(m4_if(m4_index([$1], [@]), [-1],
1520   [[$1]], [m4_bpatsubst([[$1]], [@&t@])])), [-], [$2], [$3])])
1522 m4_define([_AS_IDENTIFIER_IF],
1523 [m4_cond([[$1]], [], [],
1524          [m4_eval(m4_len(m4_translit([[$1]], ]]dnl
1525 m4_dquote(m4_dquote(m4_defn([m4_cr_symbols2])))[[)) > 0)], [1], [],
1526          [m4_len(m4_translit(m4_format([[%.1s]], [$1]), ]]dnl
1527 m4_dquote(m4_dquote(m4_defn([m4_cr_symbols1])))[[))], [0], [-])])
1530 # AS_LITERAL_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL,
1531 #               [IF-SIMPLE-REF = IF-NOT-LITERAL])
1532 # -----------------------------------------------------
1533 # If EXPRESSION has no shell indirections ($var or `expr`), expand
1534 # IF-LITERAL, else IF-NOT-LITERAL.  In some cases, IF-NOT-LITERAL
1535 # must be complex to safely deal with ``, while a simpler
1536 # expression IF-SIMPLE-REF can be used if the indirection
1537 # involves only shell variable expansion (as in ${varname}).
1539 # EXPRESSION is treated as a literal if it results in the same
1540 # interpretation whether it is unquoted or contained within double
1541 # quotes, with the exception that whitespace is ignored (on the
1542 # assumption that it will be flattened to _).  Therefore, neither `\$'
1543 # nor `a''b' is a literal, since both backslash and single quotes have
1544 # different quoting behavior in the two contexts; and `a*' is not a
1545 # literal, because it has different globbing.  Note, however, that
1546 # while `${a+b}' is neither a literal nor a simple ref, `a+b' is a
1547 # literal.  This macro is an *approximation*: it is possible that
1548 # there are some EXPRESSIONs which the shell would treat as literals,
1549 # but which this macro does not recognize.
1551 # Why do we reject EXPRESSION expanding with `[' or `]' as a literal?
1552 # Because AS_TR_SH is MUCH faster if it can use m4_translit on literals
1553 # instead of m4_bpatsubst; but m4_translit is much tougher to do safely
1554 # if `[' is translated.  That, and file globbing matters.
1556 # Note that the quadrigraph @S|@ can result in non-literals, but outright
1557 # rejecting all @ would make AC_INIT complain on its bug report address.
1559 # We used to use m4_bmatch(m4_quote($1), [[`$]], [$3], [$2]), but
1560 # profiling shows that it is faster to use m4_translit.
1562 # Because the translit is stripping quotes, it must also neutralize
1563 # anything that might be in a macro name, as well as comments, commas,
1564 # or unbalanced parentheses.  Valid shell variable characters and
1565 # unambiguous literal characters are deleted (`a.b'), and remaining
1566 # characters are normalized into `$' if they can form simple refs
1567 # (${a}), `+' if they can potentially form literals (a+b), ``' if they
1568 # can interfere with m4 parsing, or left alone otherwise.  If both `$'
1569 # and `+' are left, it is treated as a complex reference (${a+b}),
1570 # even though it could technically be a simple reference (${a}+b).
1571 # _AS_LITERAL_IF_ only has to check for an empty string after removing
1572 # one of the two normalized characters.
1574 # Rather than expand m4_defn every time AS_LITERAL_IF is expanded, we
1575 # inline its expansion up front.  _AS_LITERAL_IF expands to the name
1576 # of a macro that takes three arguments: IF-SIMPLE-REF,
1577 # IF-NOT-LITERAL, IF-LITERAL.  It also takes an optional argument of
1578 # any additional characters to allow as literals (useful for AS_TR_SH
1579 # and AS_TR_CPP to perform inline conversion of whitespace to _).  The
1580 # order of the arguments allows reuse of m4_default.
1581 m4_define([AS_LITERAL_IF],
1582 [_$0(m4_expand([$1]), [  ][
1583 ])([$4], [$3], [$2])])
1585 m4_define([_AS_LITERAL_IF],
1586 [m4_if(m4_index([$1], [@S|@]), [-1], [$0_(m4_translit([$1],
1587   [-:%/@{}[]#(),.$2]]]m4_dquote(m4_dquote(m4_defn([m4_cr_symbols2])))[[,
1588   [+++++$$`````]))], [$0_NO])])
1590 m4_define([_AS_LITERAL_IF_],
1591 [m4_if(m4_translit([$1], [+]), [], [$0YES],
1592        m4_translit([$1], [$]), [], [m4_default], [$0NO])])
1594 m4_define([_AS_LITERAL_IF_YES], [$3])
1595 m4_define([_AS_LITERAL_IF_NO], [$2])
1597 # AS_LITERAL_WORD_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL,
1598 #                    [IF-SIMPLE-REF = IF-NOT-LITERAL])
1599 # ----------------------------------------------------------
1600 # Like AS_LITERAL_IF, except that spaces and tabs in EXPRESSION
1601 # are treated as non-literal.
1602 m4_define([AS_LITERAL_WORD_IF],
1603 [_AS_LITERAL_IF(m4_expand([$1]))([$4], [$3], [$2])])
1605 # AS_LITERAL_HEREDOC_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL)
1606 # -------------------------------------------------------------
1607 # Like AS_LITERAL_IF, except that a string is considered literal
1608 # if it results in the same output in both quoted and unquoted
1609 # here-documents.
1610 m4_define([AS_LITERAL_HEREDOC_IF],
1611 [_$0(m4_expand([$1]))([$2], [$3])])
1613 m4_define([_AS_LITERAL_HEREDOC_IF],
1614 [m4_if(m4_index([$1], [@S|@]), [-1],
1615   [m4_if(m4_index(m4_translit([[$1]], [\`], [$]), [$]), [-1],
1616     [$0_YES], [$0_NO])],
1617   [$0_NO])])
1619 m4_define([_AS_LITERAL_HEREDOC_IF_YES], [$1])
1620 m4_define([_AS_LITERAL_HEREDOC_IF_NO], [$2])
1623 # AS_TMPDIR(PREFIX, [DIRECTORY = $TMPDIR [= /tmp]])
1624 # -------------------------------------------------
1625 # Create as safely as possible a temporary directory in DIRECTORY
1626 # which name is inspired by PREFIX (should be 2-4 chars max).
1628 # Even though $tmp does not fit our normal naming scheme of $as_*,
1629 # it is a documented part of the public API and must not be changed.
1630 m4_define([AS_TMPDIR],
1631 [# Create a (secure) tmp directory for tmp files.
1632 m4_if([$2], [], [: "${TMPDIR:=/tmp}"])
1634   tmp=`(umask 077 && mktemp -d "m4_default([$2],
1635     [$TMPDIR])/$1XXXXXX") 2>/dev/null` &&
1636   test -d "$tmp"
1637 }  ||
1639   tmp=m4_default([$2], [$TMPDIR])/$1$$-$RANDOM
1640   (umask 077 && mkdir "$tmp")
1641 } || AS_ERROR([cannot create a temporary directory in m4_default([$2],
1642               [$TMPDIR])])])# AS_TMPDIR
1645 # AS_UNAME
1646 # --------
1647 # Try to describe this machine.  Meant for logs.
1648 m4_define([AS_UNAME],
1650 cat <<_ASUNAME
1651 m4_text_box([Platform.])
1653 hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
1654 uname -m = `(uname -m) 2>/dev/null || echo unknown`
1655 uname -r = `(uname -r) 2>/dev/null || echo unknown`
1656 uname -s = `(uname -s) 2>/dev/null || echo unknown`
1657 uname -v = `(uname -v) 2>/dev/null || echo unknown`
1659 /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
1660 /bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
1662 /bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
1663 /usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
1664 /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
1665 /usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`
1666 /bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
1667 /usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
1668 /bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
1670 _ASUNAME
1672 _AS_PATH_WALK([$PATH], [AS_ECHO(["PATH: $as_dir"])])
1676 # _AS_VERSION_COMPARE_PREPARE
1677 # ---------------------------
1678 # Output variables for comparing version numbers.
1679 m4_defun([_AS_VERSION_COMPARE_PREPARE],
1680 [[as_awk_strverscmp='
1681   # Use only awk features that work with 7th edition Unix awk (1978).
1682   # My, what an old awk you have, Mr. Solaris!
1683   END {
1684     while (length(v1) && length(v2)) {
1685       # Set d1 to be the next thing to compare from v1, and likewise for d2.
1686       # Normally this is a single character, but if v1 and v2 contain digits,
1687       # compare them as integers and fractions as strverscmp does.
1688       if (v1 ~ /^[0-9]/ && v2 ~ /^[0-9]/) {
1689         # Split v1 and v2 into their leading digit string components d1 and d2,
1690         # and advance v1 and v2 past the leading digit strings.
1691         for (len1 = 1; substr(v1, len1 + 1) ~ /^[0-9]/; len1++) continue
1692         for (len2 = 1; substr(v2, len2 + 1) ~ /^[0-9]/; len2++) continue
1693         d1 = substr(v1, 1, len1); v1 = substr(v1, len1 + 1)
1694         d2 = substr(v2, 1, len2); v2 = substr(v2, len2 + 1)
1695         if (d1 ~ /^0/) {
1696           if (d2 ~ /^0/) {
1697             # Compare two fractions.
1698             while (d1 ~ /^0/ && d2 ~ /^0/) {
1699               d1 = substr(d1, 2); len1--
1700               d2 = substr(d2, 2); len2--
1701             }
1702             if (len1 != len2 && ! (len1 && len2 && substr(d1, 1, 1) == substr(d2, 1, 1))) {
1703               # The two components differ in length, and the common prefix
1704               # contains only leading zeros.  Consider the longer to be less.
1705               d1 = -len1
1706               d2 = -len2
1707             } else {
1708               # Otherwise, compare as strings.
1709               d1 = "x" d1
1710               d2 = "x" d2
1711             }
1712           } else {
1713             # A fraction is less than an integer.
1714             exit 1
1715           }
1716         } else {
1717           if (d2 ~ /^0/) {
1718             # An integer is greater than a fraction.
1719             exit 2
1720           } else {
1721             # Compare two integers.
1722             d1 += 0
1723             d2 += 0
1724           }
1725         }
1726       } else {
1727         # The normal case, without worrying about digits.
1728         d1 = substr(v1, 1, 1); v1 = substr(v1, 2)
1729         d2 = substr(v2, 1, 1); v2 = substr(v2, 2)
1730       }
1731       if (d1 < d2) exit 1
1732       if (d1 > d2) exit 2
1733     }
1734     # Beware Solaris /usr/xgp4/bin/awk (at least through Solaris 10),
1735     # which mishandles some comparisons of empty strings to integers.
1736     if (length(v2)) exit 1
1737     if (length(v1)) exit 2
1738   }
1739 ']])# _AS_VERSION_COMPARE_PREPARE
1742 # AS_VERSION_COMPARE(VERSION-1, VERSION-2,
1743 #                    [ACTION-IF-LESS], [ACTION-IF-EQUAL], [ACTION-IF-GREATER])
1744 # ----------------------------------------------------------------------------
1745 # Compare two strings possibly containing shell variables as version strings.
1747 # This usage is portable even to ancient awk,
1748 # so don't worry about finding a "nice" awk version.
1749 m4_defun_init([AS_VERSION_COMPARE],
1750 [AS_REQUIRE([_$0_PREPARE])],
1751 [as_arg_v1=$1
1752 as_arg_v2=$2
1753 awk "$as_awk_strverscmp" v1="$as_arg_v1" v2="$as_arg_v2" /dev/null
1754 AS_CASE([$?],
1755         [1], [$3],
1756         [0], [$4],
1757         [2], [$5])])# AS_VERSION_COMPARE
1761 ## --------------------------------------- ##
1762 ## 6. Common m4/sh character translation.  ##
1763 ## --------------------------------------- ##
1765 # The point of this section is to provide high level macros comparable
1766 # to m4's `translit' primitive, but m4/sh polymorphic.
1767 # Transliteration of literal strings should be handled by m4, while
1768 # shell variables' content will be translated at runtime (tr or sed).
1771 # _AS_CR_PREPARE
1772 # --------------
1773 # Output variables defining common character ranges.
1774 # See m4_cr_letters etc.
1775 m4_defun([_AS_CR_PREPARE],
1776 [# Avoid depending upon Character Ranges.
1777 as_cr_letters='abcdefghijklmnopqrstuvwxyz'
1778 as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
1779 as_cr_Letters=$as_cr_letters$as_cr_LETTERS
1780 as_cr_digits='0123456789'
1781 as_cr_alnum=$as_cr_Letters$as_cr_digits
1785 # _AS_TR_SH_PREPARE
1786 # -----------------
1787 m4_defun([_AS_TR_SH_PREPARE],
1788 [AS_REQUIRE([_AS_CR_PREPARE])]dnl
1789 [# Sed expression to map a string onto a valid variable name.
1790 as_tr_sh="eval sed 'y%*+%pp%;s%[[^_$as_cr_alnum]]%_%g'"
1794 # AS_TR_SH(EXPRESSION)
1795 # --------------------
1796 # Transform EXPRESSION into a valid shell variable name.
1797 # sh/m4 polymorphic.
1798 # Be sure to update the definition of `$as_tr_sh' if you change this.
1800 # AS_LITERAL_IF guarantees that a literal does not have any nested quotes,
1801 # once $1 is expanded.  m4_translit silently uses only the first occurrence
1802 # of a character that appears multiple times in argument 2, since we know
1803 # that m4_cr_not_symbols2 also contains [ and ].  m4_translit also silently
1804 # ignores characters in argument 3 that do not match argument 2; we use this
1805 # fact to skip worrying about the length of m4_cr_not_symbols2.
1807 # For speed, we inline the literal definitions that can be computed up front.
1808 m4_defun_init([AS_TR_SH],
1809 [AS_REQUIRE([_$0_PREPARE])],
1810 [_$0(m4_expand([$1]))])
1812 m4_define([_AS_TR_SH],
1813 [_AS_LITERAL_IF([$1], [*][       ][
1814 ])([], [$0_INDIR], [$0_LITERAL])([$1])])
1816 m4_define([_AS_TR_SH_LITERAL],
1817 [m4_translit([[$1]],
1818   [*+[]]]m4_dquote(m4_defn([m4_cr_not_symbols2]))[,
1819   [pp[]]]m4_dquote(m4_for(,1,255,,[[_]]))[)])
1821 m4_define([_AS_TR_SH_INDIR],
1822 [`AS_ECHO(["_AS_ESCAPE([[$1]], [`], [\])"]) | $as_tr_sh`])
1825 # _AS_TR_CPP_PREPARE
1826 # ------------------
1827 m4_defun([_AS_TR_CPP_PREPARE],
1828 [AS_REQUIRE([_AS_CR_PREPARE])]dnl
1829 [# Sed expression to map a string onto a valid CPP name.
1830 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[[^_$as_cr_alnum]]%_%g'"
1834 # AS_TR_CPP(EXPRESSION)
1835 # ---------------------
1836 # Map EXPRESSION to an upper case string which is valid as rhs for a
1837 # `#define'.  sh/m4 polymorphic.  Be sure to update the definition
1838 # of `$as_tr_cpp' if you change this.
1840 # See implementation comments in AS_TR_SH.
1841 m4_defun_init([AS_TR_CPP],
1842 [AS_REQUIRE([_$0_PREPARE])],
1843 [_$0(m4_expand([$1]))])
1845 m4_define([_AS_TR_CPP],
1846 [_AS_LITERAL_IF([$1], [*][       ][
1847 ])([], [$0_INDIR], [$0_LITERAL])([$1])])
1849 m4_define([_AS_TR_CPP_LITERAL],
1850 [m4_translit([[$1]],
1851   [*[]]]m4_dquote(m4_defn([m4_cr_letters])m4_defn([m4_cr_not_symbols2]))[,
1852   [P[]]]m4_dquote(m4_defn([m4_cr_LETTERS])m4_for(,1,255,,[[_]]))[)])
1854 m4_define([_AS_TR_CPP_INDIR],
1855 [`AS_ECHO(["_AS_ESCAPE([[$1]], [`], [\])"]) | $as_tr_cpp`])
1858 # _AS_TR_PREPARE
1859 # --------------
1860 m4_defun([_AS_TR_PREPARE],
1861 [AS_REQUIRE([_AS_TR_SH_PREPARE])AS_REQUIRE([_AS_TR_CPP_PREPARE])])
1866 ## ------------------------------------------------------ ##
1867 ## 7. Common m4/sh handling of variables (indirections).  ##
1868 ## ------------------------------------------------------ ##
1871 # The purpose of this section is to provide a uniform API for
1872 # reading/setting sh variables with or without indirection.
1873 # Typically, one can write
1874 #   AS_VAR_SET(var, val)
1875 # or
1876 #   AS_VAR_SET(as_$var, val)
1877 # and expect the right thing to happen.  In the descriptions below,
1878 # a literal name matches the regex [a-zA-Z_][a-zA-Z0-9_]*, an
1879 # indirect name is a shell expression that produces a literal name
1880 # when passed through eval, and a polymorphic name is either type.
1883 # _AS_VAR_APPEND_PREPARE
1884 # ----------------------
1885 # Define as_fn_append to the optimum definition for the current
1886 # shell (bash and zsh provide the += assignment operator to avoid
1887 # quadratic append growth over repeated appends).
1888 m4_defun([_AS_VAR_APPEND_PREPARE],
1889 [AS_FUNCTION_DESCRIBE([as_fn_append], [VAR VALUE],
1890 [Append the text in VALUE to the end of the definition contained in
1891 VAR.  Take advantage of any shell optimizations that allow amortized
1892 linear growth over repeated appends, instead of the typical quadratic
1893 growth present in naive implementations.])
1894 AS_IF([_AS_RUN(["AS_ESCAPE(m4_quote(_AS_VAR_APPEND_WORKS))"])],
1895 [eval 'as_fn_append ()
1896   {
1897     eval $[]1+=\$[]2
1898   }'],
1899 [as_fn_append ()
1900   {
1901     eval $[]1=\$$[]1\$[]2
1902   }]) # as_fn_append
1905 # _AS_VAR_APPEND_WORKS
1906 # --------------------
1907 # Output a shell test to discover whether += works.
1908 m4_define([_AS_VAR_APPEND_WORKS],
1909 [as_var=1; as_var+=2; test x$as_var = x12])
1911 # AS_VAR_APPEND(VAR, VALUE)
1912 # -------------------------
1913 # Append the shell expansion of VALUE to the end of the existing
1914 # contents of the polymorphic shell variable VAR, taking advantage of
1915 # any shell optimizations that allow repeated appends to result in
1916 # amortized linear scaling rather than quadratic behavior.  This macro
1917 # is not worth the overhead unless the expected final size of the
1918 # contents of VAR outweigh the typical VALUE size of repeated appends.
1919 # Note that unlike AS_VAR_SET, VALUE must be properly quoted to avoid
1920 # field splitting and file name expansion.
1921 m4_defun_init([AS_VAR_APPEND],
1922 [AS_REQUIRE([_AS_VAR_APPEND_PREPARE], [], [M4SH-INIT-FN])],
1923 [as_fn_append $1 $2])
1926 # _AS_VAR_ARITH_PREPARE
1927 # ---------------------
1928 # Define as_fn_arith to the optimum definition for the current
1929 # shell (using POSIX $(()) where supported).
1930 m4_defun([_AS_VAR_ARITH_PREPARE],
1931 [AS_FUNCTION_DESCRIBE([as_fn_arith], [ARG...],
1932 [Perform arithmetic evaluation on the ARGs, and store the result in
1933 the global $as_val.  Take advantage of shells that can avoid forks.
1934 The arguments must be portable across $(()) and expr.])
1935 AS_IF([_AS_RUN(["AS_ESCAPE(m4_quote(_AS_VAR_ARITH_WORKS))"])],
1936 [eval 'as_fn_arith ()
1937   {
1938     as_val=$(( $[]* ))
1939   }'],
1940 [as_fn_arith ()
1941   {
1942     as_val=`expr "$[]@" || test $? -eq 1`
1943   }]) # as_fn_arith
1946 # _AS_VAR_ARITH_WORKS
1947 # -------------------
1948 # Output a shell test to discover whether $(()) works.
1949 m4_define([_AS_VAR_ARITH_WORKS],
1950 [test $(( 1 + 1 )) = 2])
1952 # AS_VAR_ARITH(VAR, EXPR)
1953 # -----------------------
1954 # Perform the arithmetic evaluation of the arguments in EXPR, and set
1955 # contents of the polymorphic shell variable VAR to the result, taking
1956 # advantage of any shell optimizations that perform arithmetic without
1957 # forks.  Note that numbers occuring within EXPR must be written in
1958 # decimal, and without leading zeroes; variables containing numbers
1959 # must be expanded prior to arithmetic evaluation; the first argument
1960 # must not be a negative number; there is no portable equality
1961 # operator; and operators must be given as separate arguments and
1962 # properly quoted.
1963 m4_defun_init([AS_VAR_ARITH],
1964 [_AS_DETECT_SUGGESTED([_AS_VAR_ARITH_WORKS])]dnl
1965 [AS_REQUIRE([_AS_VAR_ARITH_PREPARE], [], [M4SH-INIT-FN])],
1966 [as_fn_arith $2 && AS_VAR_SET([$1], [$as_val])])
1969 # AS_VAR_COPY(DEST, SOURCE)
1970 # -------------------------
1971 # Set the polymorphic shell variable DEST to the contents of the polymorphic
1972 # shell variable SOURCE.
1973 m4_define([AS_VAR_COPY],
1974 [AS_LITERAL_WORD_IF([$1[]$2], [$1=$$2], [eval $1=\$$2])])
1977 # AS_VAR_GET(VARIABLE)
1978 # --------------------
1979 # Get the value of the shell VARIABLE.
1980 # Evaluates to $VARIABLE if there is no indirection in VARIABLE,
1981 # else to the appropriate `eval' sequence.
1982 # This macro is deprecated because it sometimes mishandles trailing newlines;
1983 # use AS_VAR_COPY instead.
1984 m4_define([AS_VAR_GET],
1985 [AS_LITERAL_WORD_IF([$1],
1986                [$$1],
1987   [`eval 'as_val=${'_AS_ESCAPE([[$1]], [`], [\])'};AS_ECHO(["$as_val"])'`])])
1990 # AS_VAR_IF(VARIABLE, VALUE, IF-TRUE, IF-FALSE)
1991 # ---------------------------------------------
1992 # Implement a shell `if test $VARIABLE = VALUE; then-else'.
1993 # Polymorphic, and avoids sh expansion error upon interrupt or term signal.
1994 m4_define([AS_VAR_IF],
1995 [AS_LITERAL_WORD_IF([$1],
1996   [AS_IF(m4_ifval([$2], [[test "x$$1" = x[]$2]], [[${$1:+false} :]])],
1997   [AS_VAR_COPY([as_val], [$1])
1998    AS_IF(m4_ifval([$2], [[test "x$as_val" = x[]$2]], [[${as_val:+false} :]])],
1999   [AS_IF(m4_ifval([$2],
2000     [[eval test \"x\$"$1"\" = x"_AS_ESCAPE([$2], [`], [\"$])"]],
2001     [[eval \${$1:+false} :]])]),
2002 [$3], [$4])])
2005 # AS_VAR_PUSHDEF and AS_VAR_POPDEF
2006 # --------------------------------
2009 # Sometimes we may have to handle literals (e.g. `stdlib.h'), while at
2010 # other moments, the same code may have to get the value from a
2011 # variable (e.g., `ac_header').  To have a uniform handling of both
2012 # cases, when a new value is about to be processed, declare a local
2013 # variable, e.g.:
2015 #   AS_VAR_PUSHDEF([header], [ac_cv_header_$1])
2017 # and then in the body of the macro, use `header' as is.  It is of
2018 # first importance to use `AS_VAR_*' to access this variable.
2020 # If the value `$1' was a literal (e.g. `stdlib.h'), then `header' is
2021 # in fact the value `ac_cv_header_stdlib_h'.  If `$1' was indirect,
2022 # then `header's value in m4 is in fact `$as_header', the shell
2023 # variable that holds all of the magic to get the expansion right.
2025 # At the end of the block, free the variable with
2027 #   AS_VAR_POPDEF([header])
2030 # AS_VAR_POPDEF(VARNAME)
2031 # ----------------------
2032 # Free the shell variable accessor VARNAME.  To be dnl'ed.
2033 m4_define([AS_VAR_POPDEF],
2034 [m4_popdef([$1])])
2037 # AS_VAR_PUSHDEF(VARNAME, VALUE)
2038 # ------------------------------
2039 # Define the m4 macro VARNAME to an accessor to the shell variable
2040 # named VALUE.  VALUE does not need to be a valid shell variable name:
2041 # the transliteration is handled here.  To be dnl'ed.
2043 # AS_TR_SH attempts to play with diversions if _AS_TR_SH_PREPARE has
2044 # not been expanded.  However, users are expected to do subsequent
2045 # calls that trigger AS_LITERAL_IF([VARNAME]), and that macro performs
2046 # expansion inside an argument collection context, where diversions
2047 # don't work.  Therefore, we must require the preparation ourselves.
2048 m4_defun_init([AS_VAR_PUSHDEF],
2049 [AS_REQUIRE([_AS_TR_SH_PREPARE])],
2050 [_$0([$1], m4_expand([$2]))])
2052 m4_define([_AS_VAR_PUSHDEF],
2053 [_AS_LITERAL_IF([$2], [  ][
2054 ])([], [as_$1=_AS_TR_SH_INDIR([$2])
2055 m4_pushdef([$1], [$as_[$1]])],
2056 [m4_pushdef([$1], [_AS_TR_SH_LITERAL([$2])])])])
2059 # AS_VAR_SET(VARIABLE, VALUE)
2060 # ---------------------------
2061 # Set the contents of the polymorphic shell VARIABLE to the shell
2062 # expansion of VALUE.  VALUE is immune to field splitting and file
2063 # name expansion.
2064 m4_define([AS_VAR_SET],
2065 [AS_LITERAL_WORD_IF([$1],
2066                [$1=$2],
2067                [eval "$1=_AS_ESCAPE([$2], [`], [\"$])"])])
2070 # AS_VAR_SET_IF(VARIABLE, IF-TRUE, IF-FALSE)
2071 # ------------------------------------------
2072 # Implement a shell `if-then-else' depending whether VARIABLE is set
2073 # or not.  Polymorphic.
2074 m4_define([AS_VAR_SET_IF],
2075 [AS_IF([AS_VAR_TEST_SET([$1])], [$2], [$3])])
2078 # AS_VAR_TEST_SET(VARIABLE)
2079 # -------------------------
2080 # Expands into an expression which is true if VARIABLE
2081 # is set.  Polymorphic.
2082 m4_define([AS_VAR_TEST_SET],
2083 [AS_LITERAL_WORD_IF([$1],
2084   [${$1+:} false],
2085   [{ as_var=$1; eval \${$as_var+:} false; }],
2086   [eval \${$1+:} false])])
2089 ## -------------------- ##
2090 ## 8. Setting M4sh up.  ##
2091 ## -------------------- ##
2094 # AS_INIT_GENERATED(FILE, [COMMENT])
2095 # ----------------------------------
2096 # Generate a child script FILE with all initialization necessary to
2097 # reuse the environment learned by the parent script, and make the
2098 # file executable.  If COMMENT is supplied, it is inserted after the
2099 # `#!' sequence but before initialization text begins.  After this
2100 # macro, additional text can be appended to FILE to form the body of
2101 # the child script.  The macro ends with non-zero status if the
2102 # file could not be fully written (such as if the disk is full).
2103 m4_defun([AS_INIT_GENERATED],
2104 [m4_require([AS_PREPARE])]dnl
2105 [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl
2106 [as_write_fail=0
2107 cat >$1 <<_ASEOF || as_write_fail=1
2108 #! $SHELL
2109 # Generated by $as_me.
2111 SHELL=\${CONFIG_SHELL-$SHELL}
2112 export SHELL
2113 _ASEOF
2114 cat >>$1 <<\_ASEOF || as_write_fail=1
2115 _AS_SHELL_SANITIZE
2116 _AS_PREPARE
2117 m4_if(AS_MESSAGE_FD, [1], [], [exec AS_MESSAGE_FD>&1
2118 ])]dnl
2119 [m4_text_box([Main body of $1 script.])
2120 _ASEOF
2121 test $as_write_fail = 0 && chmod +x $1[]dnl
2122 _m4_popdef([AS_MESSAGE_LOG_FD])])# AS_INIT_GENERATED
2125 # AS_INIT
2126 # -------
2127 # Initialize m4sh.
2128 m4_define([AS_INIT],
2129 [# Wrap our cleanup prior to m4sugar's cleanup.
2130 m4_wrap([_AS_CLEANUP])
2131 m4_init
2132 m4_provide([AS_INIT])
2134 # Forbidden tokens and exceptions.
2135 m4_pattern_forbid([^_?AS_])
2137 # Bangshe and minimal initialization.
2138 m4_divert_text([BINSH], [@%:@! /bin/sh])
2139 m4_divert_text([HEADER-COMMENT],
2140                [@%:@ Generated from __file__ by m4_PACKAGE_STRING.])
2141 m4_divert_text([M4SH-SANITIZE], [_AS_SHELL_SANITIZE])
2142 m4_divert_text([M4SH-INIT-FN], [m4_text_box([M4sh Shell Functions.])])
2144 # Let's go!
2145 m4_divert([BODY])dnl
2146 m4_text_box([Main body of script.])
2147 _AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])dnl
2148 AS_REQUIRE([_AS_UNSET_PREPARE], [], [M4SH-INIT-FN])dnl