Add third argument to _AS_PATH_WALK
[autoconf.git] / lib / m4sugar / m4sh.m4
blob3eac1a8752f10811376abc47ca29c6b23f2dd606
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_candidate_shells=
225     _AS_PATH_WALK([/bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH],
226       [case $as_dir in @%:@(
227          /*)
228            for as_base in sh bash ksh sh5; do
229              as_candidate_shells="$as_candidate_shells $as_dir/$as_base"
230            done;;
231        esac])
233       for as_shell in $as_candidate_shells $SHELL; do
234          # Try only shells that exist, to save several forks.
235          AS_IF([{ test -f "$as_shell" || test -f "$as_shell.exe"; } &&
236                 _AS_RUN(["$as_required"], ["$as_shell"])],
237                [CONFIG_SHELL=$as_shell
238                as_have_required=yes
239                m4_set_empty([_AS_DETECT_SUGGESTED_BODY], [break],
240                  [AS_IF([_AS_RUN(["$as_suggested"], ["$as_shell"])], [break])])])
241       done
243       AS_IF([test "x$CONFIG_SHELL" != x],
244         [# We cannot yet assume a decent shell, so we have to provide a
245         # neutralization value for shells without unset; and this also
246         # works around shells that cannot unset nonexistent variables.
247         BASH_ENV=/dev/null
248         ENV=/dev/null
249         (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
250         export CONFIG_SHELL
251         exec "$CONFIG_SHELL" "$as_myself" ${1+"$[@]"}])
253 dnl Unfortunately, $as_me isn't available here.
254     AS_IF([test x$as_have_required = xno],
255       [AS_ECHO(["$[]0: This script requires a shell more modern than all"])
256   AS_ECHO(["$[]0: the shells that I found on your system."])
257   if test x${ZSH_VERSION+set} = xset ; then
258     AS_ECHO(["$[]0: In particular, zsh $ZSH_VERSION has bugs and should"])
259     AS_ECHO(["$[]0: be upgraded to zsh 4.3.4 or later."])
260   else
261     AS_ECHO("m4_text_wrap([Please tell ]_m4_defn([m4_PACKAGE_BUGREPORT])
262 m4_ifset([AC_PACKAGE_BUGREPORT], [m4_if(_m4_defn([m4_PACKAGE_BUGREPORT]),
263 _m4_defn([AC_PACKAGE_BUGREPORT]), [], [and _m4_defn([AC_PACKAGE_BUGREPORT])])])
264 [about your system, including any error possibly output before this message.
265 Then install a modern shell, or manually run the script under such a
266 shell if you do have one.], [$[]0: ], [], [62])")
267   fi
268       AS_EXIT(1)])])
270 _m4_popdef([AS_EXIT])])# _AS_DETECT_BETTER_SHELL
273 # _AS_PREPARE
274 # -----------
275 # This macro has a very special status.  Normal use of M4sh relies
276 # heavily on AS_REQUIRE, so that needed initializations (such as
277 # _AS_TEST_PREPARE) are performed on need, not on demand.  But
278 # Autoconf is the first client of M4sh, and for two reasons: configure
279 # and config.status.  Relying on AS_REQUIRE is of course fine for
280 # configure, but fails for config.status (which is created by
281 # configure).  So we need a means to force the inclusion of the
282 # various _AS_*_PREPARE on top of config.status.  That's basically why
283 # there are so many _AS_*_PREPARE below, and that's also why it is
284 # important not to forget some: config.status needs them.
285 # List any preparations that create shell functions first, then
286 # topologically sort the others by their dependencies.
287 m4_defun([_AS_PREPARE],
288 [m4_pushdef([AS_REQUIRE])]dnl
289 [m4_pushdef([AS_REQUIRE_SHELL_FN], _m4_defn([_AS_REQUIRE_SHELL_FN])
290 )]dnl
291 [_AS_UNSET_PREPARE
292 _AS_VAR_APPEND_PREPARE
293 _AS_VAR_ARITH_PREPARE
295 _AS_EXPR_PREPARE
296 _AS_BASENAME_PREPARE
297 _AS_DIRNAME_PREPARE
298 _AS_ME_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_LINENO_PREPARE])
321 AS_REQUIRE([_AS_ECHO_N_PREPARE])
322 AS_REQUIRE([_AS_LN_S_PREPARE])
323 AS_REQUIRE([_AS_MKDIR_P_PREPARE])
324 AS_REQUIRE([_AS_TEST_PREPARE])
325 AS_REQUIRE([_AS_TR_CPP_PREPARE])
326 AS_REQUIRE([_AS_TR_SH_PREPARE])
327 AS_REQUIRE([_AS_UNSET_PREPARE])
328 AS_REQUIRE([_AS_VAR_APPEND_PREPARE], [], [M4SH-INIT-FN])
329 AS_REQUIRE([_AS_VAR_ARITH_PREPARE], [], [M4SH-INIT-FN])
330 m4_divert_pop[]])
333 # AS_REQUIRE(NAME-TO-CHECK, [BODY-TO-EXPAND = NAME-TO-CHECK],
334 #            [DIVERSION = M4SH-INIT])
335 # -----------------------------------------------------------
336 # BODY-TO-EXPAND is some initialization which must be expanded in the
337 # given diversion when expanded (required or not).  The expansion
338 # goes in the named diversion or an earlier one.
340 # Note: we expand _m4_divert_desired before passing it to m4_divert_require,
341 # otherwise we would need to use m4_pushdef and m4_popdef instead of
342 # simply m4_define.
344 # Since $2 can be quite large, this is factored for faster execution, giving
345 # either m4_require([$1], [$2]) or m4_divert_require(desired, [$1], [$2]).
346 m4_defun([AS_REQUIRE],
347 [m4_define([_m4_divert_desired], [m4_default_quoted([$3], [M4SH-INIT])])]dnl
348 [m4_if(m4_eval(_m4_divert(_m4_divert_dump) <= _m4_divert(_m4_divert_desired)),
349        1, [m4_require(],
350           [m4_divert_require(_m4_divert(_m4_divert_desired),]) [$1], [$2])])
352 # _AS_REQUIRE_SHELL_FN(NAME-TO-CHECK, COMMENT, BODY-TO-EXPAND)
353 # ------------------------------------------------------------
354 # Core of AS_REQUIRE_SHELL_FN, but without diversion support.
355 m4_define([_AS_REQUIRE_SHELL_FN], [
356 m4_n([$2])$1 ()
359 } @%:@ $1[]])
361 # AS_REQUIRE_SHELL_FN(NAME-TO-CHECK, COMMENT, BODY-TO-EXPAND,
362 #                     [DIVERSION = M4SH-INIT-FN])
363 # -----------------------------------------------------------
364 # BODY-TO-EXPAND is the body of a shell function to be emitted in the
365 # given diversion when expanded (required or not).  Unlike other
366 # xx_REQUIRE macros, BODY-TO-EXPAND is mandatory.  If COMMENT is
367 # provided (often via AS_FUNCTION_DESCRIBE), it is listed with a
368 # newline before the function name.
369 m4_define([AS_REQUIRE_SHELL_FN],
370 [m4_provide_if([AS_SHELL_FN_$1], [],
371 [AS_REQUIRE([AS_SHELL_FN_$1],
372 [m4_provide([AS_SHELL_FN_$1])_$0($@)],
373 m4_default_quoted([$4], [M4SH-INIT-FN]))])])
376 # _AS_RUN(TEST, [SHELL])
377 # ----------------------
378 # Run TEST under the current shell (if one parameter is used)
379 # or under the given SHELL, protecting it from syntax errors.
380 # Set as_run in order to assist _AS_LINENO_WORKS.
381 m4_define([_AS_RUN],
382 [m4_ifval([$2], [{ $as_echo "$as_bourne_compatible"$1 | as_run=a $2; }],
383                 [(eval $1)]) 2>/dev/null])
386 # _AS_SHELL_FN_WORK
387 # -----------------
388 # This is a spy to detect "in the wild" shells that do not support shell
389 # functions correctly.  It is based on the m4sh.at Autotest testcases.
390 m4_define([_AS_SHELL_FN_WORK],
391 [as_func_return ()
393   (exit [$]1)
395 as_func_success ()
397   as_func_return 0
399 as_func_failure ()
401   as_func_return 1
403 as_func_ret_success ()
405   return 0
407 as_func_ret_failure ()
409   return 1
412 exitcode=0
413 AS_IF([as_func_success], [],
414   [exitcode=1
415   echo as_func_success failed.])
416 AS_IF([as_func_failure],
417   [exitcode=1
418   echo as_func_failure succeeded.])
419 AS_IF([as_func_ret_success], [],
420   [exitcode=1
421   echo as_func_ret_success failed.])
422 AS_IF([as_func_ret_failure],
423   [exitcode=1
424   echo as_func_ret_failure succeeded.])
425 AS_IF([( set x; as_func_ret_success y && test x = "[$]1" )], [],
426   [exitcode=1
427   echo positional parameters were not saved.])
428 test x$exitcode = x0[]])# _AS_SHELL_FN_WORK
431 # _AS_SHELL_SANITIZE
432 # ------------------
433 # This is the prolog that is emitted by AS_INIT and AS_INIT_GENERATED.
434 m4_defun([_AS_SHELL_SANITIZE],
435 [m4_text_box([M4sh Initialization.])
437 AS_BOURNE_COMPATIBLE
438 _AS_ECHO_PREPARE
439 _AS_PATH_SEPARATOR_PREPARE
441 # IFS
442 # We need space, tab and new line, in precisely that order.  Quoting is
443 # there to prevent editors from complaining about space-tab.
444 # (If _AS_PATH_WALK were called with IFS unset, it would disable word
445 # splitting by setting IFS to empty value.)
446 IFS=" ""        $as_nl"
448 # Find who we are.  Look in the path if we contain no directory separator.
449 case $[0] in @%:@((
450   *[[\\/]]* ) as_myself=$[0] ;;
451   *) _AS_PATH_WALK([],
452                    [test -r "$as_dir/$[0]" && as_myself=$as_dir/$[0] && break])
453      ;;
454 esac
455 # We did not find ourselves, most probably we were run as `sh COMMAND'
456 # in which case we are not to be found in the path.
457 if test "x$as_myself" = x; then
458   as_myself=$[0]
460 if test ! -f "$as_myself"; then
461   AS_ECHO(["$as_myself: error: cannot find myself; rerun with an absolute file name"]) >&2
462   AS_EXIT
465 # Unset variables that we do not need and which cause bugs (e.g. in
466 # pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
467 # suppresses any "Segmentation fault" message there.  '((' could
468 # trigger a bug in pdksh 5.2.14.
469 for as_var in BASH_ENV ENV MAIL MAILPATH
470 do eval test x\${$as_var+set} = xset \
471   && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
472 done
473 PS1='$ '
474 PS2='> '
475 PS4='+ '
477 # NLS nuisances.
478 LC_ALL=C
479 export LC_ALL
480 LANGUAGE=C
481 export LANGUAGE
483 # CDPATH.
484 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
485 ])# _AS_SHELL_SANITIZE
488 # AS_SHELL_SANITIZE
489 # -----------------
490 # This is only needed for the sake of Libtool, which screws up royally
491 # in its usage of M4sh internals.
492 m4_define([AS_SHELL_SANITIZE],
493 [_AS_SHELL_SANITIZE
494 m4_provide_if([AS_INIT], [],
495 [m4_provide([AS_INIT])
496 _AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])
497 _AS_DETECT_BETTER_SHELL
498 _AS_UNSET_PREPARE
499 ])])
502 ## ----------------------------- ##
503 ## 2. Wrappers around builtins.  ##
504 ## ----------------------------- ##
506 # This section is lexicographically sorted.
509 # AS_CASE(WORD, [PATTERN1], [IF-MATCHED1]...[DEFAULT])
510 # ----------------------------------------------------
511 # Expand into
512 # | case WORD in #(
513 # |   PATTERN1) IF-MATCHED1 ;; #(
514 # |   ...
515 # |   *) DEFAULT ;;
516 # | esac
517 # The shell comments are intentional, to work around people who don't
518 # realize the impacts of using insufficient m4 quoting.
519 m4_define([_AS_CASE],
520 [ [@%:@(]
521   $1[)] $2 ;;])
522 m4_define([_AS_CASE_DEFAULT],
523 [ [@%:@(]
524   *[)] $1 ;;])
526 m4_defun([AS_CASE],
527 [case $1 in[]m4_map_args_pair([_$0], [_$0_DEFAULT], m4_shift($@))
528 esac])# AS_CASE
531 # AS_EXIT([EXIT-CODE = 1])
532 # ------------------------
533 # Exit and set exit code to EXIT-CODE in the way that it's seen
534 # within "trap 0".
536 # We cannot simply use "exit N" because some shells (zsh and Solaris sh)
537 # will not set $? to N while running the code set by "trap 0"
538 # So we set $? by executing "exit N" in the subshell and then exit.
539 # Other shells don't use `$?' as default for `exit', hence just repeating
540 # the exit value can only help improving portability.
541 m4_define([AS_EXIT],
542 [{ (exit m4_default([$1], 1)); exit m4_default([$1], 1); }])
545 # AS_IF(TEST1, [IF-TRUE1 = :]...[IF-FALSE = :])
546 # ---------------------------------------------
547 # Expand into
548 # | if TEST1; then
549 # |   IF-TRUE1
550 # | elif TEST2; then
551 # |   IF-TRUE2
552 # [...]
553 # | else
554 # |   IF-FALSE
555 # | fi
556 # with simplifications if IF-TRUE1 and/or IF-FALSE is empty.
558 m4_define([_AS_IF],
559 [elif $1; then
560   m4_default([$2], [:])
562 m4_define([_AS_IF_ELSE],
563 [m4_ifvaln([$1],
564 [else
565   $1])])
567 m4_defun([AS_IF],
568 [if $1; then
569   m4_default([$2], [:])
570 m4_map_args_pair([_$0], [_$0_ELSE], m4_shift2($@))]dnl
571 [fi[]])# AS_IF
574 # _AS_UNSET_PREPARE
575 # -----------------
576 # Define $as_unset to execute AS_UNSET, for backwards compatibility
577 # with older versions of M4sh.
578 m4_defun([_AS_UNSET_PREPARE],
579 [AS_FUNCTION_DESCRIBE([as_func_unset], [VAR], [Portably unset VAR.])
580 as_func_unset ()
582   AS_UNSET([$[1]])
584 as_unset=as_func_unset])
587 # AS_UNSET(VAR)
588 # -------------
589 # Unset the env VAR, working around shells that do not allow unsetting
590 # a variable that is not already set.  You should not unset MAIL and
591 # MAILCHECK, as that triggers a bug in Bash 2.01.
592 m4_defun([AS_UNSET],
593 [{ AS_LITERAL_IF([$1], [], [eval ])$1=; unset $1;}])
600 ## ------------------------------------------ ##
601 ## 3. Error and warnings at the shell level.  ##
602 ## ------------------------------------------ ##
604 # If AS_MESSAGE_LOG_FD is defined, shell messages are duplicated there
605 # too.
608 # AS_ESCAPE(STRING, [CHARS = $"`\])
609 # ---------------------------------
610 # Escape the CHARS in STRING.
612 # Avoid the m4_bpatsubst if there are no interesting characters to escape.
613 # _AS_ESCAPE bypasses argument defaulting.
614 m4_define([AS_ESCAPE],
615 [_$0([$1], m4_default([$2], [\"$`]))])
616 m4_define([_AS_ESCAPE],
617 [m4_if(m4_len([$1]),
618        m4_len(m4_translit([[$1]], [$2])),
619        [$1], [m4_bpatsubst([$1], [[$2]], [\\\&])])])
622 # _AS_QUOTE_IFELSE(STRING, IF-MODERN-QUOTATION, IF-OLD-QUOTATION)
623 # ---------------------------------------------------------------
624 # Compatibility glue between the old AS_MSG suite which did not
625 # quote anything, and the modern suite which quotes the quotes.
626 # If STRING contains `\\' or `\$', it's modern.
627 # If STRING contains `\"' or `\`', it's old.
628 # Otherwise it's modern.
630 # Profiling shows that m4_index is 5 to 8x faster than m4_bregexp.  The
631 # slower implementation used:
632 # m4_bmatch([$1],
633 #           [\\[\\$]], [$2],
634 #           [\\[`"]], [$3],
635 #           [$2])
636 # The current implementation caters to the common case of no backslashes,
637 # to minimize m4_index expansions (hence the nested if).
638 m4_define([_AS_QUOTE_IFELSE],
639 [m4_cond([m4_index([$1], [\])], [-1], [$2],
640          [m4_eval(m4_index([$1], [\\]) >= 0)], [1], [$2],
641          [m4_eval(m4_index([$1], [\$]) >= 0)], [1], [$2],
642          [m4_eval(m4_index([$1], [\`]) >= 0)], [1], [$3],
643          [m4_eval(m4_index([$1], [\"]) >= 0)], [1], [$3],
644          [$2])])
647 # _AS_QUOTE(STRING, [CHARS = `"])
648 # -------------------------------
649 # If there are quoted (via backslash) backquotes do nothing, else
650 # backslash all the quotes.
651 m4_define([_AS_QUOTE],
652 [_AS_QUOTE_IFELSE([$1],
653                   [_AS_ESCAPE([$1], m4_default([$2], [`""]))],
654                   [m4_warn([obsolete],
655            [back quotes and double quotes must not be escaped in: $1])dnl
656 $1])])
659 # _AS_ECHO_UNQUOTED(STRING, [FD = AS_MESSAGE_FD])
660 # -----------------------------------------------
661 # Perform shell expansions on STRING and echo the string to FD.
662 m4_define([_AS_ECHO_UNQUOTED],
663 [AS_ECHO(["$1"]) >&m4_default([$2], [AS_MESSAGE_FD])])
666 # _AS_ECHO(STRING, [FD = AS_MESSAGE_FD])
667 # --------------------------------------
668 # Protect STRING from backquote expansion, echo the result to FD.
669 m4_define([_AS_ECHO],
670 [_AS_ECHO_UNQUOTED([_AS_QUOTE([$1])], [$2])])
673 # _AS_ECHO_LOG(STRING)
674 # --------------------
675 # Log the string to AS_MESSAGE_LOG_FD.
676 m4_defun_init([_AS_ECHO_LOG],
677 [AS_REQUIRE([_AS_LINENO_PREPARE])],
678 [_AS_ECHO([$as_me:${as_lineno-$LINENO}: $1], [AS_MESSAGE_LOG_FD])])
681 # _AS_ECHO_N_PREPARE
682 # ------------------
683 # Check whether to use -n, \c, or newline-tab to separate
684 # checking messages from result messages.
685 # Don't try to cache, since the results of this macro are needed to
686 # display the checking message.  In addition, caching something used once
687 # has little interest.
688 # Idea borrowed from dist 3.0.  Use `*c*,', not `*c,' because if `\c'
689 # failed there is also a newline to match.
690 m4_defun([_AS_ECHO_N_PREPARE],
691 [ECHO_C= ECHO_N= ECHO_T=
692 case `echo -n x` in @%:@((((
693 -n*)
694   case `echo 'x\c'` in
695   *c*) ECHO_T=' ';;     # ECHO_T is single tab character.
696   *)   ECHO_C='\c';;
697   esac;;
699   ECHO_N='-n';;
700 esac
701 ])# _AS_ECHO_N_PREPARE
704 # _AS_ECHO_N(STRING, [FD = AS_MESSAGE_FD])
705 # ----------------------------------------
706 # Same as _AS_ECHO, but echo doesn't return to a new line.
707 m4_define([_AS_ECHO_N],
708 [AS_ECHO_N(["_AS_QUOTE([$1])"]) >&m4_default([$2], [AS_MESSAGE_FD])])
711 # AS_MESSAGE(STRING, [FD = AS_MESSAGE_FD])
712 # ----------------------------------------
713 # Output "`basename $0`: "STRING to the open file FD.
714 m4_defun_init([AS_MESSAGE],
715 [AS_REQUIRE([_AS_ME_PREPARE])],
716 [m4_ifset([AS_MESSAGE_LOG_FD],
717           [{ _AS_ECHO_LOG([$1])
718 _AS_ECHO([$as_me: $1], [$2]);}],
719           [_AS_ECHO([$as_me: $1], [$2])])[]])
722 # AS_WARN(PROBLEM)
723 # ----------------
724 m4_define([AS_WARN],
725 [AS_MESSAGE([WARNING: $1], [2])])# AS_WARN
728 # AS_ERROR(ERROR, [EXIT-STATUS = 1])
729 # ----------------------------------
730 m4_define([AS_ERROR],
731 [{ AS_MESSAGE([error: $1], [2])
732    AS_EXIT([$2]); }])# AS_ERROR
736 # AS_LINENO_PUSH([LINENO])
737 # ------------------------
738 # If this is the outermost call to AS_LINENO_PUSH, make sure that
739 # AS_MESSAGE will print LINENO as the line number.
740 m4_defun([AS_LINENO_PUSH],
741 [as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack])
744 # AS_LINENO_POP([LINENO])
745 # ------------------------
746 # If this is call balances the outermost call to AS_LINENO_PUSH,
747 # AS_MESSAGE will restart printing $LINENO as the line number.
748 m4_defun([AS_LINENO_POP],
749 [eval $as_lineno_stack; test "x$as_lineno_stack" = x && AS_UNSET([as_lineno])])
753 ## -------------------------------------- ##
754 ## 4. Portable versions of common tools.  ##
755 ## -------------------------------------- ##
757 # This section is lexicographically sorted.
760 # AS_BASENAME(FILE-NAME)
761 # ----------------------
762 # Simulate the command 'basename FILE-NAME'.  Not all systems have basename.
763 # Also see the comments for AS_DIRNAME.
765 m4_defun([_AS_BASENAME_EXPR],
766 [$as_expr X/[]$1 : '.*/\([[^/][^/]*]\)/*$' \| \
767          X[]$1 : 'X\(//\)$' \| \
768          X[]$1 : 'X\(/\)' \| .])
770 m4_defun([_AS_BASENAME_SED],
771 [AS_ECHO([X/[]$1]) |
772     sed ['/^.*\/\([^/][^/]*\)\/*$/{
773             s//\1/
774             q
775           }
776           /^X\/\(\/\/\)$/{
777             s//\1/
778             q
779           }
780           /^X\/\(\/\).*/{
781             s//\1/
782             q
783           }
784           s/.*/./; q']])
786 m4_defun_init([AS_BASENAME],
787 [AS_REQUIRE([_$0_PREPARE])],
788 [$as_basename -- $1 ||
789 _AS_BASENAME_EXPR([$1]) 2>/dev/null ||
790 _AS_BASENAME_SED([$1])])
793 # _AS_BASENAME_PREPARE
794 # --------------------
795 # Avoid Solaris 9 /usr/ucb/basename, as `basename /' outputs an empty line.
796 # Also, traditional basename mishandles --.  Require here _AS_EXPR_PREPARE,
797 # to avoid problems when _AS_BASENAME is called from the M4SH-INIT diversion.
798 m4_defun([_AS_BASENAME_PREPARE],
799 [AS_REQUIRE([_AS_EXPR_PREPARE])]dnl
800 [if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
801   as_basename=basename
802 else
803   as_basename=false
805 ])# _AS_BASENAME_PREPARE
808 # AS_DIRNAME(FILE-NAME)
809 # ---------------------
810 # Simulate the command 'dirname FILE-NAME'.  Not all systems have dirname.
811 # This macro must be usable from inside ` `.
813 # Prefer expr to echo|sed, since expr is usually faster and it handles
814 # backslashes and newlines correctly.  However, older expr
815 # implementations (e.g. SunOS 4 expr and Solaris 8 /usr/ucb/expr) have
816 # a silly length limit that causes expr to fail if the matched
817 # substring is longer than 120 bytes.  So fall back on echo|sed if
818 # expr fails.
819 m4_defun_init([_AS_DIRNAME_EXPR],
820 [AS_REQUIRE([_AS_EXPR_PREPARE])],
821 [$as_expr X[]$1 : 'X\(.*[[^/]]\)//*[[^/][^/]]*/*$' \| \
822          X[]$1 : 'X\(//\)[[^/]]' \| \
823          X[]$1 : 'X\(//\)$' \| \
824          X[]$1 : 'X\(/\)' \| .])
826 m4_defun([_AS_DIRNAME_SED],
827 [AS_ECHO([X[]$1]) |
828     sed ['/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
829             s//\1/
830             q
831           }
832           /^X\(\/\/\)[^/].*/{
833             s//\1/
834             q
835           }
836           /^X\(\/\/\)$/{
837             s//\1/
838             q
839           }
840           /^X\(\/\).*/{
841             s//\1/
842             q
843           }
844           s/.*/./; q']])
846 m4_defun_init([AS_DIRNAME],
847 [AS_REQUIRE([_$0_PREPARE])],
848 [$as_dirname -- $1 ||
849 _AS_DIRNAME_EXPR([$1]) 2>/dev/null ||
850 _AS_DIRNAME_SED([$1])])
853 # _AS_DIRNAME_PREPARE
854 # --------------------
855 m4_defun([_AS_DIRNAME_PREPARE],
856 [AS_REQUIRE([_AS_EXPR_PREPARE])]dnl
857 [if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
858   as_dirname=dirname
859 else
860   as_dirname=false
862 ])# _AS_DIRNAME_PREPARE
865 # AS_ECHO(WORD)
866 # -------------
867 # Output WORD followed by a newline.  WORD must be a single shell word
868 # (typically a quoted string).  The bytes of WORD are output as-is, even
869 # if it starts with "-" or contains "\".
870 m4_defun_init([AS_ECHO],
871 [AS_REQUIRE([_$0_PREPARE])],
872 [$as_echo $1])
875 # AS_ECHO_N(WORD)
876 # -------------
877 # Like AS_ECHO(WORD), except do not output the trailing newline.
878 m4_defun_init([AS_ECHO_N],
879 [AS_REQUIRE([_AS_ECHO_PREPARE])],
880 [$as_echo_n $1])
883 # _AS_ECHO_PREPARE
884 # -----------------
885 # Arrange for $as_echo 'FOO' to echo FOO without escape-interpretation;
886 # and similarly for $as_echo_foo, which omits the trailing newline.
887 # 'FOO' is an optional single argument; a missing FOO is treated as empty.
888 m4_defun([_AS_ECHO_PREPARE],
889 [[as_nl='
891 export as_nl
892 # Printing a long string crashes Solaris 7 /usr/bin/printf.
893 as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
894 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
895 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
896 if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
897   as_echo='printf %s\n'
898   as_echo_n='printf %s'
899 else
900   if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
901     as_echo_body='eval /usr/ucb/echo -n "$][1$as_nl"'
902     as_echo_n='/usr/ucb/echo -n'
903   else
904     as_echo_body='eval expr "X$][1" : "X\\(.*\\)"'
905     as_echo_n_body='eval
906       arg=$][1;
907       case $arg in @%:@(
908       *"$as_nl"*)
909         expr "X$arg" : "X\\(.*\\)$as_nl";
910         arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
911       esac;
912       expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
913     '
914     export as_echo_n_body
915     as_echo_n='sh -c $as_echo_n_body as_echo'
916   fi
917   export as_echo_body
918   as_echo='sh -c $as_echo_body as_echo'
920 ]])# _AS_ECHO_PREPARE
923 # AS_TEST_X
924 # ---------
925 # Check whether a file has executable or search permissions.
926 m4_defun_init([AS_TEST_X],
927 [AS_REQUIRE([_AS_TEST_PREPARE])],
928 [$as_test_x $1[]])# AS_TEST_X
931 # AS_EXECUTABLE_P
932 # ---------------
933 # Check whether a file is a regular file that has executable permissions.
934 m4_defun_init([AS_EXECUTABLE_P],
935 [AS_REQUIRE([_AS_TEST_PREPARE])],
936 [{ test -f $1 && AS_TEST_X([$1]); }])# AS_EXECUTABLE_P
939 # _AS_EXPR_PREPARE
940 # ----------------
941 # QNX 4.25 expr computes and issue the right result but exits with failure.
942 # Tru64 expr mishandles leading zeros in numeric strings.
943 # Detect these flaws.
944 m4_defun([_AS_EXPR_PREPARE],
945 [if expr a : '\(a\)' >/dev/null 2>&1 &&
946    test "X`expr 00001 : '.*\(...\)'`" = X001; then
947   as_expr=expr
948 else
949   as_expr=false
951 ])# _AS_EXPR_PREPARE
954 # _AS_ME_PREPARE
955 # --------------
956 # Define $as_me to the basename of the executable file's name.
957 m4_defun([AS_ME_PREPARE], [AS_REQUIRE([_$0])])
958 m4_defun([_AS_ME_PREPARE],
959 [AS_REQUIRE([_AS_BASENAME_PREPARE])]dnl
960 [as_me=`AS_BASENAME("$[0]")`
963 # _AS_LINENO_WORKS
964 # ---------------
965 # Succeed if the currently executing shell supports LINENO.
966 # This macro does not expand to a single shell command, so be careful
967 # when using it.  Surrounding the body of this macro with {} would
968 # cause "bash -c '_ASLINENO_WORKS'" to fail (with Bash 2.05, anyway),
969 # but that bug is irrelevant to our use of LINENO.  We can't use
970 # AS_VAR_ARITH, as this is expanded prior to shell functions.
972 # Testing for LINENO support is hard; we use _AS_LINENO_WORKS inside
973 # _AS_RUN, which sometimes eval's its argument (pdksh gives false
974 # negatives if $LINENO is expanded by eval), and sometimes passes the
975 # argument to another shell (if the current shell supports LINENO,
976 # then expanding $LINENO prior to the string leads to false
977 # positives).  Hence, we perform two tests, and coordinate with
978 # _AS_DETECT_EXPAND (which ensures that only the first of two LINENO
979 # is expanded in advance) and _AS_RUN (which sets $as_run to 'a' when
980 # handing the test to another shell), so that we know which test to
981 # trust.
982 m4_define([_AS_LINENO_WORKS],
983 [  as_lineno_1=$LINENO as_lineno_1a=$LINENO
984   as_lineno_2=$LINENO as_lineno_2a=$LINENO
985   eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
986   test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"'])
989 # _AS_LINENO_PREPARE
990 # ------------------
991 # If LINENO is not supported by the shell, produce a version of this
992 # script where LINENO is hard coded.
993 # Comparing LINENO against _oline_ is not a good solution, since in
994 # the case of embedded executables (such as config.status within
995 # configure) you'd compare LINENO wrt config.status vs. _oline_ wrt
996 # configure.
997 m4_defun([AS_LINENO_PREPARE], [AS_REQUIRE([_$0])])
998 m4_defun([_AS_LINENO_PREPARE],
999 [AS_REQUIRE([_AS_CR_PREPARE])]dnl
1000 [AS_REQUIRE([_AS_ME_PREPARE])]dnl
1001 [_AS_DETECT_SUGGESTED([_AS_LINENO_WORKS])]dnl
1002 dnl Even if the logging fd is open, we don't want to use $LINENO in the
1003 dnl AS_ERROR complaining that LINENO is broken.
1004 [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl
1005 dnl Create $as_me.lineno as a copy of $as_myself, but with $LINENO
1006 dnl uniformly replaced by the line number.  The first 'sed' inserts a
1007 dnl line-number line after each line using $LINENO; the second 'sed'
1008 dnl does the real work.  The second script uses 'N' to pair each
1009 dnl line-number line with the line containing $LINENO, and appends
1010 dnl trailing '-' during substitution so that $LINENO is not a special
1011 dnl case at line end.  (Raja R Harinath suggested sed '=', and Paul
1012 dnl Eggert wrote the scripts with optimization help from Paolo Bonzini).
1013 [_AS_LINENO_WORKS || {
1014   # Blame Lee E. McMahon (1931-1989) for sed's syntax.  :-)
1015   sed -n '
1016     p
1017     /[[$]]LINENO/=
1018   ' <$as_myself |
1019     sed '
1020       s/[[$]]LINENO.*/&-/
1021       t lineno
1022       b
1023       :lineno
1024       N
1025       :loop
1026       s/[[$]]LINENO\([[^'$as_cr_alnum'_]].*\n\)\(.*\)/\2\1\2/
1027       t loop
1028       s/-\n.*//
1029     ' >$as_me.lineno &&
1030   chmod +x "$as_me.lineno" ||
1031     AS_ERROR([cannot create $as_me.lineno; rerun with a POSIX shell])
1033   # Don't try to exec as it changes $[0], causing all sort of problems
1034   # (the dirname of $[0] is not the place where we might find the
1035   # original and so on.  Autoconf is especially sensitive to this).
1036   . "./$as_me.lineno"
1037   # Exit status is that of the last command.
1038   exit
1040 _m4_popdef([AS_MESSAGE_LOG_FD])])# _AS_LINENO_PREPARE
1043 # _AS_LN_S_PREPARE
1044 # ----------------
1045 # Don't use conftest.sym to avoid file name issues on DJGPP, where this
1046 # would yield conftest.sym.exe for DJGPP < 2.04.  And don't use `conftest'
1047 # as base name to avoid prohibiting concurrency (e.g., concurrent
1048 # config.statuses).  On read-only media, assume 'cp -p' and hope we
1049 # are just running --help anyway.
1050 m4_defun([_AS_LN_S_PREPARE],
1051 [rm -f conf$$ conf$$.exe conf$$.file
1052 if test -d conf$$.dir; then
1053   rm -f conf$$.dir/conf$$.file
1054 else
1055   rm -f conf$$.dir
1056   mkdir conf$$.dir 2>/dev/null
1058 if (echo >conf$$.file) 2>/dev/null; then
1059   if ln -s conf$$.file conf$$ 2>/dev/null; then
1060     as_ln_s='ln -s'
1061     # ... but there are two gotchas:
1062     # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
1063     # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
1064     # In both cases, we have to default to `cp -p'.
1065     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
1066       as_ln_s='cp -p'
1067   elif ln conf$$.file conf$$ 2>/dev/null; then
1068     as_ln_s=ln
1069   else
1070     as_ln_s='cp -p'
1071   fi
1072 else
1073   as_ln_s='cp -p'
1075 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
1076 rmdir conf$$.dir 2>/dev/null
1077 ])# _AS_LN_S_PREPARE
1080 # AS_LN_S(FILE, LINK)
1081 # -------------------
1082 # FIXME: Should we add the glue code to handle properly relative symlinks
1083 # simulated with `ln' or `cp'?
1084 m4_defun_init([AS_LN_S],
1085 [AS_REQUIRE([_AS_LN_S_PREPARE])],
1086 [$as_ln_s $1 $2])
1089 # _AS_MKDIR_P
1090 # -----------
1091 # Emit code that can be used to emulate `mkdir -p` with plain `mkdir';
1092 # the code assumes that "$as_dir" contains the directory to create.
1093 # $as_dir is normalized, so there is no need to worry about using --.
1094 m4_define([_AS_MKDIR_P],
1095 [case $as_dir in #(
1096   -*) as_dir=./$as_dir;;
1097   esac
1098   test -d "$as_dir" || eval $as_mkdir_p || {
1099     as_dirs=
1100     while :; do
1101       case $as_dir in #(
1102       *\'*) as_qdir=`AS_ECHO(["$as_dir"]) | sed "s/'/'\\\\\\\\''/g"`;; #'(
1103       *) as_qdir=$as_dir;;
1104       esac
1105       as_dirs="'$as_qdir' $as_dirs"
1106       as_dir=`AS_DIRNAME("$as_dir")`
1107       test -d "$as_dir" && break
1108     done
1109     test -z "$as_dirs" || eval "mkdir $as_dirs"
1110   } || test -d "$as_dir" || AS_ERROR([cannot create directory $as_dir])
1113 # AS_MKDIR_P(DIR)
1114 # ---------------
1115 # Emulate `mkdir -p' with plain `mkdir' if needed.
1116 m4_defun_init([AS_MKDIR_P],
1117 [AS_REQUIRE([_$0_PREPARE])],
1118 [as_dir=$1; as_func_mkdir_p])# AS_MKDIR_P
1121 # _AS_MKDIR_P_PREPARE
1122 # -------------------
1123 m4_defun([_AS_MKDIR_P_PREPARE],
1124 [AS_REQUIRE_SHELL_FN([as_func_mkdir_p],
1125   [AS_FUNCTION_DESCRIBE([as_func_mkdir_p], [],
1126     [Create "$as_dir" as a directory, including parents if necessary.])],
1128   _AS_MKDIR_P
1129 ])]dnl
1130 [if mkdir -p . 2>/dev/null; then
1131   as_mkdir_p='mkdir -p "$as_dir"'
1132 else
1133   test -d ./-p && rmdir ./-p
1134   as_mkdir_p=false
1136 ])# _AS_MKDIR_P_PREPARE
1139 # _AS_PATH_SEPARATOR_PREPARE
1140 # --------------------------
1141 # Compute the path separator.
1142 m4_defun([_AS_PATH_SEPARATOR_PREPARE],
1143 [# The user is always right.
1144 if test "${PATH_SEPARATOR+set}" != set; then
1145   PATH_SEPARATOR=:
1146   (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
1147     (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
1148       PATH_SEPARATOR=';'
1149   }
1151 ])# _AS_PATH_SEPARATOR_PREPARE
1154 # _AS_PATH_WALK([PATH = $PATH], BODY, [IF-NOT-FOUND])
1155 # ---------------------------------------------------
1156 # Walk through PATH running BODY for each `as_dir'.  If BODY never does a
1157 # `break', evaluate IF-NOT-FOUND.
1159 # Still very private as its interface looks quite bad.
1161 # `$as_dummy' forces splitting on constant user-supplied paths.
1162 # POSIX.2 field splitting is done only on the result of word
1163 # expansions, not on literal text.  This closes a longstanding sh security
1164 # hole.  Optimize it away when not needed, i.e., if there are no literal
1165 # path separators.
1166 m4_defun_init([_AS_PATH_WALK],
1167 [AS_REQUIRE([_AS_PATH_SEPARATOR_PREPARE])],
1168 [as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
1169 m4_ifvaln([$3], [as_found=false])dnl
1170 m4_bmatch([$1], [[:;]],
1171 [as_dummy="$1"
1172 for as_dir in $as_dummy],
1173 [for as_dir in m4_default([$1], [$PATH])])
1175   IFS=$as_save_IFS
1176   test -z "$as_dir" && as_dir=.
1177   m4_ifvaln([$3], [as_found=:])dnl
1178   $2
1179   m4_ifvaln([$3], [as_found=false])dnl
1180 done
1181 m4_ifvaln([$3], [$as_found || { $3; }])dnl
1182 IFS=$as_save_IFS
1186 # AS_SET_CATFILE(VAR, DIR-NAME, FILE-NAME)
1187 # ----------------------------------------
1188 # Set VAR to DIR-NAME/FILE-NAME.
1189 # Optimize the common case where $2 or $3 is '.'.
1190 m4_define([AS_SET_CATFILE],
1191 [case $2 in @%:@((
1192 .) $1=$3;;
1194   case $3 in @%:@(((
1195   .) $1=$2;;
1196   [[\\/]]* | ?:[[\\/]]* ) $1=$3;;
1197   *) $1=$2/$3;;
1198   esac;;
1199 esac[]])# AS_SET_CATFILE
1202 # _AS_TEST_PREPARE
1203 # ----------------
1204 # Find out whether `test -x' works.  If not, prepare a substitute
1205 # that should work well enough for most scripts.
1207 # Here are some of the problems with the substitute.
1208 # The 'ls' tests whether the owner, not the current user, can execute/search.
1209 # The eval means '*', '?', and '[' cause inadvertent file name globbing
1210 # after the 'eval', so jam together as many tokens as we can to minimize
1211 # the likelihood that the inadvertent globbing will actually do anything.
1212 # Luckily, this gorp is needed only on really ancient hosts.
1214 m4_defun([_AS_TEST_PREPARE],
1215 [if test -x / >/dev/null 2>&1; then
1216   as_test_x='test -x'
1217 else
1218   if ls -dL / >/dev/null 2>&1; then
1219     as_ls_L_option=L
1220   else
1221     as_ls_L_option=
1222   fi
1223   as_test_x='
1224     eval sh -c '\''
1225       if test -d "$[]1"; then
1226         test -d "$[]1/.";
1227       else
1228         case $[]1 in @%:@(
1229         -*)set "./$[]1";;
1230         esac;
1231         case `ls -ld'$as_ls_L_option' "$[]1" 2>/dev/null` in @%:@((
1232         ???[[sx]]*):;;*)false;;esac;fi
1233     '\'' sh
1234   '
1236 dnl as_executable_p is present for backward compatibility with Libtool
1237 dnl 1.5.22, but it should go away at some point.
1238 as_executable_p=$as_test_x
1239 ])# _AS_TEST_PREPARE
1244 ## ------------------ ##
1245 ## 5. Common idioms.  ##
1246 ## ------------------ ##
1248 # This section is lexicographically sorted.
1251 # AS_BOX(MESSAGE, [FRAME-CHARACTER = `-'])
1252 # ----------------------------------------
1253 # Output MESSAGE, a single line text, framed with FRAME-CHARACTER (which
1254 # must not be `/').
1255 m4_define([AS_BOX],
1256 [AS_LITERAL_IF([$1],
1257                [_AS_BOX_LITERAL($@)],
1258                [_AS_BOX_INDIR($@)])])
1261 # _AS_BOX_LITERAL(MESSAGE, [FRAME-CHARACTER = `-'])
1262 # -------------------------------------------------
1263 m4_define([_AS_BOX_LITERAL],
1264 [cat <<\_ASBOX
1265 m4_text_box($@)
1266 _ASBOX])
1269 # _AS_BOX_INDIR(MESSAGE, [FRAME-CHARACTER = `-'])
1270 # -----------------------------------------------
1271 m4_define([_AS_BOX_INDIR],
1272 [sed 'h;s/./m4_default([$2], [-])/g;s/^.../@%:@@%:@ /;s/...$/ @%:@@%:@/;p;x;p;x' <<_ASBOX
1273 @%:@@%:@ $1 @%:@@%:@
1274 _ASBOX])
1277 # AS_FUNCTION_DESCRIBE(NAME, [ARGS], DESCRIPTION, [WRAP-COLUMN = 79])
1278 # -------------------------------------------------------------------
1279 # Output a shell comment describing NAME and its arguments ARGS, then
1280 # a separator line, then the DESCRIPTION wrapped at a decimal
1281 # WRAP-COLUMN.  The output resembles:
1282 #  # NAME ARGS
1283 #  # ---------
1284 #  # Wrapped DESCRIPTION text
1285 # NAME and ARGS are expanded, while DESCRIPTION is treated as a
1286 # whitespace-separated list of strings that are not expanded.
1287 m4_define([AS_FUNCTION_DESCRIBE],
1288 [@%:@ $1[]m4_ifval([$2], [ $2])
1289 @%:@ m4_translit(m4_format([%*s],
1290                    m4_qlen(m4_expand([$1[]m4_ifval([$2], [ $2])])), []),
1291                  [ ], [-])
1292 m4_text_wrap([$3], [@%:@ ], [], [$4])])
1295 # AS_HELP_STRING(LHS, RHS, [INDENT-COLUMN = 26], [WRAP-COLUMN = 79])
1296 # ------------------------------------------------------------------
1298 # Format a help string so that it looks pretty when the user executes
1299 # "script --help".  This macro takes up to four arguments, a
1300 # "left hand side" (LHS), a "right hand side" (RHS), a decimal
1301 # INDENT-COLUMN which is the column where wrapped lines should begin
1302 # (the default of 26 is recommended), and a decimal WRAP-COLUMN which is
1303 # the column where lines should wrap (the default of 79 is recommended).
1304 # LHS is expanded, RHS is not.
1306 # For backwards compatibility not documented in the manual, INDENT-COLUMN
1307 # can also be specified as a string of white spaces, whose width
1308 # determines the indentation column.  Using TABs in INDENT-COLUMN is not
1309 # recommended, since screen width of TAB is not computed.
1311 # The resulting string is suitable for use in other macros that require
1312 # a help string (e.g. AC_ARG_WITH).
1314 # Here is the sample string from the Autoconf manual (Node: External
1315 # Software) which shows the proper spacing for help strings.
1317 #    --with-readline         support fancy command line editing
1318 #  ^ ^                       ^
1319 #  | |                       |
1320 #  | column 2                column 26
1321 #  |
1322 #  column 0
1324 # A help string is made up of a "left hand side" (LHS) and a "right
1325 # hand side" (RHS).  In the example above, the LHS is
1326 # "--with-readline", while the RHS is "support fancy command line
1327 # editing".
1329 # If the LHS contains more than (INDENT-COLUMN - 3) characters, then the
1330 # LHS is terminated with a newline so that the RHS starts on a line of its
1331 # own beginning at INDENT-COLUMN.  In the default case, this corresponds to an
1332 # LHS with more than 23 characters.
1334 # Therefore, in the example, if the LHS were instead
1335 # "--with-readline-blah-blah-blah", then the AS_HELP_STRING macro would
1336 # expand into:
1339 #    --with-readline-blah-blah-blah
1340 #  ^ ^                       support fancy command line editing
1341 #  | |                       ^
1342 #  | column 2                |
1343 #  column 0                  column 26
1346 # m4_text_wrap hacks^Wworks around the fact that m4_format does not
1347 # know quadrigraphs.
1349 m4_define([AS_HELP_STRING],
1350 [m4_text_wrap([$2], m4_cond([[$3]], [], [                          ],
1351                             [m4_eval([$3]+0)], [0], [[$3]],
1352                             [m4_format([[%*s]], [$3], [])]),
1353               m4_expand([  $1 ]), [$4])])# AS_HELP_STRING
1356 # AS_IDENTIFIER_IF(EXPRESSION, IF-IDENT, IF-NOT-IDENT)
1357 # ----------------------------------------------------
1358 # If EXPRESSION serves as an identifier (ie, after removal of @&t@, it
1359 # matches the regex `^[a-zA-Z_][a-zA-Z_0-9]*$'), execute IF-IDENT,
1360 # otherwise IF-NOT-IDENT.
1362 # This is generally faster than the alternative:
1363 #   m4_bmatch(m4_bpatsubst([[$1]], [@&t@]), ^m4_defn([m4_re_word])$,
1364 #             [$2], [$3])
1366 # Rather than expand m4_defn every time AS_IDENTIFIER_IF is expanded, we
1367 # inline its expansion up front.  Only use a regular expression if we
1368 # detect a potential quadrigraph.
1370 # First, check if the entire string matches m4_cr_symbol2.  Only then do
1371 # we worry if the first character also matches m4_cr_symbol1 (ie. does not
1372 # match m4_cr_digit).
1373 m4_define([AS_IDENTIFIER_IF],
1374 [m4_if(m4_index([$1], [@]), [-1],
1375        [_$0($@)],
1376        [_$0(m4_bpatsubst([[$1]], [@&t@]), [$2], [$3])])])
1377 m4_define([_AS_IDENTIFIER_IF],
1378 [m4_cond([[$1]], [], [$3],
1379          [m4_eval(m4_len(m4_translit([[$1]], ]]dnl
1380 m4_dquote(m4_dquote(m4_defn([m4_cr_symbols2])))[[)) > 0)], [1], [$3],
1381          [m4_len(m4_translit(m4_format([[%.1s]], [$1]), ]]dnl
1382 m4_dquote(m4_dquote(m4_defn([m4_cr_symbols1])))[[))], [0], [$2], [$3])])
1385 # AS_LITERAL_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL)
1386 # -----------------------------------------------------
1387 # If EXPRESSION has shell indirections ($var or `expr`), expand
1388 # IF-INDIR, else IF-NOT-INDIR.
1389 # This is an *approximation*: for instance EXPRESSION = `\$' is
1390 # definitely a literal, but will not be recognized as such.
1392 # Why do we reject EXPRESSION expanding with `[' or `]' as a literal?
1393 # Because AS_TR_SH is MUCH faster if it can use m4_translit on literals
1394 # instead of m4_bpatsubst; but m4_translit is much tougher to do safely
1395 # if `[' is translated.
1397 # Note that the quadrigraph @S|@ can result in non-literals, but outright
1398 # rejecting all @ would make AC_INIT complain on its bug report address.
1400 # We used to use m4_bmatch(m4_quote($1), [[`$]], [$3], [$2]), but
1401 # profiling shows that it is faster to use m4_translit.
1403 # Because the translit is stripping quotes, it must also neutralize anything
1404 # that might be in a macro name, as well as comments and commas.  All the
1405 # problem characters are unified so that a single m4_index can scan the
1406 # result.
1408 # Rather than expand m4_defn every time AS_LITERAL_IF is expanded, we
1409 # inline its expansion up front.
1410 m4_define([AS_LITERAL_IF],
1411 [m4_cond([m4_eval(m4_index(m4_quote($1), [@S|@]) == -1)], [0], [$3],
1412          [m4_index(m4_translit(m4_quote($1),
1413                                [[]`,#]]]dnl
1414 m4_dquote(m4_dquote(m4_defn([m4_cr_symbols2])))[[,
1415                                [$$$]),
1416                    [$])], [-1], [$2],
1417          [$3])])
1420 # AS_TMPDIR(PREFIX, [DIRECTORY = $TMPDIR [= /tmp]])
1421 # -------------------------------------------------
1422 # Create as safely as possible a temporary directory in DIRECTORY
1423 # which name is inspired by PREFIX (should be 2-4 chars max).
1424 m4_define([AS_TMPDIR],
1425 [# Create a (secure) tmp directory for tmp files.
1426 m4_if([$2], [], [: ${TMPDIR=/tmp}])
1428   tmp=`(umask 077 && mktemp -d "m4_default([$2], [$TMPDIR])/$1XXXXXX") 2>/dev/null` &&
1429   test -n "$tmp" && test -d "$tmp"
1430 }  ||
1432   tmp=m4_default([$2], [$TMPDIR])/$1$$-$RANDOM
1433   (umask 077 && mkdir "$tmp")
1434 } || AS_ERROR([cannot create a temporary directory in m4_default([$2],
1435               [$TMPDIR])])])# AS_TMPDIR
1438 # AS_UNAME
1439 # --------
1440 # Try to describe this machine.  Meant for logs.
1441 m4_define([AS_UNAME],
1443 cat <<_ASUNAME
1444 m4_text_box([Platform.])
1446 hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
1447 uname -m = `(uname -m) 2>/dev/null || echo unknown`
1448 uname -r = `(uname -r) 2>/dev/null || echo unknown`
1449 uname -s = `(uname -s) 2>/dev/null || echo unknown`
1450 uname -v = `(uname -v) 2>/dev/null || echo unknown`
1452 /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
1453 /bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
1455 /bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
1456 /usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
1457 /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
1458 /usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`
1459 /bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
1460 /usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
1461 /bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
1463 _ASUNAME
1465 _AS_PATH_WALK([$PATH], [AS_ECHO(["PATH: $as_dir"])])
1469 # _AS_VERSION_COMPARE_PREPARE
1470 # ---------------------------
1471 # Output variables for comparing version numbers.
1472 m4_defun([_AS_VERSION_COMPARE_PREPARE],
1473 [[as_awk_strverscmp='
1474   # Use only awk features that work with 7th edition Unix awk (1978).
1475   # My, what an old awk you have, Mr. Solaris!
1476   END {
1477     while (length(v1) && length(v2)) {
1478       # Set d1 to be the next thing to compare from v1, and likewise for d2.
1479       # Normally this is a single character, but if v1 and v2 contain digits,
1480       # compare them as integers and fractions as strverscmp does.
1481       if (v1 ~ /^[0-9]/ && v2 ~ /^[0-9]/) {
1482         # Split v1 and v2 into their leading digit string components d1 and d2,
1483         # and advance v1 and v2 past the leading digit strings.
1484         for (len1 = 1; substr(v1, len1 + 1) ~ /^[0-9]/; len1++) continue
1485         for (len2 = 1; substr(v2, len2 + 1) ~ /^[0-9]/; len2++) continue
1486         d1 = substr(v1, 1, len1); v1 = substr(v1, len1 + 1)
1487         d2 = substr(v2, 1, len2); v2 = substr(v2, len2 + 1)
1488         if (d1 ~ /^0/) {
1489           if (d2 ~ /^0/) {
1490             # Compare two fractions.
1491             while (d1 ~ /^0/ && d2 ~ /^0/) {
1492               d1 = substr(d1, 2); len1--
1493               d2 = substr(d2, 2); len2--
1494             }
1495             if (len1 != len2 && ! (len1 && len2 && substr(d1, 1, 1) == substr(d2, 1, 1))) {
1496               # The two components differ in length, and the common prefix
1497               # contains only leading zeros.  Consider the longer to be less.
1498               d1 = -len1
1499               d2 = -len2
1500             } else {
1501               # Otherwise, compare as strings.
1502               d1 = "x" d1
1503               d2 = "x" d2
1504             }
1505           } else {
1506             # A fraction is less than an integer.
1507             exit 1
1508           }
1509         } else {
1510           if (d2 ~ /^0/) {
1511             # An integer is greater than a fraction.
1512             exit 2
1513           } else {
1514             # Compare two integers.
1515             d1 += 0
1516             d2 += 0
1517           }
1518         }
1519       } else {
1520         # The normal case, without worrying about digits.
1521         d1 = substr(v1, 1, 1); v1 = substr(v1, 2)
1522         d2 = substr(v2, 1, 1); v2 = substr(v2, 2)
1523       }
1524       if (d1 < d2) exit 1
1525       if (d1 > d2) exit 2
1526     }
1527     # Beware Solaris /usr/xgp4/bin/awk (at least through Solaris 10),
1528     # which mishandles some comparisons of empty strings to integers.
1529     if (length(v2)) exit 1
1530     if (length(v1)) exit 2
1531   }
1532 ']])# _AS_VERSION_COMPARE_PREPARE
1535 # AS_VERSION_COMPARE(VERSION-1, VERSION-2,
1536 #                    [ACTION-IF-LESS], [ACTION-IF-EQUAL], [ACTION-IF-GREATER])
1537 # -----------------------------------------------------------------------------
1538 # Compare two strings possibly containing shell variables as version strings.
1540 # This usage is portable even to ancient awk,
1541 # so don't worry about finding a "nice" awk version.
1542 m4_defun_init([AS_VERSION_COMPARE],
1543 [AS_REQUIRE([_$0_PREPARE])],
1544 [as_arg_v1=$1
1545 as_arg_v2=$2
1546 awk "$as_awk_strverscmp" v1="$as_arg_v1" v2="$as_arg_v2" /dev/null
1547 AS_CASE([$?],
1548         [1], [$3],
1549         [0], [$4],
1550         [2], [$5])])# AS_VERSION_COMPARE
1554 ## --------------------------------------- ##
1555 ## 6. Common m4/sh character translation.  ##
1556 ## --------------------------------------- ##
1558 # The point of this section is to provide high level macros comparable
1559 # to m4's `translit' primitive, but m4/sh polymorphic.
1560 # Transliteration of literal strings should be handled by m4, while
1561 # shell variables' content will be translated at runtime (tr or sed).
1564 # _AS_CR_PREPARE
1565 # --------------
1566 # Output variables defining common character ranges.
1567 # See m4_cr_letters etc.
1568 m4_defun([_AS_CR_PREPARE],
1569 [# Avoid depending upon Character Ranges.
1570 as_cr_letters='abcdefghijklmnopqrstuvwxyz'
1571 as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
1572 as_cr_Letters=$as_cr_letters$as_cr_LETTERS
1573 as_cr_digits='0123456789'
1574 as_cr_alnum=$as_cr_Letters$as_cr_digits
1578 # _AS_TR_SH_PREPARE
1579 # -----------------
1580 m4_defun([_AS_TR_SH_PREPARE],
1581 [AS_REQUIRE([_AS_CR_PREPARE])]dnl
1582 [# Sed expression to map a string onto a valid variable name.
1583 as_tr_sh="eval sed 'y%*+%pp%;s%[[^_$as_cr_alnum]]%_%g'"
1587 # AS_TR_SH(EXPRESSION)
1588 # --------------------
1589 # Transform EXPRESSION into a valid shell variable name.
1590 # sh/m4 polymorphic.
1591 # Be sure to update the definition of `$as_tr_sh' if you change this.
1593 # AS_LITERAL_IF guarantees that a literal does not have any nested quotes,
1594 # once $1 is expanded.  m4_translit silently uses only the first occurrence
1595 # of a character that appears multiple times in argument 2, since we know
1596 # that m4_cr_not_symbols2 also contains [ and ].  m4_translit also silently
1597 # ignores characters in argument 3 that do not match argument 2; we use this
1598 # fact to skip worrying about the length of m4_cr_not_symbols2.
1600 # For speed, we inline the literal definitions that can be computed up front.
1601 m4_defun_init([AS_TR_SH],
1602 [AS_REQUIRE([_$0_PREPARE])],
1603 [AS_LITERAL_IF([$1],
1604               [m4_translit([$1], [*+[]]]]dnl
1605 m4_dquote(m4_dquote(m4_defn([m4_cr_not_symbols2])))[[,
1606                                  [pp[]]]]dnl
1607 m4_dquote(m4_dquote(m4_for(,1,255,,[[_]])))[[)],
1608               [`AS_ECHO(["m4_bpatsubst(m4_dquote(m4_expand([$1])),
1609                                        [[\\`]], [\\\&])"]) | $as_tr_sh`])])
1612 # _AS_TR_CPP_PREPARE
1613 # ------------------
1614 m4_defun([_AS_TR_CPP_PREPARE],
1615 [AS_REQUIRE([_AS_CR_PREPARE])]dnl
1616 [# Sed expression to map a string onto a valid CPP name.
1617 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[[^_$as_cr_alnum]]%_%g'"
1621 # AS_TR_CPP(EXPRESSION)
1622 # ---------------------
1623 # Map EXPRESSION to an upper case string which is valid as rhs for a
1624 # `#define'.  sh/m4 polymorphic.  Be sure to update the definition
1625 # of `$as_tr_cpp' if you change this.
1627 # See implementation comments in AS_TR_SH.
1628 m4_defun_init([AS_TR_CPP],
1629 [AS_REQUIRE([_$0_PREPARE])],
1630 [AS_LITERAL_IF([$1],
1631               [m4_translit([$1], [*[]]]]dnl
1632 m4_dquote(m4_dquote(m4_defn([m4_cr_letters])m4_defn([m4_cr_not_symbols2])))[[,
1633                                  [P[]]]]dnl
1634 m4_dquote(m4_dquote(m4_defn([m4_cr_LETTERS])m4_for(,1,255,,[[_]])))[[)],
1635               [`AS_ECHO(["$1"]) | $as_tr_cpp`])])
1638 # _AS_TR_PREPARE
1639 # --------------
1640 m4_defun([_AS_TR_PREPARE],
1641 [AS_REQUIRE([_AS_TR_SH_PREPARE])AS_REQUIRE([_AS_TR_CPP_PREPARE])])
1646 ## ------------------------------------------------------ ##
1647 ## 7. Common m4/sh handling of variables (indirections).  ##
1648 ## ------------------------------------------------------ ##
1651 # The purpose of this section is to provide a uniform API for
1652 # reading/setting sh variables with or without indirection.
1653 # Typically, one can write
1654 #   AS_VAR_SET(var, val)
1655 # or
1656 #   AS_VAR_SET(as_$var, val)
1657 # and expect the right thing to happen.  In the descriptions below,
1658 # a literal name matches the regex [a-zA-Z_][a-zA-Z0-9_]*, an
1659 # indirect name is a shell expression that produces a literal name
1660 # when passed through eval, and a polymorphic name is either type.
1663 # _AS_VAR_APPEND_PREPARE
1664 # ----------------------
1665 # Define as_func_append to the optimum definition for the current
1666 # shell (bash and zsh provide the += assignment operator to avoid
1667 # quadratic append growth over repeated appends).
1668 m4_defun([_AS_VAR_APPEND_PREPARE],
1669 [AS_FUNCTION_DESCRIBE([as_func_append], [VAR VALUE],
1670 [Append the text in VALUE to the end of the definition contained in
1671 VAR.  Take advantage of any shell optimizations that allow amortized
1672 linear growth over repeated appends, instead of the typical quadratic
1673 growth present in naive implementations.])
1674 AS_IF([_AS_RUN(["AS_ESCAPE([_AS_VAR_APPEND_WORKS])"])],
1675 [eval 'as_func_append ()
1676   {
1677     eval $[]1+=\$[]2
1678   }'],
1679 [as_func_append ()
1680   {
1681     eval $[]1=\$$[]1\$[]2
1682   }]) # as_func_append
1685 # _AS_VAR_APPEND_WORKS
1686 # --------------------
1687 # Output a shell test to discover whether += works.
1688 m4_define([_AS_VAR_APPEND_WORKS],
1689 [as_var=1; as_var+=2; test x$as_var = x12])
1691 # AS_VAR_APPEND(VAR, VALUE)
1692 # -------------------------
1693 # Append the shell expansion of VALUE to the end of the existing
1694 # contents of the polymorphic shell variable VAR, taking advantage of
1695 # any shell optimizations that allow repeated appends to result in
1696 # amortized linear scaling rather than quadratic behavior.  This macro
1697 # is not worth the overhead unless the expected final size of the
1698 # contents of VAR outweigh the typical VALUE size of repeated appends.
1699 # Note that unlike AS_VAR_SET, VALUE must be properly quoted to avoid
1700 # field splitting and file name expansion.
1701 m4_defun_init([AS_VAR_APPEND],
1702 [_AS_DETECT_SUGGESTED([_AS_VAR_APPEND_WORKS])]dnl
1703 [AS_REQUIRE([_AS_VAR_APPEND_PREPARE], [], [M4SH-INIT-FN])],
1704 [as_func_append $1 $2])
1707 # _AS_VAR_ARITH_PREPARE
1708 # ---------------------
1709 # Define as_func_arith to the optimum definition for the current
1710 # shell (using POSIX $(()) where supported).
1711 m4_defun([_AS_VAR_ARITH_PREPARE],
1712 [AS_FUNCTION_DESCRIBE([as_func_arith], [ARG...],
1713 [Perform arithmetic evaluation on the ARGs, and store the result in
1714 the global $as_val.  Take advantage of shells that can avoid forks.
1715 The arguments must be portable across $(()) and expr.])
1716 AS_IF([_AS_RUN(["AS_ESCAPE([_AS_VAR_ARITH_WORKS])"])],
1717 [eval 'as_func_arith ()
1718   {
1719     as_val=$(( $[]* ))
1720   }'],
1721 [as_func_arith ()
1722   {
1723     as_val=`expr "$[]@"`
1724   }]) # as_func_arith
1727 # _AS_VAR_ARITH_WORKS
1728 # -------------------
1729 # Output a shell test to discover whether $(()) works.
1730 m4_define([_AS_VAR_ARITH_WORKS],
1731 [test $(( 1 + 1 )) = 2])
1733 # AS_VAR_ARITH(VAR, EXPR)
1734 # -----------------------
1735 # Perform the arithmetic evaluation of the arguments in EXPR, and set
1736 # contents of the polymorphic shell variable VAR to the result, taking
1737 # advantage of any shell optimizations that perform arithmetic without
1738 # forks.  Note that numbers occuring within EXPR must be written in
1739 # decimal, and without leading zeroes; variables containing numbers
1740 # must be expanded prior to arithmetic evaluation; the first argument
1741 # must not be a negative number; there is no portable equality
1742 # operator; and operators must be given as separate arguments and
1743 # properly quoted.
1744 m4_defun_init([AS_VAR_ARITH],
1745 [_AS_DETECT_SUGGESTED([_AS_VAR_ARITH_WORKS])]dnl
1746 [AS_REQUIRE([_AS_VAR_ARITH_PREPARE], [], [M4SH-INIT-FN])],
1747 [as_func_arith $2 && AS_VAR_SET([$1], [$as_val])])
1750 # AS_VAR_COPY(DEST, SOURCE)
1751 # -------------------------
1752 # Set the polymorphic shell variable DEST to the contents of the polymorphic
1753 # shell variable SOURCE.
1754 m4_define([AS_VAR_COPY],
1755 [AS_LITERAL_IF([$1[]$2], [$1=$$2], [eval $1=\$$2])])
1758 # AS_VAR_GET(VARIABLE)
1759 # --------------------
1760 # Get the value of the shell VARIABLE.
1761 # Evaluates to $VARIABLE if there are no indirection in VARIABLE,
1762 # else into the appropriate `eval' sequence.
1763 # This macro is deprecated because it sometimes mishandles trailing newlines;
1764 # use AS_VAR_COPY instead.
1765 m4_define([AS_VAR_GET],
1766 [AS_LITERAL_IF([$1],
1767                [$$1],
1768                [`eval 'as_val=${'m4_bpatsubst([$1], [[\\`]], [\\\&])'};dnl
1769 AS_ECHO(["$as_val"])'`])])
1772 # AS_VAR_IF(VARIABLE, VALUE, IF-TRUE, IF-FALSE)
1773 # ---------------------------------------------
1774 # Implement a shell `if test $VARIABLE = VALUE; then-else'.
1775 # Polymorphic, and avoids sh expansion error upon interrupt or term signal.
1776 m4_define([AS_VAR_IF],
1777 [AS_LITERAL_IF([$1],
1778   [AS_IF([test "x$$1" = x""$2], [$3], [$4])],
1779   [AS_VAR_COPY([as_val], [$1])
1780    AS_IF([test "x$as_val" = x""$2], [$3], [$4])])])
1783 # AS_VAR_PUSHDEF and AS_VAR_POPDEF
1784 # --------------------------------
1787 # Sometimes we may have to handle literals (e.g. `stdlib.h'), while at
1788 # other moments, the same code may have to get the value from a
1789 # variable (e.g., `ac_header').  To have a uniform handling of both
1790 # cases, when a new value is about to be processed, declare a local
1791 # variable, e.g.:
1793 #   AS_VAR_PUSHDEF([header], [ac_cv_header_$1])
1795 # and then in the body of the macro, use `header' as is.  It is of
1796 # first importance to use `AS_VAR_*' to access this variable.
1798 # If the value `$1' was a literal (e.g. `stdlib.h'), then `header' is
1799 # in fact the value `ac_cv_header_stdlib_h'.  If `$1' was indirect,
1800 # then `header's value in m4 is in fact `$as_header', the shell
1801 # variable that holds all of the magic to get the expansion right.
1803 # At the end of the block, free the variable with
1805 #   AS_VAR_POPDEF([header])
1808 # AS_VAR_POPDEF(VARNAME)
1809 # ----------------------
1810 # Free the shell variable accessor VARNAME.  To be dnl'ed.
1811 m4_define([AS_VAR_POPDEF],
1812 [m4_popdef([$1])])
1815 # AS_VAR_PUSHDEF(VARNAME, VALUE)
1816 # ------------------------------
1817 # Define the m4 macro VARNAME to an accessor to the shell variable
1818 # named VALUE.  VALUE does not need to be a valid shell variable name:
1819 # the transliteration is handled here.  To be dnl'ed.
1821 # AS_TR_SH attempts to play with diversions if _AS_TR_SH_PREPARE has
1822 # not been expanded.  However, users are expected to do subsequent
1823 # calls that trigger AS_LITERAL_IF([VARNAME]), and that macro performs
1824 # expansion inside an argument collection context, where diversions
1825 # don't work.  Therefore, we must require the preparation ourselves.
1826 m4_defun_init([AS_VAR_PUSHDEF],
1827 [AS_REQUIRE([_AS_TR_SH_PREPARE])],
1828 [AS_LITERAL_IF([$2],
1829                [m4_pushdef([$1], [AS_TR_SH($2)])],
1830                [as_$1=AS_TR_SH($2)
1831 m4_pushdef([$1], [$as_[$1]])])])
1834 # AS_VAR_SET(VARIABLE, VALUE)
1835 # ---------------------------
1836 # Set the contents of the polymorphic shell VARIABLE to the shell
1837 # expansion of VALUE.  VALUE is immune to field splitting and file
1838 # name expansion.
1839 m4_define([AS_VAR_SET],
1840 [AS_LITERAL_IF([$1],
1841                [$1=$2],
1842                [eval "$1=AS_ESCAPE([$2])"])])
1845 # AS_VAR_SET_IF(VARIABLE, IF-TRUE, IF-FALSE)
1846 # ------------------------------------------
1847 # Implement a shell `if-then-else' depending whether VARIABLE is set
1848 # or not.  Polymorphic.
1849 m4_define([AS_VAR_SET_IF],
1850 [AS_IF([AS_VAR_TEST_SET([$1])], [$2], [$3])])
1853 # AS_VAR_TEST_SET(VARIABLE)
1854 # -------------------------
1855 # Expands into the `test' expression which is true if VARIABLE
1856 # is set.  Polymorphic.
1857 m4_define([AS_VAR_TEST_SET],
1858 [AS_LITERAL_IF([$1],
1859                [test "${$1+set}" = set],
1860                [{ as_var=$1; eval "test \"\${$as_var+set}\" = set"; }])])
1863 ## -------------------- ##
1864 ## 8. Setting M4sh up.  ##
1865 ## -------------------- ##
1868 # AS_INIT_GENERATED(FILE, [COMMENT])
1869 # ----------------------------------
1870 # Generate a child script FILE with all initialization necessary to
1871 # reuse the environment learned by the parent script, and make the
1872 # file executable.  If COMMENT is supplied, it is inserted after the
1873 # `#!' sequence but before initialization text begins.  After this
1874 # macro, additional text can be appended to FILE to form the body of
1875 # the child script.  The macro ends with non-zero status if the
1876 # file could not be fully written (such as if the disk is full).
1877 m4_defun([AS_INIT_GENERATED],
1878 [m4_require([AS_PREPARE])]dnl
1879 [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl
1880 [as_write_fail=0
1881 cat >$1 <<_ASEOF || as_write_fail=1
1882 #! $SHELL
1883 # Generated by $as_me.
1885 SHELL=\${CONFIG_SHELL-$SHELL}
1886 _ASEOF
1887 cat >>$1 <<\_ASEOF || as_write_fail=1
1888 _AS_SHELL_SANITIZE
1889 _AS_PREPARE
1890 exec AS_MESSAGE_FD>&1
1891 m4_text_box([Main body of $1 script.])
1892 _ASEOF
1893 test $as_write_fail = 0 && chmod +x $1[]dnl
1894 _m4_popdef([AS_MESSAGE_LOG_FD])])# AS_INIT_GENERATED
1897 # AS_INIT
1898 # -------
1899 # Initialize m4sh.
1900 m4_define([AS_INIT],
1901 [# Wrap our cleanup prior to m4sugar's cleanup.
1902 m4_wrap([_AS_CLEANUP])
1903 m4_init
1904 m4_provide([AS_INIT])
1906 # Forbidden tokens and exceptions.
1907 m4_pattern_forbid([^_?AS_])
1909 # Bangshe and minimal initialization.
1910 m4_divert_text([BINSH], [@%:@! /bin/sh])
1911 m4_divert_text([HEADER-COMMENT],
1912                [@%:@ Generated from __file__ by m4_PACKAGE_STRING.])
1913 m4_divert_text([M4SH-SANITIZE], [_AS_SHELL_SANITIZE])
1914 m4_divert_text([M4SH-INIT-FN], [m4_text_box([M4sh Shell Functions.])])
1916 # Let's go!
1917 m4_divert_pop([KILL])[]dnl
1918 m4_divert_push([BODY])
1919 m4_text_box([Main body of script.])
1920 _AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])dnl
1921 AS_REQUIRE([_AS_UNSET_PREPARE], [], [M4SH-INIT-FN])dnl