Require _AS_CR_PREPARE where appropriate and fix ChangeLog.
[autoconf.git] / lib / m4sugar / m4sh.m4
bloba67c30d5181ae41a742002fe854394240b6f94b6
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 # Free Software Foundation, Inc.
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2, or (at your option)
11 # 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 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 # 02110-1301, USA.
23 # As a special exception, the Free Software Foundation gives unlimited
24 # permission to copy, distribute and modify the configure scripts that
25 # are the output of Autoconf.  You need not follow the terms of the GNU
26 # General Public License when using or distributing such scripts, even
27 # though portions of the text of Autoconf appear in them.  The GNU
28 # General Public License (GPL) does govern all other use of the material
29 # that constitutes the Autoconf program.
31 # Certain portions of the Autoconf source text are designed to be copied
32 # (in certain cases, depending on the input) into the output of
33 # Autoconf.  We call these the "data" portions.  The rest of the Autoconf
34 # source text consists of comments plus executable code that decides which
35 # of the data portions to output in any given case.  We call these
36 # comments and executable code the "non-data" portions.  Autoconf never
37 # copies any of the non-data portions into its output.
39 # This special exception to the GPL applies to versions of Autoconf
40 # released by the Free Software Foundation.  When you make and
41 # distribute a modified version of Autoconf, you may extend this special
42 # exception to the GPL to apply to your modified version as well, *unless*
43 # your modified version has the potential to copy into its output some
44 # of the text that was the non-data portion of the version that you started
45 # with.  (In other words, unless your change moves or copies text from
46 # the non-data portions to the data portions.)  If your modification has
47 # such potential, you must delete any notice of this special exception
48 # to the GPL from your modified version.
50 # Written by Akim Demaille, Pavel Roskin, Alexandre Oliva, Lars J. Aas
51 # and many other people.
54 # We heavily use m4's diversions both for the initializations and for
55 # required macros, because in both cases we have to issue soon in
56 # output something which is discovered late.
59 # KILL is only used to suppress output.
61 # - BINSH
62 #   AC_REQUIRE'd #! /bin/sh line
63 # - HEADER-REVISION
64 #   RCS keywords etc.
65 # - HEADER-COMMENT
66 #   Purpose of the script etc.
67 # - HEADER-COPYRIGHT
68 #   Copyright notice(s)
69 # - M4SH-SANITIZE
70 #   M4sh's shell setup
71 # - M4SH-INIT-FN
72 #   M4sh initialization (shell functions)
73 # - M4SH-INIT
74 #   M4sh initialization (detection code)
75 # - BODY
76 #   The body of the script.
79 # _m4_divert(DIVERSION-NAME)
80 # --------------------------
81 # Convert a diversion name into its number.  Otherwise, return
82 # DIVERSION-NAME which is supposed to be an actual diversion number.
83 # Of course it would be nicer to use m4_case here, instead of zillions
84 # of little macros, but it then takes twice longer to run `autoconf'!
85 m4_define([_m4_divert(BINSH)],             0)
86 m4_define([_m4_divert(HEADER-REVISION)],   1)
87 m4_define([_m4_divert(HEADER-COMMENT)],    2)
88 m4_define([_m4_divert(HEADER-COPYRIGHT)],  3)
89 m4_define([_m4_divert(M4SH-SANITIZE)],     4)
90 m4_define([_m4_divert(M4SH-INIT-FN)],      5)
91 m4_define([_m4_divert(M4SH-INIT)],         6)
92 m4_define([_m4_divert(BODY)],           1000)
94 # Aaarg.  Yet it starts with compatibility issues...  Libtool wants to
95 # use NOTICE to insert its own LIBTOOL-INIT stuff.  People should ask
96 # before diving into our internals :(
97 m4_copy([_m4_divert(M4SH-INIT)], [_m4_divert(NOTICE)])
101 ## ------------------------- ##
102 ## 1. Sanitizing the shell.  ##
103 ## ------------------------- ##
104 # Please maintain lexicographic sorting of this section, ignoring leading _.
106 # AS_BOURNE_COMPATIBLE
107 # --------------------
108 # Try to be as Bourne and/or POSIX as possible.
110 # This does not set BIN_SH, due to the problems described in
111 # <http://lists.gnu.org/archive/html/autoconf-patches/2006-03/msg00081.html>.
112 # People who need BIN_SH should set it in their environment before invoking
113 # configure; apparently this would include UnixWare, as described in
114 # <http://lists.gnu.org/archive/html/bug-autoconf/2006-06/msg00025.html>.
115 m4_define([AS_BOURNE_COMPATIBLE],
116 [# Be more Bourne compatible
117 DUALCASE=1; export DUALCASE # for MKS sh
121 # _AS_BOURNE_COMPATIBLE
122 # ---------------------
123 # This is the part of AS_BOURNE_COMPATIBLE which has to be repeated inside
124 # each instance.
125 m4_define([_AS_BOURNE_COMPATIBLE],
126 [AS_IF([test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1],
127  [emulate sh
128   NULLCMD=:
129   [#] Pre-4.2 versions of Zsh do word splitting on ${1+"$[@]"}, which
130   # is contrary to our usage.  Disable this feature.
131   alias -g '${1+"$[@]"}'='"$[@]"'
132   setopt NO_GLOB_SUBST],
133  [AS_CASE([`(set -o) 2>/dev/null`], [*posix*], [set -o posix])])
137 # _AS_CLEANUP
138 # -----------
139 # Expanded as the last thing before m4sugar cleanup begins.  Macros
140 # may append m4sh cleanup hooks to this as appropriate.
141 m4_define([_AS_CLEANUP],
142 [m4_divert_text([M4SH-SANITIZE], [_AS_DETECT_BETTER_SHELL])])
145 # AS_COPYRIGHT(TEXT)
146 # ------------------
147 # Emit TEXT, a copyright notice, as a shell comment near the top of the
148 # script.  TEXT is evaluated once; to accomplish that, we do not prepend
149 # `# ' but `@%:@ '.
150 m4_define([AS_COPYRIGHT],
151 [m4_divert_text([HEADER-COPYRIGHT],
152 [m4_bpatsubst([
153 $1], [^], [@%:@ ])])])
156 # _AS_DETECT_EXPAND(VAR, SET)
157 # ---------------------------
158 # Assign the contents of VAR from the contents of SET, expanded in such
159 # a manner that VAR can be passed to _AS_RUN.  In order to make
160 # _AS_LINENO_WORKS operate correctly, we must specially handle the
161 # first instance of $LINENO within any line being expanded (the first
162 # instance is important to tests using the current shell, leaving
163 # remaining instances for tests using a candidate shell).  Bash loses
164 # track of line numbers if a double quote contains a newline, hence,
165 # we must piece-meal the assignment of VAR such that $LINENO expansion
166 # occurs in a single line.
167 m4_define([_AS_DETECT_EXPAND],
168 [$1="m4_bpatsubst(m4_dquote(AS_ESCAPE(m4_expand(m4_set_contents([$2], [
169 ])))), [\\\$LINENO\(.*\)$], [";$1=$$1$LINENO;$1=$$1"\1])"])
172 # _AS_DETECT_REQUIRED(TEST)
173 # -------------------------
174 # Refuse to execute under a shell that does not pass the given TEST.
175 # Does not do AS_REQUIRE for the better-shell detection code.
176 m4_defun([_AS_DETECT_REQUIRED],
177 [m4_set_add([_AS_DETECT_REQUIRED_BODY], [$1 || AS_EXIT])])
180 # _AS_DETECT_SUGGESTED(TEST)
181 # --------------------------
182 # Prefer to execute under a shell that passes the given TEST.
183 # Does not do AS_REQUIRE for the better-shell detection code.
184 m4_defun([_AS_DETECT_SUGGESTED],
185 [m4_set_add([_AS_DETECT_SUGGESTED_BODY], [$1 || AS_EXIT])])
188 # _AS_DETECT_SUGGESTED_PRUNE(TEST)
189 # --------------------------------
190 # If TEST is also a required test, remove it from the set of suggested tests.
191 m4_define([_AS_DETECT_SUGGESTED_PRUNE],
192 [m4_set_contains([_AS_DETECT_REQUIRED_BODY], [$1],
193                  [m4_set_remove([_AS_DETECT_SUGGESTED_BODY], [$1])])])
196 # _AS_DETECT_BETTER_SHELL
197 # -----------------------
198 # The real workhorse for detecting a shell with the correct
199 # features.
201 # In previous versions, we prepended /usr/posix/bin to the path, but that
202 # caused a regression on OpenServer 6.0.0
203 # <http://lists.gnu.org/archive/html/bug-autoconf/2006-06/msg00017.html>
204 # and on HP-UX 11.11, see the failure of test 120 in
205 # <http://lists.gnu.org/archive/html/bug-autoconf/2006-10/msg00003.html>
207 # FIXME: The code should test for the OSF bug described in
208 # <http://lists.gnu.org/archive/html/autoconf-patches/2006-03/msg00081.html>.
210 # This code is run outside any trap 0 context, hence we can simplify AS_EXIT.
211 m4_defun([_AS_DETECT_BETTER_SHELL],
212 dnl Remove any tests from suggested that are also required
213 [m4_set_map([_AS_DETECT_SUGGESTED_BODY], [_AS_DETECT_SUGGESTED_PRUNE])]dnl
214 [m4_pushdef([AS_EXIT], [exit m4_default([$1], 1)])]dnl
215 [if test "x$CONFIG_SHELL" = x; then
216   as_bourne_compatible="AS_ESCAPE(m4_expand([_AS_BOURNE_COMPATIBLE]))"
217   _AS_DETECT_EXPAND([as_required], [_AS_DETECT_REQUIRED_BODY])
218   _AS_DETECT_EXPAND([as_suggested], [_AS_DETECT_SUGGESTED_BODY])
219   AS_IF([_AS_RUN(["$as_required"])],
220         [as_have_required=yes],
221         [as_have_required=no])
222   AS_IF([test x$as_have_required = xyes && _AS_RUN(["$as_suggested"])],
223     [],
224     [_AS_PATH_WALK([/bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH],
225       [case $as_dir in @%:@(
226          /*)
227            for as_base in sh bash ksh sh5; do
228              # Try only shells that exist, to save several forks.
229              as_shell=$as_dir/$as_base
230              AS_IF([{ test -f "$as_shell" || test -f "$as_shell.exe"; } &&
231                     _AS_RUN(["$as_required"], ["$as_shell"])],
232                    [CONFIG_SHELL=$as_shell as_have_required=yes
233                    m4_set_empty([_AS_DETECT_SUGGESTED_BODY], [break 2],
234                      [AS_IF([_AS_RUN(["$as_suggested"], ["$as_shell"])],
235                             [break 2])])])
236            done;;
237        esac],
238       [AS_IF([{ test -f "$SHELL" || test -f "$SHELL.exe"; } &&
239               _AS_RUN(["$as_required"], ["$SHELL"])],
240              [CONFIG_SHELL=$SHELL as_have_required=yes])])
242       AS_IF([test "x$CONFIG_SHELL" != x],
243         [# We cannot yet assume a decent shell, so we have to provide a
244         # neutralization value for shells without unset; and this also
245         # works around shells that cannot unset nonexistent variables.
246         BASH_ENV=/dev/null
247         ENV=/dev/null
248         (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
249         export CONFIG_SHELL
250         exec "$CONFIG_SHELL" "$as_myself" ${1+"$[@]"}])
252 dnl Unfortunately, $as_me isn't available here.
253     AS_IF([test x$as_have_required = xno],
254       [AS_ECHO(["$[]0: This script requires a shell more modern than all"])
255   AS_ECHO(["$[]0: the shells that I found on your system."])
256   if test x${ZSH_VERSION+set} = xset ; then
257     AS_ECHO(["$[]0: In particular, zsh $ZSH_VERSION has bugs and should"])
258     AS_ECHO(["$[]0: be upgraded to zsh 4.3.4 or later."])
259   else
260     AS_ECHO("m4_text_wrap([Please tell ]_m4_defn([m4_PACKAGE_BUGREPORT])
261 m4_ifset([AC_PACKAGE_BUGREPORT], [m4_if(_m4_defn([m4_PACKAGE_BUGREPORT]),
262 _m4_defn([AC_PACKAGE_BUGREPORT]), [], [and _m4_defn([AC_PACKAGE_BUGREPORT])])])
263 [about your system, including any error possibly output before this message.
264 Then install a modern shell, or manually run the script under such a
265 shell if you do have one.], [$[]0: ], [], [62])")
266   fi
267       AS_EXIT(1)])])
269 _m4_popdef([AS_EXIT])])# _AS_DETECT_BETTER_SHELL
272 # _AS_PREPARE
273 # -----------
274 # This macro has a very special status.  Normal use of M4sh relies
275 # heavily on AS_REQUIRE, so that needed initializations (such as
276 # _AS_TEST_PREPARE) are performed on need, not on demand.  But
277 # Autoconf is the first client of M4sh, and for two reasons: configure
278 # and config.status.  Relying on AS_REQUIRE is of course fine for
279 # configure, but fails for config.status (which is created by
280 # configure).  So we need a means to force the inclusion of the
281 # various _AS_*_PREPARE on top of config.status.  That's basically why
282 # there are so many _AS_*_PREPARE below, and that's also why it is
283 # important not to forget some: config.status needs them.
284 # List any preparations that create shell functions first, then
285 # topologically sort the others by their dependencies.
286 m4_defun([_AS_PREPARE],
287 [m4_pushdef([AS_REQUIRE])]dnl
288 [m4_pushdef([AS_REQUIRE_SHELL_FN], _m4_defn([_AS_REQUIRE_SHELL_FN])
289 )]dnl
290 [_AS_UNSET_PREPARE
291 _AS_VAR_APPEND_PREPARE
292 _AS_VAR_ARITH_PREPARE
294 _AS_EXPR_PREPARE
295 _AS_BASENAME_PREPARE
296 _AS_DIRNAME_PREPARE
297 _AS_ME_PREPARE
298 _AS_CR_PREPARE
299 _AS_LINENO_PREPARE
300 _AS_ECHO_N_PREPARE
301 _AS_LN_S_PREPARE
302 _AS_MKDIR_P_PREPARE
303 _AS_TEST_PREPARE
304 _AS_TR_CPP_PREPARE
305 _AS_TR_SH_PREPARE
306 _m4_popdef([AS_REQUIRE], [AS_REQUIRE_SHELL_FN])])
308 # AS_PREPARE
309 # ----------
310 # Output all the M4sh possible initialization into the initialization
311 # diversion.  We do not use _AS_PREPARE so that the m4_provide symbols for
312 # AS_REQUIRE and AS_REQUIRE_SHELL_FN are defined properly, and so that
313 # shell functions are placed in M4SH-INIT-FN.
314 m4_defun([AS_PREPARE],
315 [m4_divert_push([KILL])
316 AS_REQUIRE([_AS_EXPR_PREPARE])
317 AS_REQUIRE([_AS_BASENAME_PREPARE])
318 AS_REQUIRE([_AS_DIRNAME_PREPARE])
319 AS_REQUIRE([_AS_ME_PREPARE])
320 AS_REQUIRE([_AS_CR_PREPARE])
321 AS_REQUIRE([_AS_LINENO_PREPARE])
322 AS_REQUIRE([_AS_ECHO_N_PREPARE])
323 AS_REQUIRE([_AS_LN_S_PREPARE])
324 AS_REQUIRE([_AS_MKDIR_P_PREPARE])
325 AS_REQUIRE([_AS_TEST_PREPARE])
326 AS_REQUIRE([_AS_TR_CPP_PREPARE])
327 AS_REQUIRE([_AS_TR_SH_PREPARE])
328 AS_REQUIRE([_AS_UNSET_PREPARE])
329 AS_REQUIRE([_AS_VAR_APPEND_PREPARE], [], [M4SH-INIT-FN])
330 AS_REQUIRE([_AS_VAR_ARITH_PREPARE], [], [M4SH-INIT-FN])
331 m4_divert_pop[]])
334 # AS_REQUIRE(NAME-TO-CHECK, [BODY-TO-EXPAND = NAME-TO-CHECK],
335 #            [DIVERSION = M4SH-INIT])
336 # -----------------------------------------------------------
337 # BODY-TO-EXPAND is some initialization which must be expanded in the
338 # given diversion when expanded (required or not).  The expansion
339 # goes in the named diversion or an earlier one.
341 # Note: we expand _m4_divert_desired before passing it to m4_divert_require,
342 # otherwise we would need to use m4_pushdef and m4_popdef instead of
343 # simply m4_define.
345 # Since $2 can be quite large, this is factored for faster execution, giving
346 # either m4_require([$1], [$2]) or m4_divert_require(desired, [$1], [$2]).
347 m4_defun([AS_REQUIRE],
348 [m4_define([_m4_divert_desired], [m4_default_quoted([$3], [M4SH-INIT])])]dnl
349 [m4_if(m4_eval(_m4_divert(_m4_divert_dump) <= _m4_divert(_m4_divert_desired)),
350        1, [m4_require(],
351           [m4_divert_require(_m4_divert(_m4_divert_desired),]) [$1], [$2])])
353 # _AS_REQUIRE_SHELL_FN(NAME-TO-CHECK, COMMENT, BODY-TO-EXPAND)
354 # ------------------------------------------------------------
355 # Core of AS_REQUIRE_SHELL_FN, but without diversion support.
356 m4_define([_AS_REQUIRE_SHELL_FN], [
357 m4_n([$2])$1 ()
360 } @%:@ $1[]])
362 # AS_REQUIRE_SHELL_FN(NAME-TO-CHECK, COMMENT, BODY-TO-EXPAND,
363 #                     [DIVERSION = M4SH-INIT-FN])
364 # -----------------------------------------------------------
365 # BODY-TO-EXPAND is the body of a shell function to be emitted in the
366 # given diversion when expanded (required or not).  Unlike other
367 # xx_REQUIRE macros, BODY-TO-EXPAND is mandatory.  If COMMENT is
368 # provided (often via AS_FUNCTION_DESCRIBE), it is listed with a
369 # newline before the function name.
370 m4_define([AS_REQUIRE_SHELL_FN],
371 [m4_provide_if([AS_SHELL_FN_$1], [],
372 [AS_REQUIRE([AS_SHELL_FN_$1],
373 [m4_provide([AS_SHELL_FN_$1])_$0($@)],
374 m4_default_quoted([$4], [M4SH-INIT-FN]))])])
377 # _AS_RUN(TEST, [SHELL])
378 # ----------------------
379 # Run TEST under the current shell (if one parameter is used)
380 # or under the given SHELL, protecting it from syntax errors.
381 # Set as_run in order to assist _AS_LINENO_WORKS.
382 m4_define([_AS_RUN],
383 [m4_ifval([$2], [{ $as_echo "$as_bourne_compatible"$1 | as_run=a $2; }],
384                 [(eval $1)]) 2>/dev/null])
387 # _AS_SHELL_FN_WORK
388 # -----------------
389 # This is a spy to detect "in the wild" shells that do not support shell
390 # functions correctly.  It is based on the m4sh.at Autotest testcases.
391 m4_define([_AS_SHELL_FN_WORK],
392 [as_func_return () { (exit [$]1); }
393 as_func_success () { as_func_return 0; }
394 as_func_failure () { as_func_return 1; }
395 as_func_ret_success () { return 0; }
396 as_func_ret_failure () { return 1; }
398 exitcode=0
399 as_func_success || { exitcode=1; echo as_func_success failed.; }
400 as_func_failure && { exitcode=1; echo as_func_failure succeeded.; }
401 as_func_ret_success || { exitcode=1; echo as_func_ret_success failed.; }
402 as_func_ret_failure && { exitcode=1; echo as_func_ret_failure succeeded.; }
403 AS_IF([( set x; as_func_ret_success y && test x = "[$]1" )], [],
404       [exitcode=1; echo positional parameters were not saved.])
405 test x$exitcode = x0[]])# _AS_SHELL_FN_WORK
408 # _AS_SHELL_SANITIZE
409 # ------------------
410 # This is the prolog that is emitted by AS_INIT and AS_INIT_GENERATED.
411 m4_defun([_AS_SHELL_SANITIZE],
412 [m4_text_box([M4sh Initialization.])
414 AS_BOURNE_COMPATIBLE
415 _AS_ECHO_PREPARE
416 _AS_PATH_SEPARATOR_PREPARE
418 # IFS
419 # We need space, tab and new line, in precisely that order.  Quoting is
420 # there to prevent editors from complaining about space-tab.
421 # (If _AS_PATH_WALK were called with IFS unset, it would disable word
422 # splitting by setting IFS to empty value.)
423 IFS=" ""        $as_nl"
425 # Find who we are.  Look in the path if we contain no directory separator.
426 case $[0] in @%:@((
427   *[[\\/]]* ) as_myself=$[0] ;;
428   *) _AS_PATH_WALK([],
429                    [test -r "$as_dir/$[0]" && as_myself=$as_dir/$[0] && break])
430      ;;
431 esac
432 # We did not find ourselves, most probably we were run as `sh COMMAND'
433 # in which case we are not to be found in the path.
434 if test "x$as_myself" = x; then
435   as_myself=$[0]
437 if test ! -f "$as_myself"; then
438   AS_ECHO(["$as_myself: error: cannot find myself; rerun with an absolute file name"]) >&2
439   AS_EXIT
442 # Unset variables that we do not need and which cause bugs (e.g. in
443 # pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
444 # suppresses any "Segmentation fault" message there.  '((' could
445 # trigger a bug in pdksh 5.2.14.
446 for as_var in BASH_ENV ENV MAIL MAILPATH
447 do eval test x\${$as_var+set} = xset \
448   && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
449 done
450 PS1='$ '
451 PS2='> '
452 PS4='+ '
454 # NLS nuisances.
455 LC_ALL=C
456 export LC_ALL
457 LANGUAGE=C
458 export LANGUAGE
460 # CDPATH.
461 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
462 ])# _AS_SHELL_SANITIZE
465 # AS_SHELL_SANITIZE
466 # -----------------
467 # This is only needed for the sake of Libtool, which screws up royally
468 # in its usage of M4sh internals.
469 m4_define([AS_SHELL_SANITIZE],
470 [_AS_SHELL_SANITIZE
471 m4_provide_if([AS_INIT], [],
472 [m4_provide([AS_INIT])
473 _AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])
474 _AS_DETECT_BETTER_SHELL
475 _AS_UNSET_PREPARE
476 ])])
479 ## ----------------------------- ##
480 ## 2. Wrappers around builtins.  ##
481 ## ----------------------------- ##
483 # This section is lexicographically sorted.
486 # AS_CASE(WORD, [PATTERN1], [IF-MATCHED1]...[DEFAULT])
487 # ----------------------------------------------------
488 # Expand into
489 # | case WORD in #(
490 # |   PATTERN1) IF-MATCHED1 ;; #(
491 # |   ...
492 # |   *) DEFAULT ;;
493 # | esac
494 # The shell comments are intentional, to work around people who don't
495 # realize the impacts of using insufficient m4 quoting.
496 m4_define([_AS_CASE],
497 [ [@%:@(]
498   $1[)] $2 ;;])
499 m4_define([_AS_CASE_DEFAULT],
500 [ [@%:@(]
501   *[)] $1 ;;])
503 m4_defun([AS_CASE],
504 [case $1 in[]m4_map_args_pair([_$0], [_$0_DEFAULT], m4_shift($@))
505 esac])# AS_CASE
508 # AS_EXIT([EXIT-CODE = 1])
509 # ------------------------
510 # Exit and set exit code to EXIT-CODE in the way that it's seen
511 # within "trap 0".
513 # We cannot simply use "exit N" because some shells (zsh and Solaris sh)
514 # will not set $? to N while running the code set by "trap 0"
515 # So we set $? by executing "exit N" in the subshell and then exit.
516 # Other shells don't use `$?' as default for `exit', hence just repeating
517 # the exit value can only help improving portability.
518 m4_define([AS_EXIT],
519 [{ (exit m4_default([$1], 1)); exit m4_default([$1], 1); }])
522 # AS_IF(TEST1, [IF-TRUE1 = :]...[IF-FALSE = :])
523 # ---------------------------------------------
524 # Expand into
525 # | if TEST1; then
526 # |   IF-TRUE1
527 # | elif TEST2; then
528 # |   IF-TRUE2
529 # [...]
530 # | else
531 # |   IF-FALSE
532 # | fi
533 # with simplifications if IF-TRUE1 and/or IF-FALSE is empty.
535 m4_define([_AS_IF],
536 [elif $1; then
537   m4_default([$2], [:])
539 m4_define([_AS_IF_ELSE],
540 [m4_ifvaln([$1],
541 [else
542   $1])])
544 m4_defun([AS_IF],
545 [if $1; then
546   m4_default([$2], [:])
547 m4_map_args_pair([_$0], [_$0_ELSE], m4_shift2($@))]dnl
548 [fi[]])# AS_IF
551 # _AS_UNSET_PREPARE
552 # -----------------
553 # Define $as_unset to execute AS_UNSET, for backwards compatibility
554 # with older versions of M4sh.
555 m4_defun([_AS_UNSET_PREPARE],
556 [AS_FUNCTION_DESCRIBE([as_func_unset], [VAR], [Portably unset VAR.])
557 as_func_unset ()
559   AS_UNSET([$[1]])
561 as_unset=as_func_unset])
564 # AS_UNSET(VAR)
565 # -------------
566 # Unset the env VAR, working around shells that do not allow unsetting
567 # a variable that is not already set.  You should not unset MAIL and
568 # MAILCHECK, as that triggers a bug in Bash 2.01.
569 m4_defun([AS_UNSET],
570 [{ AS_LITERAL_IF([$1], [], [eval ])$1=; unset $1;}])
577 ## ------------------------------------------ ##
578 ## 3. Error and warnings at the shell level.  ##
579 ## ------------------------------------------ ##
581 # If AS_MESSAGE_LOG_FD is defined, shell messages are duplicated there
582 # too.
585 # AS_ESCAPE(STRING, [CHARS = $"`\])
586 # ---------------------------------
587 # Escape the CHARS in STRING.
589 # Avoid the m4_bpatsubst if there are no interesting characters to escape.
590 # _AS_ESCAPE bypasses argument defaulting.
591 m4_define([AS_ESCAPE],
592 [_$0([$1], m4_default([$2], [\"$`]))])
593 m4_define([_AS_ESCAPE],
594 [m4_if(m4_len([$1]),
595        m4_len(m4_translit([[$1]], [$2])),
596        [$1], [m4_bpatsubst([$1], [[$2]], [\\\&])])])
599 # _AS_QUOTE_IFELSE(STRING, IF-MODERN-QUOTATION, IF-OLD-QUOTATION)
600 # ---------------------------------------------------------------
601 # Compatibility glue between the old AS_MSG suite which did not
602 # quote anything, and the modern suite which quotes the quotes.
603 # If STRING contains `\\' or `\$', it's modern.
604 # If STRING contains `\"' or `\`', it's old.
605 # Otherwise it's modern.
607 # Profiling shows that m4_index is 5 to 8x faster than m4_bregexp.  The
608 # slower implementation used:
609 # m4_bmatch([$1],
610 #           [\\[\\$]], [$2],
611 #           [\\[`"]], [$3],
612 #           [$2])
613 # The current implementation caters to the common case of no backslashes,
614 # to minimize m4_index expansions (hence the nested if).
615 m4_define([_AS_QUOTE_IFELSE],
616 [m4_cond([m4_index([$1], [\])], [-1], [$2],
617          [m4_eval(m4_index([$1], [\\]) >= 0)], [1], [$2],
618          [m4_eval(m4_index([$1], [\$]) >= 0)], [1], [$2],
619          [m4_eval(m4_index([$1], [\`]) >= 0)], [1], [$3],
620          [m4_eval(m4_index([$1], [\"]) >= 0)], [1], [$3],
621          [$2])])
624 # _AS_QUOTE(STRING, [CHARS = `"])
625 # -------------------------------
626 # If there are quoted (via backslash) backquotes do nothing, else
627 # backslash all the quotes.
628 m4_define([_AS_QUOTE],
629 [_AS_QUOTE_IFELSE([$1],
630                   [_AS_ESCAPE([$1], m4_default([$2], [`""]))],
631                   [m4_warn([obsolete],
632            [back quotes and double quotes must not be escaped in: $1])dnl
633 $1])])
636 # _AS_ECHO_UNQUOTED(STRING, [FD = AS_MESSAGE_FD])
637 # -----------------------------------------------
638 # Perform shell expansions on STRING and echo the string to FD.
639 m4_define([_AS_ECHO_UNQUOTED],
640 [AS_ECHO(["$1"]) >&m4_default([$2], [AS_MESSAGE_FD])])
643 # _AS_ECHO(STRING, [FD = AS_MESSAGE_FD])
644 # --------------------------------------
645 # Protect STRING from backquote expansion, echo the result to FD.
646 m4_define([_AS_ECHO],
647 [_AS_ECHO_UNQUOTED([_AS_QUOTE([$1])], [$2])])
650 # _AS_ECHO_LOG(STRING)
651 # --------------------
652 # Log the string to AS_MESSAGE_LOG_FD.
653 m4_defun_init([_AS_ECHO_LOG],
654 [AS_REQUIRE([_AS_LINENO_PREPARE])],
655 [_AS_ECHO([$as_me:${as_lineno-$LINENO}: $1], [AS_MESSAGE_LOG_FD])])
658 # _AS_ECHO_N_PREPARE
659 # ------------------
660 # Check whether to use -n, \c, or newline-tab to separate
661 # checking messages from result messages.
662 # Don't try to cache, since the results of this macro are needed to
663 # display the checking message.  In addition, caching something used once
664 # has little interest.
665 # Idea borrowed from dist 3.0.  Use `*c*,', not `*c,' because if `\c'
666 # failed there is also a newline to match.
667 m4_defun([_AS_ECHO_N_PREPARE],
668 [ECHO_C= ECHO_N= ECHO_T=
669 case `echo -n x` in @%:@((((
670 -n*)
671   case `echo 'x\c'` in
672   *c*) ECHO_T=' ';;     # ECHO_T is single tab character.
673   *)   ECHO_C='\c';;
674   esac;;
676   ECHO_N='-n';;
677 esac
678 ])# _AS_ECHO_N_PREPARE
681 # _AS_ECHO_N(STRING, [FD = AS_MESSAGE_FD])
682 # ----------------------------------------
683 # Same as _AS_ECHO, but echo doesn't return to a new line.
684 m4_define([_AS_ECHO_N],
685 [AS_ECHO_N(["_AS_QUOTE([$1])"]) >&m4_default([$2], [AS_MESSAGE_FD])])
688 # AS_MESSAGE(STRING, [FD = AS_MESSAGE_FD])
689 # ----------------------------------------
690 # Output "`basename $0`: "STRING to the open file FD.
691 m4_defun_init([AS_MESSAGE],
692 [AS_REQUIRE([_AS_ME_PREPARE])],
693 [m4_ifset([AS_MESSAGE_LOG_FD],
694           [{ _AS_ECHO_LOG([$1])
695 _AS_ECHO([$as_me: $1], [$2]);}],
696           [_AS_ECHO([$as_me: $1], [$2])])[]])
699 # AS_WARN(PROBLEM)
700 # ----------------
701 m4_define([AS_WARN],
702 [AS_MESSAGE([WARNING: $1], [2])])# AS_WARN
705 # AS_ERROR(ERROR, [EXIT-STATUS = 1])
706 # ----------------------------------
707 m4_define([AS_ERROR],
708 [{ AS_MESSAGE([error: $1], [2])
709    AS_EXIT([$2]); }])# AS_ERROR
713 # AS_LINENO_PUSH([LINENO])
714 # ------------------------
715 # If this is the outermost call to AS_LINENO_PUSH, make sure that
716 # AS_MESSAGE will print LINENO as the line number.
717 m4_defun([AS_LINENO_PUSH],
718 [as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack])
721 # AS_LINENO_POP([LINENO])
722 # ------------------------
723 # If this is call balances the outermost call to AS_LINENO_PUSH,
724 # AS_MESSAGE will restart printing $LINENO as the line number.
725 m4_defun([AS_LINENO_POP],
726 [eval $as_lineno_stack; test "x$as_lineno_stack" = x && AS_UNSET([as_lineno])])
730 ## -------------------------------------- ##
731 ## 4. Portable versions of common tools.  ##
732 ## -------------------------------------- ##
734 # This section is lexicographically sorted.
737 # AS_BASENAME(FILE-NAME)
738 # ----------------------
739 # Simulate the command 'basename FILE-NAME'.  Not all systems have basename.
740 # Also see the comments for AS_DIRNAME.
742 m4_defun([_AS_BASENAME_EXPR],
743 [$as_expr X/[]$1 : '.*/\([[^/][^/]*]\)/*$' \| \
744          X[]$1 : 'X\(//\)$' \| \
745          X[]$1 : 'X\(/\)' \| .])
747 m4_defun([_AS_BASENAME_SED],
748 [AS_ECHO([X/[]$1]) |
749     sed ['/^.*\/\([^/][^/]*\)\/*$/{
750             s//\1/
751             q
752           }
753           /^X\/\(\/\/\)$/{
754             s//\1/
755             q
756           }
757           /^X\/\(\/\).*/{
758             s//\1/
759             q
760           }
761           s/.*/./; q']])
763 m4_defun_init([AS_BASENAME],
764 [AS_REQUIRE([_$0_PREPARE])],
765 [$as_basename -- $1 ||
766 _AS_BASENAME_EXPR([$1]) 2>/dev/null ||
767 _AS_BASENAME_SED([$1])])
770 # _AS_BASENAME_PREPARE
771 # --------------------
772 # Avoid Solaris 9 /usr/ucb/basename, as `basename /' outputs an empty line.
773 # Also, traditional basename mishandles --.  Require here _AS_EXPR_PREPARE,
774 # to avoid problems when _AS_BASENAME is called from the M4SH-INIT diversion.
775 m4_defun([_AS_BASENAME_PREPARE],
776 [AS_REQUIRE([_AS_EXPR_PREPARE])]dnl
777 [if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
778   as_basename=basename
779 else
780   as_basename=false
782 ])# _AS_BASENAME_PREPARE
785 # AS_DIRNAME(FILE-NAME)
786 # ---------------------
787 # Simulate the command 'dirname FILE-NAME'.  Not all systems have dirname.
788 # This macro must be usable from inside ` `.
790 # Prefer expr to echo|sed, since expr is usually faster and it handles
791 # backslashes and newlines correctly.  However, older expr
792 # implementations (e.g. SunOS 4 expr and Solaris 8 /usr/ucb/expr) have
793 # a silly length limit that causes expr to fail if the matched
794 # substring is longer than 120 bytes.  So fall back on echo|sed if
795 # expr fails.
796 m4_defun_init([_AS_DIRNAME_EXPR],
797 [AS_REQUIRE([_AS_EXPR_PREPARE])],
798 [$as_expr X[]$1 : 'X\(.*[[^/]]\)//*[[^/][^/]]*/*$' \| \
799          X[]$1 : 'X\(//\)[[^/]]' \| \
800          X[]$1 : 'X\(//\)$' \| \
801          X[]$1 : 'X\(/\)' \| .])
803 m4_defun([_AS_DIRNAME_SED],
804 [AS_ECHO([X[]$1]) |
805     sed ['/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
806             s//\1/
807             q
808           }
809           /^X\(\/\/\)[^/].*/{
810             s//\1/
811             q
812           }
813           /^X\(\/\/\)$/{
814             s//\1/
815             q
816           }
817           /^X\(\/\).*/{
818             s//\1/
819             q
820           }
821           s/.*/./; q']])
823 m4_defun_init([AS_DIRNAME],
824 [AS_REQUIRE([_$0_PREPARE])],
825 [$as_dirname -- $1 ||
826 _AS_DIRNAME_EXPR([$1]) 2>/dev/null ||
827 _AS_DIRNAME_SED([$1])])
830 # _AS_DIRNAME_PREPARE
831 # --------------------
832 m4_defun([_AS_DIRNAME_PREPARE],
833 [AS_REQUIRE([_AS_EXPR_PREPARE])]dnl
834 [if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
835   as_dirname=dirname
836 else
837   as_dirname=false
839 ])# _AS_DIRNAME_PREPARE
842 # AS_ECHO(WORD)
843 # -------------
844 # Output WORD followed by a newline.  WORD must be a single shell word
845 # (typically a quoted string).  The bytes of WORD are output as-is, even
846 # if it starts with "-" or contains "\".
847 m4_defun_init([AS_ECHO],
848 [AS_REQUIRE([_$0_PREPARE])],
849 [$as_echo $1])
852 # AS_ECHO_N(WORD)
853 # -------------
854 # Like AS_ECHO(WORD), except do not output the trailing newline.
855 m4_defun_init([AS_ECHO_N],
856 [AS_REQUIRE([_AS_ECHO_PREPARE])],
857 [$as_echo_n $1])
860 # _AS_ECHO_PREPARE
861 # -----------------
862 # Arrange for $as_echo 'FOO' to echo FOO without escape-interpretation;
863 # and similarly for $as_echo_foo, which omits the trailing newline.
864 # 'FOO' is an optional single argument; a missing FOO is treated as empty.
865 m4_defun([_AS_ECHO_PREPARE],
866 [[as_nl='
868 export as_nl
869 # Printing a long string crashes Solaris 7 /usr/bin/printf.
870 as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
871 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
872 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
873 if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
874   as_echo='printf %s\n'
875   as_echo_n='printf %s'
876 else
877   if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
878     as_echo_body='eval /usr/ucb/echo -n "$][1$as_nl"'
879     as_echo_n='/usr/ucb/echo -n'
880   else
881     as_echo_body='eval expr "X$][1" : "X\\(.*\\)"'
882     as_echo_n_body='eval
883       arg=$][1;
884       case $arg in @%:@(
885       *"$as_nl"*)
886         expr "X$arg" : "X\\(.*\\)$as_nl";
887         arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
888       esac;
889       expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
890     '
891     export as_echo_n_body
892     as_echo_n='sh -c $as_echo_n_body as_echo'
893   fi
894   export as_echo_body
895   as_echo='sh -c $as_echo_body as_echo'
897 ]])# _AS_ECHO_PREPARE
900 # AS_TEST_X
901 # ---------
902 # Check whether a file has executable or search permissions.
903 m4_defun_init([AS_TEST_X],
904 [AS_REQUIRE([_AS_TEST_PREPARE])],
905 [$as_test_x $1[]])# AS_TEST_X
908 # AS_EXECUTABLE_P
909 # ---------------
910 # Check whether a file is a regular file that has executable permissions.
911 m4_defun_init([AS_EXECUTABLE_P],
912 [AS_REQUIRE([_AS_TEST_PREPARE])],
913 [{ test -f $1 && AS_TEST_X([$1]); }])# AS_EXECUTABLE_P
916 # _AS_EXPR_PREPARE
917 # ----------------
918 # QNX 4.25 expr computes and issue the right result but exits with failure.
919 # Tru64 expr mishandles leading zeros in numeric strings.
920 # Detect these flaws.
921 m4_defun([_AS_EXPR_PREPARE],
922 [if expr a : '\(a\)' >/dev/null 2>&1 &&
923    test "X`expr 00001 : '.*\(...\)'`" = X001; then
924   as_expr=expr
925 else
926   as_expr=false
928 ])# _AS_EXPR_PREPARE
931 # _AS_ME_PREPARE
932 # --------------
933 # Define $as_me to the basename of the executable file's name.
934 m4_defun([AS_ME_PREPARE], [AS_REQUIRE([_$0])])
935 m4_defun([_AS_ME_PREPARE],
936 [AS_REQUIRE([_AS_BASENAME_PREPARE])]dnl
937 [as_me=`AS_BASENAME("$[0]")`
940 # _AS_LINENO_WORKS
941 # ---------------
942 # Succeed if the currently executing shell supports LINENO.
943 # This macro does not expand to a single shell command, so be careful
944 # when using it.  Surrounding the body of this macro with {} would
945 # cause "bash -c '_ASLINENO_WORKS'" to fail (with Bash 2.05, anyway),
946 # but that bug is irrelevant to our use of LINENO.  We can't use
947 # AS_VAR_ARITH, as this is expanded prior to shell functions.
949 # Testing for LINENO support is hard; we use _AS_LINENO_WORKS inside
950 # _AS_RUN, which sometimes eval's its argument (pdksh gives false
951 # negatives if $LINENO is expanded by eval), and sometimes passes the
952 # argument to another shell (if the current shell supports LINENO,
953 # then expanding $LINENO prior to the string leads to false
954 # positives).  Hence, we perform two tests, and coordinate with
955 # _AS_DETECT_EXPAND (which ensures that only the first of two LINENO
956 # is expanded in advance) and _AS_RUN (which sets $as_run to 'a' when
957 # handing the test to another shell), so that we know which test to
958 # trust.
959 m4_define([_AS_LINENO_WORKS],
960 [  as_lineno_1=$LINENO as_lineno_1a=$LINENO
961   as_lineno_2=$LINENO as_lineno_2a=$LINENO
962   eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
963   test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"'])
966 # _AS_LINENO_PREPARE
967 # ------------------
968 # If LINENO is not supported by the shell, produce a version of this
969 # script where LINENO is hard coded.
970 # Comparing LINENO against _oline_ is not a good solution, since in
971 # the case of embedded executables (such as config.status within
972 # configure) you'd compare LINENO wrt config.status vs. _oline_ wrt
973 # configure.
974 m4_defun([AS_LINENO_PREPARE], [AS_REQUIRE([_$0])])
975 m4_defun([_AS_LINENO_PREPARE],
976 [AS_REQUIRE([_AS_CR_PREPARE])]dnl
977 [AS_REQUIRE([_AS_ME_PREPARE])]dnl
978 [_AS_DETECT_SUGGESTED([_AS_LINENO_WORKS])]dnl
979 dnl Even if the logging fd is open, we don't want to use $LINENO in the
980 dnl AS_ERROR complaining that LINENO is broken.
981 [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl
982 dnl Create $as_me.lineno as a copy of $as_myself, but with $LINENO
983 dnl uniformly replaced by the line number.  The first 'sed' inserts a
984 dnl line-number line after each line using $LINENO; the second 'sed'
985 dnl does the real work.  The second script uses 'N' to pair each
986 dnl line-number line with the line containing $LINENO, and appends
987 dnl trailing '-' during substitution so that $LINENO is not a special
988 dnl case at line end.  (Raja R Harinath suggested sed '=', and Paul
989 dnl Eggert wrote the scripts with optimization help from Paolo Bonzini).
990 [_AS_LINENO_WORKS || {
991   # Blame Lee E. McMahon (1931-1989) for sed's syntax.  :-)
992   sed -n '
993     p
994     /[[$]]LINENO/=
995   ' <$as_myself |
996     sed '
997       s/[[$]]LINENO.*/&-/
998       t lineno
999       b
1000       :lineno
1001       N
1002       :loop
1003       s/[[$]]LINENO\([[^'$as_cr_alnum'_]].*\n\)\(.*\)/\2\1\2/
1004       t loop
1005       s/-\n.*//
1006     ' >$as_me.lineno &&
1007   chmod +x "$as_me.lineno" ||
1008     AS_ERROR([cannot create $as_me.lineno; rerun with a POSIX shell])
1010   # Don't try to exec as it changes $[0], causing all sort of problems
1011   # (the dirname of $[0] is not the place where we might find the
1012   # original and so on.  Autoconf is especially sensitive to this).
1013   . "./$as_me.lineno"
1014   # Exit status is that of the last command.
1015   exit
1017 _m4_popdef([AS_MESSAGE_LOG_FD])])# _AS_LINENO_PREPARE
1020 # _AS_LN_S_PREPARE
1021 # ----------------
1022 # Don't use conftest.sym to avoid file name issues on DJGPP, where this
1023 # would yield conftest.sym.exe for DJGPP < 2.04.  And don't use `conftest'
1024 # as base name to avoid prohibiting concurrency (e.g., concurrent
1025 # config.statuses).  On read-only media, assume 'cp -p' and hope we
1026 # are just running --help anyway.
1027 m4_defun([_AS_LN_S_PREPARE],
1028 [rm -f conf$$ conf$$.exe conf$$.file
1029 if test -d conf$$.dir; then
1030   rm -f conf$$.dir/conf$$.file
1031 else
1032   rm -f conf$$.dir
1033   mkdir conf$$.dir 2>/dev/null
1035 if (echo >conf$$.file) 2>/dev/null; then
1036   if ln -s conf$$.file conf$$ 2>/dev/null; then
1037     as_ln_s='ln -s'
1038     # ... but there are two gotchas:
1039     # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
1040     # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
1041     # In both cases, we have to default to `cp -p'.
1042     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
1043       as_ln_s='cp -p'
1044   elif ln conf$$.file conf$$ 2>/dev/null; then
1045     as_ln_s=ln
1046   else
1047     as_ln_s='cp -p'
1048   fi
1049 else
1050   as_ln_s='cp -p'
1052 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
1053 rmdir conf$$.dir 2>/dev/null
1054 ])# _AS_LN_S_PREPARE
1057 # AS_LN_S(FILE, LINK)
1058 # -------------------
1059 # FIXME: Should we add the glue code to handle properly relative symlinks
1060 # simulated with `ln' or `cp'?
1061 m4_defun_init([AS_LN_S],
1062 [AS_REQUIRE([_AS_LN_S_PREPARE])],
1063 [$as_ln_s $1 $2])
1066 # _AS_MKDIR_P
1067 # -----------
1068 # Emit code that can be used to emulate `mkdir -p` with plain `mkdir';
1069 # the code assumes that "$as_dir" contains the directory to create.
1070 # $as_dir is normalized, so there is no need to worry about using --.
1071 m4_define([_AS_MKDIR_P],
1072 [case $as_dir in #(
1073   -*) as_dir=./$as_dir;;
1074   esac
1075   test -d "$as_dir" || eval $as_mkdir_p || {
1076     as_dirs=
1077     while :; do
1078       case $as_dir in #(
1079       *\'*) as_qdir=`AS_ECHO(["$as_dir"]) | sed "s/'/'\\\\\\\\''/g"`;; #'(
1080       *) as_qdir=$as_dir;;
1081       esac
1082       as_dirs="'$as_qdir' $as_dirs"
1083       as_dir=`AS_DIRNAME("$as_dir")`
1084       test -d "$as_dir" && break
1085     done
1086     test -z "$as_dirs" || eval "mkdir $as_dirs"
1087   } || test -d "$as_dir" || AS_ERROR([cannot create directory $as_dir])
1090 # AS_MKDIR_P(DIR)
1091 # ---------------
1092 # Emulate `mkdir -p' with plain `mkdir' if needed.
1093 m4_defun_init([AS_MKDIR_P],
1094 [AS_REQUIRE([_$0_PREPARE])],
1095 [as_dir=$1; as_func_mkdir_p])# AS_MKDIR_P
1098 # _AS_MKDIR_P_PREPARE
1099 # -------------------
1100 m4_defun([_AS_MKDIR_P_PREPARE],
1101 [AS_REQUIRE_SHELL_FN([as_func_mkdir_p],
1102   [AS_FUNCTION_DESCRIBE([as_func_mkdir_p], [],
1103     [Create "$as_dir" as a directory, including parents if necessary.])],
1105   _AS_MKDIR_P
1106 ])]dnl
1107 [if mkdir -p . 2>/dev/null; then
1108   as_mkdir_p='mkdir -p "$as_dir"'
1109 else
1110   test -d ./-p && rmdir ./-p
1111   as_mkdir_p=false
1113 ])# _AS_MKDIR_P_PREPARE
1116 # _AS_PATH_SEPARATOR_PREPARE
1117 # --------------------------
1118 # Compute the path separator.
1119 m4_defun([_AS_PATH_SEPARATOR_PREPARE],
1120 [# The user is always right.
1121 if test "${PATH_SEPARATOR+set}" != set; then
1122   PATH_SEPARATOR=:
1123   (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
1124     (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
1125       PATH_SEPARATOR=';'
1126   }
1128 ])# _AS_PATH_SEPARATOR_PREPARE
1131 # _AS_PATH_WALK([PATH = $PATH], BODY, [IF-NOT-FOUND])
1132 # ---------------------------------------------------
1133 # Walk through PATH running BODY for each `as_dir'.  If BODY never does a
1134 # `break', evaluate IF-NOT-FOUND.
1136 # Still very private as its interface looks quite bad.
1138 # `$as_dummy' forces splitting on constant user-supplied paths.
1139 # POSIX.2 field splitting is done only on the result of word
1140 # expansions, not on literal text.  This closes a longstanding sh security
1141 # hole.  Optimize it away when not needed, i.e., if there are no literal
1142 # path separators.
1143 m4_defun_init([_AS_PATH_WALK],
1144 [AS_REQUIRE([_AS_PATH_SEPARATOR_PREPARE])],
1145 [as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
1146 m4_ifvaln([$3], [as_found=false])dnl
1147 m4_bmatch([$1], [[:;]],
1148 [as_dummy="$1"
1149 for as_dir in $as_dummy],
1150 [for as_dir in m4_default([$1], [$PATH])])
1152   IFS=$as_save_IFS
1153   test -z "$as_dir" && as_dir=.
1154   m4_ifvaln([$3], [as_found=:])dnl
1155   $2
1156   m4_ifvaln([$3], [as_found=false])dnl
1157 done
1158 m4_ifvaln([$3], [$as_found || { $3; }])dnl
1159 IFS=$as_save_IFS
1163 # AS_SET_CATFILE(VAR, DIR-NAME, FILE-NAME)
1164 # ----------------------------------------
1165 # Set VAR to DIR-NAME/FILE-NAME.
1166 # Optimize the common case where $2 or $3 is '.'.
1167 m4_define([AS_SET_CATFILE],
1168 [case $2 in @%:@((
1169 .) $1=$3;;
1171   case $3 in @%:@(((
1172   .) $1=$2;;
1173   [[\\/]]* | ?:[[\\/]]* ) $1=$3;;
1174   *) $1=$2/$3;;
1175   esac;;
1176 esac[]])# AS_SET_CATFILE
1179 # _AS_TEST_PREPARE
1180 # ----------------
1181 # Find out whether `test -x' works.  If not, prepare a substitute
1182 # that should work well enough for most scripts.
1184 # Here are some of the problems with the substitute.
1185 # The 'ls' tests whether the owner, not the current user, can execute/search.
1186 # The eval means '*', '?', and '[' cause inadvertent file name globbing
1187 # after the 'eval', so jam together as many tokens as we can to minimize
1188 # the likelihood that the inadvertent globbing will actually do anything.
1189 # Luckily, this gorp is needed only on really ancient hosts.
1191 m4_defun([_AS_TEST_PREPARE],
1192 [if test -x / >/dev/null 2>&1; then
1193   as_test_x='test -x'
1194 else
1195   if ls -dL / >/dev/null 2>&1; then
1196     as_ls_L_option=L
1197   else
1198     as_ls_L_option=
1199   fi
1200   as_test_x='
1201     eval sh -c '\''
1202       if test -d "$[]1"; then
1203         test -d "$[]1/.";
1204       else
1205         case $[]1 in @%:@(
1206         -*)set "./$[]1";;
1207         esac;
1208         case `ls -ld'$as_ls_L_option' "$[]1" 2>/dev/null` in @%:@((
1209         ???[[sx]]*):;;*)false;;esac;fi
1210     '\'' sh
1211   '
1213 dnl as_executable_p is present for backward compatibility with Libtool
1214 dnl 1.5.22, but it should go away at some point.
1215 as_executable_p=$as_test_x
1216 ])# _AS_TEST_PREPARE
1221 ## ------------------ ##
1222 ## 5. Common idioms.  ##
1223 ## ------------------ ##
1225 # This section is lexicographically sorted.
1228 # AS_BOX(MESSAGE, [FRAME-CHARACTER = `-'])
1229 # ----------------------------------------
1230 # Output MESSAGE, a single line text, framed with FRAME-CHARACTER (which
1231 # must not be `/').
1232 m4_define([AS_BOX],
1233 [AS_LITERAL_IF([$1],
1234                [_AS_BOX_LITERAL($@)],
1235                [_AS_BOX_INDIR($@)])])
1238 # _AS_BOX_LITERAL(MESSAGE, [FRAME-CHARACTER = `-'])
1239 # -------------------------------------------------
1240 m4_define([_AS_BOX_LITERAL],
1241 [cat <<\_ASBOX
1242 m4_text_box($@)
1243 _ASBOX])
1246 # _AS_BOX_INDIR(MESSAGE, [FRAME-CHARACTER = `-'])
1247 # -----------------------------------------------
1248 m4_define([_AS_BOX_INDIR],
1249 [sed 'h;s/./m4_default([$2], [-])/g;s/^.../@%:@@%:@ /;s/...$/ @%:@@%:@/;p;x;p;x' <<_ASBOX
1250 @%:@@%:@ $1 @%:@@%:@
1251 _ASBOX])
1254 # AS_FUNCTION_DESCRIBE(NAME, [ARGS], DESCRIPTION, [WRAP-COLUMN = 79])
1255 # -------------------------------------------------------------------
1256 # Output a shell comment describing NAME and its arguments ARGS, then
1257 # a separator line, then the DESCRIPTION wrapped at a decimal
1258 # WRAP-COLUMN.  The output resembles:
1259 #  # NAME ARGS
1260 #  # ---------
1261 #  # Wrapped DESCRIPTION text
1262 # NAME and ARGS are expanded, while DESCRIPTION is treated as a
1263 # whitespace-separated list of strings that are not expanded.
1264 m4_define([AS_FUNCTION_DESCRIBE],
1265 [@%:@ $1[]m4_ifval([$2], [ $2])
1266 @%:@ m4_translit(m4_format([%*s],
1267                    m4_qlen(m4_expand([$1[]m4_ifval([$2], [ $2])])), []),
1268                  [ ], [-])
1269 m4_text_wrap([$3], [@%:@ ], [], [$4])])
1272 # AS_HELP_STRING(LHS, RHS, [INDENT-COLUMN = 26], [WRAP-COLUMN = 79])
1273 # ------------------------------------------------------------------
1275 # Format a help string so that it looks pretty when the user executes
1276 # "script --help".  This macro takes up to four arguments, a
1277 # "left hand side" (LHS), a "right hand side" (RHS), a decimal
1278 # INDENT-COLUMN which is the column where wrapped lines should begin
1279 # (the default of 26 is recommended), and a decimal WRAP-COLUMN which is
1280 # the column where lines should wrap (the default of 79 is recommended).
1281 # LHS is expanded, RHS is not.
1283 # For backwards compatibility not documented in the manual, INDENT-COLUMN
1284 # can also be specified as a string of white spaces, whose width
1285 # determines the indentation column.  Using TABs in INDENT-COLUMN is not
1286 # recommended, since screen width of TAB is not computed.
1288 # The resulting string is suitable for use in other macros that require
1289 # a help string (e.g. AC_ARG_WITH).
1291 # Here is the sample string from the Autoconf manual (Node: External
1292 # Software) which shows the proper spacing for help strings.
1294 #    --with-readline         support fancy command line editing
1295 #  ^ ^                       ^
1296 #  | |                       |
1297 #  | column 2                column 26
1298 #  |
1299 #  column 0
1301 # A help string is made up of a "left hand side" (LHS) and a "right
1302 # hand side" (RHS).  In the example above, the LHS is
1303 # "--with-readline", while the RHS is "support fancy command line
1304 # editing".
1306 # If the LHS contains more than (INDENT-COLUMN - 3) characters, then the
1307 # LHS is terminated with a newline so that the RHS starts on a line of its
1308 # own beginning at INDENT-COLUMN.  In the default case, this corresponds to an
1309 # LHS with more than 23 characters.
1311 # Therefore, in the example, if the LHS were instead
1312 # "--with-readline-blah-blah-blah", then the AS_HELP_STRING macro would
1313 # expand into:
1316 #    --with-readline-blah-blah-blah
1317 #  ^ ^                       support fancy command line editing
1318 #  | |                       ^
1319 #  | column 2                |
1320 #  column 0                  column 26
1323 # m4_text_wrap hacks^Wworks around the fact that m4_format does not
1324 # know quadrigraphs.
1326 m4_define([AS_HELP_STRING],
1327 [m4_text_wrap([$2], m4_cond([[$3]], [], [                          ],
1328                             [m4_eval([$3]+0)], [0], [[$3]],
1329                             [m4_format([[%*s]], [$3], [])]),
1330               m4_expand([  $1 ]), [$4])])# AS_HELP_STRING
1333 # AS_IDENTIFIER_IF(EXPRESSION, IF-IDENT, IF-NOT-IDENT)
1334 # ----------------------------------------------------
1335 # If EXPRESSION serves as an identifier (ie, after removal of @&t@, it
1336 # matches the regex `^[a-zA-Z_][a-zA-Z_0-9]*$'), execute IF-IDENT,
1337 # otherwise IF-NOT-IDENT.
1339 # This is generally faster than the alternative:
1340 #   m4_bmatch(m4_bpatsubst([[$1]], [@&t@]), ^m4_defn([m4_re_word])$,
1341 #             [$2], [$3])
1343 # Rather than expand m4_defn every time AS_IDENTIFIER_IF is expanded, we
1344 # inline its expansion up front.  Only use a regular expression if we
1345 # detect a potential quadrigraph.
1347 # First, check if the entire string matches m4_cr_symbol2.  Only then do
1348 # we worry if the first character also matches m4_cr_symbol1 (ie. does not
1349 # match m4_cr_digit).
1350 m4_define([AS_IDENTIFIER_IF],
1351 [m4_if(m4_index([$1], [@]), [-1],
1352        [_$0($@)],
1353        [_$0(m4_bpatsubst([[$1]], [@&t@]), [$2], [$3])])])
1354 m4_define([_AS_IDENTIFIER_IF],
1355 [m4_cond([[$1]], [], [$3],
1356          [m4_eval(m4_len(m4_translit([[$1]], ]]dnl
1357 m4_dquote(m4_dquote(m4_defn([m4_cr_symbols2])))[[)) > 0)], [1], [$3],
1358          [m4_len(m4_translit(m4_format([[%.1s]], [$1]), ]]dnl
1359 m4_dquote(m4_dquote(m4_defn([m4_cr_symbols1])))[[))], [0], [$2], [$3])])
1362 # AS_LITERAL_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL)
1363 # -----------------------------------------------------
1364 # If EXPRESSION has shell indirections ($var or `expr`), expand
1365 # IF-INDIR, else IF-NOT-INDIR.
1366 # This is an *approximation*: for instance EXPRESSION = `\$' is
1367 # definitely a literal, but will not be recognized as such.
1369 # Why do we reject EXPRESSION expanding with `[' or `]' as a literal?
1370 # Because AS_TR_SH is MUCH faster if it can use m4_translit on literals
1371 # instead of m4_bpatsubst; but m4_translit is much tougher to do safely
1372 # if `[' is translated.
1374 # Note that the quadrigraph @S|@ can result in non-literals, but outright
1375 # rejecting all @ would make AC_INIT complain on its bug report address.
1377 # We used to use m4_bmatch(m4_quote($1), [[`$]], [$3], [$2]), but
1378 # profiling shows that it is faster to use m4_translit.
1380 # Because the translit is stripping quotes, it must also neutralize anything
1381 # that might be in a macro name, as well as comments and commas.  All the
1382 # problem characters are unified so that a single m4_index can scan the
1383 # result.
1385 # Rather than expand m4_defn every time AS_LITERAL_IF is expanded, we
1386 # inline its expansion up front.
1387 m4_define([AS_LITERAL_IF],
1388 [m4_cond([m4_eval(m4_index(m4_quote($1), [@S|@]) == -1)], [0], [$3],
1389          [m4_index(m4_translit(m4_quote($1),
1390                                [[]`,#]]]dnl
1391 m4_dquote(m4_dquote(m4_defn([m4_cr_symbols2])))[[,
1392                                [$$$]),
1393                    [$])], [-1], [$2],
1394          [$3])])
1397 # AS_TMPDIR(PREFIX, [DIRECTORY = $TMPDIR [= /tmp]])
1398 # -------------------------------------------------
1399 # Create as safely as possible a temporary directory in DIRECTORY
1400 # which name is inspired by PREFIX (should be 2-4 chars max).
1401 m4_define([AS_TMPDIR],
1402 [# Create a (secure) tmp directory for tmp files.
1403 m4_if([$2], [], [: ${TMPDIR=/tmp}])
1405   tmp=`(umask 077 && mktemp -d "m4_default([$2], [$TMPDIR])/$1XXXXXX") 2>/dev/null` &&
1406   test -n "$tmp" && test -d "$tmp"
1407 }  ||
1409   tmp=m4_default([$2], [$TMPDIR])/$1$$-$RANDOM
1410   (umask 077 && mkdir "$tmp")
1411 } || AS_ERROR([cannot create a temporary directory in m4_default([$2],
1412               [$TMPDIR])])])# AS_TMPDIR
1415 # AS_UNAME
1416 # --------
1417 # Try to describe this machine.  Meant for logs.
1418 m4_define([AS_UNAME],
1420 cat <<_ASUNAME
1421 m4_text_box([Platform.])
1423 hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
1424 uname -m = `(uname -m) 2>/dev/null || echo unknown`
1425 uname -r = `(uname -r) 2>/dev/null || echo unknown`
1426 uname -s = `(uname -s) 2>/dev/null || echo unknown`
1427 uname -v = `(uname -v) 2>/dev/null || echo unknown`
1429 /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
1430 /bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
1432 /bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
1433 /usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
1434 /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
1435 /usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`
1436 /bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
1437 /usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
1438 /bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
1440 _ASUNAME
1442 _AS_PATH_WALK([$PATH], [AS_ECHO(["PATH: $as_dir"])])
1446 # _AS_VERSION_COMPARE_PREPARE
1447 # ---------------------------
1448 # Output variables for comparing version numbers.
1449 m4_defun([_AS_VERSION_COMPARE_PREPARE],
1450 [[as_awk_strverscmp='
1451   # Use only awk features that work with 7th edition Unix awk (1978).
1452   # My, what an old awk you have, Mr. Solaris!
1453   END {
1454     while (length(v1) && length(v2)) {
1455       # Set d1 to be the next thing to compare from v1, and likewise for d2.
1456       # Normally this is a single character, but if v1 and v2 contain digits,
1457       # compare them as integers and fractions as strverscmp does.
1458       if (v1 ~ /^[0-9]/ && v2 ~ /^[0-9]/) {
1459         # Split v1 and v2 into their leading digit string components d1 and d2,
1460         # and advance v1 and v2 past the leading digit strings.
1461         for (len1 = 1; substr(v1, len1 + 1) ~ /^[0-9]/; len1++) continue
1462         for (len2 = 1; substr(v2, len2 + 1) ~ /^[0-9]/; len2++) continue
1463         d1 = substr(v1, 1, len1); v1 = substr(v1, len1 + 1)
1464         d2 = substr(v2, 1, len2); v2 = substr(v2, len2 + 1)
1465         if (d1 ~ /^0/) {
1466           if (d2 ~ /^0/) {
1467             # Compare two fractions.
1468             while (d1 ~ /^0/ && d2 ~ /^0/) {
1469               d1 = substr(d1, 2); len1--
1470               d2 = substr(d2, 2); len2--
1471             }
1472             if (len1 != len2 && ! (len1 && len2 && substr(d1, 1, 1) == substr(d2, 1, 1))) {
1473               # The two components differ in length, and the common prefix
1474               # contains only leading zeros.  Consider the longer to be less.
1475               d1 = -len1
1476               d2 = -len2
1477             } else {
1478               # Otherwise, compare as strings.
1479               d1 = "x" d1
1480               d2 = "x" d2
1481             }
1482           } else {
1483             # A fraction is less than an integer.
1484             exit 1
1485           }
1486         } else {
1487           if (d2 ~ /^0/) {
1488             # An integer is greater than a fraction.
1489             exit 2
1490           } else {
1491             # Compare two integers.
1492             d1 += 0
1493             d2 += 0
1494           }
1495         }
1496       } else {
1497         # The normal case, without worrying about digits.
1498         d1 = substr(v1, 1, 1); v1 = substr(v1, 2)
1499         d2 = substr(v2, 1, 1); v2 = substr(v2, 2)
1500       }
1501       if (d1 < d2) exit 1
1502       if (d1 > d2) exit 2
1503     }
1504     # Beware Solaris /usr/xgp4/bin/awk (at least through Solaris 10),
1505     # which mishandles some comparisons of empty strings to integers.
1506     if (length(v2)) exit 1
1507     if (length(v1)) exit 2
1508   }
1509 ']])# _AS_VERSION_COMPARE_PREPARE
1512 # AS_VERSION_COMPARE(VERSION-1, VERSION-2,
1513 #                    [ACTION-IF-LESS], [ACTION-IF-EQUAL], [ACTION-IF-GREATER])
1514 # -----------------------------------------------------------------------------
1515 # Compare two strings possibly containing shell variables as version strings.
1517 # This usage is portable even to ancient awk,
1518 # so don't worry about finding a "nice" awk version.
1519 m4_defun_init([AS_VERSION_COMPARE],
1520 [AS_REQUIRE([_$0_PREPARE])],
1521 [as_arg_v1=$1
1522 as_arg_v2=$2
1523 awk "$as_awk_strverscmp" v1="$as_arg_v1" v2="$as_arg_v2" /dev/null
1524 AS_CASE([$?],
1525         [1], [$3],
1526         [0], [$4],
1527         [2], [$5])])# AS_VERSION_COMPARE
1531 ## --------------------------------------- ##
1532 ## 6. Common m4/sh character translation.  ##
1533 ## --------------------------------------- ##
1535 # The point of this section is to provide high level macros comparable
1536 # to m4's `translit' primitive, but m4/sh polymorphic.
1537 # Transliteration of literal strings should be handled by m4, while
1538 # shell variables' content will be translated at runtime (tr or sed).
1541 # _AS_CR_PREPARE
1542 # --------------
1543 # Output variables defining common character ranges.
1544 # See m4_cr_letters etc.
1545 m4_defun([_AS_CR_PREPARE],
1546 [# Avoid depending upon Character Ranges.
1547 as_cr_letters='abcdefghijklmnopqrstuvwxyz'
1548 as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
1549 as_cr_Letters=$as_cr_letters$as_cr_LETTERS
1550 as_cr_digits='0123456789'
1551 as_cr_alnum=$as_cr_Letters$as_cr_digits
1555 # _AS_TR_SH_PREPARE
1556 # -----------------
1557 m4_defun([_AS_TR_SH_PREPARE],
1558 [AS_REQUIRE([_AS_CR_PREPARE])]dnl
1559 [# Sed expression to map a string onto a valid variable name.
1560 as_tr_sh="eval sed 'y%*+%pp%;s%[[^_$as_cr_alnum]]%_%g'"
1564 # AS_TR_SH(EXPRESSION)
1565 # --------------------
1566 # Transform EXPRESSION into a valid shell variable name.
1567 # sh/m4 polymorphic.
1568 # Be sure to update the definition of `$as_tr_sh' if you change this.
1570 # AS_LITERAL_IF guarantees that a literal does not have any nested quotes,
1571 # once $1 is expanded.  m4_translit silently uses only the first occurrence
1572 # of a character that appears multiple times in argument 2, since we know
1573 # that m4_cr_not_symbols2 also contains [ and ].  m4_translit also silently
1574 # ignores characters in argument 3 that do not match argument 2; we use this
1575 # fact to skip worrying about the length of m4_cr_not_symbols2.
1577 # For speed, we inline the literal definitions that can be computed up front.
1578 m4_defun_init([AS_TR_SH],
1579 [AS_REQUIRE([_$0_PREPARE])],
1580 [AS_LITERAL_IF([$1],
1581               [m4_translit([$1], [*+[]]]]dnl
1582 m4_dquote(m4_dquote(m4_defn([m4_cr_not_symbols2])))[[,
1583                                  [pp[]]]]dnl
1584 m4_dquote(m4_dquote(m4_for(,1,255,,[[_]])))[[)],
1585               [`AS_ECHO(["m4_bpatsubst(m4_dquote(m4_expand([$1])),
1586                                        [[\\`]], [\\\&])"]) | $as_tr_sh`])])
1589 # _AS_TR_CPP_PREPARE
1590 # ------------------
1591 m4_defun([_AS_TR_CPP_PREPARE],
1592 [AS_REQUIRE([_AS_CR_PREPARE])]dnl
1593 [# Sed expression to map a string onto a valid CPP name.
1594 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[[^_$as_cr_alnum]]%_%g'"
1598 # AS_TR_CPP(EXPRESSION)
1599 # ---------------------
1600 # Map EXPRESSION to an upper case string which is valid as rhs for a
1601 # `#define'.  sh/m4 polymorphic.  Be sure to update the definition
1602 # of `$as_tr_cpp' if you change this.
1604 # See implementation comments in AS_TR_SH.
1605 m4_defun_init([AS_TR_CPP],
1606 [AS_REQUIRE([_$0_PREPARE])],
1607 [AS_LITERAL_IF([$1],
1608               [m4_translit([$1], [*[]]]]dnl
1609 m4_dquote(m4_dquote(m4_defn([m4_cr_letters])m4_defn([m4_cr_not_symbols2])))[[,
1610                                  [P[]]]]dnl
1611 m4_dquote(m4_dquote(m4_defn([m4_cr_LETTERS])m4_for(,1,255,,[[_]])))[[)],
1612               [`AS_ECHO(["$1"]) | $as_tr_cpp`])])
1615 # _AS_TR_PREPARE
1616 # --------------
1617 m4_defun([_AS_TR_PREPARE],
1618 [AS_REQUIRE([_AS_TR_SH_PREPARE])AS_REQUIRE([_AS_TR_CPP_PREPARE])])
1623 ## ------------------------------------------------------ ##
1624 ## 7. Common m4/sh handling of variables (indirections).  ##
1625 ## ------------------------------------------------------ ##
1628 # The purpose of this section is to provide a uniform API for
1629 # reading/setting sh variables with or without indirection.
1630 # Typically, one can write
1631 #   AS_VAR_SET(var, val)
1632 # or
1633 #   AS_VAR_SET(as_$var, val)
1634 # and expect the right thing to happen.  In the descriptions below,
1635 # a literal name matches the regex [a-zA-Z_][a-zA-Z0-9_]*, an
1636 # indirect name is a shell expression that produces a literal name
1637 # when passed through eval, and a polymorphic name is either type.
1640 # _AS_VAR_APPEND_PREPARE
1641 # ----------------------
1642 # Define as_func_append to the optimum definition for the current
1643 # shell (bash and zsh provide the += assignment operator to avoid
1644 # quadratic append growth over repeated appends).
1645 m4_defun([_AS_VAR_APPEND_PREPARE],
1646 [AS_FUNCTION_DESCRIBE([as_func_append], [VAR VALUE],
1647 [Append the text in VALUE to the end of the definition contained in
1648 VAR.  Take advantage of any shell optimizations that allow amortized
1649 linear growth over repeated appends, instead of the typical quadratic
1650 growth present in naive implementations.])
1651 AS_IF([_AS_RUN(["AS_ESCAPE([_AS_VAR_APPEND_WORKS])"])],
1652 [eval 'as_func_append ()
1653   {
1654     eval $[]1+=\$[]2
1655   }'],
1656 [as_func_append ()
1657   {
1658     eval $[]1=\$$[]1\$[]2
1659   }]) # as_func_append
1662 # _AS_VAR_APPEND_WORKS
1663 # --------------------
1664 # Output a shell test to discover whether += works.
1665 m4_define([_AS_VAR_APPEND_WORKS],
1666 [as_var=1; as_var+=2; test x$as_var = x12])
1668 # AS_VAR_APPEND(VAR, VALUE)
1669 # -------------------------
1670 # Append the shell expansion of VALUE to the end of the existing
1671 # contents of the polymorphic shell variable VAR, taking advantage of
1672 # any shell optimizations that allow repeated appends to result in
1673 # amortized linear scaling rather than quadratic behavior.  This macro
1674 # is not worth the overhead unless the expected final size of the
1675 # contents of VAR outweigh the typical VALUE size of repeated appends.
1676 # Note that unlike AS_VAR_SET, VALUE must be properly quoted to avoid
1677 # field splitting and file name expansion.
1678 m4_defun_init([AS_VAR_APPEND],
1679 [_AS_DETECT_SUGGESTED([_AS_VAR_APPEND_WORKS])]dnl
1680 [AS_REQUIRE([_AS_VAR_APPEND_PREPARE], [], [M4SH-INIT-FN])],
1681 [as_func_append $1 $2])
1684 # _AS_VAR_ARITH_PREPARE
1685 # ---------------------
1686 # Define as_func_arith to the optimum definition for the current
1687 # shell (using POSIX $(()) where supported).
1688 m4_defun([_AS_VAR_ARITH_PREPARE],
1689 [AS_FUNCTION_DESCRIBE([as_func_arith], [ARG...],
1690 [Perform arithmetic evaluation on the ARGs, and store the result in
1691 the global $as_val.  Take advantage of shells that can avoid forks.
1692 The arguments must be portable across $(()) and expr.])
1693 AS_IF([_AS_RUN(["AS_ESCAPE([_AS_VAR_ARITH_WORKS])"])],
1694 [eval 'as_func_arith ()
1695   {
1696     as_val=$(( $[]* ))
1697   }'],
1698 [as_func_arith ()
1699   {
1700     as_val=`expr "$[]@"`
1701   }]) # as_func_arith
1704 # _AS_VAR_ARITH_WORKS
1705 # -------------------
1706 # Output a shell test to discover whether $(()) works.
1707 m4_define([_AS_VAR_ARITH_WORKS],
1708 [test $(( 1 + 1 )) = 2])
1710 # AS_VAR_ARITH(VAR, EXPR)
1711 # -----------------------
1712 # Perform the arithmetic evaluation of the arguments in EXPR, and set
1713 # contents of the polymorphic shell variable VAR to the result, taking
1714 # advantage of any shell optimizations that perform arithmetic without
1715 # forks.  Note that numbers occuring within EXPR must be written in
1716 # decimal, and without leading zeroes; variables containing numbers
1717 # must be expanded prior to arithmetic evaluation; the first argument
1718 # must not be a negative number; there is no portable equality
1719 # operator; and operators must be given as separate arguments and
1720 # properly quoted.
1721 m4_defun_init([AS_VAR_ARITH],
1722 [_AS_DETECT_SUGGESTED([_AS_VAR_ARITH_WORKS])]dnl
1723 [AS_REQUIRE([_AS_VAR_ARITH_PREPARE], [], [M4SH-INIT-FN])],
1724 [as_func_arith $2 && AS_VAR_SET([$1], [$as_val])])
1727 # AS_VAR_COPY(DEST, SOURCE)
1728 # -------------------------
1729 # Set the polymorphic shell variable DEST to the contents of the polymorphic
1730 # shell variable SOURCE.
1731 m4_define([AS_VAR_COPY],
1732 [AS_LITERAL_IF([$1[]$2], [$1=$$2], [eval $1=\$$2])])
1735 # AS_VAR_GET(VARIABLE)
1736 # --------------------
1737 # Get the value of the shell VARIABLE.
1738 # Evaluates to $VARIABLE if there are no indirection in VARIABLE,
1739 # else into the appropriate `eval' sequence.
1740 # This macro is deprecated because it sometimes mishandles trailing newlines;
1741 # use AS_VAR_COPY instead.
1742 m4_define([AS_VAR_GET],
1743 [AS_LITERAL_IF([$1],
1744                [$$1],
1745                [`eval 'as_val=${'m4_bpatsubst([$1], [[\\`]], [\\\&])'};dnl
1746 AS_ECHO(["$as_val"])'`])])
1749 # AS_VAR_IF(VARIABLE, VALUE, IF-TRUE, IF-FALSE)
1750 # ---------------------------------------------
1751 # Implement a shell `if test $VARIABLE = VALUE; then-else'.
1752 # Polymorphic, and avoids sh expansion error upon interrupt or term signal.
1753 m4_define([AS_VAR_IF],
1754 [AS_LITERAL_IF([$1],
1755   [AS_IF([test "x$$1" = x""$2], [$3], [$4])],
1756   [AS_VAR_COPY([as_val], [$1])
1757    AS_IF([test "x$as_val" = x""$2], [$3], [$4])])])
1760 # AS_VAR_PUSHDEF and AS_VAR_POPDEF
1761 # --------------------------------
1764 # Sometimes we may have to handle literals (e.g. `stdlib.h'), while at
1765 # other moments, the same code may have to get the value from a
1766 # variable (e.g., `ac_header').  To have a uniform handling of both
1767 # cases, when a new value is about to be processed, declare a local
1768 # variable, e.g.:
1770 #   AS_VAR_PUSHDEF([header], [ac_cv_header_$1])
1772 # and then in the body of the macro, use `header' as is.  It is of
1773 # first importance to use `AS_VAR_*' to access this variable.
1775 # If the value `$1' was a literal (e.g. `stdlib.h'), then `header' is
1776 # in fact the value `ac_cv_header_stdlib_h'.  If `$1' was indirect,
1777 # then `header's value in m4 is in fact `$as_header', the shell
1778 # variable that holds all of the magic to get the expansion right.
1780 # At the end of the block, free the variable with
1782 #   AS_VAR_POPDEF([header])
1785 # AS_VAR_POPDEF(VARNAME)
1786 # ----------------------
1787 # Free the shell variable accessor VARNAME.  To be dnl'ed.
1788 m4_define([AS_VAR_POPDEF],
1789 [m4_popdef([$1])])
1792 # AS_VAR_PUSHDEF(VARNAME, VALUE)
1793 # ------------------------------
1794 # Define the m4 macro VARNAME to an accessor to the shell variable
1795 # named VALUE.  VALUE does not need to be a valid shell variable name:
1796 # the transliteration is handled here.  To be dnl'ed.
1798 # AS_TR_SH attempts to play with diversions if _AS_TR_SH_PREPARE has
1799 # not been expanded.  However, users are expected to do subsequent
1800 # calls that trigger AS_LITERAL_IF([VARNAME]), and that macro performs
1801 # expansion inside an argument collection context, where diversions
1802 # don't work.  Therefore, we must require the preparation ourselves.
1803 m4_defun_init([AS_VAR_PUSHDEF],
1804 [AS_REQUIRE([_AS_TR_SH_PREPARE])],
1805 [AS_LITERAL_IF([$2],
1806                [m4_pushdef([$1], [AS_TR_SH($2)])],
1807                [as_$1=AS_TR_SH($2)
1808 m4_pushdef([$1], [$as_[$1]])])])
1811 # AS_VAR_SET(VARIABLE, VALUE)
1812 # ---------------------------
1813 # Set the contents of the polymorphic shell VARIABLE to the shell
1814 # expansion of VALUE.  VALUE is immune to field splitting and file
1815 # name expansion.
1816 m4_define([AS_VAR_SET],
1817 [AS_LITERAL_IF([$1],
1818                [$1=$2],
1819                [eval "$1=AS_ESCAPE([$2])"])])
1822 # AS_VAR_SET_IF(VARIABLE, IF-TRUE, IF-FALSE)
1823 # ------------------------------------------
1824 # Implement a shell `if-then-else' depending whether VARIABLE is set
1825 # or not.  Polymorphic.
1826 m4_define([AS_VAR_SET_IF],
1827 [AS_IF([AS_VAR_TEST_SET([$1])], [$2], [$3])])
1830 # AS_VAR_TEST_SET(VARIABLE)
1831 # -------------------------
1832 # Expands into the `test' expression which is true if VARIABLE
1833 # is set.  Polymorphic.
1834 m4_define([AS_VAR_TEST_SET],
1835 [AS_LITERAL_IF([$1],
1836                [test "${$1+set}" = set],
1837                [{ as_var=$1; eval "test \"\${$as_var+set}\" = set"; }])])
1840 ## -------------------- ##
1841 ## 8. Setting M4sh up.  ##
1842 ## -------------------- ##
1845 # AS_INIT_GENERATED(FILE, [COMMENT])
1846 # ----------------------------------
1847 # Generate a child script FILE with all initialization necessary to
1848 # reuse the environment learned by the parent script, and make the
1849 # file executable.  If COMMENT is supplied, it is inserted after the
1850 # `#!' sequence but before initialization text begins.  After this
1851 # macro, additional text can be appended to FILE to form the body of
1852 # the child script.  The macro ends with non-zero status if the
1853 # file could not be fully written (such as if the disk is full).
1854 m4_defun([AS_INIT_GENERATED],
1855 [m4_require([AS_PREPARE])]dnl
1856 [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl
1857 [as_write_fail=0
1858 cat >$1 <<_ASEOF || as_write_fail=1
1859 #! $SHELL
1860 # Generated by $as_me.
1862 SHELL=\${CONFIG_SHELL-$SHELL}
1863 _ASEOF
1864 cat >>$1 <<\_ASEOF || as_write_fail=1
1865 _AS_SHELL_SANITIZE
1866 _AS_PREPARE
1867 exec AS_MESSAGE_FD>&1
1868 m4_text_box([Main body of $1 script.])
1869 _ASEOF
1870 test $as_write_fail = 0 && chmod +x $1[]dnl
1871 _m4_popdef([AS_MESSAGE_LOG_FD])])# AS_INIT_GENERATED
1874 # AS_INIT
1875 # -------
1876 # Initialize m4sh.
1877 m4_define([AS_INIT],
1878 [# Wrap our cleanup prior to m4sugar's cleanup.
1879 m4_wrap([_AS_CLEANUP])
1880 m4_init
1881 m4_provide([AS_INIT])
1883 # Forbidden tokens and exceptions.
1884 m4_pattern_forbid([^_?AS_])
1886 # Bangshe and minimal initialization.
1887 m4_divert_text([BINSH], [@%:@! /bin/sh])
1888 m4_divert_text([HEADER-COMMENT],
1889                [@%:@ Generated from __file__ by m4_PACKAGE_STRING.])
1890 m4_divert_text([M4SH-SANITIZE], [_AS_SHELL_SANITIZE])
1891 m4_divert_text([M4SH-INIT-FN], [m4_text_box([M4sh Shell Functions.])])
1893 # Let's go!
1894 m4_divert_pop([KILL])[]dnl
1895 m4_divert_push([BODY])
1896 m4_text_box([Main body of script.])
1897 _AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])dnl
1898 AS_REQUIRE([_AS_UNSET_PREPARE], [], [M4SH-INIT-FN])dnl