Tweak m4_wrap to force FIFO or LIFO semantics.
[autoconf.git] / lib / m4sugar / m4sh.m4
blob8014f155b3fd51708152bfe544c491b51962da10
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 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 # As a special exception, the Free Software Foundation gives unlimited
22 # permission to copy, distribute and modify the configure scripts that
23 # are the output of Autoconf.  You need not follow the terms of the GNU
24 # General Public License when using or distributing such scripts, even
25 # though portions of the text of Autoconf appear in them.  The GNU
26 # General Public License (GPL) does govern all other use of the material
27 # that constitutes the Autoconf program.
29 # Certain portions of the Autoconf source text are designed to be copied
30 # (in certain cases, depending on the input) into the output of
31 # Autoconf.  We call these the "data" portions.  The rest of the Autoconf
32 # source text consists of comments plus executable code that decides which
33 # of the data portions to output in any given case.  We call these
34 # comments and executable code the "non-data" portions.  Autoconf never
35 # copies any of the non-data portions into its output.
37 # This special exception to the GPL applies to versions of Autoconf
38 # released by the Free Software Foundation.  When you make and
39 # distribute a modified version of Autoconf, you may extend this special
40 # exception to the GPL to apply to your modified version as well, *unless*
41 # your modified version has the potential to copy into its output some
42 # of the text that was the non-data portion of the version that you started
43 # with.  (In other words, unless your change moves or copies text from
44 # the non-data portions to the data portions.)  If your modification has
45 # such potential, you must delete any notice of this special exception
46 # to the GPL from your modified version.
48 # Written by Akim Demaille, Pavel Roskin, Alexandre Oliva, Lars J. Aas
49 # and many other people.
52 # We heavily use m4's diversions both for the initializations and for
53 # required macros, because in both cases we have to issue soon in
54 # output something which is discovered late.
57 # KILL is only used to suppress output.
59 # - BINSH
60 #   AC_REQUIRE'd #! /bin/sh line
61 # - HEADER-REVISION
62 #   RCS keywords etc.
63 # - HEADER-COMMENT
64 #   Purpose of the script etc.
65 # - HEADER-COPYRIGHT
66 #   Copyright notice(s)
67 # - M4SH-SANITIZE
68 #   M4sh's shell setup
69 # - M4SH-INIT
70 #   M4sh initialization
71 # - BODY
72 #   The body of the script.
75 # _m4_divert(DIVERSION-NAME)
76 # --------------------------
77 # Convert a diversion name into its number.  Otherwise, return
78 # DIVERSION-NAME which is supposed to be an actual diversion number.
79 # Of course it would be nicer to use m4_case here, instead of zillions
80 # of little macros, but it then takes twice longer to run `autoconf'!
81 m4_define([_m4_divert(BINSH)],             0)
82 m4_define([_m4_divert(HEADER-REVISION)],   1)
83 m4_define([_m4_divert(HEADER-COMMENT)],    2)
84 m4_define([_m4_divert(HEADER-COPYRIGHT)],  3)
85 m4_define([_m4_divert(M4SH-SANITIZE)],     4)
86 m4_define([_m4_divert(M4SH-INIT)],         5)
87 m4_define([_m4_divert(BODY)],           1000)
89 # Aaarg.  Yet it starts with compatibility issues...  Libtool wants to
90 # use NOTICE to insert its own LIBTOOL-INIT stuff.  People should ask
91 # before diving into our internals :(
92 m4_copy([_m4_divert(M4SH-INIT)], [_m4_divert(NOTICE)])
96 ## ------------------------- ##
97 ## 1. Sanitizing the shell.  ##
98 ## ------------------------- ##
101 # AS_REQUIRE(NAME-TO-CHECK, [BODY-TO-EXPAND = NAME-TO-CHECK])
102 # -----------------------------------------------------------
103 # BODY-TO-EXPAND is some initialization which must be expanded in the
104 # M4SH-INIT section when expanded (required or not).  This is very
105 # different from m4_require.  For instance:
107 #      m4_defun([_FOO_PREPARE], [foo=foo])
108 #      m4_defun([FOO],
109 #      [m4_require([_FOO_PREPARE])dnl
110 #      echo $foo])
112 #      m4_defun([_BAR_PREPARE], [bar=bar])
113 #      m4_defun([BAR],
114 #      [AS_REQUIRE([_BAR_PREPARE])dnl
115 #      echo $bar])
117 #      AS_INIT
118 #      foo1=`FOO`
119 #      foo2=`FOO`
120 #      bar1=`BAR`
121 #      bar2=`BAR`
123 # gives
125 #      #! /bin/sh
126 #      bar=bar
128 #      foo1=`foo=foo
129 #      echo $foo`
130 #      foo2=`echo $foo`
131 #      bar1=`echo $bar`
132 #      bar2=`echo $bar`
134 # Due to the simple implementation, all the AS_REQUIRE calls have to be at
135 # the very beginning of the macro body, or the AS_REQUIREs may not be nested.
136 # More exactly, if a macro doesn't have all AS_REQUIREs at its beginning,
137 # it may not be AS_REQUIREd.
139 m4_define([AS_REQUIRE],
140 [m4_provide_if([$1], [],
141                [m4_divert_text([M4SH-INIT], [m4_default([$2], [$1])])])])
144 # AS_REQUIRE_SHELL_FN(NAME-TO-CHECK, BODY-TO-EXPAND)
145 # --------------------------------------------------
146 # BODY-TO-EXPAND is the body of a shell function to be emitted in the
147 # M4SH-INIT section when expanded (required or not).  Unlike other
148 # xx_REQUIRE macros, BODY-TO-EXPAND is mandatory.
150 m4_define([AS_REQUIRE_SHELL_FN],
151 [_AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])dnl
152 m4_provide_if([AS_SHELL_FN_$1], [],
153                [m4_provide([AS_SHELL_FN_$1])m4_divert_text([M4SH-INIT], [$1() {
155 }])])])
158 # AS_BOURNE_COMPATIBLE
159 # --------------------
160 # Try to be as Bourne and/or POSIX as possible.
162 # This does not set BIN_SH, due to the problems described in
163 # <http://lists.gnu.org/archive/html/autoconf-patches/2006-03/msg00081.html>.
164 # People who need BIN_SH should set it in their environment before invoking
165 # configure; apparently this would include UnixWare, as described in
166 # <http://lists.gnu.org/archive/html/bug-autoconf/2006-06/msg00025.html>.
167 m4_define([AS_BOURNE_COMPATIBLE],
168 [# Be more Bourne compatible
169 DUALCASE=1; export DUALCASE # for MKS sh
173 # _AS_BOURNE_COMPATIBLE
174 # ---------------------
175 # This is the part of AS_BOURNE_COMPATIBLE which has to be repeated inside
176 # each instance.
177 m4_define([_AS_BOURNE_COMPATIBLE],
178 [AS_IF([test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1],
179  [emulate sh
180   NULLCMD=:
181   [#] Pre-4.2 versions of Zsh do word splitting on ${1+"$[@]"}, which
182   # is contrary to our usage.  Disable this feature.
183   alias -g '${1+"$[@]"}'='"$[@]"'
184   setopt NO_GLOB_SUBST],
185  [AS_CASE([`(set -o) 2>/dev/null`], [*posix*], [set -o posix])])
189 # _AS_RUN(TEST, [SHELL])
190 # ----------------------
191 # Run TEST under the current shell (if one parameter is used)
192 # or under the given SHELL, protecting it from syntax errors.
193 m4_define([_AS_RUN],
194 [m4_ifval([$2],
195 [{ $2 <<\_ASEOF
196 _AS_BOURNE_COMPATIBLE
198 _ASEOF
200 [(eval "AS_ESCAPE(m4_expand([$1]))")])])
203 # _AS_DETECT_REQUIRED(TEST)
204 # -------------------------
205 # Refuse to execute under a shell that does not pass the given TEST.
206 m4_define([_AS_DETECT_REQUIRED_BODY], [:])
207 m4_defun([_AS_DETECT_REQUIRED],
208 [m4_require([_AS_DETECT_BETTER_SHELL])dnl
209 m4_expand_once([m4_append([_AS_DETECT_REQUIRED_BODY], [
210 ($1) || AS_EXIT(1)
211 ])], [_AS_DETECT_REQUIRED_provide($1)])])
214 # _AS_DETECT_SUGGESTED(TEST)
215 # --------------------------
216 # Prefer to execute under a shell that passes the given TEST.
217 m4_define([_AS_DETECT_SUGGESTED_BODY], [:])
218 m4_defun([_AS_DETECT_SUGGESTED],
219 [m4_require([_AS_DETECT_BETTER_SHELL])dnl
220 m4_expand_once([m4_append([_AS_DETECT_SUGGESTED_BODY], [
221 ($1) || AS_EXIT(1)
222 ])], [_AS_DETECT_SUGGESTED_provide($1)])])
225 # _AS_DETECT_BETTER_SHELL
226 # -----------------------
227 # The real workhorse for detecting a shell with the correct
228 # features.
230 # In previous versions, we prepended /usr/posix/bin to the path, but that
231 # caused a regression on OpenServer 6.0.0
232 # <http://lists.gnu.org/archive/html/bug-autoconf/2006-06/msg00017.html>
233 # and on HP-UX 11.11, see the failure of test 120 in
234 # <http://lists.gnu.org/archive/html/bug-autoconf/2006-10/msg00003.html>
236 # FIXME: The code should test for the OSF bug described in
237 # <http://lists.gnu.org/archive/html/autoconf-patches/2006-03/msg00081.html>.
239 m4_defun_once([_AS_DETECT_BETTER_SHELL],
240 [m4_append([_AS_CLEANUP], [m4_divert_text([M4SH-SANITIZE], [
241 AS_REQUIRE([_AS_UNSET_PREPARE])dnl
242 if test "x$CONFIG_SHELL" = x; then
243   AS_IF([_AS_RUN([_AS_DETECT_REQUIRED_BODY]) 2>/dev/null],
244         [as_have_required=yes],
245         [as_have_required=no])
246   AS_IF([test $as_have_required = yes &&dnl
247          _AS_RUN([_AS_DETECT_SUGGESTED_BODY]) 2> /dev/null],
248     [],
249     [as_candidate_shells=
250     _AS_PATH_WALK([/bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH],
251       [case $as_dir in
252          /*)
253            for as_base in sh bash ksh sh5; do
254              as_candidate_shells="$as_candidate_shells $as_dir/$as_base"
255            done;;
256        esac])
258       for as_shell in $as_candidate_shells $SHELL; do
259          # Try only shells that exist, to save several forks.
260          AS_IF([{ test -f "$as_shell" || test -f "$as_shell.exe"; } &&
261                 _AS_RUN([_AS_DETECT_REQUIRED_BODY],
262                         [("$as_shell") 2> /dev/null])],
263                [CONFIG_SHELL=$as_shell
264                as_have_required=yes
265                AS_IF([_AS_RUN([_AS_DETECT_SUGGESTED_BODY], ["$as_shell" 2> /dev/null])],
266                      [break])])
267       done
269       AS_IF([test "x$CONFIG_SHELL" != x],
270         [for as_var in BASH_ENV ENV
271         do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
272         done
273         export CONFIG_SHELL
274         exec "$CONFIG_SHELL" "$as_myself" ${1+"$[@]"}])
276     AS_IF([test $as_have_required = no],
277       [echo This script requires a shell more modern than all the
278       echo shells that I found on your system.  Please install a
279       echo modern shell, or manually run the script under such a
280       echo shell if you do have one.
281       AS_EXIT(1)])
282     ])
284 ])])])# _AS_DETECT_BETTER_SHELL
287 # _AS_SHELL_FN_WORK
288 # -----------------
289 # This is a spy to detect "in the wild" shells that do not support shell
290 # functions correctly.  It is based on the m4sh.at Autotest testcases.
291 m4_define([_AS_SHELL_FN_WORK],
292 [as_func_return () {
293   (exit [$]1)
295 as_func_success () {
296   as_func_return 0
298 as_func_failure () {
299   as_func_return 1
301 as_func_ret_success () {
302   return 0
304 as_func_ret_failure () {
305   return 1
308 exitcode=0
309 AS_IF([as_func_success], [],
310   [exitcode=1
311   echo as_func_success failed.])
312 AS_IF([as_func_failure],
313   [exitcode=1
314   echo as_func_failure succeeded.])
315 AS_IF([as_func_ret_success], [],
316   [exitcode=1
317   echo as_func_ret_success failed.])
318 AS_IF([as_func_ret_failure],
319   [exitcode=1
320   echo as_func_ret_failure succeeded.])
321 AS_IF([( set x; as_func_ret_success y && test x = "[$]1" )], [],
322   [exitcode=1
323   echo positional parameters were not saved.])
324 test $exitcode = 0[]dnl
325 ])# _AS_SHELL_FN_WORK
328 # AS_COPYRIGHT(TEXT)
329 # ------------------
330 # Emit TEXT, a copyright notice, as a shell comment near the top of the
331 # script.  TEXT is evaluated once; to accomplish that, we do not prepend
332 # `# ' but `@%:@ '.
333 m4_define([AS_COPYRIGHT],
334 [m4_divert_text([HEADER-COPYRIGHT],
335 [m4_bpatsubst([
336 $1], [^], [@%:@ ])])])
339 # AS_SHELL_SANITIZE
340 # -----------------
341 m4_defun([AS_SHELL_SANITIZE],
342 [## --------------------- ##
343 ## M4sh Initialization.  ##
344 ## --------------------- ##
346 AS_BOURNE_COMPATIBLE
348 # PATH needs CR
349 _AS_CR_PREPARE
350 _AS_ECHO_PREPARE
351 _AS_PATH_SEPARATOR_PREPARE
352 _AS_UNSET_PREPARE
354 # IFS
355 # We need space, tab and new line, in precisely that order.  Quoting is
356 # there to prevent editors from complaining about space-tab.
357 # (If _AS_PATH_WALK were called with IFS unset, it would disable word
358 # splitting by setting IFS to empty value.)
359 IFS=" ""        $as_nl"
361 # Find who we are.  Look in the path if we contain no directory separator.
362 case $[0] in
363   *[[\\/]]* ) as_myself=$[0] ;;
364   *) _AS_PATH_WALK([],
365                    [test -r "$as_dir/$[0]" && as_myself=$as_dir/$[0] && break])
366      ;;
367 esac
368 # We did not find ourselves, most probably we were run as `sh COMMAND'
369 # in which case we are not to be found in the path.
370 if test "x$as_myself" = x; then
371   as_myself=$[0]
373 if test ! -f "$as_myself"; then
374   AS_ECHO(["$as_myself: error: cannot find myself; rerun with an absolute file name"]) >&2
375   AS_EXIT
378 # Work around bugs in pre-3.0 UWIN ksh.
379 for as_var in ENV MAIL MAILPATH
380 do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
381 done
382 PS1='$ '
383 PS2='> '
384 PS4='+ '
386 # NLS nuisances.
387 LC_ALL=C
388 export LC_ALL
389 LANGUAGE=C
390 export LANGUAGE
392 # Required to use basename.
393 _AS_EXPR_PREPARE
394 _AS_BASENAME_PREPARE
396 # Name of the executable.
397 as_me=`AS_BASENAME("$[0]")`
399 # CDPATH.
400 $as_unset CDPATH
401 ])# AS_SHELL_SANITIZE
404 # _AS_PREPARE
405 # -----------
406 # This macro has a very special status.  Normal use of M4sh relies
407 # heavily on AS_REQUIRE, so that needed initializations (such as
408 # _AS_TEST_PREPARE) are performed on need, not on demand.  But
409 # Autoconf is the first client of M4sh, and for two reasons: configure
410 # and config.status.  Relying on AS_REQUIRE is of course fine for
411 # configure, but fails for config.status (which is created by
412 # configure).  So we need a means to force the inclusion of the
413 # various _AS_PREPARE_* on top of config.status.  That's basically why
414 # there are so many _AS_PREPARE_* below, and that's also why it is
415 # important not to forget some: config.status needs them.
416 m4_defun([_AS_PREPARE],
417 [_AS_LINENO_PREPARE
419 _AS_DIRNAME_PREPARE
420 _AS_ECHO_N_PREPARE[]dnl We do not need this ourselves but user code might.
421 _AS_EXPR_PREPARE
422 _AS_LN_S_PREPARE
423 _AS_MKDIR_P_PREPARE
424 _AS_TEST_PREPARE
425 _AS_TR_CPP_PREPARE
426 _AS_TR_SH_PREPARE
430 # AS_PREPARE
431 # ----------
432 # Output all the M4sh possible initialization into the initialization
433 # diversion.
434 m4_defun([AS_PREPARE],
435 [m4_divert_text([M4SH-INIT], [_AS_PREPARE])])
438 ## ----------------------------- ##
439 ## 2. Wrappers around builtins.  ##
440 ## ----------------------------- ##
442 # This section is lexicographically sorted.
445 # AS_CASE(WORD, [PATTERN1], [IF-MATCHED1]...[DEFAULT])
446 # ----------------------------------------------------
447 # Expand into
448 # | case WORD in
449 # | PATTERN1) IF-MATCHED1 ;;
450 # | ...
451 # | *) DEFAULT ;;
452 # | esac
453 m4_define([_AS_CASE],
454 [m4_if([$#], 0, [m4_fatal([$0: too few arguments: $#])],
455        [$#], 1, [  *) $1 ;;],
456        [$#], 2, [  $1) m4_default([$2], [:]) ;;],
457        [  $1) m4_default([$2], [:]) ;;
458 $0(m4_shift2($@))])dnl
460 m4_defun([AS_CASE],
461 [m4_ifval([$2$3],
462 [case $1 in
463 _AS_CASE(m4_shift($@))
464 esac
465 ])dnl
466 ])# AS_CASE
469 # AS_EXIT([EXIT-CODE = 1])
470 # ------------------------
471 # Exit and set exit code to EXIT-CODE in the way that it's seen
472 # within "trap 0".
474 # We cannot simply use "exit N" because some shells (zsh and Solaris sh)
475 # will not set $? to N while running the code set by "trap 0"
476 # So we set $? by executing "exit N" in the subshell and then exit.
477 # Other shells don't use `$?' as default for `exit', hence just repeating
478 # the exit value can only help improving portability.
479 m4_define([AS_EXIT],
480 [{ (exit m4_default([$1], 1)); exit m4_default([$1], 1); }])
483 # AS_IF(TEST1, [IF-TRUE1]...[IF-FALSE])
484 # -------------------------------------
485 # Expand into
486 # | if TEST1; then
487 # |   IF-TRUE1
488 # | elif TEST2; then
489 # |   IF-TRUE2
490 # [...]
491 # | else
492 # |   IF-FALSE
493 # | fi
494 # with simplifications if IF-TRUE1 and/or IF-FALSE is empty.
496 m4_define([_AS_IF],
497 [m4_ifval([$2$3],
498 [elif $1; then
499   m4_default([$2], [:])
500 m4_ifval([$3], [$0(m4_shift2($@))])],
501 [m4_ifvaln([$1],
502 [else
503   $1])dnl
504 ])dnl
505 ])# _AS_IF
506 m4_defun([AS_IF],
507 [m4_ifval([$2$3],
508 [if $1; then
509   m4_default([$2], [:])
510 m4_ifval([$3], [_$0(m4_shift2($@))])[]dnl
512 ])dnl
513 ])# AS_IF
516 # _AS_UNSET_PREPARE
517 # -----------------
518 # AS_UNSET depends upon $as_unset: compute it.
519 # Use MAIL to trigger a bug in Bash 2.01;
520 # the "|| exit" suppresses the resulting "Segmentation fault" message.
521 # Avoid 'if ((', as that triggers a bug in pdksh 5.2.14.
522 m4_defun([_AS_UNSET_PREPARE],
523 [# Support unset when possible.
524 if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
525   as_unset=unset
526 else
527   as_unset=false
532 # AS_UNSET(VAR, [VALUE-IF-UNSET-NOT-SUPPORTED = `'])
533 # --------------------------------------------------
534 # Try to unset the env VAR, otherwise set it to
535 # VALUE-IF-UNSET-NOT-SUPPORTED.  `as_unset' must have been computed.
536 m4_defun([AS_UNSET],
537 [AS_REQUIRE([_AS_UNSET_PREPARE])dnl
538 $as_unset $1 || test "${$1+set}" != set || { $1=$2; export $1; }])
545 ## ------------------------------------------ ##
546 ## 3. Error and warnings at the shell level.  ##
547 ## ------------------------------------------ ##
549 # If AS_MESSAGE_LOG_FD is defined, shell messages are duplicated there
550 # too.
553 # AS_ESCAPE(STRING, [CHARS = $"`\])
554 # ---------------------------------
555 # Escape the CHARS in STRING.
557 # Avoid the m4_bpatsubst if there are no interesting characters to escape.
558 # _AS_ESCAPE bypasses argument defaulting.
559 m4_define([AS_ESCAPE],
560 [_$0([$1], m4_default([$2], [\"$`]))])
561 m4_define([_AS_ESCAPE],
562 [m4_if(m4_len([$1]),
563        m4_len(m4_translit([[$1]], [$2])),
564        [$1], [m4_bpatsubst([$1], [[$2]], [\\\&])])])
567 # _AS_QUOTE_IFELSE(STRING, IF-MODERN-QUOTATION, IF-OLD-QUOTATION)
568 # ---------------------------------------------------------------
569 # Compatibility glue between the old AS_MSG suite which did not
570 # quote anything, and the modern suite which quotes the quotes.
571 # If STRING contains `\\' or `\$', it's modern.
572 # If STRING contains `\"' or `\`', it's old.
573 # Otherwise it's modern.
575 # Profiling shows that m4_index is 5 to 8x faster than m4_bregexp.  The
576 # slower implementation used:
577 # m4_bmatch([$1],
578 #           [\\[\\$]], [$2],
579 #           [\\[`"]], [$3],
580 #           [$2])
581 # The current implementation caters to the common case of no backslashes,
582 # to minimize m4_index expansions (hence the nested if).
583 m4_define([_AS_QUOTE_IFELSE],
584 [m4_cond([m4_index([$1], [\])], [-1], [$2],
585          [m4_eval(m4_index([$1], [\\]) >= 0)], [1], [$2],
586          [m4_eval(m4_index([$1], [\$]) >= 0)], [1], [$2],
587          [m4_eval(m4_index([$1], [\`]) >= 0)], [1], [$3],
588          [m4_eval(m4_index([$1], [\"]) >= 0)], [1], [$3],
589          [$2])])
592 # _AS_QUOTE(STRING, [CHARS = `"])
593 # -------------------------------
594 # If there are quoted (via backslash) backquotes do nothing, else
595 # backslash all the quotes.
596 m4_define([_AS_QUOTE],
597 [_AS_QUOTE_IFELSE([$1],
598                   [_AS_ESCAPE([$1], m4_default([$2], [`""]))],
599                   [m4_warn([obsolete],
600            [back quotes and double quotes must not be escaped in: $1])dnl
601 $1])])
604 # _AS_ECHO_UNQUOTED(STRING, [FD = AS_MESSAGE_FD])
605 # -----------------------------------------------
606 # Perform shell expansions on STRING and echo the string to FD.
607 m4_define([_AS_ECHO_UNQUOTED],
608 [AS_ECHO(["$1"]) >&m4_default([$2], [AS_MESSAGE_FD])])
611 # _AS_ECHO(STRING, [FD = AS_MESSAGE_FD])
612 # --------------------------------------
613 # Protect STRING from backquote expansion, echo the result to FD.
614 m4_define([_AS_ECHO],
615 [_AS_ECHO_UNQUOTED([_AS_QUOTE([$1])], [$2])])
618 # _AS_ECHO_LOG(STRING)
619 # --------------------
620 # Log the string to AS_MESSAGE_LOG_FD.
621 m4_define([_AS_ECHO_LOG],
622 [_AS_ECHO([$as_me:$LINENO: $1], [AS_MESSAGE_LOG_FD])])
625 # _AS_ECHO_N_PREPARE
626 # ------------------
627 # Check whether to use -n, \c, or newline-tab to separate
628 # checking messages from result messages.
629 # Don't try to cache, since the results of this macro are needed to
630 # display the checking message.  In addition, caching something used once
631 # has little interest.
632 # Idea borrowed from dist 3.0.  Use `*c*,', not `*c,' because if `\c'
633 # failed there is also a newline to match.
634 m4_defun([_AS_ECHO_N_PREPARE],
635 [ECHO_C= ECHO_N= ECHO_T=
636 case `echo -n x` in
637 -n*)
638   case `echo 'x\c'` in
639   *c*) ECHO_T=' ';;     # ECHO_T is single tab character.
640   *)   ECHO_C='\c';;
641   esac;;
643   ECHO_N='-n';;
644 esac
645 ])# _AS_ECHO_N_PREPARE
648 # _AS_ECHO_N(STRING, [FD = AS_MESSAGE_FD])
649 # ----------------------------------------
650 # Same as _AS_ECHO, but echo doesn't return to a new line.
651 m4_define([_AS_ECHO_N],
652 [AS_ECHO_N(["_AS_QUOTE([$1])"]) >&m4_default([$2], [AS_MESSAGE_FD])])
655 # AS_MESSAGE(STRING, [FD = AS_MESSAGE_FD])
656 # ----------------------------------------
657 m4_define([AS_MESSAGE],
658 [m4_ifset([AS_MESSAGE_LOG_FD],
659           [{ _AS_ECHO_LOG([$1])
660 _AS_ECHO([$as_me: $1], [$2]);}],
661           [_AS_ECHO([$as_me: $1], [$2])])[]dnl
665 # AS_WARN(PROBLEM)
666 # ----------------
667 m4_define([AS_WARN],
668 [AS_MESSAGE([WARNING: $1], [2])])# AS_WARN
671 # AS_ERROR(ERROR, [EXIT-STATUS = 1])
672 # ----------------------------------
673 m4_define([AS_ERROR],
674 [{ AS_MESSAGE([error: $1], [2])
675    AS_EXIT([$2]); }[]dnl
676 ])# AS_ERROR
680 ## -------------------------------------- ##
681 ## 4. Portable versions of common tools.  ##
682 ## -------------------------------------- ##
684 # This section is lexicographically sorted.
687 # AS_BASENAME(FILE-NAME)
688 # ----------------------
689 # Simulate the command 'basename FILE-NAME'.  Not all systems have basename.
690 # Also see the comments for AS_DIRNAME.
692 m4_defun([_AS_BASENAME_EXPR],
693 [AS_REQUIRE([_AS_EXPR_PREPARE])dnl
694 $as_expr X/[]$1 : '.*/\([[^/][^/]*]\)/*$' \| \
695          X[]$1 : 'X\(//\)$' \| \
696          X[]$1 : 'X\(/\)' \| .])
698 m4_defun([_AS_BASENAME_SED],
699 [AS_ECHO([X/[]$1]) |
700     sed ['/^.*\/\([^/][^/]*\)\/*$/{
701             s//\1/
702             q
703           }
704           /^X\/\(\/\/\)$/{
705             s//\1/
706             q
707           }
708           /^X\/\(\/\).*/{
709             s//\1/
710             q
711           }
712           s/.*/./; q']])
714 m4_defun([AS_BASENAME],
715 [AS_REQUIRE([_$0_PREPARE])dnl
716 $as_basename -- $1 ||
717 _AS_BASENAME_EXPR([$1]) 2>/dev/null ||
718 _AS_BASENAME_SED([$1])])
721 # _AS_BASENAME_PREPARE
722 # --------------------
723 # Avoid Solaris 9 /usr/ucb/basename, as `basename /' outputs an empty line.
724 # Also, traditional basename mishandles --.
725 m4_defun([_AS_BASENAME_PREPARE],
726 [if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
727   as_basename=basename
728 else
729   as_basename=false
731 ])# _AS_BASENAME_PREPARE
734 # AS_DIRNAME(FILE-NAME)
735 # ---------------------
736 # Simulate the command 'dirname FILE-NAME'.  Not all systems have dirname.
737 # This macro must be usable from inside ` `.
739 # Prefer expr to echo|sed, since expr is usually faster and it handles
740 # backslashes and newlines correctly.  However, older expr
741 # implementations (e.g. SunOS 4 expr and Solaris 8 /usr/ucb/expr) have
742 # a silly length limit that causes expr to fail if the matched
743 # substring is longer than 120 bytes.  So fall back on echo|sed if
744 # expr fails.
745 m4_defun([_AS_DIRNAME_EXPR],
746 [AS_REQUIRE([_AS_EXPR_PREPARE])dnl
747 $as_expr X[]$1 : 'X\(.*[[^/]]\)//*[[^/][^/]]*/*$' \| \
748          X[]$1 : 'X\(//\)[[^/]]' \| \
749          X[]$1 : 'X\(//\)$' \| \
750          X[]$1 : 'X\(/\)' \| .])
752 m4_defun([_AS_DIRNAME_SED],
753 [AS_ECHO([X[]$1]) |
754     sed ['/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
755             s//\1/
756             q
757           }
758           /^X\(\/\/\)[^/].*/{
759             s//\1/
760             q
761           }
762           /^X\(\/\/\)$/{
763             s//\1/
764             q
765           }
766           /^X\(\/\).*/{
767             s//\1/
768             q
769           }
770           s/.*/./; q']])
772 m4_defun([AS_DIRNAME],
773 [AS_REQUIRE([_$0_PREPARE])dnl
774 $as_dirname -- $1 ||
775 _AS_DIRNAME_EXPR([$1]) 2>/dev/null ||
776 _AS_DIRNAME_SED([$1])])
779 # _AS_DIRNAME_PREPARE
780 # --------------------
781 m4_defun([_AS_DIRNAME_PREPARE],
782 [if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
783   as_dirname=dirname
784 else
785   as_dirname=false
787 ])# _AS_DIRNAME_PREPARE
790 # AS_ECHO(WORD)
791 # -------------
792 # Output WORD followed by a newline.  WORD must be a single shell word
793 # (typically a quoted string).  The bytes of WORD are output as-is, even
794 # if it starts with "-" or contains "\".
795 m4_defun([AS_ECHO],
796 [AS_REQUIRE([_$0_PREPARE])dnl
797 $as_echo $1])
800 # AS_ECHO_N(WORD)
801 # -------------
802 # Like AS_ECHO(WORD), except do not output the trailing newline.
803 m4_defun([AS_ECHO_N],
804 [AS_REQUIRE([_AS_ECHO_PREPARE])dnl
805 $as_echo_n $1])
808 # _AS_ECHO_PREPARE
809 # -----------------
810 # Arrange for $as_echo 'FOO' to echo FOO without escape-interpretation;
811 # and similarly for $as_echo_foo, which omits the trailing newline.
812 # 'FOO' is an optional single argument; a missing FOO is treated as empty.
813 m4_defun([_AS_ECHO_PREPARE],
814 [[as_nl='
816 export as_nl
817 # Printing a long string crashes Solaris 7 /usr/bin/printf.
818 as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
819 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
820 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
821 if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
822   as_echo='printf %s\n'
823   as_echo_n='printf %s'
824 else
825   if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
826     as_echo_body='eval /usr/ucb/echo -n "$][1$as_nl"'
827     as_echo_n='/usr/ucb/echo -n'
828   else
829     as_echo_body='eval expr "X$][1" : "X\\(.*\\)"'
830     as_echo_n_body='eval
831       arg=$][1;
832       case $arg in
833       *"$as_nl"*)
834         expr "X$arg" : "X\\(.*\\)$as_nl";
835         arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
836       esac;
837       expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
838     '
839     export as_echo_n_body
840     as_echo_n='sh -c $as_echo_n_body as_echo'
841   fi
842   export as_echo_body
843   as_echo='sh -c $as_echo_body as_echo'
845 ]])# _AS_ECHO_PREPARE
848 # AS_TEST_X
849 # ---------
850 # Check whether a file has executable or search permissions.
851 m4_defun([AS_TEST_X],
852 [AS_REQUIRE([_AS_TEST_PREPARE])dnl
853 $as_test_x $1[]dnl
854 ])# AS_TEST_X
857 # AS_EXECUTABLE_P
858 # ---------------
859 # Check whether a file is a regular file that has executable permissions.
860 m4_defun([AS_EXECUTABLE_P],
861 [AS_REQUIRE([_AS_TEST_PREPARE])dnl
862 { test -f $1 && AS_TEST_X([$1]); }dnl
863 ])# AS_EXECUTABLE_P
866 # _AS_EXPR_PREPARE
867 # ----------------
868 # QNX 4.25 expr computes and issue the right result but exits with failure.
869 # Tru64 expr mishandles leading zeros in numeric strings.
870 # Detect these flaws.
871 m4_defun([_AS_EXPR_PREPARE],
872 [if expr a : '\(a\)' >/dev/null 2>&1 &&
873    test "X`expr 00001 : '.*\(...\)'`" = X001; then
874   as_expr=expr
875 else
876   as_expr=false
878 ])# _AS_EXPR_PREPARE
881 # _AS_LINENO_WORKS
882 # ---------------
883 # Succeed if the currently executing shell supports LINENO.
884 # This macro does not expand to a single shell command, so be careful
885 # when using it.  Surrounding the body of this macro with {} would
886 # cause "bash -c '_ASLINENO_WORKS'" to fail (with Bash 2.05, anyway),
887 # but that bug is irrelevant to our use of LINENO.
888 m4_define([_AS_LINENO_WORKS],
890   as_lineno_1=$LINENO
891   as_lineno_2=$LINENO
892   test "x$as_lineno_1" != "x$as_lineno_2" &&
893   test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2"])
896 # _AS_LINENO_PREPARE
897 # ------------------
898 # If LINENO is not supported by the shell, produce a version of this
899 # script where LINENO is hard coded.
900 # Comparing LINENO against _oline_ is not a good solution, since in
901 # the case of embedded executables (such as config.status within
902 # configure) you'd compare LINENO wrt config.status vs. _oline_ wrt
903 # configure.
904 m4_define([_AS_LINENO_PREPARE],
905 [AS_REQUIRE([_AS_CR_PREPARE])dnl
906 _AS_DETECT_SUGGESTED([_AS_LINENO_WORKS])
907 _AS_LINENO_WORKS || {
909   # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
910   # uniformly replaced by the line number.  The first 'sed' inserts a
911   # line-number line after each line using $LINENO; the second 'sed'
912   # does the real work.  The second script uses 'N' to pair each
913   # line-number line with the line containing $LINENO, and appends
914   # trailing '-' during substitution so that $LINENO is not a special
915   # case at line end.
916   # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
917   # scripts with optimization help from Paolo Bonzini.  Blame Lee
918   # E. McMahon (1931-1989) for sed's syntax.  :-)
919   sed -n '
920     p
921     /[[$]]LINENO/=
922   ' <$as_myself |
923     sed '
924       s/[[$]]LINENO.*/&-/
925       t lineno
926       b
927       :lineno
928       N
929       :loop
930       s/[[$]]LINENO\([[^'$as_cr_alnum'_]].*\n\)\(.*\)/\2\1\2/
931       t loop
932       s/-\n.*//
933     ' >$as_me.lineno &&
934   chmod +x "$as_me.lineno" ||
935     AS_ERROR([cannot create $as_me.lineno; rerun with a POSIX shell])
937   # Don't try to exec as it changes $[0], causing all sort of problems
938   # (the dirname of $[0] is not the place where we might find the
939   # original and so on.  Autoconf is especially sensitive to this).
940   . "./$as_me.lineno"
941   # Exit status is that of the last command.
942   exit
944 ])# _AS_LINENO_PREPARE
947 # _AS_LN_S_PREPARE
948 # ----------------
949 # Don't use conftest.sym to avoid file name issues on DJGPP, where this
950 # would yield conftest.sym.exe for DJGPP < 2.04.  And don't use `conftest'
951 # as base name to avoid prohibiting concurrency (e.g., concurrent
952 # config.statuses).  On read-only media, assume 'cp -p' and hope we
953 # are just running --help anyway.
954 m4_defun([_AS_LN_S_PREPARE],
955 [rm -f conf$$ conf$$.exe conf$$.file
956 if test -d conf$$.dir; then
957   rm -f conf$$.dir/conf$$.file
958 else
959   rm -f conf$$.dir
960   mkdir conf$$.dir 2>/dev/null
962 if (echo >conf$$.file) 2>/dev/null; then
963   if ln -s conf$$.file conf$$ 2>/dev/null; then
964     as_ln_s='ln -s'
965     # ... but there are two gotchas:
966     # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
967     # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
968     # In both cases, we have to default to `cp -p'.
969     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
970       as_ln_s='cp -p'
971   elif ln conf$$.file conf$$ 2>/dev/null; then
972     as_ln_s=ln
973   else
974     as_ln_s='cp -p'
975   fi
976 else
977   as_ln_s='cp -p'
979 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
980 rmdir conf$$.dir 2>/dev/null
981 ])# _AS_LN_S_PREPARE
984 # AS_LN_S(FILE, LINK)
985 # -------------------
986 # FIXME: Should we add the glue code to handle properly relative symlinks
987 # simulated with `ln' or `cp'?
988 m4_defun([AS_LN_S],
989 [AS_REQUIRE([_AS_LN_S_PREPARE])dnl
990 $as_ln_s $1 $2
994 # AS_MKDIR_P(DIR)
995 # ---------------
996 # Emulate `mkdir -p' with plain `mkdir'.
997 m4_define([AS_MKDIR_P],
998 [AS_REQUIRE([_$0_PREPARE])dnl
999 { as_dir=$1
1000   case $as_dir in #(
1001   -*) as_dir=./$as_dir;;
1002   esac
1003   test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
1004     as_dirs=
1005     while :; do
1006       case $as_dir in #(
1007       *\'*) as_qdir=`AS_ECHO(["$as_dir"]) | sed "s/'/'\\\\\\\\''/g"`;; #'(
1008       *) as_qdir=$as_dir;;
1009       esac
1010       as_dirs="'$as_qdir' $as_dirs"
1011       as_dir=`AS_DIRNAME("$as_dir")`
1012       test -d "$as_dir" && break
1013     done
1014     test -z "$as_dirs" || eval "mkdir $as_dirs"
1015   } || test -d "$as_dir" || AS_ERROR([cannot create directory $as_dir]); }dnl
1016 ])# AS_MKDIR_P
1019 # _AS_MKDIR_P_PREPARE
1020 # -------------------
1021 m4_defun([_AS_MKDIR_P_PREPARE],
1022 [if mkdir -p . 2>/dev/null; then
1023   as_mkdir_p=:
1024 else
1025   test -d ./-p && rmdir ./-p
1026   as_mkdir_p=false
1028 ])# _AS_MKDIR_P_PREPARE
1031 # _AS_PATH_SEPARATOR_PREPARE
1032 # --------------------------
1033 # Compute the path separator.
1034 m4_defun([_AS_PATH_SEPARATOR_PREPARE],
1035 [# The user is always right.
1036 if test "${PATH_SEPARATOR+set}" != set; then
1037   PATH_SEPARATOR=:
1038   (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
1039     (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
1040       PATH_SEPARATOR=';'
1041   }
1043 ])# _AS_PATH_SEPARATOR_PREPARE
1046 # _AS_PATH_WALK([PATH = $PATH], BODY)
1047 # -----------------------------------
1048 # Walk through PATH running BODY for each `as_dir'.
1050 # Still very private as its interface looks quite bad.
1052 # `$as_dummy' forces splitting on constant user-supplied paths.
1053 # POSIX.2 field splitting is done only on the result of word
1054 # expansions, not on literal text.  This closes a longstanding sh security
1055 # hole.  Optimize it away when not needed, i.e., if there are no literal
1056 # path separators.
1057 m4_define([_AS_PATH_WALK],
1058 [AS_REQUIRE([_AS_PATH_SEPARATOR_PREPARE])dnl
1059 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
1060 m4_bmatch([$1], [[:;]],
1061 [as_dummy="$1"
1062 for as_dir in $as_dummy],
1063 [for as_dir in m4_default([$1], [$PATH])])
1065   IFS=$as_save_IFS
1066   test -z "$as_dir" && as_dir=.
1067   $2
1068 done
1069 IFS=$as_save_IFS
1073 # AS_SET_CATFILE(VAR, DIR-NAME, FILE-NAME)
1074 # ----------------------------------------
1075 # Set VAR to DIR-NAME/FILE-NAME.
1076 # Optimize the common case where $2 or $3 is '.'.
1077 m4_define([AS_SET_CATFILE],
1078 [case $2 in
1079 .) $1=$3;;
1081   case $3 in
1082   .) $1=$2;;
1083   [[\\/]]* | ?:[[\\/]]* ) $1=$3;;
1084   *) $1=$2/$3;;
1085   esac;;
1086 esac[]dnl
1087 ])# AS_SET_CATFILE
1090 # _AS_TEST_PREPARE
1091 # ----------------
1092 # Find out whether `test -x' works.  If not, prepare a substitute
1093 # that should work well enough for most scripts.
1095 # Here are some of the problems with the substitute.
1096 # The 'ls' tests whether the owner, not the current user, can execute/search.
1097 # The eval means '*', '?', and '[' cause inadvertent file name globbing
1098 # after the 'eval', so jam together as many tokens as we can to minimize
1099 # the likelihood that the inadvertent globbing will actually do anything.
1100 # Luckily, this gorp is needed only on really ancient hosts.
1102 m4_defun([_AS_TEST_PREPARE],
1103 [if test -x / >/dev/null 2>&1; then
1104   as_test_x='test -x'
1105 else
1106   if ls -dL / >/dev/null 2>&1; then
1107     as_ls_L_option=L
1108   else
1109     as_ls_L_option=
1110   fi
1111   as_test_x='
1112     eval sh -c '\''
1113       if test -d "$[]1"; then
1114         test -d "$[]1/.";
1115       else
1116         case $[]1 in
1117         -*)set "./$[]1";;
1118         esac;
1119         case `ls -ld'$as_ls_L_option' "$[]1" 2>/dev/null` in
1120         ???[[sx]]*):;;*)false;;esac;fi
1121     '\'' sh
1122   '
1124 dnl as_executable_p is present for backward compatibility with Libtool
1125 dnl 1.5.22, but it should go away at some point.
1126 as_executable_p=$as_test_x
1127 ])# _AS_TEST_PREPARE
1132 ## ------------------ ##
1133 ## 5. Common idioms.  ##
1134 ## ------------------ ##
1136 # This section is lexicographically sorted.
1139 # AS_BOX(MESSAGE, [FRAME-CHARACTER = `-'])
1140 # ----------------------------------------
1141 # Output MESSAGE, a single line text, framed with FRAME-CHARACTER (which
1142 # must not be `/').
1143 m4_define([AS_BOX],
1144 [AS_LITERAL_IF([$1],
1145                [_AS_BOX_LITERAL($@)],
1146                [_AS_BOX_INDIR($@)])])
1149 # _AS_BOX_LITERAL(MESSAGE, [FRAME-CHARACTER = `-'])
1150 # -------------------------------------------------
1151 m4_define([_AS_BOX_LITERAL],
1152 [cat <<\_ASBOX
1153 m4_text_box($@)
1154 _ASBOX])
1157 # _AS_BOX_INDIR(MESSAGE, [FRAME-CHARACTER = `-'])
1158 # -----------------------------------------------
1159 m4_define([_AS_BOX_INDIR],
1160 [sed 'h;s/./m4_default([$2], [-])/g;s/^.../@%:@@%:@ /;s/...$/ @%:@@%:@/;p;x;p;x' <<_ASBOX
1161 @%:@@%:@ $1 @%:@@%:@
1162 _ASBOX])
1165 # AS_HELP_STRING(LHS, RHS, [INDENT-COLUMN = 26], [WRAP-COLUMN = 79])
1166 # ------------------------------------------------------------------
1168 # Format a help string so that it looks pretty when the user executes
1169 # "script --help".  This macro takes up to four arguments, a
1170 # "left hand side" (LHS), a "right hand side" (RHS), a decimal
1171 # INDENT-COLUMN which is the column where wrapped lines should begin
1172 # (the default of 26 is recommended), and a decimal WRAP-COLUMN which is
1173 # the column where lines should wrap (the default of 79 is recommended).
1174 # LHS is expanded, RHS is not.
1176 # For backwards compatibility not documented in the manual, INDENT-COLUMN
1177 # can also be specified as a string of white spaces, whose width
1178 # determines the indentation column.  Using TABs in INDENT-COLUMN is not
1179 # recommended, since screen width of TAB is not computed.
1181 # The resulting string is suitable for use in other macros that require
1182 # a help string (e.g. AC_ARG_WITH).
1184 # Here is the sample string from the Autoconf manual (Node: External
1185 # Software) which shows the proper spacing for help strings.
1187 #    --with-readline         support fancy command line editing
1188 #  ^ ^                       ^
1189 #  | |                       |
1190 #  | column 2                column 26
1191 #  |
1192 #  column 0
1194 # A help string is made up of a "left hand side" (LHS) and a "right
1195 # hand side" (RHS).  In the example above, the LHS is
1196 # "--with-readline", while the RHS is "support fancy command line
1197 # editing".
1199 # If the LHS contains more than (INDENT-COLUMN - 3) characters, then the
1200 # LHS is terminated with a newline so that the RHS starts on a line of its
1201 # own beginning at INDENT-COLUMN.  In the default case, this corresponds to an
1202 # LHS with more than 23 characters.
1204 # Therefore, in the example, if the LHS were instead
1205 # "--with-readline-blah-blah-blah", then the AS_HELP_STRING macro would
1206 # expand into:
1209 #    --with-readline-blah-blah-blah
1210 #  ^ ^                       support fancy command line editing
1211 #  | |                       ^
1212 #  | column 2                |
1213 #  column 0                  column 26
1216 # m4_text_wrap hacks^Wworks around the fact that m4_format does not
1217 # know quadrigraphs.
1219 m4_define([AS_HELP_STRING],
1220 [m4_text_wrap([$2], m4_cond([[$3]], [], [                          ],
1221                             [m4_eval([$3]+0)], [0], [[$3]],
1222                             [m4_format([[%*s]], [$3], [])]),
1223               m4_expand([  $1 ]), [$4])dnl
1224 ])# AS_HELP_STRING
1227 # AS_IDENTIFIER_IF(EXPRESSION, IF-IDENT, IF-NOT-IDENT)
1228 # ----------------------------------------------------
1229 # If EXPRESSION serves as an identifier (ie, after removal of @&t@, it
1230 # matches the regex `^[a-zA-Z_][a-zA-Z_0-9]*$'), execute IF-IDENT,
1231 # otherwise IF-NOT-IDENT.
1233 # This is generally faster than the alternative:
1234 #   m4_bmatch(m4_bpatsubst([[$1]], [@&t@]), ^m4_defn([m4_re_word])$,
1235 #             [$2], [$3])
1237 # Rather than expand m4_defn every time AS_IDENTIFIER_IF is expanded, we
1238 # inline its expansion up front.  Only use a regular expression if we
1239 # detect a potential quadrigraph.
1241 # First, check if the entire string matches m4_cr_symbol2.  Only then do
1242 # we worry if the first character also matches m4_cr_symbol1 (ie. does not
1243 # match m4_cr_digit).
1244 m4_define([AS_IDENTIFIER_IF],
1245 [m4_if(m4_index([$1], [@]), [-1],
1246        [_$0($@)],
1247        [_$0(m4_bpatsubst([[$1]], [@&t@]), [$2], [$3])])])
1248 m4_define([_AS_IDENTIFIER_IF],
1249 [m4_cond([[$1]], [], [$3],
1250          [m4_eval(m4_len(m4_translit([[$1]], ]]dnl
1251 m4_dquote(m4_dquote(m4_defn([m4_cr_symbols2])))[[)) > 0)], [1], [$3],
1252          [m4_len(m4_translit(m4_format([[%.1s]], [$1]), ]]dnl
1253 m4_dquote(m4_dquote(m4_defn([m4_cr_symbols1])))[[))], [0], [$2], [$3])])
1256 # AS_LITERAL_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL)
1257 # -----------------------------------------------------
1258 # If EXPRESSION has shell indirections ($var or `expr`), expand
1259 # IF-INDIR, else IF-NOT-INDIR.
1260 # This is an *approximation*: for instance EXPRESSION = `\$' is
1261 # definitely a literal, but will not be recognized as such.
1263 # Why do we reject EXPRESSION expanding with `[' or `]' as a literal?
1264 # Because AS_TR_SH is MUCH faster if it can use m4_translit on literals
1265 # instead of m4_bpatsubst; but m4_translit is much tougher to do safely
1266 # if `[' is translated.
1268 # Note that the quadrigraph @S|@ can result in non-literals, but outright
1269 # rejecting all @ would make AC_INIT complain on its bug report address.
1271 # We used to use m4_bmatch(m4_quote($1), [[`$]], [$3], [$2]), but
1272 # profiling shows that it is faster to use m4_translit.
1274 # Because the translit is stripping quotes, it must also neutralize anything
1275 # that might be in a macro name, as well as comments and commas.  All the
1276 # problem characters are unified so that a single m4_index can scan the
1277 # result.
1279 # Rather than expand m4_defn every time AS_LITERAL_IF is expanded, we
1280 # inline its expansion up front.
1281 m4_define([AS_LITERAL_IF],
1282 [m4_cond([m4_eval(m4_index(m4_quote($1), [@S|@]) == -1)], [0], [$3],
1283          [m4_index(m4_translit(m4_quote($1),
1284                                [[]`,#]]]dnl
1285 m4_dquote(m4_dquote(m4_defn([m4_cr_symbols2])))[[,
1286                                [$$$]),
1287                    [$])], [-1], [$2],
1288          [$3])])
1291 # AS_TMPDIR(PREFIX, [DIRECTORY = $TMPDIR [= /tmp]])
1292 # -------------------------------------------------
1293 # Create as safely as possible a temporary directory in DIRECTORY
1294 # which name is inspired by PREFIX (should be 2-4 chars max).
1295 m4_define([AS_TMPDIR],
1296 [# Create a (secure) tmp directory for tmp files.
1297 m4_if([$2], [], [: ${TMPDIR=/tmp}])
1299   tmp=`(umask 077 && mktemp -d "m4_default([$2], [$TMPDIR])/$1XXXXXX") 2>/dev/null` &&
1300   test -n "$tmp" && test -d "$tmp"
1301 }  ||
1303   tmp=m4_default([$2], [$TMPDIR])/$1$$-$RANDOM
1304   (umask 077 && mkdir "$tmp")
1305 } ||
1307    AS_ECHO(["$as_me: cannot create a temporary directory in m4_default([$2], [$TMPDIR])"]) >&2
1308    AS_EXIT
1309 }dnl
1310 ])# AS_TMPDIR
1313 # AS_UNAME
1314 # --------
1315 # Try to describe this machine.  Meant for logs.
1316 m4_define([AS_UNAME],
1318 cat <<_ASUNAME
1319 m4_text_box([Platform.])
1321 hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
1322 uname -m = `(uname -m) 2>/dev/null || echo unknown`
1323 uname -r = `(uname -r) 2>/dev/null || echo unknown`
1324 uname -s = `(uname -s) 2>/dev/null || echo unknown`
1325 uname -v = `(uname -v) 2>/dev/null || echo unknown`
1327 /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
1328 /bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
1330 /bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
1331 /usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
1332 /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
1333 /usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`
1334 /bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
1335 /usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
1336 /bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
1338 _ASUNAME
1340 _AS_PATH_WALK([$PATH], [AS_ECHO(["PATH: $as_dir"])])
1344 # _AS_VERSION_COMPARE_PREPARE
1345 # ---------------------------
1346 # Output variables for comparing version numbers.
1347 m4_defun([_AS_VERSION_COMPARE_PREPARE],
1348 [[as_awk_strverscmp='
1349   # Use only awk features that work with 7th edition Unix awk (1978).
1350   # My, what an old awk you have, Mr. Solaris!
1351   END {
1352     while (length(v1) && length(v2)) {
1353       # Set d1 to be the next thing to compare from v1, and likewise for d2.
1354       # Normally this is a single character, but if v1 and v2 contain digits,
1355       # compare them as integers and fractions as strverscmp does.
1356       if (v1 ~ /^[0-9]/ && v2 ~ /^[0-9]/) {
1357         # Split v1 and v2 into their leading digit string components d1 and d2,
1358         # and advance v1 and v2 past the leading digit strings.
1359         for (len1 = 1; substr(v1, len1 + 1) ~ /^[0-9]/; len1++) continue
1360         for (len2 = 1; substr(v2, len2 + 1) ~ /^[0-9]/; len2++) continue
1361         d1 = substr(v1, 1, len1); v1 = substr(v1, len1 + 1)
1362         d2 = substr(v2, 1, len2); v2 = substr(v2, len2 + 1)
1363         if (d1 ~ /^0/) {
1364           if (d2 ~ /^0/) {
1365             # Compare two fractions.
1366             while (d1 ~ /^0/ && d2 ~ /^0/) {
1367               d1 = substr(d1, 2); len1--
1368               d2 = substr(d2, 2); len2--
1369             }
1370             if (len1 != len2 && ! (len1 && len2 && substr(d1, 1, 1) == substr(d2, 1, 1))) {
1371               # The two components differ in length, and the common prefix
1372               # contains only leading zeros.  Consider the longer to be less.
1373               d1 = -len1
1374               d2 = -len2
1375             } else {
1376               # Otherwise, compare as strings.
1377               d1 = "x" d1
1378               d2 = "x" d2
1379             }
1380           } else {
1381             # A fraction is less than an integer.
1382             exit 1
1383           }
1384         } else {
1385           if (d2 ~ /^0/) {
1386             # An integer is greater than a fraction.
1387             exit 2
1388           } else {
1389             # Compare two integers.
1390             d1 += 0
1391             d2 += 0
1392           }
1393         }
1394       } else {
1395         # The normal case, without worrying about digits.
1396         d1 = substr(v1, 1, 1); v1 = substr(v1, 2)
1397         d2 = substr(v2, 1, 1); v2 = substr(v2, 2)
1398       }
1399       if (d1 < d2) exit 1
1400       if (d1 > d2) exit 2
1401     }
1402     # Beware Solaris /usr/xgp4/bin/awk (at least through Solaris 10),
1403     # which mishandles some comparisons of empty strings to integers.
1404     if (length(v2)) exit 1
1405     if (length(v1)) exit 2
1406   }
1407 ']])# _AS_VERSION_COMPARE_PREPARE
1410 # AS_VERSION_COMPARE(VERSION-1, VERSION-2,
1411 #                    [ACTION-IF-LESS], [ACTION-IF-EQUAL], [ACTION-IF-GREATER])
1412 # -----------------------------------------------------------------------------
1413 # Compare two strings possibly containing shell variables as version strings.
1414 m4_defun([AS_VERSION_COMPARE],
1415 [AS_REQUIRE([_$0_PREPARE])dnl
1416 as_arg_v1=$1
1417 as_arg_v2=$2
1418 dnl This usage is portable even to ancient awk,
1419 dnl so don't worry about finding a "nice" awk version.
1420 awk "$as_awk_strverscmp" v1="$as_arg_v1" v2="$as_arg_v2" /dev/null
1421 case $? in
1422 1) $3;;
1423 0) $4;;
1424 2) $5;;
1425 esac[]dnl
1426 ])# _AS_VERSION_COMPARE
1430 ## ------------------------------------ ##
1431 ## Common m4/sh character translation.  ##
1432 ## ------------------------------------ ##
1434 # The point of this section is to provide high level macros comparable
1435 # to m4's `translit' primitive, but m4/sh polymorphic.
1436 # Transliteration of literal strings should be handled by m4, while
1437 # shell variables' content will be translated at runtime (tr or sed).
1440 # _AS_CR_PREPARE
1441 # --------------
1442 # Output variables defining common character ranges.
1443 # See m4_cr_letters etc.
1444 m4_defun([_AS_CR_PREPARE],
1445 [# Avoid depending upon Character Ranges.
1446 as_cr_letters='abcdefghijklmnopqrstuvwxyz'
1447 as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
1448 as_cr_Letters=$as_cr_letters$as_cr_LETTERS
1449 as_cr_digits='0123456789'
1450 as_cr_alnum=$as_cr_Letters$as_cr_digits
1454 # _AS_TR_SH_PREPARE
1455 # -----------------
1456 m4_defun([_AS_TR_SH_PREPARE],
1457 [AS_REQUIRE([_AS_CR_PREPARE])dnl
1458 # Sed expression to map a string onto a valid variable name.
1459 as_tr_sh="eval sed 'y%*+%pp%;s%[[^_$as_cr_alnum]]%_%g'"
1463 # AS_TR_SH(EXPRESSION)
1464 # --------------------
1465 # Transform EXPRESSION into a valid shell variable name.
1466 # sh/m4 polymorphic.
1467 # Be sure to update the definition of `$as_tr_sh' if you change this.
1469 # AS_LITERAL_IF guarantees that a literal does not have any nested quotes,
1470 # once $1 is expanded.  m4_translit silently uses only the first occurrence
1471 # of a character that appears multiple times in argument 2, since we know
1472 # that m4_cr_not_symbols2 also contains [ and ].  m4_translit also silently
1473 # ignores characters in argument 3 that do not match argument 2; we use this
1474 # fact to skip worrying about the length of m4_cr_not_symbols2.
1476 # For speed, we inline the literal definitions that can be computed up front.
1477 m4_defun([AS_TR_SH],
1478 [AS_REQUIRE([_$0_PREPARE])dnl
1479 AS_LITERAL_IF([$1],
1480               [m4_translit([$1], [*+[]]]]dnl
1481 m4_dquote(m4_dquote(m4_defn([m4_cr_not_symbols2])))[[,
1482                                  [pp[]]]]dnl
1483 m4_dquote(m4_dquote(m4_for(,1,255,,[[_]])))[[)],
1484               [`AS_ECHO(["$1"]) | $as_tr_sh`])])
1487 # _AS_TR_CPP_PREPARE
1488 # ------------------
1489 m4_defun([_AS_TR_CPP_PREPARE],
1490 [AS_REQUIRE([_AS_CR_PREPARE])dnl
1491 # Sed expression to map a string onto a valid CPP name.
1492 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[[^_$as_cr_alnum]]%_%g'"
1496 # AS_TR_CPP(EXPRESSION)
1497 # ---------------------
1498 # Map EXPRESSION to an upper case string which is valid as rhs for a
1499 # `#define'.  sh/m4 polymorphic.  Be sure to update the definition
1500 # of `$as_tr_cpp' if you change this.
1502 # See implementation comments in AS_TR_SH.
1503 m4_defun([AS_TR_CPP],
1504 [AS_REQUIRE([_$0_PREPARE])dnl
1505 AS_LITERAL_IF([$1],
1506               [m4_translit([$1], [*[]]]]dnl
1507 m4_dquote(m4_dquote(m4_defn([m4_cr_letters])m4_defn([m4_cr_not_symbols2])))[[,
1508                                  [P[]]]]dnl
1509 m4_dquote(m4_dquote(m4_defn([m4_cr_LETTERS])m4_for(,1,255,,[[_]])))[[)],
1510               [`AS_ECHO(["$1"]) | $as_tr_cpp`])])
1513 # _AS_TR_PREPARE
1514 # --------------
1515 m4_defun([_AS_TR_PREPARE],
1516 [AS_REQUIRE([_AS_TR_SH_PREPARE])dnl
1517 AS_REQUIRE([_AS_TR_CPP_PREPARE])dnl
1523 ## --------------------------------------------------- ##
1524 ## Common m4/sh handling of variables (indirections).  ##
1525 ## --------------------------------------------------- ##
1528 # The purpose of this section is to provide a uniform API for
1529 # reading/setting sh variables with or without indirection.
1530 # Typically, one can write
1531 #   AS_VAR_SET(var, val)
1532 # or
1533 #   AS_VAR_SET(as_$var, val)
1534 # and expect the right thing to happen.
1537 # AS_VAR_SET(VARIABLE, VALUE)
1538 # ---------------------------
1539 # Set the VALUE of the shell VARIABLE.
1540 # If the variable contains indirections (e.g. `ac_cv_func_$ac_func')
1541 # perform whenever possible at m4 level, otherwise sh level.
1542 m4_define([AS_VAR_SET],
1543 [AS_LITERAL_IF([$1],
1544                [$1=$2],
1545                [eval "$1=AS_ESCAPE([$2])"])])
1548 # AS_VAR_GET(VARIABLE)
1549 # --------------------
1550 # Get the value of the shell VARIABLE.
1551 # Evaluates to $VARIABLE if there are no indirection in VARIABLE,
1552 # else into the appropriate `eval' sequence.
1553 # FIXME: This mishandles values that end in newlines.
1554 # Fixing this will require changing the API.
1555 m4_define([AS_VAR_GET],
1556 [AS_LITERAL_IF([$1],
1557                [$$1],
1558                [`eval 'as_val=${'m4_bpatsubst([$1], [[\\`]], [\\\&])'}
1559                  AS_ECHO(["$as_val"])'`])])
1562 # AS_VAR_TEST_SET(VARIABLE)
1563 # -------------------------
1564 # Expands into the `test' expression which is true if VARIABLE
1565 # is set.  Polymorphic.  Should be dnl'ed.
1566 m4_define([AS_VAR_TEST_SET],
1567 [AS_LITERAL_IF([$1],
1568                [test "${$1+set}" = set],
1569                [{ as_var=$1; eval "test \"\${$as_var+set}\" = set"; }])])
1572 # AS_VAR_SET_IF(VARIABLE, IF-TRUE, IF-FALSE)
1573 # ------------------------------------------
1574 # Implement a shell `if-then-else' depending whether VARIABLE is set
1575 # or not.  Polymorphic.
1576 m4_define([AS_VAR_SET_IF],
1577 [AS_IF([AS_VAR_TEST_SET([$1])], [$2], [$3])])
1580 # AS_VAR_PUSHDEF and AS_VAR_POPDEF
1581 # --------------------------------
1584 # Sometimes we may have to handle literals (e.g. `stdlib.h'), while at
1585 # other moments, the same code may have to get the value from a
1586 # variable (e.g., `ac_header').  To have a uniform handling of both
1587 # cases, when a new value is about to be processed, declare a local
1588 # variable, e.g.:
1590 #   AS_VAR_PUSHDEF([header], [ac_cv_header_$1])
1592 # and then in the body of the macro, use `header' as is.  It is of
1593 # first importance to use `AS_VAR_*' to access this variable.  Don't
1594 # quote its name: it must be used right away by m4.
1596 # If the value `$1' was a literal (e.g. `stdlib.h'), then `header' is
1597 # in fact the value `ac_cv_header_stdlib_h'.  If `$1' was indirect,
1598 # then `header's value in m4 is in fact `$as_header', the shell
1599 # variable that holds all of the magic to get the expansion right.
1601 # At the end of the block, free the variable with
1603 #   AS_VAR_POPDEF([header])
1606 # AS_VAR_PUSHDEF(VARNAME, VALUE)
1607 # ------------------------------
1608 # Define the m4 macro VARNAME to an accessor to the shell variable
1609 # named VALUE.  VALUE does not need to be a valid shell variable name:
1610 # the transliteration is handled here.  To be dnl'ed.
1611 m4_define([AS_VAR_PUSHDEF],
1612 [AS_LITERAL_IF([$2],
1613                [m4_pushdef([$1], [AS_TR_SH($2)])],
1614                [as_$1=AS_TR_SH($2)
1615 m4_pushdef([$1], [$as_[$1]])])])
1618 # AS_VAR_POPDEF(VARNAME)
1619 # ----------------------
1620 # Free the shell variable accessor VARNAME.  To be dnl'ed.
1621 m4_define([AS_VAR_POPDEF],
1622 [m4_popdef([$1])])
1625 ## ----------------- ##
1626 ## Setting M4sh up.  ##
1627 ## ----------------- ##
1630 # _AS_SHELL_FN_SPY
1631 # ----------------
1632 # This temporary macro checks "in the wild" for shells that do
1633 # not support shell functions.
1634 m4_define([_AS_SHELL_FN_SPY],
1635 [_AS_DETECT_SUGGESTED([_AS_SHELL_FN_WORK])
1636 _AS_RUN([_AS_SHELL_FN_WORK]) || {
1637   echo No shell found that supports shell functions.
1638   echo Please tell bug-autoconf@gnu.org about your system,
1639   echo including any error possibly output before this message.
1640   echo This can help us improve future autoconf versions.
1641   echo Configuration will now proceed without shell functions.
1646 # AS_INIT
1647 # -------
1648 # Initialize m4sh.
1649 m4_define([AS_INIT],
1650 [# Wrap our cleanup prior to m4sugar's cleanup.
1651 m4_wrap([_AS_CLEANUP])
1652 m4_init
1654 # Forbidden tokens and exceptions.
1655 m4_pattern_forbid([^_?AS_])
1657 # Bangshe and minimal initialization.
1658 m4_divert_text([BINSH], [@%:@! /bin/sh])
1659 m4_divert_text([HEADER-COMMENT],
1660                [@%:@ Generated from __file__ by m4_PACKAGE_STRING.])
1661 m4_divert_text([M4SH-SANITIZE], [AS_SHELL_SANITIZE])
1662 AS_REQUIRE([_AS_SHELL_FN_SPY])
1664 # Let's go!
1665 m4_divert_pop([KILL])[]dnl
1666 m4_divert_push([BODY])[]dnl