1include(m4sugar.m4)#                                        -*- Autoconf -*-
2# This file is part of Autoconf.
3# M4 sugar for common shell constructs.
4# Requires GNU M4 and M4sugar.
5# Copyright 2000, 2001 Free Software Foundation, Inc.
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2, or (at your option)
10# any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20# 02111-1307, USA.
21#
22# As a special exception, the Free Software Foundation gives unlimited
23# permission to copy, distribute and modify the configure scripts that
24# are the output of Autoconf.  You need not follow the terms of the GNU
25# General Public License when using or distributing such scripts, even
26# though portions of the text of Autoconf appear in them.  The GNU
27# General Public License (GPL) does govern all other use of the material
28# that constitutes the Autoconf program.
29#
30# Certain portions of the Autoconf source text are designed to be copied
31# (in certain cases, depending on the input) into the output of
32# Autoconf.  We call these the "data" portions.  The rest of the Autoconf
33# source text consists of comments plus executable code that decides which
34# of the data portions to output in any given case.  We call these
35# comments and executable code the "non-data" portions.  Autoconf never
36# copies any of the non-data portions into its output.
37#
38# This special exception to the GPL applies to versions of Autoconf
39# released by the Free Software Foundation.  When you make and
40# distribute a modified version of Autoconf, you may extend this special
41# exception to the GPL to apply to your modified version as well, *unless*
42# your modified version has the potential to copy into its output some
43# of the text that was the non-data portion of the version that you started
44# with.  (In other words, unless your change moves or copies text from
45# the non-data portions to the data portions.)  If your modification has
46# such potential, you must delete any notice of this special exception
47# to the GPL from your modified version.
48#
49# Written by Akim Demaille, Pavel Roskin, Alexandre Oliva, Lars J. Aas
50# and many other people.
51
52
53## ------------------------- ##
54## 1. Sanitizing the shell.  ##
55## ------------------------- ##
56
57# AS_SHELL_SANITIZE
58# -----------------
59# Try to be as Bourne and/or POSIX as possible.
60m4_defun([AS_SHELL_SANITIZE],
61[# Be Bourne compatible
62if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
63  emulate sh
64  NULLCMD=:
65elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
66  set -o posix
67fi
68
69# Name of the executable.
70dnl Moved here because the tests below can use AC_MSG_ERROR, which uses $as_me
71as_me=`AS_BASENAME($[0])`
72
73_AS_EXPR_PREPARE
74_AS_LN_S_PREPARE
75_AS_TEST_PREPARE
76_AS_UNSET_PREPARE
77_AS_TR_PREPARE
78
79# NLS nuisances.
80AS_UNSET([LANG],        [C])
81AS_UNSET([LC_ALL],      [C])
82AS_UNSET([LC_TIME],     [C])
83AS_UNSET([LC_CTYPE],    [C])
84AS_UNSET([LANGUAGE],    [C])
85AS_UNSET([LC_COLLATE],  [C])
86AS_UNSET([LC_NUMERIC],  [C])
87AS_UNSET([LC_MESSAGES], [C])
88
89# IFS
90# We need space, tab and new line, in precisely that order.
91as_nl='
92'
93IFS=" 	$as_nl"
94
95# CDPATH.
96AS_UNSET([CDPATH], [:])
97])
98
99
100## ----------------------------- ##
101## 2. Wrappers around builtins.  ##
102## ----------------------------- ##
103
104# This section is lexicographically sorted.
105
106
107# AS_EXIT([EXIT-CODE = 1])
108# ------------------------
109# Exit and set exit code to EXIT-CODE in the way that it's seen
110# within "trap 0".
111#
112# We cannot simply use "exit N" because some shells (zsh and Solaris sh)
113# will not set $? to N while running the code set by "trap 0"
114# So we set $? by executing "exit N" in the subshell and then exit.
115# Other shells don't use `$?' as default for `exit', hence just repeating
116# the exit value can only help improving portability.
117m4_define([AS_EXIT],
118[{ (exit m4_default([$1], 1)); exit m4_default([$1], 1); }])
119
120
121# AS_IF(TEST, [IF-TRUE], [IF-FALSE])
122# ----------------------------------
123# Expand into
124# | if TEST; then
125# |   IF-TRUE
126# | else
127# |   IF-FALSE
128# | fi
129# with simplifications is IF-TRUE and/or IF-FALSE is empty.
130m4_define([AS_IF],
131[m4_ifval([$2$3],
132[if $1; then
133  m4_ifval([$2], [$2], :)
134m4_ifvaln([$3],
135[else
136  $3])dnl
137fi
138])dnl
139])# AS_IF
140
141
142# _AS_UNSET_PREPARE
143# -----------------
144# AS_UNSET depends upon $as_unset: compute it.
145m4_defun([_AS_UNSET_PREPARE],
146[# Support unset when possible.
147if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
148  as_unset=unset
149else
150  as_unset=false
151fi
152])
153
154
155# AS_UNSET(VAR, [VALUE-IF-UNSET-NOT-SUPPORTED = `'])
156# --------------------------------------------------
157# Try to unset the env VAR, otherwise set it to
158# VALUE-IF-UNSET-NOT-SUPPORTED.  `as_unset' must have been computed.
159m4_defun([AS_UNSET],
160[m4_require([_AS_UNSET_PREPARE])dnl
161$as_unset $1 || test "${$1+set}" != set || { $1=$2; export $1; }])
162
163
164
165
166
167
168## ------------------------------------------ ##
169## 3. Error and warnings at the shell level.  ##
170## ------------------------------------------ ##
171
172# If AS_MESSAGE_LOG_FD is defined, shell messages are duplicated there
173# too.
174
175
176# AS_ESCAPE(STRING, [CHARS = $"'\])
177# ---------------------------------
178# Escape the CHARS in STRING.
179m4_define([AS_ESCAPE],
180[m4_patsubst([$1],
181             m4_ifval([$2], [[\([$2]\)]], [[\([\"$`]\)]]),
182             [\\\1])])
183
184
185# _AS_QUOTE_IFELSE(STRING, IF-MODERN-QUOTATION, IF-OLD-QUOTATION)
186# ---------------------------------------------------------------
187# Compatibility glue between the old AS_MSG suite which did not
188# quote anything, and the modern suite which quotes the quotes.
189# If STRING contains `\\' or `\$', it's modern.
190# If STRING contains `\"' or `\`', it's old.
191# Otherwise it's modern.
192# We use two quotes in the pattern to keep highlighting tools at peace.
193m4_define([_AS_QUOTE_IFELSE],
194[m4_if(m4_regexp([$1], [\\[\\$]]),
195       [-1], [m4_if(m4_regexp([$1], [\\[`""]]),
196                    [-1], [$2],
197                    [$3])],
198       [$2])])
199
200
201# _AS_ECHO_UNQUOTED(STRING, [FD = AS_MESSAGE_FD])
202# -----------------------------------------------
203# Perform shell expansions on STRING and echo the string to FD.
204m4_define([_AS_ECHO_UNQUOTED],
205[echo "$1" >&m4_default([$2], [AS_MESSAGE_FD])])
206
207
208# _AS_QUOTE(STRING)
209# -----------------
210# If there are quoted (via backslash) backquotes do nothing, else
211# backslash all the quotes.
212# FIXME: In a distant future (2.51 or +), this warning should be
213# classified as `syntax'.  It is classified as `obsolete' to ease
214# the transition (for Libtool for instance).
215m4_define([_AS_QUOTE],
216[_AS_QUOTE_IFELSE([$1],
217                  [AS_ESCAPE([$1], [`""])],
218                  [m4_warn([obsolete],
219           [back quotes and double quotes should not be escaped in: $1])dnl
220$1])])
221
222
223# _AS_ECHO(STRING, [FD = AS_MESSAGE_FD])
224# --------------------------------------
225# Protect STRING from backquote expansion, echo the result to FD.
226m4_define([_AS_ECHO],
227[_AS_ECHO_UNQUOTED([_AS_QUOTE([$1])], [$2])])
228
229
230# AS_MESSAGE(STRING, [FD = AS_MESSAGE_FD])
231# ----------------------------------------
232m4_define([AS_MESSAGE],
233[m4_ifset([AS_MESSAGE_LOG_FD],
234          [{ _AS_ECHO([$as_me:__oline__: $1], [AS_MESSAGE_LOG_FD])
235_AS_ECHO([$as_me: $1], [$2]);}],
236          [_AS_ECHO([$as_me: $1], [$2])])[]dnl
237])
238
239
240# AS_WARN(PROBLEM)
241# ----------------
242m4_define([AS_WARN],
243[AS_MESSAGE([WARNING: $1], [2])])# AS_WARN
244
245
246# AS_ERROR(ERROR, [EXIT-STATUS = 1])
247# ----------------------------------
248m4_define([AS_ERROR],
249[{ AS_MESSAGE([error: $1], [2])
250   AS_EXIT([$2]); }[]dnl
251])# AS_ERROR
252
253
254
255## -------------------------------------- ##
256## 4. Portable versions of common tools.  ##
257## -------------------------------------- ##
258
259# This section is lexicographically sorted.
260
261
262# AS_DIRNAME(PATHNAME)
263# --------------------
264# Simulate running `dirname(1)' on PATHNAME, not all systems have it.
265# This macro must be usable from inside ` `.
266#
267# Prefer expr to echo|sed, since expr is usually faster and it handles
268# backslashes and newlines correctly.  However, older expr
269# implementations (e.g. SunOS 4 expr and Solaris 8 /usr/ucb/expr) have
270# a silly length limit that causes expr to fail if the matched
271# substring is longer than 120 bytes.  So fall back on echo|sed if
272# expr fails.
273#
274# FIXME: Please note the following m4_require is quite wrong: if the first
275# occurrence of AS_DIRNAME_EXPR is in a backquoted expression, the
276# shell will be lost.  We might have to introduce diversions for
277# setting up an M4sh script: required macros will then be expanded there.
278m4_defun([AS_DIRNAME_EXPR],
279[m4_require([_AS_EXPR_PREPARE])dnl
280$as_expr X[]$1 : 'X\(.*[[^/]]\)//*[[^/][^/]]*/*$' \| \
281         X[]$1 : 'X\(//\)[[^/]]' \| \
282         X[]$1 : 'X\(//\)$' \| \
283         X[]$1 : 'X\(/\)' \| \
284         .     : '\(.\)'])
285
286m4_defun([AS_DIRNAME_SED],
287[echo X[]$1 |
288    sed ['/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
289  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
290  	  /^X\(\/\/\)$/{ s//\1/; q; }
291  	  /^X\(\/\).*/{ s//\1/; q; }
292  	  s/.*/./; q']])
293
294m4_defun([AS_DIRNAME],
295[AS_DIRNAME_EXPR([$1]) 2>/dev/null ||
296AS_DIRNAME_SED([$1])])
297
298
299# AS_BASENAME(PATHNAME)
300# --------------------
301# Simulate running `basename(1)' on PATHNAME, not all systems have it.
302# This macro must be usable from inside ` `.
303m4_defun([AS_BASENAME],
304[echo "$1" |sed 's,.*[[\\/]],,'])
305
306# AS_EXECUTABLE_P
307# ---------------
308# Check whether a file is executable.
309m4_defun([AS_EXECUTABLE_P],
310[m4_require([_AS_TEST_PREPARE])dnl
311$as_executable_p $1[]dnl
312])# AS_EXECUTABLE_P
313
314
315# _AS_EXPR_PREPARE
316# ----------------
317# Some expr work properly (i.e. compute and issue the right result),
318# but exit with failure.  When a fall back to expr (as in AS_DIRNAME)
319# is provided, you get twice the result.  Prevent this.
320m4_defun([_AS_EXPR_PREPARE],
321[if expr a : '\(a\)' >/dev/null 2>&1; then
322  as_expr=expr
323else
324  as_expr=false
325fi
326])# _AS_EXPR_PREPARE
327
328
329# _AS_LN_S_PREPARE
330# ----------------
331# Don't use conftest.sym to avoid filename issues on DJGPP, where this
332# would yield conftest.sym.exe for DJGPP < 2.04.  And don't use `conftest'
333# as base name to avoid prohibiting concurrency (e.g., concurrent
334# config.statuses).
335m4_defun([_AS_LN_S_PREPARE],
336[rm -f conf$$ conf$$.exe conf$$.file
337echo >conf$$.file
338if ln -s conf$$.file conf$$ 2>/dev/null; then
339  # We could just check for DJGPP; but this test a) works b) is more generic
340  # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
341  if test -f conf$$.exe; then
342    # Don't use ln at all; we don't have any links
343    as_ln_s='cp -p'
344  else
345    as_ln_s='ln -s'
346  fi
347elif ln conf$$.file conf$$ 2>/dev/null; then
348  as_ln_s=ln
349else
350  as_ln_s='cp -p'
351fi
352rm -f conf$$ conf$$.exe conf$$.file
353])# _AS_LN_S_PREPARE
354
355
356# AS_LN_S(FILE, LINK)
357# -------------------
358# FIXME: Should we add the glue code to handle properly relative symlinks
359# simulated with `ln' or `cp'?
360m4_defun([AS_LN_S],
361[m4_require([_AS_LN_S_PREPARE])dnl
362$as_ln_s $1 $2
363])
364
365
366# AS_MKDIR_P(PATH)
367# ----------------
368# Emulate `mkdir -p' with plain `mkdir'.
369#
370# Don't set IFS to '\\/' (see the doc): you would end up with
371# directories called foo\bar and foo?az and others depending upon the
372# shell.
373m4_define([AS_MKDIR_P],
374[{ case $1 in
375  [[\\/]]* | ?:[[\\/]]* ) as_incr_dir=;;
376  *)                      as_incr_dir=.;;
377esac
378as_dummy=$1
379for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$[@]"`; do
380  case $as_mkdir_dir in
381    # Skip DOS drivespec
382    ?:) as_incr_dir=$as_mkdir_dir ;;
383    *)
384      as_incr_dir=$as_incr_dir/$as_mkdir_dir
385      test -d "$as_incr_dir" || mkdir "$as_incr_dir"
386    ;;
387  esac
388done; }
389])# AS_MKDIR_P
390
391
392# _AS_BROKEN_TEST_PREPARE
393# -----------------------
394# FIXME: This does not work and breaks way too many things.
395#
396# Find out ahead of time whether we want test -x (preferred) or test -f
397# to check whether a file is executable.
398m4_defun([_AS_BROKEN_TEST_PREPARE],
399[# Find out how to test for executable files. Don't use a zero-byte file,
400# as systems may use methods other than mode bits to determine executability.
401cat >conf$$.file <<_ASEOF
402@%:@! /bin/sh
403exit 0
404_ASEOF
405chmod +x conf$$.file
406if test -x conf$$.file >/dev/null 2>&1; then
407  as_executable_p="test -x"
408elif test -f conf$$.file >/dev/null 2>&1; then
409  as_executable_p="test -f"
410else
411  AS_ERROR([cannot check whether a file is executable on this system])
412fi
413rm -f conf$$.file
414])# _AS_BROKEN_TEST_PREPARE
415
416
417# _AS_TEST_PREPARE
418# ----------------
419m4_defun([_AS_TEST_PREPARE],
420[as_executable_p="test -f"
421])# _AS_BROKEN_TEST_PREPARE
422
423
424
425
426
427
428## ------------------ ##
429## 5. Common idioms.  ##
430## ------------------ ##
431
432# This section is lexicographically sorted.
433
434
435# AS_BOX(MESSAGE, [FRAME-CHARACTER = `='])
436# ----------------------------------------
437# Output MESSAGE, a single line text, framed with FRAME-CHARACTER (which
438# must not be `/').
439m4_define([AS_BOX],
440[AS_LITERAL_IF([$1],
441               [_AS_BOX_LITERAL($@)],
442               [_AS_BOX_INDIR($@)])])
443
444# _AS_BOX_LITERAL(MESSAGE, [FRAME-CHARACTER = `='])
445# -------------------------------------------------
446m4_define([_AS_BOX_LITERAL],
447[cat <<\_ASBOX
448m4_patsubst([$1], [.], m4_if([$2], [], [[=]], [[$2]]))
449$1
450m4_patsubst([$1], [.], m4_if([$2], [], [[=]], [[$2]]))
451_ASBOX])
452
453# _AS_BOX_INDIR(MESSAGE, [FRAME-CHARACTER = `='])
454# -----------------------------------------------
455m4_define([_AS_BOX_INDIR],
456[sed 'h;s/./m4_default([$2], [=])/g;p;x;p;x' <<_ASBOX
457$1
458_ASBOX])
459
460
461# AS_LITERAL_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL)
462# -----------------------------------------------------
463# If EXPRESSION has shell indirections ($var or `expr`), expand
464# IF-INDIR, else IF-NOT-INDIR.
465# This is an *approximation*: for instance EXPRESSION = `\$' is
466# definitely a literal, but will not be recognized as such.
467m4_define([AS_LITERAL_IF],
468[m4_if(m4_regexp([$1], [[`$]]),
469       -1, [$2],
470       [$3])])
471
472
473# AS_TMPDIR(PREFIX)
474# -----------------
475# Create as safely as possible a temporary directory which name is
476# inspired by PREFIX (should be 2-4 chars max), and set trap
477# mechanisms to remove it.
478m4_define([AS_TMPDIR],
479[# Create a temporary directory, and hook for its removal unless debugging.
480$debug ||
481{
482  trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
483  trap 'AS_EXIT([1])' 1 2 13 15
484}
485
486# Create a (secure) tmp directory for tmp files.
487: ${TMPDIR=/tmp}
488{
489  tmp=`(umask 077 && mktemp -d -q "$TMPDIR/$1XXXXXX") 2>/dev/null` &&
490  test -n "$tmp" && test -d "$tmp"
491}  ||
492{
493  tmp=$TMPDIR/$1$$-$RANDOM
494  (umask 077 && mkdir $tmp)
495} ||
496{
497   echo "$me: cannot create a temporary directory in $TMPDIR" >&2
498   AS_EXIT
499}dnl
500])# AS_TMPDIR
501
502
503# AS_UNAME
504# --------
505# Try to describe this machine.  Meant for logs.
506m4_define([AS_UNAME],
507[{
508cat <<_ASUNAME
509## ---------- ##
510## Platform.  ##
511## ---------- ##
512
513hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
514uname -m = `(uname -m) 2>/dev/null || echo unknown`
515uname -r = `(uname -r) 2>/dev/null || echo unknown`
516uname -s = `(uname -s) 2>/dev/null || echo unknown`
517uname -v = `(uname -v) 2>/dev/null || echo unknown`
518
519/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
520/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
521
522/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
523/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
524/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
525hostinfo               = `(hostinfo) 2>/dev/null               || echo unknown`
526/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
527/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
528/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
529
530PATH = $PATH
531
532_ASUNAME
533}])
534
535
536
537## ------------------------------------ ##
538## Common m4/sh character translation.  ##
539## ------------------------------------ ##
540
541# The point of this section is to provide high level macros comparable
542# to m4's `translit' primitive, but m4/sh polymorphic.
543# Transliteration of literal strings should be handled by m4, while
544# shell variables' content will be translated at runtime (tr or sed).
545
546
547# _AS_CR_PREPARE
548# --------------
549# Output variables defining common character ranges.
550# See m4_cr_letters etc.
551m4_defun([_AS_CR_PREPARE],
552[# Avoid depending upon Character Ranges.
553as_cr_letters='abcdefghijklmnopqrstuvwxyz'
554as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
555as_cr_Letters=$as_cr_letters$as_cr_LETTERS
556as_cr_digits='0123456789'
557as_cr_alnum=$as_cr_Letters$as_cr_digits
558])
559
560
561# _AS_TR_SH_PREPARE
562# -----------------
563m4_defun([_AS_TR_SH_PREPARE],
564[m4_require([_AS_CR_PREPARE])dnl
565# Sed expression to map a string onto a valid variable name.
566as_tr_sh="sed y%*+%pp%;s%[[^_$as_cr_alnum]]%_%g"
567])
568
569
570# AS_TR_SH(EXPRESSION)
571# --------------------
572# Transform EXPRESSION into a valid shell variable name.
573# sh/m4 polymorphic.
574# Be sure to update the definition of `$as_tr_sh' if you change this.
575m4_defun([AS_TR_SH],
576[m4_require([_$0_PREPARE])dnl
577AS_LITERAL_IF([$1],
578              [m4_patsubst(m4_translit([[$1]], [*+], [pp]),
579                           [[^a-zA-Z0-9_]], [_])],
580              [`echo "$1" | $as_tr_sh`])])
581
582
583# _AS_TR_CPP_PREPARE
584# ------------------
585m4_defun([_AS_TR_CPP_PREPARE],
586[m4_require([_AS_CR_PREPARE])dnl
587# Sed expression to map a string onto a valid CPP name.
588as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[[^_$as_cr_alnum]]%_%g"
589])
590
591
592# AS_TR_CPP(EXPRESSION)
593# ---------------------
594# Map EXPRESSION to an upper case string which is valid as rhs for a
595# `#define'.  sh/m4 polymorphic.  Be sure to update the definition
596# of `$as_tr_cpp' if you change this.
597m4_defun([AS_TR_CPP],
598[m4_require([_$0_PREPARE])dnl
599AS_LITERAL_IF([$1],
600              [m4_patsubst(m4_translit([[$1]],
601                                       [*abcdefghijklmnopqrstuvwxyz],
602                                       [PABCDEFGHIJKLMNOPQRSTUVWXYZ]),
603                           [[^A-Z0-9_]], [_])],
604              [`echo "$1" | $as_tr_cpp`])])
605
606
607# _AS_TR_PREPARE
608# --------------
609m4_defun([_AS_TR_PREPARE],
610[m4_require([_AS_TR_SH_PREPARE])dnl
611m4_require([_AS_TR_CPP_PREPARE])dnl
612])
613
614
615
616
617## --------------------------------------------------- ##
618## Common m4/sh handling of variables (indirections).  ##
619## --------------------------------------------------- ##
620
621
622# The purpose of this section is to provide a uniform API for
623# reading/setting sh variables with or without indirection.
624# Typically, one can write
625#   AS_VAR_SET(var, val)
626# or
627#   AS_VAR_SET(as_$var, val)
628# and expect the right thing to happen.
629
630
631# AS_VAR_SET(VARIABLE, VALUE)
632# ---------------------------
633# Set the VALUE of the shell VARIABLE.
634# If the variable contains indirections (e.g. `ac_cv_func_$ac_func')
635# perform whenever possible at m4 level, otherwise sh level.
636m4_define([AS_VAR_SET],
637[AS_LITERAL_IF([$1],
638               [$1=$2],
639               [eval "$1=$2"])])
640
641
642# AS_VAR_GET(VARIABLE)
643# --------------------
644# Get the value of the shell VARIABLE.
645# Evaluates to $VARIABLE if there are no indirection in VARIABLE,
646# else into the appropriate `eval' sequence.
647m4_define([AS_VAR_GET],
648[AS_LITERAL_IF([$1],
649               [$[]$1],
650               [`eval echo '${'m4_patsubst($1, [[\\`]], [\\\&])'}'`])])
651
652
653# AS_VAR_TEST_SET(VARIABLE)
654# -------------------------
655# Expands into the `test' expression which is true if VARIABLE
656# is set.  Polymorphic.  Should be dnl'ed.
657m4_define([AS_VAR_TEST_SET],
658[AS_LITERAL_IF([$1],
659               [test "${$1+set}" = set],
660               [eval "test \"\${$1+set}\" = set"])])
661
662
663# AS_VAR_SET_IF(VARIABLE, IF-TRUE, IF-FALSE)
664# ------------------------------------------
665# Implement a shell `if-then-else' depending whether VARIABLE is set
666# or not.  Polymorphic.
667m4_define([AS_VAR_SET_IF],
668[AS_IF([AS_VAR_TEST_SET([$1])], [$2], [$3])])
669
670
671# AS_VAR_PUSHDEF and AS_VAR_POPDEF
672# --------------------------------
673#
674
675# Sometimes we may have to handle literals (e.g. `stdlib.h'), while at
676# other moments, the same code may have to get the value from a
677# variable (e.g., `ac_header').  To have a uniform handling of both
678# cases, when a new value is about to be processed, declare a local
679# variable, e.g.:
680#
681#   AS_VAR_PUSHDEF([header], [ac_cv_header_$1])
682#
683# and then in the body of the macro, use `header' as is.  It is of
684# first importance to use `AS_VAR_*' to access this variable.  Don't
685# quote its name: it must be used right away by m4.
686#
687# If the value `$1' was a literal (e.g. `stdlib.h'), then `header' is
688# in fact the value `ac_cv_header_stdlib_h'.  If `$1' was indirect,
689# then `header's value in m4 is in fact `$ac_header', the shell
690# variable that holds all of the magic to get the expansion right.
691#
692# At the end of the block, free the variable with
693#
694#   AS_VAR_POPDEF([header])
695
696
697# AS_VAR_PUSHDEF(VARNAME, VALUE)
698# ------------------------------
699# Define the m4 macro VARNAME to an accessor to the shell variable
700# named VALUE.  VALUE does not need to be a valid shell variable name:
701# the transliteration is handled here.  To be dnl'ed.
702m4_define([AS_VAR_PUSHDEF],
703[AS_LITERAL_IF([$2],
704               [m4_pushdef([$1], [AS_TR_SH($2)])],
705               [as_$1=AS_TR_SH($2)
706m4_pushdef([$1], [$as_[$1]])])])
707
708
709# AS_VAR_POPDEF(VARNAME)
710# ----------------------
711# Free the shell variable accessor VARNAME.  To be dnl'ed.
712m4_define([AS_VAR_POPDEF],
713[m4_popdef([$1])])
714
715
716
717## ----------------- ##
718## Setting M4sh up.  ##
719## ----------------- ##
720
721
722# AS_INIT
723# -------
724m4_define([AS_INIT],
725[m4_init
726
727# Forbidden tokens and exceptions.
728m4_pattern_forbid([^_?AS_])
729])
730