Use "test x$foo = xyes" to avoid upsetting Libtool's sh.test.
[autoconf.git] / lib / m4sugar / m4sh.m4
blob983e2e09f70eba7426e1ba5d3f8010294268f0e8
1 # This file is part of Autoconf.                          -*- Autoconf -*-
2 # M4 sugar for common shell constructs.
3 # Requires GNU M4 and M4sugar.
5 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
6 # Free Software Foundation, Inc.
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2, or (at your option)
11 # any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 # 02110-1301, USA.
23 # As a special exception, the Free Software Foundation gives unlimited
24 # permission to copy, distribute and modify the configure scripts that
25 # are the output of Autoconf.  You need not follow the terms of the GNU
26 # General Public License when using or distributing such scripts, even
27 # though portions of the text of Autoconf appear in them.  The GNU
28 # General Public License (GPL) does govern all other use of the material
29 # that constitutes the Autoconf program.
31 # Certain portions of the Autoconf source text are designed to be copied
32 # (in certain cases, depending on the input) into the output of
33 # Autoconf.  We call these the "data" portions.  The rest of the Autoconf
34 # source text consists of comments plus executable code that decides which
35 # of the data portions to output in any given case.  We call these
36 # comments and executable code the "non-data" portions.  Autoconf never
37 # copies any of the non-data portions into its output.
39 # This special exception to the GPL applies to versions of Autoconf
40 # released by the Free Software Foundation.  When you make and
41 # distribute a modified version of Autoconf, you may extend this special
42 # exception to the GPL to apply to your modified version as well, *unless*
43 # your modified version has the potential to copy into its output some
44 # of the text that was the non-data portion of the version that you started
45 # with.  (In other words, unless your change moves or copies text from
46 # the non-data portions to the data portions.)  If your modification has
47 # such potential, you must delete any notice of this special exception
48 # to the GPL from your modified version.
50 # Written by Akim Demaille, Pavel Roskin, Alexandre Oliva, Lars J. Aas
51 # and many other people.
54 # We heavily use m4's diversions both for the initializations and for
55 # required macros, because in both cases we have to issue soon in
56 # output something which is discovered late.
59 # KILL is only used to suppress output.
61 # - BINSH
62 #   AC_REQUIRE'd #! /bin/sh line
63 # - HEADER-REVISION
64 #   RCS keywords etc.
65 # - HEADER-COMMENT
66 #   Purpose of the script etc.
67 # - HEADER-COPYRIGHT
68 #   Copyright notice(s)
69 # - M4SH-SANITIZE
70 #   M4sh's shell setup
71 # - M4SH-INIT-FN
72 #   M4sh initialization (shell functions)
73 # - M4SH-INIT
74 #   M4sh initialization (detection code)
75 # - BODY
76 #   The body of the script.
79 # _m4_divert(DIVERSION-NAME)
80 # --------------------------
81 # Convert a diversion name into its number.  Otherwise, return
82 # DIVERSION-NAME which is supposed to be an actual diversion number.
83 # Of course it would be nicer to use m4_case here, instead of zillions
84 # of little macros, but it then takes twice longer to run `autoconf'!
85 m4_define([_m4_divert(BINSH)],             0)
86 m4_define([_m4_divert(HEADER-REVISION)],   1)
87 m4_define([_m4_divert(HEADER-COMMENT)],    2)
88 m4_define([_m4_divert(HEADER-COPYRIGHT)],  3)
89 m4_define([_m4_divert(M4SH-SANITIZE)],     4)
90 m4_define([_m4_divert(M4SH-INIT-FN)],      5)
91 m4_define([_m4_divert(M4SH-INIT)],         6)
92 m4_define([_m4_divert(BODY)],           1000)
94 # Aaarg.  Yet it starts with compatibility issues...  Libtool wants to
95 # use NOTICE to insert its own LIBTOOL-INIT stuff.  People should ask
96 # before diving into our internals :(
97 m4_copy([_m4_divert(M4SH-INIT)], [_m4_divert(NOTICE)])
101 ## ------------------------- ##
102 ## 1. Sanitizing the shell.  ##
103 ## ------------------------- ##
104 # Please maintain lexicographic sorting of this section, ignoring leading _.
106 # AS_BOURNE_COMPATIBLE
107 # --------------------
108 # Try to be as Bourne and/or POSIX as possible.
110 # This does not set BIN_SH, due to the problems described in
111 # <http://lists.gnu.org/archive/html/autoconf-patches/2006-03/msg00081.html>.
112 # People who need BIN_SH should set it in their environment before invoking
113 # configure; apparently this would include UnixWare, as described in
114 # <http://lists.gnu.org/archive/html/bug-autoconf/2006-06/msg00025.html>.
115 m4_define([AS_BOURNE_COMPATIBLE],
116 [# Be more Bourne compatible
117 DUALCASE=1; export DUALCASE # for MKS sh
121 # _AS_BOURNE_COMPATIBLE
122 # ---------------------
123 # This is the part of AS_BOURNE_COMPATIBLE which has to be repeated inside
124 # each instance.
125 m4_define([_AS_BOURNE_COMPATIBLE],
126 [AS_IF([test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1],
127  [emulate sh
128   NULLCMD=:
129   [#] Pre-4.2 versions of Zsh do word splitting on ${1+"$[@]"}, which
130   # is contrary to our usage.  Disable this feature.
131   alias -g '${1+"$[@]"}'='"$[@]"'
132   setopt NO_GLOB_SUBST],
133  [AS_CASE([`(set -o) 2>/dev/null`], [*posix*], [set -o posix])])
137 # _AS_CLEANUP
138 # -----------
139 # Expanded as the last thing before m4sugar cleanup begins.  Macros
140 # may append m4sh cleanup hooks to this as appropriate.
141 m4_define([_AS_CLEANUP])
144 # AS_COPYRIGHT(TEXT)
145 # ------------------
146 # Emit TEXT, a copyright notice, as a shell comment near the top of the
147 # script.  TEXT is evaluated once; to accomplish that, we do not prepend
148 # `# ' but `@%:@ '.
149 m4_define([AS_COPYRIGHT],
150 [m4_divert_text([HEADER-COPYRIGHT],
151 [m4_bpatsubst([
152 $1], [^], [@%:@ ])])])
155 # _AS_DETECT_REQUIRED(TEST)
156 # -------------------------
157 # Refuse to execute under a shell that does not pass the given TEST.
158 m4_defun([_AS_DETECT_REQUIRED],
159 [m4_require([_AS_DETECT_BETTER_SHELL])dnl
160 m4_set_add([_AS_DETECT_REQUIRED_BODY],
161            [($1) || AS_EXIT(1)
162 ])])
165 # _AS_DETECT_SUGGESTED(TEST)
166 # --------------------------
167 # Prefer to execute under a shell that passes the given TEST.
168 m4_defun([_AS_DETECT_SUGGESTED],
169 [m4_require([_AS_DETECT_BETTER_SHELL])dnl
170 m4_set_add([_AS_DETECT_SUGGESTED_BODY],
171            [($1) || AS_EXIT(1)
172 ])])
175 # _AS_DETECT_BETTER_SHELL
176 # -----------------------
177 # The real workhorse for detecting a shell with the correct
178 # features.
180 # In previous versions, we prepended /usr/posix/bin to the path, but that
181 # caused a regression on OpenServer 6.0.0
182 # <http://lists.gnu.org/archive/html/bug-autoconf/2006-06/msg00017.html>
183 # and on HP-UX 11.11, see the failure of test 120 in
184 # <http://lists.gnu.org/archive/html/bug-autoconf/2006-10/msg00003.html>
186 # FIXME: The code should test for the OSF bug described in
187 # <http://lists.gnu.org/archive/html/autoconf-patches/2006-03/msg00081.html>.
189 m4_defun_once([_AS_DETECT_BETTER_SHELL],
190 [AS_REQUIRE([_AS_UNSET_PREPARE], , [M4SH-SANITIZE])dnl
191 m4_append([_AS_CLEANUP], [m4_divert_text([M4SH-SANITIZE], [
192 if test "x$CONFIG_SHELL" = x; then
193 dnl Remove any tests from suggested that are also required
194   m4_set_foreach([_AS_DETECT_SUGGESTED_BODY], [AS_snippet],
195                  [m4_set_contains([_AS_DETECT_REQUIRED_BODY],
196                                   _m4_defn([AS_snippet]),
197                                   [m4_set_remove([_AS_DETECT_SUGGESTED_BODY],
198                                                  _m4_defn([AS_snippet]))])])dnl
199   m4_set_empty([_AS_DETECT_REQUIRED_BODY], [as_have_required=yes],
200     [as_bourne_compatible="AS_ESCAPE(m4_expand([_AS_BOURNE_COMPATIBLE]))"
201     as_required="AS_ESCAPE(m4_expand(m4_set_contents([_AS_DETECT_REQUIRED_BODY])))"
202     as_suggested="AS_ESCAPE(m4_expand(m4_set_contents([_AS_DETECT_SUGGESTED_BODY])))"
203     AS_IF([_AS_RUN(["$as_required"])],
204           [as_have_required=yes],
205           [as_have_required=no])])
206   AS_IF([test x$as_have_required = xyes && _AS_RUN(["$as_suggested"])],
207     [],
208     [as_candidate_shells=
209     _AS_PATH_WALK([/bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH],
210       [case $as_dir in
211          /*)
212            for as_base in sh bash ksh sh5; do
213              as_candidate_shells="$as_candidate_shells $as_dir/$as_base"
214            done;;
215        esac])
217       for as_shell in $as_candidate_shells $SHELL; do
218          # Try only shells that exist, to save several forks.
219          AS_IF([{ test -f "$as_shell" || test -f "$as_shell.exe"; } &&
220                 _AS_RUN(["$as_required"], ["$as_shell"])],
221                [CONFIG_SHELL=$as_shell
222                as_have_required=yes
223                m4_set_empty([_AS_DETECT_SUGGESTED_BODY], [break],
224                  [AS_IF([_AS_RUN(["$as_suggested"], ["$as_shell"])], [break])])])
225       done
227       AS_IF([test "x$CONFIG_SHELL" != x],
228         [for as_var in BASH_ENV ENV
229         do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
230         done
231         export CONFIG_SHELL
232         exec "$CONFIG_SHELL" "$as_myself" ${1+"$[@]"}])
234     AS_IF([test x$as_have_required = xno],
235       [echo This script requires a shell more modern than all the
236       echo shells that I found on your system.  Please install a
237       echo modern shell, or manually run the script under such a
238       echo shell if you do have one.
239       AS_EXIT(1)])
240     ])
242 ])])])# _AS_DETECT_BETTER_SHELL
245 # _AS_PREPARE
246 # -----------
247 # This macro has a very special status.  Normal use of M4sh relies
248 # heavily on AS_REQUIRE, so that needed initializations (such as
249 # _AS_TEST_PREPARE) are performed on need, not on demand.  But
250 # Autoconf is the first client of M4sh, and for two reasons: configure
251 # and config.status.  Relying on AS_REQUIRE is of course fine for
252 # configure, but fails for config.status (which is created by
253 # configure).  So we need a means to force the inclusion of the
254 # various _AS_PREPARE_* on top of config.status.  That's basically why
255 # there are so many _AS_PREPARE_* below, and that's also why it is
256 # important not to forget some: config.status needs them.
257 m4_defun([_AS_PREPARE],
258 [as_func_mkdir_p ()
260   _AS_MKDIR_P
263 _AS_EXPR_PREPARE
264 _AS_BASENAME_PREPARE
265 _AS_DIRNAME_PREPARE
266 _AS_ME_PREPARE
267 _AS_LINENO_PREPARE
268 _AS_ECHO_N_PREPARE[]dnl We do not need this ourselves but user code might.
269 _AS_LN_S_PREPARE
270 _AS_MKDIR_P_PREPARE
271 _AS_TEST_PREPARE
272 _AS_TR_CPP_PREPARE
273 _AS_TR_SH_PREPARE
276 # AS_PREPARE
277 # ----------
278 # Output all the M4sh possible initialization into the initialization
279 # diversion.  We do not use _AS_PREPARE so that the m4_provide symbols for
280 # AS_REQUIRE and AS_REQUIRE_SHELL_FN are defined properly, and so that
281 # shell functions are placed in M4SH-INIT-FN.
282 m4_defun([AS_PREPARE],
283 [AS_REQUIRE([_AS_EXPR_PREPARE])
284 AS_REQUIRE([_AS_BASENAME_PREPARE])
285 AS_REQUIRE([_AS_DIRNAME_PREPARE])
286 AS_REQUIRE([_AS_ME_PREPARE])
287 AS_REQUIRE([_AS_LINENO_PREPARE])
288 AS_REQUIRE([_AS_ECHO_N_PREPARE])
289 AS_REQUIRE([_AS_LN_S_PREPARE])
290 AS_REQUIRE([_AS_MKDIR_P_PREPARE])
291 AS_REQUIRE([_AS_TEST_PREPARE])
292 AS_REQUIRE([_AS_TR_CPP_PREPARE])
293 AS_REQUIRE([_AS_TR_SH_PREPARE])
297 # AS_REQUIRE(NAME-TO-CHECK, [BODY-TO-EXPAND = NAME-TO-CHECK],
298 #            [DIVERSION = M4SH-INIT])
299 # -----------------------------------------------------------
300 # BODY-TO-EXPAND is some initialization which must be expanded in the
301 # given diversion when expanded (required or not).  The expansion
302 # goes in the named diversion or an earlier one.
304 m4_defun([AS_REQUIRE],
305 [m4_define([_m4_divert_desired], [m4_default_quoted([$3], [M4SH-INIT])])dnl
306 m4_if(m4_eval(_m4_divert(_m4_divert_dump) <= _m4_divert(_m4_divert_desired)), 1,
307       [m4_require([$1], [$2])],
308       [m4_divert_require([_m4_divert_desired], [$1], [$2])])])
311 # AS_REQUIRE_SHELL_FN(NAME-TO-CHECK, BODY-TO-EXPAND,
312 #                     [DIVERSION = M4SH-INIT-FN])
313 # --------------------------------------------------
314 # BODY-TO-EXPAND is the body of a shell function to be emitted in the
315 # given diversion when expanded (required or not).  Unlike other
316 # xx_REQUIRE macros, BODY-TO-EXPAND is mandatory.
318 m4_define([AS_REQUIRE_SHELL_FN],
319 [_AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])dnl
320 AS_REQUIRE([AS_SHELL_FN_$1], [m4_provide([AS_SHELL_FN_$1])$1 ()
323 }], m4_default_quoted([$3], [M4SH-INIT-FN]))])
326 # _AS_RUN(TEST, [SHELL])
327 # ----------------------
328 # Run TEST under the current shell (if one parameter is used)
329 # or under the given SHELL, protecting it from syntax errors.
330 m4_define([_AS_RUN],
331 [m4_ifval([$2], [{ $as_echo "$as_bourne_compatible"$1 | ($2); }],
332                 [(eval $1)]) 2>/dev/null])
335 # _AS_SHELL_FN_WORK
336 # -----------------
337 # This is a spy to detect "in the wild" shells that do not support shell
338 # functions correctly.  It is based on the m4sh.at Autotest testcases.
339 m4_define([_AS_SHELL_FN_WORK],
340 [as_func_return ()
342   (exit [$]1)
344 as_func_success ()
346   as_func_return 0
348 as_func_failure ()
350   as_func_return 1
352 as_func_ret_success ()
354   return 0
356 as_func_ret_failure ()
358   return 1
361 exitcode=0
362 AS_IF([as_func_success], [],
363   [exitcode=1
364   echo as_func_success failed.])
365 AS_IF([as_func_failure],
366   [exitcode=1
367   echo as_func_failure succeeded.])
368 AS_IF([as_func_ret_success], [],
369   [exitcode=1
370   echo as_func_ret_success failed.])
371 AS_IF([as_func_ret_failure],
372   [exitcode=1
373   echo as_func_ret_failure succeeded.])
374 AS_IF([( set x; as_func_ret_success y && test x = "[$]1" )], [],
375   [exitcode=1
376   echo positional parameters were not saved.])
377 test x$exitcode = x0[]dnl
378 ])# _AS_SHELL_FN_WORK
381 # AS_SHELL_SANITIZE
382 # -----------------
383 m4_defun([AS_SHELL_SANITIZE],
384 [## --------------------- ##
385 ## M4sh Initialization.  ##
386 ## --------------------- ##
388 AS_BOURNE_COMPATIBLE
390 # PATH needs CR
391 _AS_CR_PREPARE
392 _AS_ECHO_PREPARE
393 _AS_PATH_SEPARATOR_PREPARE
394 _AS_UNSET_PREPARE
396 # IFS
397 # We need space, tab and new line, in precisely that order.  Quoting is
398 # there to prevent editors from complaining about space-tab.
399 # (If _AS_PATH_WALK were called with IFS unset, it would disable word
400 # splitting by setting IFS to empty value.)
401 IFS=" ""        $as_nl"
403 # Find who we are.  Look in the path if we contain no directory separator.
404 case $[0] in
405   *[[\\/]]* ) as_myself=$[0] ;;
406   *) _AS_PATH_WALK([],
407                    [test -r "$as_dir/$[0]" && as_myself=$as_dir/$[0] && break])
408      ;;
409 esac
410 # We did not find ourselves, most probably we were run as `sh COMMAND'
411 # in which case we are not to be found in the path.
412 if test "x$as_myself" = x; then
413   as_myself=$[0]
415 if test ! -f "$as_myself"; then
416   AS_ECHO(["$as_myself: error: cannot find myself; rerun with an absolute file name"]) >&2
417   AS_EXIT
420 # Work around bugs in pre-3.0 UWIN ksh.
421 for as_var in ENV MAIL MAILPATH
422 do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
423 done
424 PS1='$ '
425 PS2='> '
426 PS4='+ '
428 # NLS nuisances.
429 LC_ALL=C
430 export LC_ALL
431 LANGUAGE=C
432 export LANGUAGE
434 # CDPATH.
435 $as_unset CDPATH
436 ])# AS_SHELL_SANITIZE
439 ## ----------------------------- ##
440 ## 2. Wrappers around builtins.  ##
441 ## ----------------------------- ##
443 # This section is lexicographically sorted.
446 # AS_CASE(WORD, [PATTERN1], [IF-MATCHED1]...[DEFAULT])
447 # ----------------------------------------------------
448 # Expand into
449 # | case WORD in
450 # | PATTERN1) IF-MATCHED1 ;;
451 # | ...
452 # | *) DEFAULT ;;
453 # | esac
454 m4_define([_AS_CASE],
455 [  $1[)] m4_default([$2], [:]) ;;
457 m4_define([_AS_CASE_DEFAULT],
458 [  *[)] $1 ;;
460 m4_defun([AS_CASE],
461 [m4_ifval([$2$3],
462 [case $1 in
463 m4_transform_pair([_$0], [_$0_DEFAULT], m4_shift($@))dnl
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 [elif $1; then
498   m4_default([$2], [:])
500 m4_define([_AS_IF_ELSE],
501 [m4_ifvaln([$1],
502 [else
503   $1])])
504 m4_defun([AS_IF],
505 [m4_ifval([$2$3],
506 [if $1; then
507   m4_default([$2], [:])
508 m4_transform_pair([_$0], [_$0_ELSE], m4_shift2($@))dnl
510 ])dnl
511 ])# AS_IF
514 # _AS_UNSET_PREPARE
515 # -----------------
516 # AS_UNSET depends upon $as_unset: compute it.
517 # Use MAIL to trigger a bug in Bash 2.01;
518 # the "|| exit" suppresses the resulting "Segmentation fault" message.
519 # Avoid 'if ((', as that triggers a bug in pdksh 5.2.14.
520 m4_defun([_AS_UNSET_PREPARE],
521 [# Support unset when possible.
522 if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
523   as_unset=unset
524 else
525   as_unset=false
530 # AS_UNSET(VAR, [VALUE-IF-UNSET-NOT-SUPPORTED = `'])
531 # --------------------------------------------------
532 # Try to unset the env VAR, otherwise set it to
533 # VALUE-IF-UNSET-NOT-SUPPORTED.  `as_unset' must have been computed.
534 m4_defun([AS_UNSET],
535 [AS_REQUIRE([_AS_UNSET_PREPARE])dnl
536 $as_unset $1 || test "${$1+set}" != set || { $1=$2; export $1; }])
543 ## ------------------------------------------ ##
544 ## 3. Error and warnings at the shell level.  ##
545 ## ------------------------------------------ ##
547 # If AS_MESSAGE_LOG_FD is defined, shell messages are duplicated there
548 # too.
551 # AS_ESCAPE(STRING, [CHARS = $"`\])
552 # ---------------------------------
553 # Escape the CHARS in STRING.
555 # Avoid the m4_bpatsubst if there are no interesting characters to escape.
556 # _AS_ESCAPE bypasses argument defaulting.
557 m4_define([AS_ESCAPE],
558 [_$0([$1], m4_default([$2], [\"$`]))])
559 m4_define([_AS_ESCAPE],
560 [m4_if(m4_len([$1]),
561        m4_len(m4_translit([[$1]], [$2])),
562        [$1], [m4_bpatsubst([$1], [[$2]], [\\\&])])])
565 # _AS_QUOTE_IFELSE(STRING, IF-MODERN-QUOTATION, IF-OLD-QUOTATION)
566 # ---------------------------------------------------------------
567 # Compatibility glue between the old AS_MSG suite which did not
568 # quote anything, and the modern suite which quotes the quotes.
569 # If STRING contains `\\' or `\$', it's modern.
570 # If STRING contains `\"' or `\`', it's old.
571 # Otherwise it's modern.
573 # Profiling shows that m4_index is 5 to 8x faster than m4_bregexp.  The
574 # slower implementation used:
575 # m4_bmatch([$1],
576 #           [\\[\\$]], [$2],
577 #           [\\[`"]], [$3],
578 #           [$2])
579 # The current implementation caters to the common case of no backslashes,
580 # to minimize m4_index expansions (hence the nested if).
581 m4_define([_AS_QUOTE_IFELSE],
582 [m4_cond([m4_index([$1], [\])], [-1], [$2],
583          [m4_eval(m4_index([$1], [\\]) >= 0)], [1], [$2],
584          [m4_eval(m4_index([$1], [\$]) >= 0)], [1], [$2],
585          [m4_eval(m4_index([$1], [\`]) >= 0)], [1], [$3],
586          [m4_eval(m4_index([$1], [\"]) >= 0)], [1], [$3],
587          [$2])])
590 # _AS_QUOTE(STRING, [CHARS = `"])
591 # -------------------------------
592 # If there are quoted (via backslash) backquotes do nothing, else
593 # backslash all the quotes.
594 m4_define([_AS_QUOTE],
595 [_AS_QUOTE_IFELSE([$1],
596                   [_AS_ESCAPE([$1], m4_default([$2], [`""]))],
597                   [m4_warn([obsolete],
598            [back quotes and double quotes must not be escaped in: $1])dnl
599 $1])])
602 # _AS_ECHO_UNQUOTED(STRING, [FD = AS_MESSAGE_FD])
603 # -----------------------------------------------
604 # Perform shell expansions on STRING and echo the string to FD.
605 m4_define([_AS_ECHO_UNQUOTED],
606 [AS_ECHO(["$1"]) >&m4_default([$2], [AS_MESSAGE_FD])])
609 # _AS_ECHO(STRING, [FD = AS_MESSAGE_FD])
610 # --------------------------------------
611 # Protect STRING from backquote expansion, echo the result to FD.
612 m4_define([_AS_ECHO],
613 [_AS_ECHO_UNQUOTED([_AS_QUOTE([$1])], [$2])])
616 # _AS_ECHO_LOG(STRING)
617 # --------------------
618 # Log the string to AS_MESSAGE_LOG_FD.
619 m4_define([_AS_ECHO_LOG],
620 [AS_REQUIRE([_AS_LINENO_PREPARE])dnl
621 _AS_ECHO([$as_me:${as_lineno-$LINENO}: $1], [AS_MESSAGE_LOG_FD])])
624 # _AS_ECHO_N_PREPARE
625 # ------------------
626 # Check whether to use -n, \c, or newline-tab to separate
627 # checking messages from result messages.
628 # Don't try to cache, since the results of this macro are needed to
629 # display the checking message.  In addition, caching something used once
630 # has little interest.
631 # Idea borrowed from dist 3.0.  Use `*c*,', not `*c,' because if `\c'
632 # failed there is also a newline to match.
633 m4_defun([_AS_ECHO_N_PREPARE],
634 [ECHO_C= ECHO_N= ECHO_T=
635 case `echo -n x` in
636 -n*)
637   case `echo 'x\c'` in
638   *c*) ECHO_T=' ';;     # ECHO_T is single tab character.
639   *)   ECHO_C='\c';;
640   esac;;
642   ECHO_N='-n';;
643 esac
644 ])# _AS_ECHO_N_PREPARE
647 # _AS_ECHO_N(STRING, [FD = AS_MESSAGE_FD])
648 # ----------------------------------------
649 # Same as _AS_ECHO, but echo doesn't return to a new line.
650 m4_define([_AS_ECHO_N],
651 [AS_ECHO_N(["_AS_QUOTE([$1])"]) >&m4_default([$2], [AS_MESSAGE_FD])])
654 # AS_MESSAGE(STRING, [FD = AS_MESSAGE_FD])
655 # ----------------------------------------
656 m4_define([AS_MESSAGE],
657 [AS_REQUIRE([_AS_ME_PREPARE])dnl
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 # AS_LINENO_PUSH([LINENO])
681 # ------------------------
682 # If this is the outermost call to AS_LINENO_PUSH, make sure that
683 # AS_MESSAGE will print LINENO as the line number.
684 m4_defun([AS_LINENO_PUSH], 
685 [as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack])
688 # AS_LINENO_POP([LINENO])
689 # ------------------------
690 # If this is call balances the outermost call to AS_LINENO_PUSH,
691 # AS_MESSAGE will restart printing $LINENO as the line number.
692 m4_defun([AS_LINENO_POP],
693 [eval $as_lineno_stack; test "x$as_lineno_stack" = x && AS_UNSET([as_lineno])])
697 ## -------------------------------------- ##
698 ## 4. Portable versions of common tools.  ##
699 ## -------------------------------------- ##
701 # This section is lexicographically sorted.
704 # AS_BASENAME(FILE-NAME)
705 # ----------------------
706 # Simulate the command 'basename FILE-NAME'.  Not all systems have basename.
707 # Also see the comments for AS_DIRNAME.
709 m4_defun([_AS_BASENAME_EXPR],
710 [$as_expr X/[]$1 : '.*/\([[^/][^/]*]\)/*$' \| \
711          X[]$1 : 'X\(//\)$' \| \
712          X[]$1 : 'X\(/\)' \| .])
714 m4_defun([_AS_BASENAME_SED],
715 [AS_ECHO([X/[]$1]) |
716     sed ['/^.*\/\([^/][^/]*\)\/*$/{
717             s//\1/
718             q
719           }
720           /^X\/\(\/\/\)$/{
721             s//\1/
722             q
723           }
724           /^X\/\(\/\).*/{
725             s//\1/
726             q
727           }
728           s/.*/./; q']])
730 m4_defun([AS_BASENAME],
731 [AS_REQUIRE([_$0_PREPARE])dnl
732 $as_basename -- $1 ||
733 _AS_BASENAME_EXPR([$1]) 2>/dev/null ||
734 _AS_BASENAME_SED([$1])])
737 # _AS_BASENAME_PREPARE
738 # --------------------
739 # Avoid Solaris 9 /usr/ucb/basename, as `basename /' outputs an empty line.
740 # Also, traditional basename mishandles --.  Require here _AS_EXPR_PREPARE,
741 # to avoid problems when _AS_BASENAME is called from the M4SH-INIT diversion
742 # (AS_REQUIRE is nowhere near being as sophisticated as AC_REQUIRE).
743 m4_defun([_AS_BASENAME_PREPARE],
744 [AS_REQUIRE([_AS_EXPR_PREPARE])dnl
745 if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
746   as_basename=basename
747 else
748   as_basename=false
750 ])# _AS_BASENAME_PREPARE
753 # AS_DIRNAME(FILE-NAME)
754 # ---------------------
755 # Simulate the command 'dirname FILE-NAME'.  Not all systems have dirname.
756 # This macro must be usable from inside ` `.
758 # Prefer expr to echo|sed, since expr is usually faster and it handles
759 # backslashes and newlines correctly.  However, older expr
760 # implementations (e.g. SunOS 4 expr and Solaris 8 /usr/ucb/expr) have
761 # a silly length limit that causes expr to fail if the matched
762 # substring is longer than 120 bytes.  So fall back on echo|sed if
763 # expr fails.
764 m4_defun([_AS_DIRNAME_EXPR],
765 [AS_REQUIRE([_AS_EXPR_PREPARE])dnl
766 $as_expr X[]$1 : 'X\(.*[[^/]]\)//*[[^/][^/]]*/*$' \| \
767          X[]$1 : 'X\(//\)[[^/]]' \| \
768          X[]$1 : 'X\(//\)$' \| \
769          X[]$1 : 'X\(/\)' \| .])
771 m4_defun([_AS_DIRNAME_SED],
772 [AS_ECHO([X[]$1]) |
773     sed ['/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
774             s//\1/
775             q
776           }
777           /^X\(\/\/\)[^/].*/{
778             s//\1/
779             q
780           }
781           /^X\(\/\/\)$/{
782             s//\1/
783             q
784           }
785           /^X\(\/\).*/{
786             s//\1/
787             q
788           }
789           s/.*/./; q']])
791 m4_defun([AS_DIRNAME],
792 [AS_REQUIRE([_$0_PREPARE])dnl
793 $as_dirname -- $1 ||
794 _AS_DIRNAME_EXPR([$1]) 2>/dev/null ||
795 _AS_DIRNAME_SED([$1])])
798 # _AS_DIRNAME_PREPARE
799 # --------------------
800 m4_defun([_AS_DIRNAME_PREPARE],
801 [AS_REQUIRE([_AS_EXPR_PREPARE])dnl
802 if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
803   as_dirname=dirname
804 else
805   as_dirname=false
807 ])# _AS_DIRNAME_PREPARE
810 # AS_ECHO(WORD)
811 # -------------
812 # Output WORD followed by a newline.  WORD must be a single shell word
813 # (typically a quoted string).  The bytes of WORD are output as-is, even
814 # if it starts with "-" or contains "\".
815 m4_defun([AS_ECHO],
816 [AS_REQUIRE([_$0_PREPARE])dnl
817 $as_echo $1])
820 # AS_ECHO_N(WORD)
821 # -------------
822 # Like AS_ECHO(WORD), except do not output the trailing newline.
823 m4_defun([AS_ECHO_N],
824 [AS_REQUIRE([_AS_ECHO_PREPARE])dnl
825 $as_echo_n $1])
828 # _AS_ECHO_PREPARE
829 # -----------------
830 # Arrange for $as_echo 'FOO' to echo FOO without escape-interpretation;
831 # and similarly for $as_echo_foo, which omits the trailing newline.
832 # 'FOO' is an optional single argument; a missing FOO is treated as empty.
833 m4_defun([_AS_ECHO_PREPARE],
834 [[as_nl='
836 export as_nl
837 # Printing a long string crashes Solaris 7 /usr/bin/printf.
838 as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
839 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
840 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
841 if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
842   as_echo='printf %s\n'
843   as_echo_n='printf %s'
844 else
845   if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
846     as_echo_body='eval /usr/ucb/echo -n "$][1$as_nl"'
847     as_echo_n='/usr/ucb/echo -n'
848   else
849     as_echo_body='eval expr "X$][1" : "X\\(.*\\)"'
850     as_echo_n_body='eval
851       arg=$][1;
852       case $arg in
853       *"$as_nl"*)
854         expr "X$arg" : "X\\(.*\\)$as_nl";
855         arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
856       esac;
857       expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
858     '
859     export as_echo_n_body
860     as_echo_n='sh -c $as_echo_n_body as_echo'
861   fi
862   export as_echo_body
863   as_echo='sh -c $as_echo_body as_echo'
865 ]])# _AS_ECHO_PREPARE
868 # AS_TEST_X
869 # ---------
870 # Check whether a file has executable or search permissions.
871 m4_defun([AS_TEST_X],
872 [AS_REQUIRE([_AS_TEST_PREPARE])dnl
873 $as_test_x $1[]dnl
874 ])# AS_TEST_X
877 # AS_EXECUTABLE_P
878 # ---------------
879 # Check whether a file is a regular file that has executable permissions.
880 m4_defun([AS_EXECUTABLE_P],
881 [AS_REQUIRE([_AS_TEST_PREPARE])dnl
882 { test -f $1 && AS_TEST_X([$1]); }dnl
883 ])# AS_EXECUTABLE_P
886 # _AS_EXPR_PREPARE
887 # ----------------
888 # QNX 4.25 expr computes and issue the right result but exits with failure.
889 # Tru64 expr mishandles leading zeros in numeric strings.
890 # Detect these flaws.
891 m4_defun([_AS_EXPR_PREPARE],
892 [if expr a : '\(a\)' >/dev/null 2>&1 &&
893    test "X`expr 00001 : '.*\(...\)'`" = X001; then
894   as_expr=expr
895 else
896   as_expr=false
898 ])# _AS_EXPR_PREPARE
901 # _AS_ME_PREPARE
902 # --------------
903 # Define $as_me to the basename of the executable file's name.
904 m4_defun([AS_ME_PREPARE], [AS_REQUIRE([_$0])])
905 m4_defun([_AS_ME_PREPARE],
906 [AS_REQUIRE([_AS_BASENAME_PREPARE])dnl
907 as_me=`AS_BASENAME("$[0]")`
910 # _AS_LINENO_WORKS
911 # ---------------
912 # Succeed if the currently executing shell supports LINENO.
913 # This macro does not expand to a single shell command, so be careful
914 # when using it.  Surrounding the body of this macro with {} would
915 # cause "bash -c '_ASLINENO_WORKS'" to fail (with Bash 2.05, anyway),
916 # but that bug is irrelevant to our use of LINENO.
917 m4_define([_AS_LINENO_WORKS],
919   as_lineno_1=$LINENO
920   as_lineno_2=$LINENO
921   test "x$as_lineno_1" != "x$as_lineno_2" &&
922   test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2"])
925 # _AS_LINENO_PREPARE
926 # ------------------
927 # If LINENO is not supported by the shell, produce a version of this
928 # script where LINENO is hard coded.
929 # Comparing LINENO against _oline_ is not a good solution, since in
930 # the case of embedded executables (such as config.status within
931 # configure) you'd compare LINENO wrt config.status vs. _oline_ wrt
932 # configure.
933 m4_defun([AS_LINENO_PREPARE], [AS_REQUIRE([_$0])])
934 m4_defun([_AS_LINENO_PREPARE],
935 [AS_REQUIRE([_AS_CR_PREPARE])dnl
936 AS_REQUIRE([_AS_ME_PREPARE])dnl
937 _AS_DETECT_SUGGESTED([_AS_LINENO_WORKS])
938 _AS_LINENO_WORKS || {
940   dnl Create $as_me.lineno as a copy of $as_myself, but with $LINENO
941   dnl uniformly replaced by the line number.  The first 'sed' inserts a
942   dnl line-number line after each line using $LINENO; the second 'sed'
943   dnl does the real work.  The second script uses 'N' to pair each
944   dnl line-number line with the line containing $LINENO, and appends
945   dnl trailing '-' during substitution so that $LINENO is not a special
946   dnl case at line end.  (Raja R Harinath suggested sed '=', and Paul
947   dnl Eggert wrote the scripts with optimization help from Paolo Bonzini).
948   # Blame Lee E. McMahon (1931-1989) for sed's syntax.  :-)
949   sed -n '
950     p
951     /[[$]]LINENO/=
952   ' <$as_myself |
953     sed '
954       s/[[$]]LINENO.*/&-/
955       t lineno
956       b
957       :lineno
958       N
959       :loop
960       s/[[$]]LINENO\([[^'$as_cr_alnum'_]].*\n\)\(.*\)/\2\1\2/
961       t loop
962       s/-\n.*//
963     ' >$as_me.lineno &&
964   chmod +x "$as_me.lineno" ||
965     AS_ERROR([cannot create $as_me.lineno; rerun with a POSIX shell])
967   # Don't try to exec as it changes $[0], causing all sort of problems
968   # (the dirname of $[0] is not the place where we might find the
969   # original and so on.  Autoconf is especially sensitive to this).
970   . "./$as_me.lineno"
971   # Exit status is that of the last command.
972   exit
974 ])# _AS_LINENO_PREPARE
977 # _AS_LN_S_PREPARE
978 # ----------------
979 # Don't use conftest.sym to avoid file name issues on DJGPP, where this
980 # would yield conftest.sym.exe for DJGPP < 2.04.  And don't use `conftest'
981 # as base name to avoid prohibiting concurrency (e.g., concurrent
982 # config.statuses).  On read-only media, assume 'cp -p' and hope we
983 # are just running --help anyway.
984 m4_defun([_AS_LN_S_PREPARE],
985 [rm -f conf$$ conf$$.exe conf$$.file
986 if test -d conf$$.dir; then
987   rm -f conf$$.dir/conf$$.file
988 else
989   rm -f conf$$.dir
990   mkdir conf$$.dir 2>/dev/null
992 if (echo >conf$$.file) 2>/dev/null; then
993   if ln -s conf$$.file conf$$ 2>/dev/null; then
994     as_ln_s='ln -s'
995     # ... but there are two gotchas:
996     # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
997     # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
998     # In both cases, we have to default to `cp -p'.
999     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
1000       as_ln_s='cp -p'
1001   elif ln conf$$.file conf$$ 2>/dev/null; then
1002     as_ln_s=ln
1003   else
1004     as_ln_s='cp -p'
1005   fi
1006 else
1007   as_ln_s='cp -p'
1009 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
1010 rmdir conf$$.dir 2>/dev/null
1011 ])# _AS_LN_S_PREPARE
1014 # AS_LN_S(FILE, LINK)
1015 # -------------------
1016 # FIXME: Should we add the glue code to handle properly relative symlinks
1017 # simulated with `ln' or `cp'?
1018 m4_defun([AS_LN_S],
1019 [AS_REQUIRE([_AS_LN_S_PREPARE])dnl
1020 $as_ln_s $1 $2
1024 # _AS_MKDIR_P
1025 # -----------
1026 # Emit code that can be used to emulate `mkdir -p` with plain `mkdir';
1027 # the code assumes that "$as_dir" contains the directory to create.
1028 # $as_dir is normalized, so there is no need to worry about using --.
1029 m4_define([_AS_MKDIR_P],
1030 [case $as_dir in #(
1031   -*) as_dir=./$as_dir;;
1032   esac
1033   test -d "$as_dir" || eval $as_mkdir_p || {
1034     as_dirs=
1035     while :; do
1036       case $as_dir in #(
1037       *\'*) as_qdir=`AS_ECHO(["$as_dir"]) | sed "s/'/'\\\\\\\\''/g"`;; #'(
1038       *) as_qdir=$as_dir;;
1039       esac
1040       as_dirs="'$as_qdir' $as_dirs"
1041       as_dir=`AS_DIRNAME("$as_dir")`
1042       test -d "$as_dir" && break
1043     done
1044     test -z "$as_dirs" || eval "mkdir $as_dirs"
1045   } || test -d "$as_dir" || AS_ERROR([cannot create directory $as_dir])
1048 # AS_MKDIR_P(DIR)
1049 # ---------------
1050 # Emulate `mkdir -p' with plain `mkdir' if needed.
1051 m4_define([AS_MKDIR_P],
1052 [AS_REQUIRE([_$0_PREPARE])dnl
1053 as_dir=$1; as_func_mkdir_p])# AS_MKDIR_P
1056 # _AS_MKDIR_P_PREPARE
1057 # -------------------
1058 m4_defun([_AS_MKDIR_P_PREPARE],
1059 [AS_REQUIRE_SHELL_FN([as_func_mkdir_p], [
1060   _AS_MKDIR_P
1062 if mkdir -p . 2>/dev/null; then
1063   as_mkdir_p='mkdir -p "$as_dir"'
1064 else
1065   test -d ./-p && rmdir ./-p
1066   as_mkdir_p=false
1068 ])# _AS_MKDIR_P_PREPARE
1071 # _AS_PATH_SEPARATOR_PREPARE
1072 # --------------------------
1073 # Compute the path separator.
1074 m4_defun([_AS_PATH_SEPARATOR_PREPARE],
1075 [# The user is always right.
1076 if test "${PATH_SEPARATOR+set}" != set; then
1077   PATH_SEPARATOR=:
1078   (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
1079     (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
1080       PATH_SEPARATOR=';'
1081   }
1083 ])# _AS_PATH_SEPARATOR_PREPARE
1086 # _AS_PATH_WALK([PATH = $PATH], BODY)
1087 # -----------------------------------
1088 # Walk through PATH running BODY for each `as_dir'.
1090 # Still very private as its interface looks quite bad.
1092 # `$as_dummy' forces splitting on constant user-supplied paths.
1093 # POSIX.2 field splitting is done only on the result of word
1094 # expansions, not on literal text.  This closes a longstanding sh security
1095 # hole.  Optimize it away when not needed, i.e., if there are no literal
1096 # path separators.
1097 m4_define([_AS_PATH_WALK],
1098 [AS_REQUIRE([_AS_PATH_SEPARATOR_PREPARE])dnl
1099 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
1100 m4_bmatch([$1], [[:;]],
1101 [as_dummy="$1"
1102 for as_dir in $as_dummy],
1103 [for as_dir in m4_default([$1], [$PATH])])
1105   IFS=$as_save_IFS
1106   test -z "$as_dir" && as_dir=.
1107   $2
1108 done
1109 IFS=$as_save_IFS
1113 # AS_SET_CATFILE(VAR, DIR-NAME, FILE-NAME)
1114 # ----------------------------------------
1115 # Set VAR to DIR-NAME/FILE-NAME.
1116 # Optimize the common case where $2 or $3 is '.'.
1117 m4_define([AS_SET_CATFILE],
1118 [case $2 in
1119 .) $1=$3;;
1121   case $3 in
1122   .) $1=$2;;
1123   [[\\/]]* | ?:[[\\/]]* ) $1=$3;;
1124   *) $1=$2/$3;;
1125   esac;;
1126 esac[]dnl
1127 ])# AS_SET_CATFILE
1130 # _AS_TEST_PREPARE
1131 # ----------------
1132 # Find out whether `test -x' works.  If not, prepare a substitute
1133 # that should work well enough for most scripts.
1135 # Here are some of the problems with the substitute.
1136 # The 'ls' tests whether the owner, not the current user, can execute/search.
1137 # The eval means '*', '?', and '[' cause inadvertent file name globbing
1138 # after the 'eval', so jam together as many tokens as we can to minimize
1139 # the likelihood that the inadvertent globbing will actually do anything.
1140 # Luckily, this gorp is needed only on really ancient hosts.
1142 m4_defun([_AS_TEST_PREPARE],
1143 [if test -x / >/dev/null 2>&1; then
1144   as_test_x='test -x'
1145 else
1146   if ls -dL / >/dev/null 2>&1; then
1147     as_ls_L_option=L
1148   else
1149     as_ls_L_option=
1150   fi
1151   as_test_x='
1152     eval sh -c '\''
1153       if test -d "$[]1"; then
1154         test -d "$[]1/.";
1155       else
1156         case $[]1 in
1157         -*)set "./$[]1";;
1158         esac;
1159         case `ls -ld'$as_ls_L_option' "$[]1" 2>/dev/null` in
1160         ???[[sx]]*):;;*)false;;esac;fi
1161     '\'' sh
1162   '
1164 dnl as_executable_p is present for backward compatibility with Libtool
1165 dnl 1.5.22, but it should go away at some point.
1166 as_executable_p=$as_test_x
1167 ])# _AS_TEST_PREPARE
1172 ## ------------------ ##
1173 ## 5. Common idioms.  ##
1174 ## ------------------ ##
1176 # This section is lexicographically sorted.
1179 # AS_BOX(MESSAGE, [FRAME-CHARACTER = `-'])
1180 # ----------------------------------------
1181 # Output MESSAGE, a single line text, framed with FRAME-CHARACTER (which
1182 # must not be `/').
1183 m4_define([AS_BOX],
1184 [AS_LITERAL_IF([$1],
1185                [_AS_BOX_LITERAL($@)],
1186                [_AS_BOX_INDIR($@)])])
1189 # _AS_BOX_LITERAL(MESSAGE, [FRAME-CHARACTER = `-'])
1190 # -------------------------------------------------
1191 m4_define([_AS_BOX_LITERAL],
1192 [cat <<\_ASBOX
1193 m4_text_box($@)
1194 _ASBOX])
1197 # _AS_BOX_INDIR(MESSAGE, [FRAME-CHARACTER = `-'])
1198 # -----------------------------------------------
1199 m4_define([_AS_BOX_INDIR],
1200 [sed 'h;s/./m4_default([$2], [-])/g;s/^.../@%:@@%:@ /;s/...$/ @%:@@%:@/;p;x;p;x' <<_ASBOX
1201 @%:@@%:@ $1 @%:@@%:@
1202 _ASBOX])
1205 # AS_HELP_STRING(LHS, RHS, [INDENT-COLUMN = 26], [WRAP-COLUMN = 79])
1206 # ------------------------------------------------------------------
1208 # Format a help string so that it looks pretty when the user executes
1209 # "script --help".  This macro takes up to four arguments, a
1210 # "left hand side" (LHS), a "right hand side" (RHS), a decimal
1211 # INDENT-COLUMN which is the column where wrapped lines should begin
1212 # (the default of 26 is recommended), and a decimal WRAP-COLUMN which is
1213 # the column where lines should wrap (the default of 79 is recommended).
1214 # LHS is expanded, RHS is not.
1216 # For backwards compatibility not documented in the manual, INDENT-COLUMN
1217 # can also be specified as a string of white spaces, whose width
1218 # determines the indentation column.  Using TABs in INDENT-COLUMN is not
1219 # recommended, since screen width of TAB is not computed.
1221 # The resulting string is suitable for use in other macros that require
1222 # a help string (e.g. AC_ARG_WITH).
1224 # Here is the sample string from the Autoconf manual (Node: External
1225 # Software) which shows the proper spacing for help strings.
1227 #    --with-readline         support fancy command line editing
1228 #  ^ ^                       ^
1229 #  | |                       |
1230 #  | column 2                column 26
1231 #  |
1232 #  column 0
1234 # A help string is made up of a "left hand side" (LHS) and a "right
1235 # hand side" (RHS).  In the example above, the LHS is
1236 # "--with-readline", while the RHS is "support fancy command line
1237 # editing".
1239 # If the LHS contains more than (INDENT-COLUMN - 3) characters, then the
1240 # LHS is terminated with a newline so that the RHS starts on a line of its
1241 # own beginning at INDENT-COLUMN.  In the default case, this corresponds to an
1242 # LHS with more than 23 characters.
1244 # Therefore, in the example, if the LHS were instead
1245 # "--with-readline-blah-blah-blah", then the AS_HELP_STRING macro would
1246 # expand into:
1249 #    --with-readline-blah-blah-blah
1250 #  ^ ^                       support fancy command line editing
1251 #  | |                       ^
1252 #  | column 2                |
1253 #  column 0                  column 26
1256 # m4_text_wrap hacks^Wworks around the fact that m4_format does not
1257 # know quadrigraphs.
1259 m4_define([AS_HELP_STRING],
1260 [m4_text_wrap([$2], m4_cond([[$3]], [], [                          ],
1261                             [m4_eval([$3]+0)], [0], [[$3]],
1262                             [m4_format([[%*s]], [$3], [])]),
1263               m4_expand([  $1 ]), [$4])dnl
1264 ])# AS_HELP_STRING
1267 # AS_IDENTIFIER_IF(EXPRESSION, IF-IDENT, IF-NOT-IDENT)
1268 # ----------------------------------------------------
1269 # If EXPRESSION serves as an identifier (ie, after removal of @&t@, it
1270 # matches the regex `^[a-zA-Z_][a-zA-Z_0-9]*$'), execute IF-IDENT,
1271 # otherwise IF-NOT-IDENT.
1273 # This is generally faster than the alternative:
1274 #   m4_bmatch(m4_bpatsubst([[$1]], [@&t@]), ^m4_defn([m4_re_word])$,
1275 #             [$2], [$3])
1277 # Rather than expand m4_defn every time AS_IDENTIFIER_IF is expanded, we
1278 # inline its expansion up front.  Only use a regular expression if we
1279 # detect a potential quadrigraph.
1281 # First, check if the entire string matches m4_cr_symbol2.  Only then do
1282 # we worry if the first character also matches m4_cr_symbol1 (ie. does not
1283 # match m4_cr_digit).
1284 m4_define([AS_IDENTIFIER_IF],
1285 [m4_if(m4_index([$1], [@]), [-1],
1286        [_$0($@)],
1287        [_$0(m4_bpatsubst([[$1]], [@&t@]), [$2], [$3])])])
1288 m4_define([_AS_IDENTIFIER_IF],
1289 [m4_cond([[$1]], [], [$3],
1290          [m4_eval(m4_len(m4_translit([[$1]], ]]dnl
1291 m4_dquote(m4_dquote(m4_defn([m4_cr_symbols2])))[[)) > 0)], [1], [$3],
1292          [m4_len(m4_translit(m4_format([[%.1s]], [$1]), ]]dnl
1293 m4_dquote(m4_dquote(m4_defn([m4_cr_symbols1])))[[))], [0], [$2], [$3])])
1296 # AS_LITERAL_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL)
1297 # -----------------------------------------------------
1298 # If EXPRESSION has shell indirections ($var or `expr`), expand
1299 # IF-INDIR, else IF-NOT-INDIR.
1300 # This is an *approximation*: for instance EXPRESSION = `\$' is
1301 # definitely a literal, but will not be recognized as such.
1303 # Why do we reject EXPRESSION expanding with `[' or `]' as a literal?
1304 # Because AS_TR_SH is MUCH faster if it can use m4_translit on literals
1305 # instead of m4_bpatsubst; but m4_translit is much tougher to do safely
1306 # if `[' is translated.
1308 # Note that the quadrigraph @S|@ can result in non-literals, but outright
1309 # rejecting all @ would make AC_INIT complain on its bug report address.
1311 # We used to use m4_bmatch(m4_quote($1), [[`$]], [$3], [$2]), but
1312 # profiling shows that it is faster to use m4_translit.
1314 # Because the translit is stripping quotes, it must also neutralize anything
1315 # that might be in a macro name, as well as comments and commas.  All the
1316 # problem characters are unified so that a single m4_index can scan the
1317 # result.
1319 # Rather than expand m4_defn every time AS_LITERAL_IF is expanded, we
1320 # inline its expansion up front.
1321 m4_define([AS_LITERAL_IF],
1322 [m4_cond([m4_eval(m4_index(m4_quote($1), [@S|@]) == -1)], [0], [$3],
1323          [m4_index(m4_translit(m4_quote($1),
1324                                [[]`,#]]]dnl
1325 m4_dquote(m4_dquote(m4_defn([m4_cr_symbols2])))[[,
1326                                [$$$]),
1327                    [$])], [-1], [$2],
1328          [$3])])
1331 # AS_TMPDIR(PREFIX, [DIRECTORY = $TMPDIR [= /tmp]])
1332 # -------------------------------------------------
1333 # Create as safely as possible a temporary directory in DIRECTORY
1334 # which name is inspired by PREFIX (should be 2-4 chars max).
1335 m4_define([AS_TMPDIR],
1336 [AS_REQUIRE([_AS_ME_PREPARE])dnl
1337 # Create a (secure) tmp directory for tmp files.
1338 m4_if([$2], [], [: ${TMPDIR=/tmp}])
1340   tmp=`(umask 077 && mktemp -d "m4_default([$2], [$TMPDIR])/$1XXXXXX") 2>/dev/null` &&
1341   test -n "$tmp" && test -d "$tmp"
1342 }  ||
1344   tmp=m4_default([$2], [$TMPDIR])/$1$$-$RANDOM
1345   (umask 077 && mkdir "$tmp")
1346 } || AS_ERROR([cannot create a temporary directory in m4_default([$2], [$TMPDIR])])dnl
1347 ])# AS_TMPDIR
1350 # AS_UNAME
1351 # --------
1352 # Try to describe this machine.  Meant for logs.
1353 m4_define([AS_UNAME],
1355 cat <<_ASUNAME
1356 m4_text_box([Platform.])
1358 hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
1359 uname -m = `(uname -m) 2>/dev/null || echo unknown`
1360 uname -r = `(uname -r) 2>/dev/null || echo unknown`
1361 uname -s = `(uname -s) 2>/dev/null || echo unknown`
1362 uname -v = `(uname -v) 2>/dev/null || echo unknown`
1364 /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
1365 /bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
1367 /bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
1368 /usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
1369 /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
1370 /usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`
1371 /bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
1372 /usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
1373 /bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
1375 _ASUNAME
1377 _AS_PATH_WALK([$PATH], [AS_ECHO(["PATH: $as_dir"])])
1381 # _AS_VERSION_COMPARE_PREPARE
1382 # ---------------------------
1383 # Output variables for comparing version numbers.
1384 m4_defun([_AS_VERSION_COMPARE_PREPARE],
1385 [[as_awk_strverscmp='
1386   # Use only awk features that work with 7th edition Unix awk (1978).
1387   # My, what an old awk you have, Mr. Solaris!
1388   END {
1389     while (length(v1) && length(v2)) {
1390       # Set d1 to be the next thing to compare from v1, and likewise for d2.
1391       # Normally this is a single character, but if v1 and v2 contain digits,
1392       # compare them as integers and fractions as strverscmp does.
1393       if (v1 ~ /^[0-9]/ && v2 ~ /^[0-9]/) {
1394         # Split v1 and v2 into their leading digit string components d1 and d2,
1395         # and advance v1 and v2 past the leading digit strings.
1396         for (len1 = 1; substr(v1, len1 + 1) ~ /^[0-9]/; len1++) continue
1397         for (len2 = 1; substr(v2, len2 + 1) ~ /^[0-9]/; len2++) continue
1398         d1 = substr(v1, 1, len1); v1 = substr(v1, len1 + 1)
1399         d2 = substr(v2, 1, len2); v2 = substr(v2, len2 + 1)
1400         if (d1 ~ /^0/) {
1401           if (d2 ~ /^0/) {
1402             # Compare two fractions.
1403             while (d1 ~ /^0/ && d2 ~ /^0/) {
1404               d1 = substr(d1, 2); len1--
1405               d2 = substr(d2, 2); len2--
1406             }
1407             if (len1 != len2 && ! (len1 && len2 && substr(d1, 1, 1) == substr(d2, 1, 1))) {
1408               # The two components differ in length, and the common prefix
1409               # contains only leading zeros.  Consider the longer to be less.
1410               d1 = -len1
1411               d2 = -len2
1412             } else {
1413               # Otherwise, compare as strings.
1414               d1 = "x" d1
1415               d2 = "x" d2
1416             }
1417           } else {
1418             # A fraction is less than an integer.
1419             exit 1
1420           }
1421         } else {
1422           if (d2 ~ /^0/) {
1423             # An integer is greater than a fraction.
1424             exit 2
1425           } else {
1426             # Compare two integers.
1427             d1 += 0
1428             d2 += 0
1429           }
1430         }
1431       } else {
1432         # The normal case, without worrying about digits.
1433         d1 = substr(v1, 1, 1); v1 = substr(v1, 2)
1434         d2 = substr(v2, 1, 1); v2 = substr(v2, 2)
1435       }
1436       if (d1 < d2) exit 1
1437       if (d1 > d2) exit 2
1438     }
1439     # Beware Solaris /usr/xgp4/bin/awk (at least through Solaris 10),
1440     # which mishandles some comparisons of empty strings to integers.
1441     if (length(v2)) exit 1
1442     if (length(v1)) exit 2
1443   }
1444 ']])# _AS_VERSION_COMPARE_PREPARE
1447 # AS_VERSION_COMPARE(VERSION-1, VERSION-2,
1448 #                    [ACTION-IF-LESS], [ACTION-IF-EQUAL], [ACTION-IF-GREATER])
1449 # -----------------------------------------------------------------------------
1450 # Compare two strings possibly containing shell variables as version strings.
1451 m4_defun([AS_VERSION_COMPARE],
1452 [AS_REQUIRE([_$0_PREPARE])dnl
1453 as_arg_v1=$1
1454 as_arg_v2=$2
1455 dnl This usage is portable even to ancient awk,
1456 dnl so don't worry about finding a "nice" awk version.
1457 awk "$as_awk_strverscmp" v1="$as_arg_v1" v2="$as_arg_v2" /dev/null
1458 case $? in
1459 1) $3;;
1460 0) $4;;
1461 2) $5;;
1462 esac[]dnl
1463 ])# _AS_VERSION_COMPARE
1467 ## ------------------------------------ ##
1468 ## Common m4/sh character translation.  ##
1469 ## ------------------------------------ ##
1471 # The point of this section is to provide high level macros comparable
1472 # to m4's `translit' primitive, but m4/sh polymorphic.
1473 # Transliteration of literal strings should be handled by m4, while
1474 # shell variables' content will be translated at runtime (tr or sed).
1477 # _AS_CR_PREPARE
1478 # --------------
1479 # Output variables defining common character ranges.
1480 # See m4_cr_letters etc.
1481 m4_defun([_AS_CR_PREPARE],
1482 [# Avoid depending upon Character Ranges.
1483 as_cr_letters='abcdefghijklmnopqrstuvwxyz'
1484 as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
1485 as_cr_Letters=$as_cr_letters$as_cr_LETTERS
1486 as_cr_digits='0123456789'
1487 as_cr_alnum=$as_cr_Letters$as_cr_digits
1491 # _AS_TR_SH_PREPARE
1492 # -----------------
1493 m4_defun([_AS_TR_SH_PREPARE],
1494 [AS_REQUIRE([_AS_CR_PREPARE])dnl
1495 # Sed expression to map a string onto a valid variable name.
1496 as_tr_sh="eval sed 'y%*+%pp%;s%[[^_$as_cr_alnum]]%_%g'"
1500 # AS_TR_SH(EXPRESSION)
1501 # --------------------
1502 # Transform EXPRESSION into a valid shell variable name.
1503 # sh/m4 polymorphic.
1504 # Be sure to update the definition of `$as_tr_sh' if you change this.
1506 # AS_LITERAL_IF guarantees that a literal does not have any nested quotes,
1507 # once $1 is expanded.  m4_translit silently uses only the first occurrence
1508 # of a character that appears multiple times in argument 2, since we know
1509 # that m4_cr_not_symbols2 also contains [ and ].  m4_translit also silently
1510 # ignores characters in argument 3 that do not match argument 2; we use this
1511 # fact to skip worrying about the length of m4_cr_not_symbols2.
1513 # For speed, we inline the literal definitions that can be computed up front.
1514 m4_defun([AS_TR_SH],
1515 [AS_REQUIRE([_$0_PREPARE])dnl
1516 AS_LITERAL_IF([$1],
1517               [m4_translit([$1], [*+[]]]]dnl
1518 m4_dquote(m4_dquote(m4_defn([m4_cr_not_symbols2])))[[,
1519                                  [pp[]]]]dnl
1520 m4_dquote(m4_dquote(m4_for(,1,255,,[[_]])))[[)],
1521               [`AS_ECHO(["$1"]) | $as_tr_sh`])])
1524 # _AS_TR_CPP_PREPARE
1525 # ------------------
1526 m4_defun([_AS_TR_CPP_PREPARE],
1527 [AS_REQUIRE([_AS_CR_PREPARE])dnl
1528 # Sed expression to map a string onto a valid CPP name.
1529 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[[^_$as_cr_alnum]]%_%g'"
1533 # AS_TR_CPP(EXPRESSION)
1534 # ---------------------
1535 # Map EXPRESSION to an upper case string which is valid as rhs for a
1536 # `#define'.  sh/m4 polymorphic.  Be sure to update the definition
1537 # of `$as_tr_cpp' if you change this.
1539 # See implementation comments in AS_TR_SH.
1540 m4_defun([AS_TR_CPP],
1541 [AS_REQUIRE([_$0_PREPARE])dnl
1542 AS_LITERAL_IF([$1],
1543               [m4_translit([$1], [*[]]]]dnl
1544 m4_dquote(m4_dquote(m4_defn([m4_cr_letters])m4_defn([m4_cr_not_symbols2])))[[,
1545                                  [P[]]]]dnl
1546 m4_dquote(m4_dquote(m4_defn([m4_cr_LETTERS])m4_for(,1,255,,[[_]])))[[)],
1547               [`AS_ECHO(["$1"]) | $as_tr_cpp`])])
1550 # _AS_TR_PREPARE
1551 # --------------
1552 m4_defun([_AS_TR_PREPARE],
1553 [AS_REQUIRE([_AS_TR_SH_PREPARE])dnl
1554 AS_REQUIRE([_AS_TR_CPP_PREPARE])dnl
1560 ## --------------------------------------------------- ##
1561 ## Common m4/sh handling of variables (indirections).  ##
1562 ## --------------------------------------------------- ##
1565 # The purpose of this section is to provide a uniform API for
1566 # reading/setting sh variables with or without indirection.
1567 # Typically, one can write
1568 #   AS_VAR_SET(var, val)
1569 # or
1570 #   AS_VAR_SET(as_$var, val)
1571 # and expect the right thing to happen.
1574 # AS_VAR_SET(VARIABLE, VALUE)
1575 # ---------------------------
1576 # Set the VALUE of the shell VARIABLE.
1577 # If the variable contains indirections (e.g. `ac_cv_func_$ac_func')
1578 # perform whenever possible at m4 level, otherwise sh level.
1579 m4_define([AS_VAR_SET],
1580 [AS_LITERAL_IF([$1],
1581                [$1=$2],
1582                [eval "$1=AS_ESCAPE([$2])"])])
1585 # AS_VAR_GET(VARIABLE)
1586 # --------------------
1587 # Get the value of the shell VARIABLE.
1588 # Evaluates to $VARIABLE if there are no indirection in VARIABLE,
1589 # else into the appropriate `eval' sequence.
1590 # FIXME: This mishandles values that end in newlines.
1591 # Fixing this will require changing the API.
1592 m4_define([AS_VAR_GET],
1593 [AS_LITERAL_IF([$1],
1594                [$$1],
1595                [`eval 'as_val=${'m4_bpatsubst([$1], [[\\`]], [\\\&])'}
1596                  AS_ECHO(["$as_val"])'`])])
1599 # AS_VAR_TEST_SET(VARIABLE)
1600 # -------------------------
1601 # Expands into the `test' expression which is true if VARIABLE
1602 # is set.  Polymorphic.  Should be dnl'ed.
1603 m4_define([AS_VAR_TEST_SET],
1604 [AS_LITERAL_IF([$1],
1605                [test "${$1+set}" = set],
1606                [{ as_var=$1; eval "test \"\${$as_var+set}\" = set"; }])])
1609 # AS_VAR_SET_IF(VARIABLE, IF-TRUE, IF-FALSE)
1610 # ------------------------------------------
1611 # Implement a shell `if-then-else' depending whether VARIABLE is set
1612 # or not.  Polymorphic.
1613 m4_define([AS_VAR_SET_IF],
1614 [AS_IF([AS_VAR_TEST_SET([$1])], [$2], [$3])])
1617 # AS_VAR_IF(VARIABLE, VALUE, IF-TRUE, IF-FALSE)
1618 # ---------------------------------------------
1619 # Implement a shell `if test $VARIABLE = VALUE; then-else'.
1620 # Polymorphic, and avoids sh expansion error upon interrupt or term signal.
1621 m4_define([AS_VAR_IF],
1622 [AS_LITERAL_IF([$1],
1623   [AS_IF([test "x$$1" = x""$2], [$3], [$4])],
1624   [as_val=AS_VAR_GET([$1])
1625    AS_IF([test "x$as_val" = x""$2], [$3], [$4])])])
1628 # AS_VAR_PUSHDEF and AS_VAR_POPDEF
1629 # --------------------------------
1632 # Sometimes we may have to handle literals (e.g. `stdlib.h'), while at
1633 # other moments, the same code may have to get the value from a
1634 # variable (e.g., `ac_header').  To have a uniform handling of both
1635 # cases, when a new value is about to be processed, declare a local
1636 # variable, e.g.:
1638 #   AS_VAR_PUSHDEF([header], [ac_cv_header_$1])
1640 # and then in the body of the macro, use `header' as is.  It is of
1641 # first importance to use `AS_VAR_*' to access this variable.  Don't
1642 # quote its name: it must be used right away by m4.
1644 # If the value `$1' was a literal (e.g. `stdlib.h'), then `header' is
1645 # in fact the value `ac_cv_header_stdlib_h'.  If `$1' was indirect,
1646 # then `header's value in m4 is in fact `$as_header', the shell
1647 # variable that holds all of the magic to get the expansion right.
1649 # At the end of the block, free the variable with
1651 #   AS_VAR_POPDEF([header])
1654 # AS_VAR_PUSHDEF(VARNAME, VALUE)
1655 # ------------------------------
1656 # Define the m4 macro VARNAME to an accessor to the shell variable
1657 # named VALUE.  VALUE does not need to be a valid shell variable name:
1658 # the transliteration is handled here.  To be dnl'ed.
1659 m4_define([AS_VAR_PUSHDEF],
1660 [AS_LITERAL_IF([$2],
1661                [m4_pushdef([$1], [AS_TR_SH($2)])],
1662                [as_$1=AS_TR_SH($2)
1663 m4_pushdef([$1], [$as_[$1]])])])
1666 # AS_VAR_POPDEF(VARNAME)
1667 # ----------------------
1668 # Free the shell variable accessor VARNAME.  To be dnl'ed.
1669 m4_define([AS_VAR_POPDEF],
1670 [m4_popdef([$1])])
1673 ## ----------------- ##
1674 ## Setting M4sh up.  ##
1675 ## ----------------- ##
1678 # AS_INIT_GENERATED
1679 # -----------------
1680 # Emit m4sh initialization code in a suitable form for a quoted
1681 # here document.  Does not emit the `#!' sequence, which should be
1682 # generated with `#! $SHELL'; see the manual or autoconf/status.m4
1683 # for more detail.
1684 m4_defun([AS_INIT_GENERATED],
1685 [m4_require([AS_PREPARE])dnl
1686 AS_SHELL_SANITIZE
1687 _AS_PREPARE])
1689 # AS_INIT
1690 # -------
1691 # Initialize m4sh.
1692 m4_define([AS_INIT],
1693 [# Wrap our cleanup prior to m4sugar's cleanup.
1694 m4_wrap([_AS_CLEANUP])
1695 m4_init
1697 # Forbidden tokens and exceptions.
1698 m4_pattern_forbid([^_?AS_])
1700 # Bangshe and minimal initialization.
1701 m4_divert_text([BINSH], [@%:@! /bin/sh])
1702 m4_divert_text([HEADER-COMMENT],
1703                [@%:@ Generated from __file__ by m4_PACKAGE_STRING.])
1704 m4_divert_text([M4SH-SANITIZE], [AS_SHELL_SANITIZE])
1706 # Let's go!
1707 m4_divert_pop([KILL])[]dnl
1708 m4_divert_push([BODY])[]dnl