* lib/m4sugar/m4sh.m4 (as_awk_strverscmp): Port to Solaris /bin/awk.
[autoconf/tsuna.git] / lib / m4sugar / m4sh.m4
blob8e5af193a41d3aaa19d52f8dbb53780fafe4a289
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 Free Software
6 # 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
72 #   M4sh initialization
73 # - BODY
74 #   The body of the script.
77 # _m4_divert(DIVERSION-NAME)
78 # --------------------------
79 # Convert a diversion name into its number.  Otherwise, return
80 # DIVERSION-NAME which is supposed to be an actual diversion number.
81 # Of course it would be nicer to use m4_case here, instead of zillions
82 # of little macros, but it then takes twice longer to run `autoconf'!
83 m4_define([_m4_divert(BINSH)],             0)
84 m4_define([_m4_divert(HEADER-REVISION)],   1)
85 m4_define([_m4_divert(HEADER-COMMENT)],    2)
86 m4_define([_m4_divert(HEADER-COPYRIGHT)],  3)
87 m4_define([_m4_divert(M4SH-SANITIZE)],     4)
88 m4_define([_m4_divert(M4SH-INIT)],         5)
89 m4_define([_m4_divert(BODY)],           1000)
91 # Aaarg.  Yet it starts with compatibility issues...  Libtool wants to
92 # use NOTICE to insert its own LIBTOOL-INIT stuff.  People should ask
93 # before diving into our internals :(
94 m4_copy([_m4_divert(M4SH-INIT)], [_m4_divert(NOTICE)])
98 ## ------------------------- ##
99 ## 1. Sanitizing the shell.  ##
100 ## ------------------------- ##
103 # AS_REQUIRE(NAME-TO-CHECK, [BODY-TO-EXPAND = NAME-TO-CHECK])
104 # -----------------------------------------------------------
105 # BODY-TO-EXPAND is some initialization which must be expanded in the
106 # M4SH-INIT section when expanded (required or not).  This is very
107 # different from m4_require.  For instance:
109 #      m4_defun([_FOO_PREPARE], [foo=foo])
110 #      m4_defun([FOO],
111 #      [m4_require([_FOO_PREPARE])dnl
112 #      echo $foo])
114 #      m4_defun([_BAR_PREPARE], [bar=bar])
115 #      m4_defun([BAR],
116 #      [AS_REQUIRE([_BAR_PREPARE])dnl
117 #      echo $bar])
119 #      AS_INIT
120 #      foo1=`FOO`
121 #      foo2=`FOO`
122 #      bar1=`BAR`
123 #      bar2=`BAR`
125 # gives
127 #      #! /bin/sh
128 #      bar=bar
130 #      foo1=`foo=foo
131 #      echo $foo`
132 #      foo2=`echo $foo`
133 #      bar1=`echo $bar`
134 #      bar2=`echo $bar`
136 # Due to the simple implementation, all the AS_REQUIRE calls have to be at
137 # the very beginning of the macro body, or the AS_REQUIREs may not be nested.
138 # More exactly, if a macro doesn't have all AS_REQUIREs at its beginning,
139 # it may not be AS_REQUIREd.
141 m4_define([AS_REQUIRE],
142 [m4_provide_if([$1], [],
143                [m4_divert_text([M4SH-INIT], [m4_default([$2], [$1])])])])
146 # AS_REQUIRE_SHELL_FN(NAME-TO-CHECK, BODY-TO-EXPAND)
147 # --------------------------------------------------
148 # BODY-TO-EXPAND is the body of a shell function to be emitted in the
149 # M4SH-INIT section when expanded (required or not).  Unlike other
150 # xx_REQUIRE macros, BODY-TO-EXPAND is mandatory.
152 m4_define([AS_REQUIRE_SHELL_FN],
153 [AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])dnl
154 m4_provide_if([AS_SHELL_FN_$1], [],
155                [m4_provide([AS_SHELL_FN_$1])m4_divert_text([M4SH-INIT], [$1() {
157 }])])])
160 # _AS_BOURNE_COMPATIBLE
161 # ---------------------
162 # Try to be as Bourne and/or POSIX as possible.
163 m4_define([_AS_BOURNE_COMPATIBLE],
164 [# Be Bourne compatible
165 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
166   emulate sh
167   NULLCMD=:
168   [#] Zsh 3.x and 4.x performs word splitting on ${1+"$[@]"}, which
169   # is contrary to our usage.  Disable this feature.
170   alias -g '${1+"$[@]"}'='"$[@]"'
171   setopt NO_GLOB_SUBST
172 elif test -n "${BASH_VERSION+set}${KSH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
173   set -o posix
175 BIN_SH=xpg4; export BIN_SH # for Tru64
176 DUALCASE=1; export DUALCASE # for MKS sh
180 # _AS_RUN(TEST, [SHELL])
181 # ----------------------
182 # Run TEST under the current shell (if one parameter is used)
183 # or under the given SHELL, protecting it from syntax errors.
184 m4_define([_AS_RUN],
185 [m4_ifval([$2],
186 [{ $2 <<\_ASEOF
187 _AS_BOURNE_COMPATIBLE
189 _ASEOF
191 [(eval "AS_ESCAPE(m4_quote($1))")])])
193 # AS_DETECT_REQUIRED(TEST)
194 # ------------------------
195 # Refuse to execute under a shell that does not pass
196 # the given TEST.
197 m4_define([_AS_DETECT_REQUIRED_BODY], [:])
198 m4_defun([AS_DETECT_REQUIRED],
199 [m4_require([_AS_DETECT_BETTER_SHELL])dnl
200 m4_expand_once([m4_append([_AS_DETECT_REQUIRED_BODY], [
201 ($1) || AS_EXIT(1)
202 ])], [AS_DETECT_REQUIRED_provide($1)])])
204 # AS_DETECT_SUGGESTED(TEST)
205 # -------------------------
206 # Prefer to execute under a shell that passes the given TEST.
207 m4_define([_AS_DETECT_SUGGESTED_BODY], [:])
208 m4_defun([AS_DETECT_SUGGESTED],
209 [m4_require([_AS_DETECT_BETTER_SHELL])dnl
210 m4_expand_once([m4_append([_AS_DETECT_SUGGESTED_BODY], [
211 ($1) || AS_EXIT(1)
212 ])], [AS_DETECT_SUGGESTED_provide($1)])])
214 # _AS_DETECT_BETTER_SHELL
215 # -----------------------
216 # The real workhorse for detecting a shell with the correct
217 # features.
218 m4_defun_once([_AS_DETECT_BETTER_SHELL],
219 [m4_wrap([m4_divert_text([M4SH-SANITIZE], [
220 AS_REQUIRE([_AS_UNSET_PREPARE])dnl
221 if test "x$CONFIG_SHELL" = x; then
222   AS_IF([_AS_RUN([_AS_DETECT_REQUIRED_BODY]) 2>/dev/null],
223         [as_have_required=yes],
224         [as_have_required=no])
225   AS_IF([test $as_have_required = yes && dnl
226          _AS_RUN([_AS_DETECT_SUGGESTED_BODY]) 2> /dev/null],
227     [],
228     [as_candidate_shells=
229     _AS_PATH_WALK([/bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH],
230       [case $as_dir in
231          /*)
232            for as_base in sh bash ksh sh5; do
233              as_candidate_shells="$as_candidate_shells $as_dir/$as_base"
234            done
235        esac])
237       for as_shell in $as_candidate_shells $SHELL; do
238          AS_IF([_AS_RUN([_AS_DETECT_REQUIRED_BODY],
239                         [($as_shell) 2> /dev/null])],
240                [CONFIG_SHELL=$as_shell
241                as_have_required=yes
242                AS_IF([_AS_RUN([_AS_DETECT_SUGGESTED_BODY], [$as_shell 2> /dev/null])],
243                      [break])])
244       done
246       AS_IF([test "x$CONFIG_SHELL" != x],
247         [for as_var in BASH_ENV ENV
248         do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
249         done
250         export CONFIG_SHELL
251         exec "$CONFIG_SHELL" "$as_myself" ${1+"$[@]"}])
253     AS_IF([test $as_have_required = no],
254       [echo This script requires a shell more modern than all the
255       echo shells that I found on your system.  Please install a
256       echo modern shell, or manually run the script under such a
257       echo shell if you do have one.
258       AS_EXIT(1)])
259     ])
261 ])])])
264 # _AS_SHELL_FN_WORK
265 # -----------------
266 # This is a spy to detect "in the wild" shells that do not support shell
267 # functions correctly.  It is based on the m4sh.at Autotest testcases.
268 m4_define([_AS_SHELL_FN_WORK],
269 [as_func_return () {
270   (exit [$]1)
272 as_func_success () {
273   as_func_return 0
275 as_func_failure () {
276   as_func_return 1
278 as_func_ret_success () {
279   return 0
281 as_func_ret_failure () {
282   return 1
285 exitcode=0
286 AS_IF([as_func_success], [],
287   [exitcode=1
288   echo as_func_success failed.])
289 AS_IF([as_func_failure],
290   [exitcode=1
291   echo as_func_failure succeeded.])
292 AS_IF([as_func_ret_success], [],
293   [exitcode=1
294   echo as_func_ret_success failed.])
295 AS_IF([as_func_ret_failure],
296   [exitcode=1
297   echo as_func_ret_failure succeeded.])
298 AS_IF([( set x; as_func_ret_success y && test x = "[$]1" )], [],
299   [exitcode=1
300   echo positional parameters were not saved.])
301 test $exitcode = 0])
304 # AS_COPYRIGHT(TEXT)
305 # ------------------
306 # Emit TEXT, a copyright notice, as a shell comment near the top of the
307 # script.  TEXT is evaluated once; to accomplish that, we do not prepend
308 # `# ' but `@%:@ '.
309 m4_define([AS_COPYRIGHT],
310 [m4_divert_text([HEADER-COPYRIGHT],
311 [m4_bpatsubst([
312 $1], [^], [@%:@ ])])])
315 # AS_SHELL_SANITIZE
316 # -----------------
317 m4_defun([AS_SHELL_SANITIZE],
318 [## --------------------- ##
319 ## M4sh Initialization.  ##
320 ## --------------------- ##
322 _AS_BOURNE_COMPATIBLE
324 # PATH needs CR
325 _AS_CR_PREPARE
326 _AS_PATH_SEPARATOR_PREPARE
327 _AS_UNSET_PREPARE
329 # Find who we are.  Look in the path if we contain no path at all
330 # relative or not.
331 case $[0] in
332   *[[\\/]]* ) as_myself=$[0] ;;
333   *) _AS_PATH_WALK([],
334                    [test -r "$as_dir/$[0]" && as_myself=$as_dir/$[0] && break])
335      ;;
336 esac
337 # We did not find ourselves, most probably we were run as `sh COMMAND'
338 # in which case we are not to be found in the path.
339 if test "x$as_myself" = x; then
340   as_myself=$[0]
342 if test ! -f "$as_myself"; then
343   AS_ERROR([cannot find myself; rerun with an absolute file name])
346 # Work around bugs in pre-3.0 UWIN ksh.
347 for as_var in ENV MAIL MAILPATH
348 do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
349 done
350 PS1='$ '
351 PS2='> '
352 PS4='+ '
354 # NLS nuisances.
355 for as_var in \
356   LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
357   LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
358   LC_TELEPHONE LC_TIME
360   if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
361     eval $as_var=C; export $as_var
362   else
363     ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
364   fi
365 done
367 # Required to use basename.
368 _AS_EXPR_PREPARE
369 _AS_BASENAME_PREPARE
371 # Name of the executable.
372 as_me=`AS_BASENAME("$[0]")`
377 # _AS_PREPARE
378 # -----------
379 # This macro has a very special status.  Normal use of M4sh relies
380 # heavily on AS_REQUIRE, so that needed initializations (such as
381 # _AS_TEST_PREPARE) are performed on need, not on demand.  But
382 # Autoconf is the first client of M4sh, and for two reasons: configure
383 # and config.status.  Relying on AS_REQUIRE is of course fine for
384 # configure, but fails for config.status (which is created by
385 # configure).  So we need a means to force the inclusion of the
386 # various _AS_PREPARE_* on top of config.status.  That's basically why
387 # there are so many _AS_PREPARE_* below, and that's also why it is
388 # important not to forget some: config.status needs them.
389 m4_defun([_AS_PREPARE],
390 [_AS_LINENO_PREPARE
392 _AS_ECHO_N_PREPARE
393 _AS_EXPR_PREPARE
394 _AS_LN_S_PREPARE
395 _AS_MKDIR_P_PREPARE
396 _AS_TEST_PREPARE
397 _AS_TR_CPP_PREPARE
398 _AS_TR_SH_PREPARE
400 # IFS
401 # We need space, tab and new line, in precisely that order.
402 as_nl='
404 IFS="   $as_nl"
406 # CDPATH.
407 $as_unset CDPATH
411 # AS_PREPARE
412 # ----------
413 # Output all the M4sh possible initialization into the initialization
414 # diversion.
415 m4_defun([AS_PREPARE],
416 [m4_divert_text([M4SH-INIT], [_AS_PREPARE])])
419 ## ----------------------------- ##
420 ## 2. Wrappers around builtins.  ##
421 ## ----------------------------- ##
423 # This section is lexicographically sorted.
426 # AS_EXIT([EXIT-CODE = 1])
427 # ------------------------
428 # Exit and set exit code to EXIT-CODE in the way that it's seen
429 # within "trap 0".
431 # We cannot simply use "exit N" because some shells (zsh and Solaris sh)
432 # will not set $? to N while running the code set by "trap 0"
433 # So we set $? by executing "exit N" in the subshell and then exit.
434 # Other shells don't use `$?' as default for `exit', hence just repeating
435 # the exit value can only help improving portability.
436 m4_define([AS_EXIT],
437 [{ (exit m4_default([$1], 1)); exit m4_default([$1], 1); }])
440 # AS_IF(TEST, [IF-TRUE], [IF-FALSE])
441 # ----------------------------------
442 # Expand into
443 # | if TEST; then
444 # |   IF-TRUE
445 # | else
446 # |   IF-FALSE
447 # | fi
448 # with simplifications is IF-TRUE and/or IF-FALSE is empty.
450 # FIXME: Be n-ary, just as m4_if.
451 m4_defun([AS_IF],
452 [m4_ifval([$2$3],
453 [if $1; then
454   m4_ifval([$2], [$2], :)
455 m4_ifvaln([$3],
456 [else
457   $3])dnl
459 ])dnl
460 ])# AS_IF
463 # _AS_UNSET_PREPARE
464 # -----------------
465 # AS_UNSET depends upon $as_unset: compute it.
466 # Use MAIL to trigger a bug in Bash 2.01;
467 # the "|| exit" suppresses the resulting "Segmentation fault" message.
468 # Avoid 'if ((', as that triggers a bug in pdksh 5.2.14.
469 m4_defun([_AS_UNSET_PREPARE],
470 [# Support unset when possible.
471 if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
472   as_unset=unset
473 else
474   as_unset=false
479 # AS_UNSET(VAR, [VALUE-IF-UNSET-NOT-SUPPORTED = `'])
480 # --------------------------------------------------
481 # Try to unset the env VAR, otherwise set it to
482 # VALUE-IF-UNSET-NOT-SUPPORTED.  `as_unset' must have been computed.
483 m4_defun([AS_UNSET],
484 [AS_REQUIRE([_AS_UNSET_PREPARE])dnl
485 $as_unset $1 || test "${$1+set}" != set || { $1=$2; export $1; }])
492 ## ------------------------------------------ ##
493 ## 3. Error and warnings at the shell level.  ##
494 ## ------------------------------------------ ##
496 # If AS_MESSAGE_LOG_FD is defined, shell messages are duplicated there
497 # too.
500 # AS_ESCAPE(STRING, [CHARS = $"`\])
501 # ---------------------------------
502 # Escape the CHARS in STRING.
503 m4_define([AS_ESCAPE],
504 [m4_bpatsubst([$1],
505              m4_dquote(m4_default([$2], [\"$`])),
506              [\\\&])])
509 # _AS_QUOTE_IFELSE(STRING, IF-MODERN-QUOTATION, IF-OLD-QUOTATION)
510 # ---------------------------------------------------------------
511 # Compatibility glue between the old AS_MSG suite which did not
512 # quote anything, and the modern suite which quotes the quotes.
513 # If STRING contains `\\' or `\$', it's modern.
514 # If STRING contains `\"' or `\`', it's old.
515 # Otherwise it's modern.
516 # We use two quotes in the pattern to keep highlighting tools at peace.
517 m4_define([_AS_QUOTE_IFELSE],
518 [m4_bmatch([$1],
519           [\\[\\$]], [$2],
520           [\\[`""]], [$3],
521           [$2])])
524 # _AS_QUOTE(STRING, [CHARS = `"])
525 # -------------------------------
526 # If there are quoted (via backslash) backquotes do nothing, else
527 # backslash all the quotes.
528 m4_define([_AS_QUOTE],
529 [_AS_QUOTE_IFELSE([$1],
530                   [AS_ESCAPE([$1], m4_default([$2], [`""]))],
531                   [m4_warn([obsolete],
532            [back quotes and double quotes must not be escaped in: $1])dnl
533 $1])])
536 # _AS_ECHO_UNQUOTED(STRING, [FD = AS_MESSAGE_FD])
537 # -----------------------------------------------
538 # Perform shell expansions on STRING and echo the string to FD.
539 m4_define([_AS_ECHO_UNQUOTED],
540 [echo "$1" >&m4_default([$2], [AS_MESSAGE_FD])])
543 # _AS_ECHO(STRING, [FD = AS_MESSAGE_FD])
544 # --------------------------------------
545 # Protect STRING from backquote expansion, echo the result to FD.
546 m4_define([_AS_ECHO],
547 [_AS_ECHO_UNQUOTED([_AS_QUOTE([$1])], [$2])])
550 # _AS_ECHO_LOG(STRING)
551 # --------------------
552 # Log the string to AS_MESSAGE_LOG_FD.
553 m4_define([_AS_ECHO_LOG],
554 [_AS_ECHO([$as_me:$LINENO: $1], [AS_MESSAGE_LOG_FD])])
557 # _AS_ECHO_N_PREPARE
558 # ------------------
559 # Check whether to use -n, \c, or newline-tab to separate
560 # checking messages from result messages.
561 # Don't try to cache, since the results of this macro are needed to
562 # display the checking message.  In addition, caching something used once
563 # has little interest.
564 # Idea borrowed from dist 3.0.  Use `*c*,', not `*c,' because if `\c'
565 # failed there is also a newline to match.
566 m4_defun([_AS_ECHO_N_PREPARE],
567 [ECHO_C= ECHO_N= ECHO_T=
568 case `echo -n x` in
569 -n*)
570   case `echo 'x\c'` in
571   *c*) ECHO_T=' ';;     # ECHO_T is single tab character.
572   *)   ECHO_C='\c';;
573   esac;;
575   ECHO_N='-n';;
576 esac
577 ])# _AS_ECHO_N_PREPARE
580 # _AS_ECHO_N(STRING, [FD = AS_MESSAGE_FD])
581 # ----------------------------------------
582 # Same as _AS_ECHO, but echo doesn't return to a new line.
583 m4_define([_AS_ECHO_N],
584 [AS_REQUIRE([_AS_ECHO_N_PREPARE])dnl
585 echo $ECHO_N "_AS_QUOTE([$1])$ECHO_C" >&m4_default([$2],
586                                                     [AS_MESSAGE_FD])])
589 # AS_MESSAGE(STRING, [FD = AS_MESSAGE_FD])
590 # ----------------------------------------
591 m4_define([AS_MESSAGE],
592 [m4_ifset([AS_MESSAGE_LOG_FD],
593           [{ _AS_ECHO_LOG([$1])
594 _AS_ECHO([$as_me: $1], [$2]);}],
595           [_AS_ECHO([$as_me: $1], [$2])])[]dnl
599 # AS_WARN(PROBLEM)
600 # ----------------
601 m4_define([AS_WARN],
602 [AS_MESSAGE([WARNING: $1], [2])])# AS_WARN
605 # AS_ERROR(ERROR, [EXIT-STATUS = 1])
606 # ----------------------------------
607 m4_define([AS_ERROR],
608 [{ AS_MESSAGE([error: $1], [2])
609    AS_EXIT([$2]); }[]dnl
610 ])# AS_ERROR
614 ## -------------------------------------- ##
615 ## 4. Portable versions of common tools.  ##
616 ## -------------------------------------- ##
618 # This section is lexicographically sorted.
621 # AS_DIRNAME(FILE-NAME)
622 # ---------------------
623 # Simulate running `dirname(1)' on FILE-NAME.  Not all systems have it.
624 # This macro must be usable from inside ` `.
626 # Prefer expr to echo|sed, since expr is usually faster and it handles
627 # backslashes and newlines correctly.  However, older expr
628 # implementations (e.g. SunOS 4 expr and Solaris 8 /usr/ucb/expr) have
629 # a silly length limit that causes expr to fail if the matched
630 # substring is longer than 120 bytes.  So fall back on echo|sed if
631 # expr fails.
632 m4_defun([AS_DIRNAME_EXPR],
633 [AS_REQUIRE([_AS_EXPR_PREPARE])dnl
634 $as_expr X[]$1 : 'X\(.*[[^/]]\)//*[[^/][^/]]*/*$' \| \
635          X[]$1 : 'X\(//\)[[^/]]' \| \
636          X[]$1 : 'X\(//\)$' \| \
637          X[]$1 : 'X\(/\)' \| \
638          .     : '\(.\)'])
640 m4_defun([AS_DIRNAME_SED],
641 [echo X[]$1 |
642     sed ['/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
643           /^X\(\/\/\)[^/].*/{ s//\1/; q; }
644           /^X\(\/\/\)$/{ s//\1/; q; }
645           /^X\(\/\).*/{ s//\1/; q; }
646           s/.*/./; q']])
648 m4_defun([AS_DIRNAME],
649 [(dirname $1) 2>/dev/null ||
650 AS_DIRNAME_EXPR([$1]) 2>/dev/null ||
651 AS_DIRNAME_SED([$1])])
654 # AS_BASENAME(FILE-NAME)
655 # ----------------------
656 # Simulate running `basename(1)' on FILE-NAME.  Not all systems have it.
657 # Also see the comments for AS_DIRNAME.
659 m4_defun([AS_BASENAME_EXPR],
660 [AS_REQUIRE([_AS_EXPR_PREPARE])dnl
661 $as_expr X/[]$1 : '.*/\([[^/][^/]*]\)/*$' \| \
662          X[]$1 : 'X\(//\)$' \| \
663          X[]$1 : 'X\(/\)$' \| \
664          .     : '\(.\)'])
666 m4_defun([AS_BASENAME_SED],
667 [echo X/[]$1 |
668     sed ['/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
669           /^X\/\(\/\/\)$/{ s//\1/; q; }
670           /^X\/\(\/\).*/{ s//\1/; q; }
671           s/.*/./; q']])
673 m4_defun([AS_BASENAME],
674 [AS_REQUIRE([_$0_PREPARE])dnl
675 $as_basename $1 ||
676 AS_BASENAME_EXPR([$1]) 2>/dev/null ||
677 AS_BASENAME_SED([$1])])
680 # AS_EXECUTABLE_P
681 # ---------------
682 # Check whether a file is executable.
683 m4_defun([AS_EXECUTABLE_P],
684 [AS_REQUIRE([_AS_TEST_PREPARE])dnl
685 { test -f $1 && $as_executable_p $1; }dnl
686 ])# AS_EXECUTABLE_P
689 # _AS_BASENAME_PREPARE
690 # --------------------
691 # Avoid Solaris 9 /usr/ucb/basename, as `basename /' outputs an empty line.
692 m4_defun([_AS_BASENAME_PREPARE],
693 [if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
694   as_basename=basename
695 else
696   as_basename=false
698 ])# _AS_BASENAME_PREPARE
700 # _AS_EXPR_PREPARE
701 # ----------------
702 # Some expr work properly (i.e. compute and issue the right result),
703 # but exit with failure.  When a fall back to expr (as in AS_DIRNAME)
704 # is provided, you get twice the result.  Prevent this.
705 m4_defun([_AS_EXPR_PREPARE],
706 [if expr a : '\(a\)' >/dev/null 2>&1; then
707   as_expr=expr
708 else
709   as_expr=false
711 ])# _AS_EXPR_PREPARE
713 # _AS_LINENO_WORKS
714 # ---------------
715 # Succeed if the currently executing shell supports LINENO.
716 # This macro does not expand to a single shell command, so be careful
717 # when using it.  Surrounding the body of this macro with {} would
718 # cause "bash -c '_ASLINENO_WORKS'" to fail (with Bash 2.05, anyway),
719 # but that bug is irrelevant to our use of LINENO.
720 m4_define([_AS_LINENO_WORKS],
722   as_lineno_1=$LINENO
723   as_lineno_2=$LINENO
724   test "x$as_lineno_1" != "x$as_lineno_2" &&
725   test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2"])
727 # _AS_LINENO_PREPARE
728 # ------------------
729 # If LINENO is not supported by the shell, produce a version of this
730 # script where LINENO is hard coded.
731 # Comparing LINENO against _oline_ is not a good solution, since in
732 # the case of embedded executables (such as config.status within
733 # configure) you'd compare LINENO wrt config.status vs. _oline_ wrt
734 # configure.
735 m4_define([_AS_LINENO_PREPARE],
736 [AS_REQUIRE([_AS_CR_PREPARE])dnl
737 AS_DETECT_SUGGESTED([_AS_LINENO_WORKS])
738 _AS_LINENO_WORKS || {
740   # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
741   # uniformly replaced by the line number.  The first 'sed' inserts a
742   # line-number line after each line using $LINENO; the second 'sed'
743   # does the real work.  The second script uses 'N' to pair each
744   # line-number line with the line containing $LINENO, and appends
745   # trailing '-' during substitution so that $LINENO is not a special
746   # case at line end.
747   # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
748   # scripts with optimization help from Paolo Bonzini.  Blame Lee
749   # E. McMahon (1931-1989) for sed's syntax.  :-)
750   sed -n '
751     p
752     /[[$]]LINENO/=
753   ' <$as_myself |
754     sed '
755       s,[[$]]LINENO.*,&-,
756       t lineno
757       b
758       :lineno
759       N
760       :loop
761       s,[[$]]LINENO\([[^'$as_cr_alnum'_]].*\n\)\(.*\),\2\1\2,
762       t loop
763       s,-\n.*,,
764     ' >$as_me.lineno &&
765   chmod +x $as_me.lineno ||
766     AS_ERROR([cannot create $as_me.lineno; rerun with a POSIX shell])
768   # Don't try to exec as it changes $[0], causing all sort of problems
769   # (the dirname of $[0] is not the place where we might find the
770   # original and so on.  Autoconf is especially sensible to this).
771   . ./$as_me.lineno
772   # Exit status is that of the last command.
773   exit
775 ])# _AS_LINENO_PREPARE
778 # _AS_LN_S_PREPARE
779 # ----------------
780 # Don't use conftest.sym to avoid file name issues on DJGPP, where this
781 # would yield conftest.sym.exe for DJGPP < 2.04.  And don't use `conftest'
782 # as base name to avoid prohibiting concurrency (e.g., concurrent
783 # config.statuses).
784 m4_defun([_AS_LN_S_PREPARE],
785 [rm -f conf$$ conf$$.exe conf$$.file
786 echo >conf$$.file
787 if ln -s conf$$.file conf$$ 2>/dev/null; then
788   # We could just check for DJGPP; but this test a) works b) is more generic
789   # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
790   if test -f conf$$.exe; then
791     # Don't use ln at all; we don't have any links
792     as_ln_s='cp -p'
793   else
794     as_ln_s='ln -s'
795   fi
796 elif ln conf$$.file conf$$ 2>/dev/null; then
797   as_ln_s=ln
798 else
799   as_ln_s='cp -p'
801 rm -f conf$$ conf$$.exe conf$$.file
802 ])# _AS_LN_S_PREPARE
805 # _AS_PATH_SEPARATOR_PREPARE
806 # --------------------------
807 # Compute the path separator.
808 m4_defun([_AS_PATH_SEPARATOR_PREPARE],
809 [# The user is always right.
810 if test "${PATH_SEPARATOR+set}" != set; then
811   echo "#! /bin/sh" >conf$$.sh
812   echo  "exit 0"   >>conf$$.sh
813   chmod +x conf$$.sh
814   if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
815     PATH_SEPARATOR=';'
816   else
817     PATH_SEPARATOR=:
818   fi
819   rm -f conf$$.sh
821 ])# _AS_PATH_SEPARATOR_PREPARE
824 # _AS_PATH_WALK([PATH = $PATH], BODY)
825 # -----------------------------------
826 # Walk through PATH running BODY for each `as_dir'.
828 # Still very private as its interface looks quite bad.
830 # `$as_dummy' forces splitting on constant user-supplied paths.
831 # POSIX.2 field splitting is done only on the result of word
832 # expansions, not on literal text.  This closes a longstanding sh security
833 # hole.  Optimize it away when not needed, i.e., if there are no literal
834 # path separators.
835 m4_define([_AS_PATH_WALK],
836 [AS_REQUIRE([_AS_PATH_SEPARATOR_PREPARE])dnl
837 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
838 m4_bmatch([$1], [[:;]],
839 [as_dummy="$1"
840 for as_dir in $as_dummy],
841 [for as_dir in m4_default([$1], [$PATH])])
843   IFS=$as_save_IFS
844   test -z "$as_dir" && as_dir=.
845   $2
846 done
850 # AS_LN_S(FILE, LINK)
851 # -------------------
852 # FIXME: Should we add the glue code to handle properly relative symlinks
853 # simulated with `ln' or `cp'?
854 m4_defun([AS_LN_S],
855 [AS_REQUIRE([_AS_LN_S_PREPARE])dnl
856 $as_ln_s $1 $2
860 # _AS_MKDIR_P_PREPARE
861 # -------------------
862 m4_defun([_AS_MKDIR_P_PREPARE],
863 [if mkdir -p . 2>/dev/null; then
864   as_mkdir_p=:
865 else
866   test -d ./-p && rmdir ./-p
867   as_mkdir_p=false
869 ])# _AS_MKDIR_P_PREPARE
871 # AS_MKDIR_P(DIR)
872 # ---------------
873 # Emulate `mkdir -p' with plain `mkdir'.
874 m4_define([AS_MKDIR_P],
875 [AS_REQUIRE([_$0_PREPARE])dnl
876 { if $as_mkdir_p; then
877     test -d $1 || mkdir -p $1
878   else
879     as_dir=$1
880     as_dirs=
881     while test ! -d "$as_dir"; do
882       as_dirs="$as_dir $as_dirs"
883       as_dir=`AS_DIRNAME("$as_dir")`
884     done
885     test ! -n "$as_dirs" || mkdir $as_dirs
886   fi || AS_ERROR([cannot create directory $1]); }
887 ])# AS_MKDIR_P
890 # _AS_TEST_PREPARE
891 # ----------------
892 # Find out ahead of time whether ``test -x'' can be used to distinguish
893 # executables from other regular files.
894 m4_defun([_AS_TEST_PREPARE],
895 [# Find out whether ``test -x'' works.  Don't use a zero-byte file, as
896 # systems may use methods other than mode bits to determine executability.
897 cat >conf$$.file <<_ASEOF
898 #! /bin/sh
899 exit 0
900 _ASEOF
901 chmod +x conf$$.file
902 if test -x conf$$.file >/dev/null 2>&1; then
903   as_executable_p="test -x"
904 else
905   as_executable_p=:
907 rm -f conf$$.file
908 ])# _AS_TEST_PREPARE
911 # AS_SET_CATFILE(VAR, DIR-NAME, FILE-NAME)
912 # ----------------------------------------
913 # Set VAR to DIR-NAME/FILE-NAME.
914 # Optimize the common case where $2 or $3 is '.'.
915 m4_define([AS_SET_CATFILE],
916 [case $2 in
917 .) $1=$3;;
919   case $3 in
920   .) $1=$2;;
921   [[\\/]]* | ?:[[\\/]]* ) $1=$3;;
922   *) $1=$2/$3;;
923   esac;;
924 esac[]dnl
925 ])# AS_SET_CATFILE
930 ## ------------------ ##
931 ## 5. Common idioms.  ##
932 ## ------------------ ##
934 # This section is lexicographically sorted.
937 # AS_BOX(MESSAGE, [FRAME-CHARACTER = `-'])
938 # ----------------------------------------
939 # Output MESSAGE, a single line text, framed with FRAME-CHARACTER (which
940 # must not be `/').
941 m4_define([AS_BOX],
942 [AS_LITERAL_IF([$1],
943                [_AS_BOX_LITERAL($@)],
944                [_AS_BOX_INDIR($@)])])
946 # _AS_BOX_LITERAL(MESSAGE, [FRAME-CHARACTER = `-'])
947 # -------------------------------------------------
948 m4_define([_AS_BOX_LITERAL],
949 [cat <<\_ASBOX
950 m4_text_box($@)
951 _ASBOX])
953 # _AS_BOX_INDIR(MESSAGE, [FRAME-CHARACTER = `-'])
954 # -----------------------------------------------
955 m4_define([_AS_BOX_INDIR],
956 [sed 'h;s/./m4_default([$2], [-])/g;s/^.../@%:@@%:@ /;s/...$/ @%:@@%:@/;p;x;p;x' <<_ASBOX
957 @%:@@%:@ $1 @%:@@%:@
958 _ASBOX])
961 # AS_LITERAL_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL)
962 # -----------------------------------------------------
963 # If EXPRESSION has shell indirections ($var or `expr`), expand
964 # IF-INDIR, else IF-NOT-INDIR.
965 # This is an *approximation*: for instance EXPRESSION = `\$' is
966 # definitely a literal, but will not be recognized as such.
967 m4_define([AS_LITERAL_IF],
968 [m4_bmatch([$1], [[`$]],
969            [$3], [$2])])
972 # AS_TMPDIR(PREFIX, [DIRECTORY = $TMPDIR [= /tmp]])
973 # -------------------------------------------------
974 # Create as safely as possible a temporary directory in DIRECTORY
975 # which name is inspired by PREFIX (should be 2-4 chars max).
976 m4_define([AS_TMPDIR],
977 [# Create a (secure) tmp directory for tmp files.
978 m4_if([$2], [], [: ${TMPDIR=/tmp}])
980   tmp=`(umask 077 && mktemp -d -q "m4_default([$2], [$TMPDIR])/$1XXXXXX") 2>/dev/null` &&
981   test -n "$tmp" && test -d "$tmp"
982 }  ||
984   tmp=m4_default([$2], [$TMPDIR])/$1$$-$RANDOM
985   (umask 077 && mkdir "$tmp")
986 } ||
988    echo "$me: cannot create a temporary directory in m4_default([$2], [$TMPDIR])" >&2
989    AS_EXIT
990 }dnl
991 ])# AS_TMPDIR
994 # AS_UNAME
995 # --------
996 # Try to describe this machine.  Meant for logs.
997 m4_define([AS_UNAME],
999 cat <<_ASUNAME
1000 m4_text_box([Platform.])
1002 hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
1003 uname -m = `(uname -m) 2>/dev/null || echo unknown`
1004 uname -r = `(uname -r) 2>/dev/null || echo unknown`
1005 uname -s = `(uname -s) 2>/dev/null || echo unknown`
1006 uname -v = `(uname -v) 2>/dev/null || echo unknown`
1008 /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
1009 /bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
1011 /bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
1012 /usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
1013 /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
1014 /usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`
1015 /bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
1016 /usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
1017 /bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
1019 _ASUNAME
1021 _AS_PATH_WALK([$PATH], [echo "PATH: $as_dir"])
1025 # _AS_VERSION_COMPARE_PREPARE
1026 # ---------------------------
1027 # Output variables for comparing version numbers.
1028 m4_defun([_AS_VERSION_COMPARE_PREPARE],
1029 [[as_awk_strverscmp='
1030   # Use only awk features that work with 7th edition Unix awk (1978).
1031   # My, what an old awk you have, Mr. Solaris!
1032   END {
1033     while (length(v1) || length(v2)) {
1034       # Set d1 to be the next thing to compare from v1, and likewise for d2.
1035       # Normally this is a single character, but if v1 and v2 contain digits,
1036       # compare them as integers and fractions as strverscmp does.
1037       if (v1 ~ /^[0-9]/ && v2 ~ /^[0-9]/) {
1038         # Split v1 and v2 into their leading digit string components d1 and d2,
1039         # and advance v1 and v2 past the leading digit strings.
1040         for (len1 = 1; substr(v1, len1 + 1) ~ /^[0-9]/; len1++) continue
1041         for (len2 = 1; substr(v2, len2 + 1) ~ /^[0-9]/; len2++) continue
1042         d1 = substr(v1, 1, len1); v1 = substr(v1, len1 + 1)
1043         d2 = substr(v2, 1, len2); v2 = substr(v2, len2 + 1)
1044         if (d1 ~ /^0/) {
1045           if (d2 ~ /^0/) {
1046             # Compare two fractions.
1047             while (d1 ~ /^0/ && d2 ~ /^0/) {
1048               d1 = substr(d1, 2); len1--
1049               d2 = substr(d2, 2); len2--
1050             }
1051             if (len1 != len2 && ! (len1 && len2 && substr(d1, 1, 1) == substr(d2, 1, 1))) {
1052               # The two components differ in length, and the common prefix
1053               # contains only leading zeros.  Consider the longer to be less.
1054               d1 = -len1
1055               d2 = -len2
1056             } else {
1057               # Otherwise, compare as strings.
1058               d1 = "x" d1
1059               d2 = "x" d2
1060             }
1061           } else {
1062             # A fraction is less than an integer.
1063             exit 1
1064           }
1065         } else {
1066           if (d2 ~ /^0/) {
1067             # An integer is greater than a fraction.
1068             exit 2
1069           } else {
1070             # Compare two integers.
1071             d1 += 0
1072             d2 += 0
1073           }
1074         }
1075       } else {
1076         # The normal case, without worrying about digits.
1077         if (v1 == "") d1 = v1; else { d1 = substr(v1, 1, 1); v1 = substr(v1,2) }
1078         if (v2 == "") d2 = v2; else { d2 = substr(v2, 1, 1); v2 = substr(v2,2) }
1079       }
1080       if (d1 < d2) exit 1
1081       if (d1 > d2) exit 2
1082     }
1083   }
1084 ']])
1086 # AS_VERSION_COMPARE(VERSION-1, VERSION-2,
1087 #                    [ACTION-IF-LESS], [ACTION-IF-EQUAL], [ACTION-IF-GREATER])
1088 # -----------------------------------------------------------------------------
1089 # Compare two strings possibly containing shell variables as version strings.
1090 m4_defun([AS_VERSION_COMPARE],
1091 [AS_REQUIRE([_$0_PREPARE])dnl
1092 as_arg_v1=$1
1093 as_arg_v2=$2
1094 dnl This usage is portable even to ancient awk,
1095 dnl so don't worry about finding a "nice" awk version.
1096 awk "$as_awk_strverscmp" v1="$as_arg_v1" v2="$as_arg_v2" /dev/null
1097 case $? in
1098 1) $3;;
1099 0) $4;;
1100 2) $5;;
1101 esac[]dnl
1105 # AS_HELP_STRING(LHS, RHS, [COLUMN])
1106 # ----------------------------------
1108 # Format a help string so that it looks pretty when
1109 # the user executes "script --help".  This macro takes three
1110 # arguments, a "left hand side" (LHS), a "right hand side" (RHS), and
1111 # the COLUMN which is a string of white spaces which leads to the
1112 # the RHS column (default: 26 white spaces).
1114 # The resulting string is suitable for use in other macros that require
1115 # a help string (e.g. AC_ARG_WITH).
1117 # Here is the sample string from the Autoconf manual (Node: External
1118 # Software) which shows the proper spacing for help strings.
1120 #    --with-readline         support fancy command line editing
1121 #  ^ ^                       ^
1122 #  | |                       |
1123 #  | column 2                column 26
1124 #  |
1125 #  column 0
1127 # A help string is made up of a "left hand side" (LHS) and a "right
1128 # hand side" (RHS).  In the example above, the LHS is
1129 # "--with-readline", while the RHS is "support fancy command line
1130 # editing".
1132 # If the LHS contains more than (COLUMN - 3) characters, then the LHS is
1133 # terminated with a newline so that the RHS starts on a line of its own
1134 # beginning with COLUMN.  In the default case, this corresponds to an
1135 # LHS with more than 23 characters.
1137 # Therefore, in the example, if the LHS were instead
1138 # "--with-readline-blah-blah-blah", then the AS_HELP_STRING macro would
1139 # expand into:
1142 #    --with-readline-blah-blah-blah
1143 #  ^ ^                       support fancy command line editing
1144 #  | |                       ^
1145 #  | column 2                |
1146 #  column 0                  column 26
1149 # FIXME: Handle quadrigraphs in LHS correctly.
1150 # another one:
1151 # FIXME: the m4_text_wrap interface design seems to be wrong.  I see two ways:
1152 # 1) m4_text_wrap could pad the FIRST_PREFIX to the length of PREFIX; then
1153 #    there would be no need to handle quadrigraphs in AS_HELP_STRING.
1154 # 2) The special case when FIRST_PREFIX is longer than PREFIX could be moved
1155 #    from m4_text_wrap here; then one could call
1156 #       m4_text_wrap(TEXT, [], [    ])
1157 #    to get an indented paragraph.
1158 # My first impression is that 2) is better.  --kasal 19apr05
1160 m4_define([AS_HELP_STRING],
1161 [m4_pushdef([AS_Prefix], m4_default([$3], [                          ]))dnl
1162 m4_pushdef([AS_Prefix_Format],
1163            [  %-]m4_eval(m4_len(AS_Prefix) - 3)[s ])dnl [  %-23s ]
1164 m4_text_wrap([$2], AS_Prefix, m4_format(AS_Prefix_Format, [$1]))dnl
1165 m4_popdef([AS_Prefix_Format])dnl
1166 m4_popdef([AS_Prefix])dnl
1171 ## ------------------------------------ ##
1172 ## Common m4/sh character translation.  ##
1173 ## ------------------------------------ ##
1175 # The point of this section is to provide high level macros comparable
1176 # to m4's `translit' primitive, but m4/sh polymorphic.
1177 # Transliteration of literal strings should be handled by m4, while
1178 # shell variables' content will be translated at runtime (tr or sed).
1181 # _AS_CR_PREPARE
1182 # --------------
1183 # Output variables defining common character ranges.
1184 # See m4_cr_letters etc.
1185 m4_defun([_AS_CR_PREPARE],
1186 [# Avoid depending upon Character Ranges.
1187 as_cr_letters='abcdefghijklmnopqrstuvwxyz'
1188 as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
1189 as_cr_Letters=$as_cr_letters$as_cr_LETTERS
1190 as_cr_digits='0123456789'
1191 as_cr_alnum=$as_cr_Letters$as_cr_digits
1195 # _AS_TR_SH_PREPARE
1196 # -----------------
1197 m4_defun([_AS_TR_SH_PREPARE],
1198 [AS_REQUIRE([_AS_CR_PREPARE])dnl
1199 # Sed expression to map a string onto a valid variable name.
1200 as_tr_sh="eval sed 'y%*+%pp%;s%[[^_$as_cr_alnum]]%_%g'"
1204 # AS_TR_SH(EXPRESSION)
1205 # --------------------
1206 # Transform EXPRESSION into a valid shell variable name.
1207 # sh/m4 polymorphic.
1208 # Be sure to update the definition of `$as_tr_sh' if you change this.
1209 m4_defun([AS_TR_SH],
1210 [AS_REQUIRE([_$0_PREPARE])dnl
1211 AS_LITERAL_IF([$1],
1212               [m4_bpatsubst(m4_translit([[$1]], [*+], [pp]),
1213                             [[^a-zA-Z0-9_]], [_])],
1214               [`echo "$1" | $as_tr_sh`])])
1217 # _AS_TR_CPP_PREPARE
1218 # ------------------
1219 m4_defun([_AS_TR_CPP_PREPARE],
1220 [AS_REQUIRE([_AS_CR_PREPARE])dnl
1221 # Sed expression to map a string onto a valid CPP name.
1222 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[[^_$as_cr_alnum]]%_%g'"
1226 # AS_TR_CPP(EXPRESSION)
1227 # ---------------------
1228 # Map EXPRESSION to an upper case string which is valid as rhs for a
1229 # `#define'.  sh/m4 polymorphic.  Be sure to update the definition
1230 # of `$as_tr_cpp' if you change this.
1231 m4_defun([AS_TR_CPP],
1232 [AS_REQUIRE([_$0_PREPARE])dnl
1233 AS_LITERAL_IF([$1],
1234               [m4_bpatsubst(m4_translit([[$1]],
1235                                         [*abcdefghijklmnopqrstuvwxyz],
1236                                         [PABCDEFGHIJKLMNOPQRSTUVWXYZ]),
1237                            [[^A-Z0-9_]], [_])],
1238               [`echo "$1" | $as_tr_cpp`])])
1241 # _AS_TR_PREPARE
1242 # --------------
1243 m4_defun([_AS_TR_PREPARE],
1244 [AS_REQUIRE([_AS_TR_SH_PREPARE])dnl
1245 AS_REQUIRE([_AS_TR_CPP_PREPARE])dnl
1251 ## --------------------------------------------------- ##
1252 ## Common m4/sh handling of variables (indirections).  ##
1253 ## --------------------------------------------------- ##
1256 # The purpose of this section is to provide a uniform API for
1257 # reading/setting sh variables with or without indirection.
1258 # Typically, one can write
1259 #   AS_VAR_SET(var, val)
1260 # or
1261 #   AS_VAR_SET(as_$var, val)
1262 # and expect the right thing to happen.
1265 # AS_VAR_SET(VARIABLE, VALUE)
1266 # ---------------------------
1267 # Set the VALUE of the shell VARIABLE.
1268 # If the variable contains indirections (e.g. `ac_cv_func_$ac_func')
1269 # perform whenever possible at m4 level, otherwise sh level.
1270 m4_define([AS_VAR_SET],
1271 [AS_LITERAL_IF([$1],
1272                [$1=$2],
1273                [eval "$1=AS_ESCAPE([$2])"])])
1276 # AS_VAR_GET(VARIABLE)
1277 # --------------------
1278 # Get the value of the shell VARIABLE.
1279 # Evaluates to $VARIABLE if there are no indirection in VARIABLE,
1280 # else into the appropriate `eval' sequence.
1281 m4_define([AS_VAR_GET],
1282 [AS_LITERAL_IF([$1],
1283                [$$1],
1284                [`eval echo '${'m4_bpatsubst($1, [[\\`]], [\\\&])'}'`])])
1287 # AS_VAR_TEST_SET(VARIABLE)
1288 # -------------------------
1289 # Expands into the `test' expression which is true if VARIABLE
1290 # is set.  Polymorphic.  Should be dnl'ed.
1291 m4_define([AS_VAR_TEST_SET],
1292 [AS_LITERAL_IF([$1],
1293                [test "${$1+set}" = set],
1294                [{ as_var=$1; eval "test \"\${$as_var+set}\" = set"; }])])
1297 # AS_VAR_SET_IF(VARIABLE, IF-TRUE, IF-FALSE)
1298 # ------------------------------------------
1299 # Implement a shell `if-then-else' depending whether VARIABLE is set
1300 # or not.  Polymorphic.
1301 m4_define([AS_VAR_SET_IF],
1302 [AS_IF([AS_VAR_TEST_SET([$1])], [$2], [$3])])
1305 # AS_VAR_PUSHDEF and AS_VAR_POPDEF
1306 # --------------------------------
1309 # Sometimes we may have to handle literals (e.g. `stdlib.h'), while at
1310 # other moments, the same code may have to get the value from a
1311 # variable (e.g., `ac_header').  To have a uniform handling of both
1312 # cases, when a new value is about to be processed, declare a local
1313 # variable, e.g.:
1315 #   AS_VAR_PUSHDEF([header], [ac_cv_header_$1])
1317 # and then in the body of the macro, use `header' as is.  It is of
1318 # first importance to use `AS_VAR_*' to access this variable.  Don't
1319 # quote its name: it must be used right away by m4.
1321 # If the value `$1' was a literal (e.g. `stdlib.h'), then `header' is
1322 # in fact the value `ac_cv_header_stdlib_h'.  If `$1' was indirect,
1323 # then `header's value in m4 is in fact `$ac_header', the shell
1324 # variable that holds all of the magic to get the expansion right.
1326 # At the end of the block, free the variable with
1328 #   AS_VAR_POPDEF([header])
1331 # AS_VAR_PUSHDEF(VARNAME, VALUE)
1332 # ------------------------------
1333 # Define the m4 macro VARNAME to an accessor to the shell variable
1334 # named VALUE.  VALUE does not need to be a valid shell variable name:
1335 # the transliteration is handled here.  To be dnl'ed.
1336 m4_define([AS_VAR_PUSHDEF],
1337 [AS_LITERAL_IF([$2],
1338                [m4_pushdef([$1], [AS_TR_SH($2)])],
1339                [as_$1=AS_TR_SH($2)
1340 m4_pushdef([$1], [$as_[$1]])])])
1343 # AS_VAR_POPDEF(VARNAME)
1344 # ----------------------
1345 # Free the shell variable accessor VARNAME.  To be dnl'ed.
1346 m4_define([AS_VAR_POPDEF],
1347 [m4_popdef([$1])])
1350 ## ----------------- ##
1351 ## Setting M4sh up.  ##
1352 ## ----------------- ##
1355 # _AS_SHELL_FN_SPY
1356 # ----------------
1357 # This temporary macro checks "in the wild" for shells that do
1358 # not support shell functions.
1359 m4_define([_AS_SHELL_FN_SPY],
1360 [AS_DETECT_SUGGESTED([_AS_SHELL_FN_WORK])
1361 _AS_RUN([_AS_SHELL_FN_WORK]) || {
1362   echo No shell found that supports shell functions.
1363   echo Please tell autoconf@gnu.org about your system,
1364   echo including any error possibly output before this
1365   echo message
1370 # AS_INIT
1371 # -------
1372 # Initialize m4sh.
1373 m4_define([AS_INIT],
1374 [m4_init
1376 # Forbidden tokens and exceptions.
1377 m4_pattern_forbid([^_?AS_])
1379 # Bangshe and minimal initialization.
1380 m4_divert_text([BINSH], [@%:@! /bin/sh])
1381 m4_divert_text([M4SH-SANITIZE], [AS_SHELL_SANITIZE])
1382 AS_REQUIRE([_AS_SHELL_FN_SPY])
1384 # Let's go!
1385 m4_wrap([m4_divert_pop([BODY])[]])
1386 m4_divert_push([BODY])[]dnl