1# This file is part of Autoconf. -*- Autoconf -*- 2# M4 sugar for common shell constructs. 3# Requires GNU M4 and M4sugar. 4# 5# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software 6# Foundation, Inc. 7# 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. 12# 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. 17# 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. 22# 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. 30# 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. 38# 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. 49# 50# Written by Akim Demaille, Pavel Roskin, Alexandre Oliva, Lars J. Aas 51# and many other people. 52 53 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. 57# 58# 59# KILL is only used to suppress output. 60# 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. 75 76 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'! 83m4_define([_m4_divert(BINSH)], 0) 84m4_define([_m4_divert(HEADER-REVISION)], 1) 85m4_define([_m4_divert(HEADER-COMMENT)], 2) 86m4_define([_m4_divert(HEADER-COPYRIGHT)], 3) 87m4_define([_m4_divert(M4SH-SANITIZE)], 4) 88m4_define([_m4_divert(M4SH-INIT)], 5) 89m4_define([_m4_divert(BODY)], 1000) 90 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 :( 94m4_copy([_m4_divert(M4SH-INIT)], [_m4_divert(NOTICE)]) 95 96 97 98## ------------------------- ## 99## 1. Sanitizing the shell. ## 100## ------------------------- ## 101 102 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: 108# 109# m4_defun([_FOO_PREPARE], [foo=foo]) 110# m4_defun([FOO], 111# [m4_require([_FOO_PREPARE])dnl 112# echo $foo]) 113# 114# m4_defun([_BAR_PREPARE], [bar=bar]) 115# m4_defun([BAR], 116# [AS_REQUIRE([_BAR_PREPARE])dnl 117# echo $bar]) 118# 119# AS_INIT 120# foo1=`FOO` 121# foo2=`FOO` 122# bar1=`BAR` 123# bar2=`BAR` 124# 125# gives 126# 127# #! /bin/sh 128# bar=bar 129# 130# foo1=`foo=foo 131# echo $foo` 132# foo2=`echo $foo` 133# bar1=`echo $bar` 134# bar2=`echo $bar` 135# 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. 140# 141m4_define([AS_REQUIRE], 142[m4_provide_if([$1], [], 143 [m4_divert_text([M4SH-INIT], [m4_default([$2], [$1])])])]) 144 145 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. 151# 152m4_define([AS_REQUIRE_SHELL_FN], 153[_AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])dnl 154m4_provide_if([AS_SHELL_FN_$1], [], 155 [m4_provide([AS_SHELL_FN_$1])m4_divert_text([M4SH-INIT], [$1() { 156$2 157}])])]) 158 159 160# AS_BOURNE_COMPATIBLE 161# -------------------- 162# Try to be as Bourne and/or POSIX as possible. 163# 164# This does not set BIN_SH, due to the problems described in 165# <http://lists.gnu.org/archive/html/autoconf-patches/2006-03/msg00081.html>. 166# People who need BIN_SH should set it in their environment before invoking 167# configure; apparently this would include UnixWare, as described in 168# <http://lists.gnu.org/archive/html/bug-autoconf/2006-06/msg00025.html>. 169m4_define([AS_BOURNE_COMPATIBLE], 170[# Be more Bourne compatible 171DUALCASE=1; export DUALCASE # for MKS sh 172_$0 173]) 174 175# _AS_BOURNE_COMPATIBLE 176# --------------------- 177# This is the part of AS_BOURNE_COMPATIBLE which has to be repeated inside 178# each instance. 179m4_define([_AS_BOURNE_COMPATIBLE], 180[AS_IF([test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1], 181 [emulate sh 182 NULLCMD=: 183 [#] Zsh 3.x and 4.x performs word splitting on ${1+"$[@]"}, which 184 # is contrary to our usage. Disable this feature. 185 alias -g '${1+"$[@]"}'='"$[@]"' 186 setopt NO_GLOB_SUBST], 187 [AS_CASE([`(set -o) 2>/dev/null`], [*posix*], [set -o posix])]) 188]) 189 190 191# _AS_RUN(TEST, [SHELL]) 192# ---------------------- 193# Run TEST under the current shell (if one parameter is used) 194# or under the given SHELL, protecting it from syntax errors. 195m4_define([_AS_RUN], 196[m4_ifval([$2], 197[{ $2 <<\_ASEOF 198_AS_BOURNE_COMPATIBLE 199$1 200_ASEOF 201}], 202[(eval "AS_ESCAPE(m4_quote($1))")])]) 203 204 205# _AS_DETECT_REQUIRED(TEST) 206# ------------------------- 207# Refuse to execute under a shell that does not pass the given TEST. 208m4_define([_AS_DETECT_REQUIRED_BODY], [:]) 209m4_defun([_AS_DETECT_REQUIRED], 210[m4_require([_AS_DETECT_BETTER_SHELL])dnl 211m4_expand_once([m4_append([_AS_DETECT_REQUIRED_BODY], [ 212($1) || AS_EXIT(1) 213])], [_AS_DETECT_REQUIRED_provide($1)])]) 214 215 216# _AS_DETECT_SUGGESTED(TEST) 217# -------------------------- 218# Prefer to execute under a shell that passes the given TEST. 219m4_define([_AS_DETECT_SUGGESTED_BODY], [:]) 220m4_defun([_AS_DETECT_SUGGESTED], 221[m4_require([_AS_DETECT_BETTER_SHELL])dnl 222m4_expand_once([m4_append([_AS_DETECT_SUGGESTED_BODY], [ 223($1) || AS_EXIT(1) 224])], [_AS_DETECT_SUGGESTED_provide($1)])]) 225 226 227# _AS_DETECT_BETTER_SHELL 228# ----------------------- 229# The real workhorse for detecting a shell with the correct 230# features. 231# 232# In previous versions, we prepended /usr/posix/bin to the path, but that 233# caused a regression on OpenServer 6.0.0 234# <http://lists.gnu.org/archive/html/bug-autoconf/2006-06/msg00017.html> 235# and on HP-UX 11.11, see the failure of test 120 in 236# <http://lists.gnu.org/archive/html/bug-autoconf/2006-10/msg00003.html> 237# 238# FIXME: The code should test for the OSF bug described in 239# <http://lists.gnu.org/archive/html/autoconf-patches/2006-03/msg00081.html>. 240# 241m4_defun_once([_AS_DETECT_BETTER_SHELL], 242[m4_wrap([m4_divert_text([M4SH-SANITIZE], [ 243AS_REQUIRE([_AS_UNSET_PREPARE])dnl 244if test "x$CONFIG_SHELL" = x; then 245 AS_IF([_AS_RUN([_AS_DETECT_REQUIRED_BODY]) 2>/dev/null], 246 [as_have_required=yes], 247 [as_have_required=no]) 248 AS_IF([test $as_have_required = yes && dnl 249 _AS_RUN([_AS_DETECT_SUGGESTED_BODY]) 2> /dev/null], 250 [], 251 [as_candidate_shells= 252 _AS_PATH_WALK([/bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH], 253 [case $as_dir in 254 /*) 255 for as_base in sh bash ksh sh5; do 256 as_candidate_shells="$as_candidate_shells $as_dir/$as_base" 257 done;; 258 esac]) 259 260 for as_shell in $as_candidate_shells $SHELL; do 261 # Try only shells that exist, to save several forks. 262 AS_IF([{ test -f "$as_shell" || test -f "$as_shell.exe"; } && 263 _AS_RUN([_AS_DETECT_REQUIRED_BODY], 264 [("$as_shell") 2> /dev/null])], 265 [CONFIG_SHELL=$as_shell 266 as_have_required=yes 267 AS_IF([_AS_RUN([_AS_DETECT_SUGGESTED_BODY], ["$as_shell" 2> /dev/null])], 268 [break])]) 269 done 270 271 AS_IF([test "x$CONFIG_SHELL" != x], 272 [for as_var in BASH_ENV ENV 273 do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var 274 done 275 export CONFIG_SHELL 276 exec "$CONFIG_SHELL" "$as_myself" ${1+"$[@]"}]) 277 278 AS_IF([test $as_have_required = no], 279 [echo This script requires a shell more modern than all the 280 echo shells that I found on your system. Please install a 281 echo modern shell, or manually run the script under such a 282 echo shell if you do have one. 283 AS_EXIT(1)]) 284 ]) 285fi 286])])])# _AS_DETECT_BETTER_SHELL 287 288 289# _AS_SHELL_FN_WORK 290# ----------------- 291# This is a spy to detect "in the wild" shells that do not support shell 292# functions correctly. It is based on the m4sh.at Autotest testcases. 293m4_define([_AS_SHELL_FN_WORK], 294[as_func_return () { 295 (exit [$]1) 296} 297as_func_success () { 298 as_func_return 0 299} 300as_func_failure () { 301 as_func_return 1 302} 303as_func_ret_success () { 304 return 0 305} 306as_func_ret_failure () { 307 return 1 308} 309 310exitcode=0 311AS_IF([as_func_success], [], 312 [exitcode=1 313 echo as_func_success failed.]) 314AS_IF([as_func_failure], 315 [exitcode=1 316 echo as_func_failure succeeded.]) 317AS_IF([as_func_ret_success], [], 318 [exitcode=1 319 echo as_func_ret_success failed.]) 320AS_IF([as_func_ret_failure], 321 [exitcode=1 322 echo as_func_ret_failure succeeded.]) 323AS_IF([( set x; as_func_ret_success y && test x = "[$]1" )], [], 324 [exitcode=1 325 echo positional parameters were not saved.]) 326test $exitcode = 0[]dnl 327])# _AS_SHELL_FN_WORK 328 329 330# AS_COPYRIGHT(TEXT) 331# ------------------ 332# Emit TEXT, a copyright notice, as a shell comment near the top of the 333# script. TEXT is evaluated once; to accomplish that, we do not prepend 334# `# ' but `@%:@ '. 335m4_define([AS_COPYRIGHT], 336[m4_divert_text([HEADER-COPYRIGHT], 337[m4_bpatsubst([ 338$1], [^], [@%:@ ])])]) 339 340 341# AS_SHELL_SANITIZE 342# ----------------- 343m4_defun([AS_SHELL_SANITIZE], 344[## --------------------- ## 345## M4sh Initialization. ## 346## --------------------- ## 347 348AS_BOURNE_COMPATIBLE 349 350# PATH needs CR 351_AS_CR_PREPARE 352_AS_PATH_SEPARATOR_PREPARE 353_AS_UNSET_PREPARE 354 355# IFS 356# We need space, tab and new line, in precisely that order. Quoting is 357# there to prevent editors from complaining about space-tab. 358# (If _AS_PATH_WALK were called with IFS unset, it would disable word 359# splitting by setting IFS to empty value.) 360as_nl=' 361' 362IFS=" "" $as_nl" 363 364# Find who we are. Look in the path if we contain no directory separator. 365case $[0] in 366 *[[\\/]]* ) as_myself=$[0] ;; 367 *) _AS_PATH_WALK([], 368 [test -r "$as_dir/$[0]" && as_myself=$as_dir/$[0] && break]) 369 ;; 370esac 371# We did not find ourselves, most probably we were run as `sh COMMAND' 372# in which case we are not to be found in the path. 373if test "x$as_myself" = x; then 374 as_myself=$[0] 375fi 376if test ! -f "$as_myself"; then 377 echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 378 AS_EXIT 379fi 380 381# Work around bugs in pre-3.0 UWIN ksh. 382for as_var in ENV MAIL MAILPATH 383do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var 384done 385PS1='$ ' 386PS2='> ' 387PS4='+ ' 388 389# NLS nuisances. 390for as_var in \ 391 LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ 392 LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ 393 LC_TELEPHONE LC_TIME 394do 395 if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then 396 eval $as_var=C; export $as_var 397 else 398 ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var 399 fi 400done 401 402# Required to use basename. 403_AS_EXPR_PREPARE 404_AS_BASENAME_PREPARE 405 406# Name of the executable. 407as_me=`AS_BASENAME("$[0]")` 408 409# CDPATH. 410$as_unset CDPATH 411])# AS_SHELL_SANITIZE 412 413 414# _AS_PREPARE 415# ----------- 416# This macro has a very special status. Normal use of M4sh relies 417# heavily on AS_REQUIRE, so that needed initializations (such as 418# _AS_TEST_PREPARE) are performed on need, not on demand. But 419# Autoconf is the first client of M4sh, and for two reasons: configure 420# and config.status. Relying on AS_REQUIRE is of course fine for 421# configure, but fails for config.status (which is created by 422# configure). So we need a means to force the inclusion of the 423# various _AS_PREPARE_* on top of config.status. That's basically why 424# there are so many _AS_PREPARE_* below, and that's also why it is 425# important not to forget some: config.status needs them. 426m4_defun([_AS_PREPARE], 427[_AS_LINENO_PREPARE 428 429_AS_DIRNAME_PREPARE 430_AS_ECHO_N_PREPARE 431_AS_EXPR_PREPARE 432_AS_LN_S_PREPARE 433_AS_MKDIR_P_PREPARE 434_AS_TEST_PREPARE 435_AS_TR_CPP_PREPARE 436_AS_TR_SH_PREPARE 437]) 438 439 440# AS_PREPARE 441# ---------- 442# Output all the M4sh possible initialization into the initialization 443# diversion. 444m4_defun([AS_PREPARE], 445[m4_divert_text([M4SH-INIT], [_AS_PREPARE])]) 446 447 448## ----------------------------- ## 449## 2. Wrappers around builtins. ## 450## ----------------------------- ## 451 452# This section is lexicographically sorted. 453 454 455# AS_CASE(WORD, [PATTERN1], [IF-MATCHED1]...[DEFAULT]) 456# ---------------------------------------------------- 457# Expand into 458# | case WORD in 459# | PATTERN1) IF-MATCHED1 ;; 460# | ... 461# | *) DEFAULT ;; 462# | esac 463m4_define([_AS_CASE], 464[m4_if([$#], 0, [m4_fatal([$0: too few arguments: $#])], 465 [$#], 1, [ *) $1 ;;], 466 [$#], 2, [ $1) m4_default([$2], [:]) ;;], 467 [ $1) m4_default([$2], [:]) ;; 468$0(m4_shiftn(2, $@))])dnl 469]) 470m4_defun([AS_CASE], 471[m4_ifval([$2$3], 472[case $1 in 473_AS_CASE(m4_shift($@)) 474esac 475])dnl 476])# AS_CASE 477 478 479# AS_EXIT([EXIT-CODE = 1]) 480# ------------------------ 481# Exit and set exit code to EXIT-CODE in the way that it's seen 482# within "trap 0". 483# 484# We cannot simply use "exit N" because some shells (zsh and Solaris sh) 485# will not set $? to N while running the code set by "trap 0" 486# So we set $? by executing "exit N" in the subshell and then exit. 487# Other shells don't use `$?' as default for `exit', hence just repeating 488# the exit value can only help improving portability. 489m4_define([AS_EXIT], 490[{ (exit m4_default([$1], 1)); exit m4_default([$1], 1); }]) 491 492 493# AS_IF(TEST1, [IF-TRUE1]...[IF-FALSE]) 494# ------------------------------------- 495# Expand into 496# | if TEST1; then 497# | IF-TRUE1 498# | elif TEST2; then 499# | IF-TRUE2 500# [...] 501# | else 502# | IF-FALSE 503# | fi 504# with simplifications if IF-TRUE1 and/or IF-FALSE is empty. 505# 506m4_define([_AS_IF], 507[m4_ifval([$2$3], 508[elif $1; then 509 m4_default([$2], [:]) 510m4_ifval([$3], [$0(m4_shiftn(2, $@))])], 511[m4_ifvaln([$1], 512[else 513 $1])dnl 514])dnl 515])# _AS_IF 516m4_defun([AS_IF], 517[m4_ifval([$2$3], 518[if $1; then 519 m4_default([$2], [:]) 520m4_ifval([$3], [_$0(m4_shiftn(2, $@))])[]dnl 521fi 522])dnl 523])# AS_IF 524 525 526# _AS_UNSET_PREPARE 527# ----------------- 528# AS_UNSET depends upon $as_unset: compute it. 529# Use MAIL to trigger a bug in Bash 2.01; 530# the "|| exit" suppresses the resulting "Segmentation fault" message. 531# Avoid 'if ((', as that triggers a bug in pdksh 5.2.14. 532m4_defun([_AS_UNSET_PREPARE], 533[# Support unset when possible. 534if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then 535 as_unset=unset 536else 537 as_unset=false 538fi 539]) 540 541 542# AS_UNSET(VAR, [VALUE-IF-UNSET-NOT-SUPPORTED = `']) 543# -------------------------------------------------- 544# Try to unset the env VAR, otherwise set it to 545# VALUE-IF-UNSET-NOT-SUPPORTED. `as_unset' must have been computed. 546m4_defun([AS_UNSET], 547[AS_REQUIRE([_AS_UNSET_PREPARE])dnl 548$as_unset $1 || test "${$1+set}" != set || { $1=$2; export $1; }]) 549 550 551 552 553 554 555## ------------------------------------------ ## 556## 3. Error and warnings at the shell level. ## 557## ------------------------------------------ ## 558 559# If AS_MESSAGE_LOG_FD is defined, shell messages are duplicated there 560# too. 561 562 563# AS_ESCAPE(STRING, [CHARS = $"`\]) 564# --------------------------------- 565# Escape the CHARS in STRING. 566m4_define([AS_ESCAPE], 567[m4_bpatsubst([$1], 568 m4_dquote(m4_default([$2], [\"$`])), 569 [\\\&])]) 570 571 572# _AS_QUOTE_IFELSE(STRING, IF-MODERN-QUOTATION, IF-OLD-QUOTATION) 573# --------------------------------------------------------------- 574# Compatibility glue between the old AS_MSG suite which did not 575# quote anything, and the modern suite which quotes the quotes. 576# If STRING contains `\\' or `\$', it's modern. 577# If STRING contains `\"' or `\`', it's old. 578# Otherwise it's modern. 579# We use two quotes in the pattern to keep highlighting tools at peace. 580m4_define([_AS_QUOTE_IFELSE], 581[m4_bmatch([$1], 582 [\\[\\$]], [$2], 583 [\\[`""]], [$3], 584 [$2])]) 585 586 587# _AS_QUOTE(STRING, [CHARS = `"]) 588# ------------------------------- 589# If there are quoted (via backslash) backquotes do nothing, else 590# backslash all the quotes. 591m4_define([_AS_QUOTE], 592[_AS_QUOTE_IFELSE([$1], 593 [AS_ESCAPE([$1], m4_default([$2], [`""]))], 594 [m4_warn([obsolete], 595 [back quotes and double quotes must not be escaped in: $1])dnl 596$1])]) 597 598 599# _AS_ECHO_UNQUOTED(STRING, [FD = AS_MESSAGE_FD]) 600# ----------------------------------------------- 601# Perform shell expansions on STRING and echo the string to FD. 602m4_define([_AS_ECHO_UNQUOTED], 603[echo "$1" >&m4_default([$2], [AS_MESSAGE_FD])]) 604 605 606# _AS_ECHO(STRING, [FD = AS_MESSAGE_FD]) 607# -------------------------------------- 608# Protect STRING from backquote expansion, echo the result to FD. 609m4_define([_AS_ECHO], 610[_AS_ECHO_UNQUOTED([_AS_QUOTE([$1])], [$2])]) 611 612 613# _AS_ECHO_LOG(STRING) 614# -------------------- 615# Log the string to AS_MESSAGE_LOG_FD. 616m4_define([_AS_ECHO_LOG], 617[_AS_ECHO([$as_me:$LINENO: $1], [AS_MESSAGE_LOG_FD])]) 618 619 620# _AS_ECHO_N_PREPARE 621# ------------------ 622# Check whether to use -n, \c, or newline-tab to separate 623# checking messages from result messages. 624# Don't try to cache, since the results of this macro are needed to 625# display the checking message. In addition, caching something used once 626# has little interest. 627# Idea borrowed from dist 3.0. Use `*c*,', not `*c,' because if `\c' 628# failed there is also a newline to match. 629m4_defun([_AS_ECHO_N_PREPARE], 630[ECHO_C= ECHO_N= ECHO_T= 631case `echo -n x` in 632-n*) 633 case `echo 'x\c'` in 634 *c*) ECHO_T=' ';; # ECHO_T is single tab character. 635 *) ECHO_C='\c';; 636 esac;; 637*) 638 ECHO_N='-n';; 639esac 640])# _AS_ECHO_N_PREPARE 641 642 643# _AS_ECHO_N(STRING, [FD = AS_MESSAGE_FD]) 644# ---------------------------------------- 645# Same as _AS_ECHO, but echo doesn't return to a new line. 646m4_define([_AS_ECHO_N], 647[AS_REQUIRE([_AS_ECHO_N_PREPARE])dnl 648echo $ECHO_N "_AS_QUOTE([$1])$ECHO_C" >&m4_default([$2], 649 [AS_MESSAGE_FD])]) 650 651 652# AS_MESSAGE(STRING, [FD = AS_MESSAGE_FD]) 653# ---------------------------------------- 654m4_define([AS_MESSAGE], 655[m4_ifset([AS_MESSAGE_LOG_FD], 656 [{ _AS_ECHO_LOG([$1]) 657_AS_ECHO([$as_me: $1], [$2]);}], 658 [_AS_ECHO([$as_me: $1], [$2])])[]dnl 659]) 660 661 662# AS_WARN(PROBLEM) 663# ---------------- 664m4_define([AS_WARN], 665[AS_MESSAGE([WARNING: $1], [2])])# AS_WARN 666 667 668# AS_ERROR(ERROR, [EXIT-STATUS = 1]) 669# ---------------------------------- 670m4_define([AS_ERROR], 671[{ AS_MESSAGE([error: $1], [2]) 672 AS_EXIT([$2]); }[]dnl 673])# AS_ERROR 674 675 676 677## -------------------------------------- ## 678## 4. Portable versions of common tools. ## 679## -------------------------------------- ## 680 681# This section is lexicographically sorted. 682 683 684# AS_BASENAME(FILE-NAME) 685# ---------------------- 686# Simulate the command 'basename FILE-NAME'. Not all systems have basename. 687# Also see the comments for AS_DIRNAME. 688 689m4_defun([_AS_BASENAME_EXPR], 690[AS_REQUIRE([_AS_EXPR_PREPARE])dnl 691$as_expr X/[]$1 : '.*/\([[^/][^/]*]\)/*$' \| \ 692 X[]$1 : 'X\(//\)$' \| \ 693 X[]$1 : 'X\(/\)' \| .]) 694 695m4_defun([_AS_BASENAME_SED], 696[echo X/[]$1 | 697 sed ['/^.*\/\([^/][^/]*\)\/*$/{ 698 s//\1/ 699 q 700 } 701 /^X\/\(\/\/\)$/{ 702 s//\1/ 703 q 704 } 705 /^X\/\(\/\).*/{ 706 s//\1/ 707 q 708 } 709 s/.*/./; q']]) 710 711m4_defun([AS_BASENAME], 712[AS_REQUIRE([_$0_PREPARE])dnl 713$as_basename -- $1 || 714_AS_BASENAME_EXPR([$1]) 2>/dev/null || 715_AS_BASENAME_SED([$1])]) 716 717 718# _AS_BASENAME_PREPARE 719# -------------------- 720# Avoid Solaris 9 /usr/ucb/basename, as `basename /' outputs an empty line. 721# Also, traditional basename mishandles --. 722m4_defun([_AS_BASENAME_PREPARE], 723[if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then 724 as_basename=basename 725else 726 as_basename=false 727fi 728])# _AS_BASENAME_PREPARE 729 730 731# AS_DIRNAME(FILE-NAME) 732# --------------------- 733# Simulate the command 'dirname FILE-NAME'. Not all systems have dirname. 734# This macro must be usable from inside ` `. 735# 736# Prefer expr to echo|sed, since expr is usually faster and it handles 737# backslashes and newlines correctly. However, older expr 738# implementations (e.g. SunOS 4 expr and Solaris 8 /usr/ucb/expr) have 739# a silly length limit that causes expr to fail if the matched 740# substring is longer than 120 bytes. So fall back on echo|sed if 741# expr fails. 742m4_defun([_AS_DIRNAME_EXPR], 743[AS_REQUIRE([_AS_EXPR_PREPARE])dnl 744$as_expr X[]$1 : 'X\(.*[[^/]]\)//*[[^/][^/]]*/*$' \| \ 745 X[]$1 : 'X\(//\)[[^/]]' \| \ 746 X[]$1 : 'X\(//\)$' \| \ 747 X[]$1 : 'X\(/\)' \| .]) 748 749m4_defun([_AS_DIRNAME_SED], 750[echo X[]$1 | 751 sed ['/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ 752 s//\1/ 753 q 754 } 755 /^X\(\/\/\)[^/].*/{ 756 s//\1/ 757 q 758 } 759 /^X\(\/\/\)$/{ 760 s//\1/ 761 q 762 } 763 /^X\(\/\).*/{ 764 s//\1/ 765 q 766 } 767 s/.*/./; q']]) 768 769m4_defun([AS_DIRNAME], 770[AS_REQUIRE([_$0_PREPARE])dnl 771$as_dirname -- $1 || 772_AS_DIRNAME_EXPR([$1]) 2>/dev/null || 773_AS_DIRNAME_SED([$1])]) 774 775 776# _AS_DIRNAME_PREPARE 777# -------------------- 778m4_defun([_AS_DIRNAME_PREPARE], 779[if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then 780 as_dirname=dirname 781else 782 as_dirname=false 783fi 784])# _AS_DIRNAME_PREPARE 785 786 787# AS_TEST_X 788# --------- 789# Check whether a file has executable or search permissions. 790m4_defun([AS_TEST_X], 791[AS_REQUIRE([_AS_TEST_PREPARE])dnl 792$as_test_x $1[]dnl 793])# AS_TEST_X 794 795 796# AS_EXECUTABLE_P 797# --------------- 798# Check whether a file is a regular file that has executable permissions. 799m4_defun([AS_EXECUTABLE_P], 800[AS_REQUIRE([_AS_TEST_PREPARE])dnl 801{ test -f $1 && AS_TEST_X([$1]); }dnl 802])# AS_EXECUTABLE_P 803 804 805# _AS_EXPR_PREPARE 806# ---------------- 807# QNX 4.25 expr computes and issue the right result but exits with failure. 808# Tru64 expr mishandles leading zeros in numeric strings. 809# Detect these flaws. 810m4_defun([_AS_EXPR_PREPARE], 811[if expr a : '\(a\)' >/dev/null 2>&1 && 812 test "X`expr 00001 : '.*\(...\)'`" = X001; then 813 as_expr=expr 814else 815 as_expr=false 816fi 817])# _AS_EXPR_PREPARE 818 819 820# _AS_LINENO_WORKS 821# --------------- 822# Succeed if the currently executing shell supports LINENO. 823# This macro does not expand to a single shell command, so be careful 824# when using it. Surrounding the body of this macro with {} would 825# cause "bash -c '_ASLINENO_WORKS'" to fail (with Bash 2.05, anyway), 826# but that bug is irrelevant to our use of LINENO. 827m4_define([_AS_LINENO_WORKS], 828[ 829 as_lineno_1=$LINENO 830 as_lineno_2=$LINENO 831 test "x$as_lineno_1" != "x$as_lineno_2" && 832 test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2"]) 833 834 835# _AS_LINENO_PREPARE 836# ------------------ 837# If LINENO is not supported by the shell, produce a version of this 838# script where LINENO is hard coded. 839# Comparing LINENO against _oline_ is not a good solution, since in 840# the case of embedded executables (such as config.status within 841# configure) you'd compare LINENO wrt config.status vs. _oline_ wrt 842# configure. 843m4_define([_AS_LINENO_PREPARE], 844[AS_REQUIRE([_AS_CR_PREPARE])dnl 845_AS_DETECT_SUGGESTED([_AS_LINENO_WORKS]) 846_AS_LINENO_WORKS || { 847 848 # Create $as_me.lineno as a copy of $as_myself, but with $LINENO 849 # uniformly replaced by the line number. The first 'sed' inserts a 850 # line-number line after each line using $LINENO; the second 'sed' 851 # does the real work. The second script uses 'N' to pair each 852 # line-number line with the line containing $LINENO, and appends 853 # trailing '-' during substitution so that $LINENO is not a special 854 # case at line end. 855 # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the 856 # scripts with optimization help from Paolo Bonzini. Blame Lee 857 # E. McMahon (1931-1989) for sed's syntax. :-) 858 sed -n ' 859 p 860 /[[$]]LINENO/= 861 ' <$as_myself | 862 sed ' 863 s/[[$]]LINENO.*/&-/ 864 t lineno 865 b 866 :lineno 867 N 868 :loop 869 s/[[$]]LINENO\([[^'$as_cr_alnum'_]].*\n\)\(.*\)/\2\1\2/ 870 t loop 871 s/-\n.*// 872 ' >$as_me.lineno && 873 chmod +x "$as_me.lineno" || 874 AS_ERROR([cannot create $as_me.lineno; rerun with a POSIX shell]) 875 876 # Don't try to exec as it changes $[0], causing all sort of problems 877 # (the dirname of $[0] is not the place where we might find the 878 # original and so on. Autoconf is especially sensitive to this). 879 . "./$as_me.lineno" 880 # Exit status is that of the last command. 881 exit 882} 883])# _AS_LINENO_PREPARE 884 885 886# _AS_LN_S_PREPARE 887# ---------------- 888# Don't use conftest.sym to avoid file name issues on DJGPP, where this 889# would yield conftest.sym.exe for DJGPP < 2.04. And don't use `conftest' 890# as base name to avoid prohibiting concurrency (e.g., concurrent 891# config.statuses). 892m4_defun([_AS_LN_S_PREPARE], 893[rm -f conf$$ conf$$.exe conf$$.file 894if test -d conf$$.dir; then 895 rm -f conf$$.dir/conf$$.file 896else 897 rm -f conf$$.dir 898 mkdir conf$$.dir 899fi 900echo >conf$$.file 901if ln -s conf$$.file conf$$ 2>/dev/null; then 902 as_ln_s='ln -s' 903 # ... but there are two gotchas: 904 # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. 905 # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. 906 # In both cases, we have to default to `cp -p'. 907 ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || 908 as_ln_s='cp -p' 909elif ln conf$$.file conf$$ 2>/dev/null; then 910 as_ln_s=ln 911else 912 as_ln_s='cp -p' 913fi 914rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file 915rmdir conf$$.dir 2>/dev/null 916])# _AS_LN_S_PREPARE 917 918 919# AS_LN_S(FILE, LINK) 920# ------------------- 921# FIXME: Should we add the glue code to handle properly relative symlinks 922# simulated with `ln' or `cp'? 923m4_defun([AS_LN_S], 924[AS_REQUIRE([_AS_LN_S_PREPARE])dnl 925$as_ln_s $1 $2 926]) 927 928 929# AS_MKDIR_P(DIR) 930# --------------- 931# Emulate `mkdir -p' with plain `mkdir'. 932m4_define([AS_MKDIR_P], 933[AS_REQUIRE([_$0_PREPARE])dnl 934{ as_dir=$1 935 case $as_dir in #( 936 -*) as_dir=./$as_dir;; 937 esac 938 test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { 939 as_dirs= 940 while :; do 941 case $as_dir in #( 942 *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( 943 *) as_qdir=$as_dir;; 944 esac 945 as_dirs="'$as_qdir' $as_dirs" 946 as_dir=`AS_DIRNAME("$as_dir")` 947 test -d "$as_dir" && break 948 done 949 test -z "$as_dirs" || eval "mkdir $as_dirs" 950 } || test -d "$as_dir" || AS_ERROR([cannot create directory $as_dir]); }dnl 951])# AS_MKDIR_P 952 953 954# _AS_MKDIR_P_PREPARE 955# ------------------- 956m4_defun([_AS_MKDIR_P_PREPARE], 957[if mkdir -p . 2>/dev/null; then 958 as_mkdir_p=: 959else 960 test -d ./-p && rmdir ./-p 961 as_mkdir_p=false 962fi 963])# _AS_MKDIR_P_PREPARE 964 965 966# _AS_PATH_SEPARATOR_PREPARE 967# -------------------------- 968# Compute the path separator. 969m4_defun([_AS_PATH_SEPARATOR_PREPARE], 970[# The user is always right. 971if test "${PATH_SEPARATOR+set}" != set; then 972 echo "#! /bin/sh" >conf$$.sh 973 echo "exit 0" >>conf$$.sh 974 chmod +x conf$$.sh 975 if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then 976 PATH_SEPARATOR=';' 977 else 978 PATH_SEPARATOR=: 979 fi 980 rm -f conf$$.sh 981fi 982])# _AS_PATH_SEPARATOR_PREPARE 983 984 985# _AS_PATH_WALK([PATH = $PATH], BODY) 986# ----------------------------------- 987# Walk through PATH running BODY for each `as_dir'. 988# 989# Still very private as its interface looks quite bad. 990# 991# `$as_dummy' forces splitting on constant user-supplied paths. 992# POSIX.2 field splitting is done only on the result of word 993# expansions, not on literal text. This closes a longstanding sh security 994# hole. Optimize it away when not needed, i.e., if there are no literal 995# path separators. 996m4_define([_AS_PATH_WALK], 997[AS_REQUIRE([_AS_PATH_SEPARATOR_PREPARE])dnl 998as_save_IFS=$IFS; IFS=$PATH_SEPARATOR 999m4_bmatch([$1], [[:;]], 1000[as_dummy="$1" 1001for as_dir in $as_dummy], 1002[for as_dir in m4_default([$1], [$PATH])]) 1003do 1004 IFS=$as_save_IFS 1005 test -z "$as_dir" && as_dir=. 1006 $2 1007done 1008IFS=$as_save_IFS 1009]) 1010 1011 1012# AS_SET_CATFILE(VAR, DIR-NAME, FILE-NAME) 1013# ---------------------------------------- 1014# Set VAR to DIR-NAME/FILE-NAME. 1015# Optimize the common case where $2 or $3 is '.'. 1016m4_define([AS_SET_CATFILE], 1017[case $2 in 1018.) $1=$3;; 1019*) 1020 case $3 in 1021 .) $1=$2;; 1022 [[\\/]]* | ?:[[\\/]]* ) $1=$3;; 1023 *) $1=$2/$3;; 1024 esac;; 1025esac[]dnl 1026])# AS_SET_CATFILE 1027 1028 1029# _AS_TEST_PREPARE 1030# ---------------- 1031# Find out whether `test -x' works. If not, prepare a substitute 1032# that should work well enough for most scripts. 1033# 1034# Here are some of the problems with the substitute. 1035# The 'ls' tests whether the owner, not the current user, can execute/search. 1036# The eval means '*', '?', and '[' cause inadvertent file name globbing 1037# after the 'eval', so jam together as many tokens as we can to minimize 1038# the likelihood that the inadvertent globbing will actually do anything. 1039# Luckily, this gorp is needed only on really ancient hosts. 1040# 1041m4_defun([_AS_TEST_PREPARE], 1042[if test -x / >/dev/null 2>&1; then 1043 as_test_x='test -x' 1044else 1045 if ls -dL / >/dev/null 2>&1; then 1046 as_ls_L_option=L 1047 else 1048 as_ls_L_option= 1049 fi 1050 as_test_x=' 1051 eval sh -c '\'' 1052 if test -d "$[]1"; then 1053 test -d "$[]1/."; 1054 else 1055 case $[]1 in 1056 -*)set "./$[]1";; 1057 esac; 1058 case `ls -ld'$as_ls_L_option' "$[]1" 2>/dev/null` in 1059 ???[[sx]]*):;;*)false;;esac;fi 1060 '\'' sh 1061 ' 1062fi 1063dnl as_executable_p is present for backward compatibility with Libtool 1064dnl 1.5.22, but it should go away at some point. 1065as_executable_p=$as_test_x 1066])# _AS_TEST_PREPARE 1067 1068 1069 1070 1071## ------------------ ## 1072## 5. Common idioms. ## 1073## ------------------ ## 1074 1075# This section is lexicographically sorted. 1076 1077 1078# AS_BOX(MESSAGE, [FRAME-CHARACTER = `-']) 1079# ---------------------------------------- 1080# Output MESSAGE, a single line text, framed with FRAME-CHARACTER (which 1081# must not be `/'). 1082m4_define([AS_BOX], 1083[AS_LITERAL_IF([$1], 1084 [_AS_BOX_LITERAL($@)], 1085 [_AS_BOX_INDIR($@)])]) 1086 1087 1088# _AS_BOX_LITERAL(MESSAGE, [FRAME-CHARACTER = `-']) 1089# ------------------------------------------------- 1090m4_define([_AS_BOX_LITERAL], 1091[cat <<\_ASBOX 1092m4_text_box($@) 1093_ASBOX]) 1094 1095 1096# _AS_BOX_INDIR(MESSAGE, [FRAME-CHARACTER = `-']) 1097# ----------------------------------------------- 1098m4_define([_AS_BOX_INDIR], 1099[sed 'h;s/./m4_default([$2], [-])/g;s/^.../@%:@@%:@ /;s/...$/ @%:@@%:@/;p;x;p;x' <<_ASBOX 1100@%:@@%:@ $1 @%:@@%:@ 1101_ASBOX]) 1102 1103 1104# AS_HELP_STRING(LHS, RHS, [COLUMN]) 1105# ---------------------------------- 1106# 1107# Format a help string so that it looks pretty when 1108# the user executes "script --help". This macro takes three 1109# arguments, a "left hand side" (LHS), a "right hand side" (RHS), and 1110# the COLUMN which is a string of white spaces which leads to the 1111# the RHS column (default: 26 white spaces). 1112# 1113# The resulting string is suitable for use in other macros that require 1114# a help string (e.g. AC_ARG_WITH). 1115# 1116# Here is the sample string from the Autoconf manual (Node: External 1117# Software) which shows the proper spacing for help strings. 1118# 1119# --with-readline support fancy command line editing 1120# ^ ^ ^ 1121# | | | 1122# | column 2 column 26 1123# | 1124# column 0 1125# 1126# A help string is made up of a "left hand side" (LHS) and a "right 1127# hand side" (RHS). In the example above, the LHS is 1128# "--with-readline", while the RHS is "support fancy command line 1129# editing". 1130# 1131# If the LHS contains more than (COLUMN - 3) characters, then the LHS is 1132# terminated with a newline so that the RHS starts on a line of its own 1133# beginning with COLUMN. In the default case, this corresponds to an 1134# LHS with more than 23 characters. 1135# 1136# Therefore, in the example, if the LHS were instead 1137# "--with-readline-blah-blah-blah", then the AS_HELP_STRING macro would 1138# expand into: 1139# 1140# 1141# --with-readline-blah-blah-blah 1142# ^ ^ support fancy command line editing 1143# | | ^ 1144# | column 2 | 1145# column 0 column 26 1146# 1147# 1148# m4_text_wrap hacks^Wworks around the fact that m4_format does not 1149# know quadrigraphs. 1150# 1151m4_define([AS_HELP_STRING], 1152[m4_pushdef([AS_Prefix], m4_default([$3], [ ]))dnl 1153m4_pushdef([AS_Prefix_Format], 1154 [ %-]m4_eval(m4_len(AS_Prefix) - 3)[s ])dnl [ %-23s ] 1155m4_text_wrap([$2], AS_Prefix, m4_format(AS_Prefix_Format, [$1]))dnl 1156m4_popdef([AS_Prefix_Format])dnl 1157m4_popdef([AS_Prefix])dnl 1158])# AS_HELP_STRING 1159 1160 1161# AS_LITERAL_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL) 1162# ----------------------------------------------------- 1163# If EXPRESSION has shell indirections ($var or `expr`), expand 1164# IF-INDIR, else IF-NOT-INDIR. 1165# This is an *approximation*: for instance EXPRESSION = `\$' is 1166# definitely a literal, but will not be recognized as such. 1167m4_define([AS_LITERAL_IF], 1168[m4_bmatch(m4_quote($1), [[`$]], 1169 [$3], [$2])]) 1170 1171 1172# AS_TMPDIR(PREFIX, [DIRECTORY = $TMPDIR [= /tmp]]) 1173# ------------------------------------------------- 1174# Create as safely as possible a temporary directory in DIRECTORY 1175# which name is inspired by PREFIX (should be 2-4 chars max). 1176m4_define([AS_TMPDIR], 1177[# Create a (secure) tmp directory for tmp files. 1178m4_if([$2], [], [: ${TMPDIR=/tmp}]) 1179{ 1180 tmp=`(umask 077 && mktemp -d "m4_default([$2], [$TMPDIR])/$1XXXXXX") 2>/dev/null` && 1181 test -n "$tmp" && test -d "$tmp" 1182} || 1183{ 1184 tmp=m4_default([$2], [$TMPDIR])/$1$$-$RANDOM 1185 (umask 077 && mkdir "$tmp") 1186} || 1187{ 1188 echo "$me: cannot create a temporary directory in m4_default([$2], [$TMPDIR])" >&2 1189 AS_EXIT 1190}dnl 1191])# AS_TMPDIR 1192 1193 1194# AS_UNAME 1195# -------- 1196# Try to describe this machine. Meant for logs. 1197m4_define([AS_UNAME], 1198[{ 1199cat <<_ASUNAME 1200m4_text_box([Platform.]) 1201 1202hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` 1203uname -m = `(uname -m) 2>/dev/null || echo unknown` 1204uname -r = `(uname -r) 2>/dev/null || echo unknown` 1205uname -s = `(uname -s) 2>/dev/null || echo unknown` 1206uname -v = `(uname -v) 2>/dev/null || echo unknown` 1207 1208/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` 1209/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` 1210 1211/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` 1212/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` 1213/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` 1214/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` 1215/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` 1216/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` 1217/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` 1218 1219_ASUNAME 1220 1221_AS_PATH_WALK([$PATH], [echo "PATH: $as_dir"]) 1222}]) 1223 1224 1225# _AS_VERSION_COMPARE_PREPARE 1226# --------------------------- 1227# Output variables for comparing version numbers. 1228m4_defun([_AS_VERSION_COMPARE_PREPARE], 1229[[as_awk_strverscmp=' 1230 # Use only awk features that work with 7th edition Unix awk (1978). 1231 # My, what an old awk you have, Mr. Solaris! 1232 END { 1233 while (length(v1) && length(v2)) { 1234 # Set d1 to be the next thing to compare from v1, and likewise for d2. 1235 # Normally this is a single character, but if v1 and v2 contain digits, 1236 # compare them as integers and fractions as strverscmp does. 1237 if (v1 ~ /^[0-9]/ && v2 ~ /^[0-9]/) { 1238 # Split v1 and v2 into their leading digit string components d1 and d2, 1239 # and advance v1 and v2 past the leading digit strings. 1240 for (len1 = 1; substr(v1, len1 + 1) ~ /^[0-9]/; len1++) continue 1241 for (len2 = 1; substr(v2, len2 + 1) ~ /^[0-9]/; len2++) continue 1242 d1 = substr(v1, 1, len1); v1 = substr(v1, len1 + 1) 1243 d2 = substr(v2, 1, len2); v2 = substr(v2, len2 + 1) 1244 if (d1 ~ /^0/) { 1245 if (d2 ~ /^0/) { 1246 # Compare two fractions. 1247 while (d1 ~ /^0/ && d2 ~ /^0/) { 1248 d1 = substr(d1, 2); len1-- 1249 d2 = substr(d2, 2); len2-- 1250 } 1251 if (len1 != len2 && ! (len1 && len2 && substr(d1, 1, 1) == substr(d2, 1, 1))) { 1252 # The two components differ in length, and the common prefix 1253 # contains only leading zeros. Consider the longer to be less. 1254 d1 = -len1 1255 d2 = -len2 1256 } else { 1257 # Otherwise, compare as strings. 1258 d1 = "x" d1 1259 d2 = "x" d2 1260 } 1261 } else { 1262 # A fraction is less than an integer. 1263 exit 1 1264 } 1265 } else { 1266 if (d2 ~ /^0/) { 1267 # An integer is greater than a fraction. 1268 exit 2 1269 } else { 1270 # Compare two integers. 1271 d1 += 0 1272 d2 += 0 1273 } 1274 } 1275 } else { 1276 # The normal case, without worrying about digits. 1277 d1 = substr(v1, 1, 1); v1 = substr(v1, 2) 1278 d2 = substr(v2, 1, 1); v2 = substr(v2, 2) 1279 } 1280 if (d1 < d2) exit 1 1281 if (d1 > d2) exit 2 1282 } 1283 # Beware Solaris /usr/xgp4/bin/awk (at least through Solaris 10), 1284 # which mishandles some comparisons of empty strings to integers. 1285 if (length(v2)) exit 1 1286 if (length(v1)) exit 2 1287 } 1288']])# _AS_VERSION_COMPARE_PREPARE 1289 1290 1291# AS_VERSION_COMPARE(VERSION-1, VERSION-2, 1292# [ACTION-IF-LESS], [ACTION-IF-EQUAL], [ACTION-IF-GREATER]) 1293# ----------------------------------------------------------------------------- 1294# Compare two strings possibly containing shell variables as version strings. 1295m4_defun([AS_VERSION_COMPARE], 1296[AS_REQUIRE([_$0_PREPARE])dnl 1297as_arg_v1=$1 1298as_arg_v2=$2 1299dnl This usage is portable even to ancient awk, 1300dnl so don't worry about finding a "nice" awk version. 1301awk "$as_awk_strverscmp" v1="$as_arg_v1" v2="$as_arg_v2" /dev/null 1302case $? in 13031) $3;; 13040) $4;; 13052) $5;; 1306esac[]dnl 1307])# _AS_VERSION_COMPARE 1308 1309 1310 1311## ------------------------------------ ## 1312## Common m4/sh character translation. ## 1313## ------------------------------------ ## 1314 1315# The point of this section is to provide high level macros comparable 1316# to m4's `translit' primitive, but m4/sh polymorphic. 1317# Transliteration of literal strings should be handled by m4, while 1318# shell variables' content will be translated at runtime (tr or sed). 1319 1320 1321# _AS_CR_PREPARE 1322# -------------- 1323# Output variables defining common character ranges. 1324# See m4_cr_letters etc. 1325m4_defun([_AS_CR_PREPARE], 1326[# Avoid depending upon Character Ranges. 1327as_cr_letters='abcdefghijklmnopqrstuvwxyz' 1328as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' 1329as_cr_Letters=$as_cr_letters$as_cr_LETTERS 1330as_cr_digits='0123456789' 1331as_cr_alnum=$as_cr_Letters$as_cr_digits 1332]) 1333 1334 1335# _AS_TR_SH_PREPARE 1336# ----------------- 1337m4_defun([_AS_TR_SH_PREPARE], 1338[AS_REQUIRE([_AS_CR_PREPARE])dnl 1339# Sed expression to map a string onto a valid variable name. 1340as_tr_sh="eval sed 'y%*+%pp%;s%[[^_$as_cr_alnum]]%_%g'" 1341]) 1342 1343 1344# AS_TR_SH(EXPRESSION) 1345# -------------------- 1346# Transform EXPRESSION into a valid shell variable name. 1347# sh/m4 polymorphic. 1348# Be sure to update the definition of `$as_tr_sh' if you change this. 1349m4_defun([AS_TR_SH], 1350[AS_REQUIRE([_$0_PREPARE])dnl 1351AS_LITERAL_IF([$1], 1352 [m4_bpatsubst(m4_translit([[$1]], [*+], [pp]), 1353 [[^a-zA-Z0-9_]], [_])], 1354 [`echo "$1" | $as_tr_sh`])]) 1355 1356 1357# _AS_TR_CPP_PREPARE 1358# ------------------ 1359m4_defun([_AS_TR_CPP_PREPARE], 1360[AS_REQUIRE([_AS_CR_PREPARE])dnl 1361# Sed expression to map a string onto a valid CPP name. 1362as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[[^_$as_cr_alnum]]%_%g'" 1363]) 1364 1365 1366# AS_TR_CPP(EXPRESSION) 1367# --------------------- 1368# Map EXPRESSION to an upper case string which is valid as rhs for a 1369# `#define'. sh/m4 polymorphic. Be sure to update the definition 1370# of `$as_tr_cpp' if you change this. 1371m4_defun([AS_TR_CPP], 1372[AS_REQUIRE([_$0_PREPARE])dnl 1373AS_LITERAL_IF([$1], 1374 [m4_bpatsubst(m4_translit([[$1]], 1375 [*abcdefghijklmnopqrstuvwxyz], 1376 [PABCDEFGHIJKLMNOPQRSTUVWXYZ]), 1377 [[^A-Z0-9_]], [_])], 1378 [`echo "$1" | $as_tr_cpp`])]) 1379 1380 1381# _AS_TR_PREPARE 1382# -------------- 1383m4_defun([_AS_TR_PREPARE], 1384[AS_REQUIRE([_AS_TR_SH_PREPARE])dnl 1385AS_REQUIRE([_AS_TR_CPP_PREPARE])dnl 1386]) 1387 1388 1389 1390 1391## --------------------------------------------------- ## 1392## Common m4/sh handling of variables (indirections). ## 1393## --------------------------------------------------- ## 1394 1395 1396# The purpose of this section is to provide a uniform API for 1397# reading/setting sh variables with or without indirection. 1398# Typically, one can write 1399# AS_VAR_SET(var, val) 1400# or 1401# AS_VAR_SET(as_$var, val) 1402# and expect the right thing to happen. 1403 1404 1405# AS_VAR_SET(VARIABLE, VALUE) 1406# --------------------------- 1407# Set the VALUE of the shell VARIABLE. 1408# If the variable contains indirections (e.g. `ac_cv_func_$ac_func') 1409# perform whenever possible at m4 level, otherwise sh level. 1410m4_define([AS_VAR_SET], 1411[AS_LITERAL_IF([$1], 1412 [$1=$2], 1413 [eval "$1=AS_ESCAPE([$2])"])]) 1414 1415 1416# AS_VAR_GET(VARIABLE) 1417# -------------------- 1418# Get the value of the shell VARIABLE. 1419# Evaluates to $VARIABLE if there are no indirection in VARIABLE, 1420# else into the appropriate `eval' sequence. 1421# FIXME: This mishandles values that end in newlines, or have backslashes, 1422# or are '-n'. Fixing this will require changing the API. 1423m4_define([AS_VAR_GET], 1424[AS_LITERAL_IF([$1], 1425 [$$1], 1426 [`eval echo '${'m4_bpatsubst($1, [[\\`]], [\\\&])'}'`])]) 1427 1428 1429# AS_VAR_TEST_SET(VARIABLE) 1430# ------------------------- 1431# Expands into the `test' expression which is true if VARIABLE 1432# is set. Polymorphic. Should be dnl'ed. 1433m4_define([AS_VAR_TEST_SET], 1434[AS_LITERAL_IF([$1], 1435 [test "${$1+set}" = set], 1436 [{ as_var=$1; eval "test \"\${$as_var+set}\" = set"; }])]) 1437 1438 1439# AS_VAR_SET_IF(VARIABLE, IF-TRUE, IF-FALSE) 1440# ------------------------------------------ 1441# Implement a shell `if-then-else' depending whether VARIABLE is set 1442# or not. Polymorphic. 1443m4_define([AS_VAR_SET_IF], 1444[AS_IF([AS_VAR_TEST_SET([$1])], [$2], [$3])]) 1445 1446 1447# AS_VAR_PUSHDEF and AS_VAR_POPDEF 1448# -------------------------------- 1449# 1450 1451# Sometimes we may have to handle literals (e.g. `stdlib.h'), while at 1452# other moments, the same code may have to get the value from a 1453# variable (e.g., `ac_header'). To have a uniform handling of both 1454# cases, when a new value is about to be processed, declare a local 1455# variable, e.g.: 1456# 1457# AS_VAR_PUSHDEF([header], [ac_cv_header_$1]) 1458# 1459# and then in the body of the macro, use `header' as is. It is of 1460# first importance to use `AS_VAR_*' to access this variable. Don't 1461# quote its name: it must be used right away by m4. 1462# 1463# If the value `$1' was a literal (e.g. `stdlib.h'), then `header' is 1464# in fact the value `ac_cv_header_stdlib_h'. If `$1' was indirect, 1465# then `header's value in m4 is in fact `$ac_header', the shell 1466# variable that holds all of the magic to get the expansion right. 1467# 1468# At the end of the block, free the variable with 1469# 1470# AS_VAR_POPDEF([header]) 1471 1472 1473# AS_VAR_PUSHDEF(VARNAME, VALUE) 1474# ------------------------------ 1475# Define the m4 macro VARNAME to an accessor to the shell variable 1476# named VALUE. VALUE does not need to be a valid shell variable name: 1477# the transliteration is handled here. To be dnl'ed. 1478m4_define([AS_VAR_PUSHDEF], 1479[AS_LITERAL_IF([$2], 1480 [m4_pushdef([$1], [AS_TR_SH($2)])], 1481 [as_$1=AS_TR_SH($2) 1482m4_pushdef([$1], [$as_[$1]])])]) 1483 1484 1485# AS_VAR_POPDEF(VARNAME) 1486# ---------------------- 1487# Free the shell variable accessor VARNAME. To be dnl'ed. 1488m4_define([AS_VAR_POPDEF], 1489[m4_popdef([$1])]) 1490 1491 1492## ----------------- ## 1493## Setting M4sh up. ## 1494## ----------------- ## 1495 1496 1497# _AS_SHELL_FN_SPY 1498# ---------------- 1499# This temporary macro checks "in the wild" for shells that do 1500# not support shell functions. 1501m4_define([_AS_SHELL_FN_SPY], 1502[_AS_DETECT_SUGGESTED([_AS_SHELL_FN_WORK]) 1503_AS_RUN([_AS_SHELL_FN_WORK]) || { 1504 echo No shell found that supports shell functions. 1505 echo Please tell autoconf@gnu.org about your system, 1506 echo including any error possibly output before this 1507 echo message 1508} 1509]) 1510 1511 1512# AS_INIT 1513# ------- 1514# Initialize m4sh. 1515m4_define([AS_INIT], 1516[m4_init 1517 1518# Forbidden tokens and exceptions. 1519m4_pattern_forbid([^_?AS_]) 1520 1521# Bangshe and minimal initialization. 1522m4_divert_text([BINSH], [@%:@! /bin/sh]) 1523m4_divert_text([M4SH-SANITIZE], [AS_SHELL_SANITIZE]) 1524AS_REQUIRE([_AS_SHELL_FN_SPY]) 1525 1526# Let's go! 1527m4_divert_pop([KILL])[]dnl 1528m4_divert_push([BODY])[]dnl 1529]) 1530