m4sh.m4 73 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136
  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-2012 Free Software Foundation, Inc.
  6. # This file is part of Autoconf. This program is free
  7. # software; you can redistribute it and/or modify it under the
  8. # terms of the GNU General Public License as published by the
  9. # Free Software Foundation, either version 3 of the License, or
  10. # (at your option) 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. # Under Section 7 of GPL version 3, you are granted additional
  18. # permissions described in the Autoconf Configure Script Exception,
  19. # version 3.0, as published by the Free Software Foundation.
  20. #
  21. # You should have received a copy of the GNU General Public License
  22. # and a copy of the Autoconf Configure Script Exception along with
  23. # this program; see the files COPYINGv3 and COPYING.EXCEPTION
  24. # respectively. If not, see <http://www.gnu.org/licenses/>.
  25. # Written by Akim Demaille, Pavel Roskin, Alexandre Oliva, Lars J. Aas
  26. # and many other people.
  27. # We heavily use m4's diversions both for the initializations and for
  28. # required macros, because in both cases we have to issue soon in
  29. # output something which is discovered late.
  30. #
  31. #
  32. # KILL is only used to suppress output.
  33. #
  34. # - BINSH
  35. # AC_REQUIRE'd #! /bin/sh line
  36. # - HEADER-REVISION
  37. # RCS keywords etc.
  38. # - HEADER-COMMENT
  39. # Purpose of the script etc.
  40. # - HEADER-COPYRIGHT
  41. # Copyright notice(s)
  42. # - M4SH-SANITIZE
  43. # M4sh's shell setup
  44. # - M4SH-INIT-FN
  45. # M4sh initialization (shell functions)
  46. # - M4SH-INIT
  47. # M4sh initialization (detection code)
  48. # - BODY
  49. # The body of the script.
  50. # _m4_divert(DIVERSION-NAME)
  51. # --------------------------
  52. # Convert a diversion name into its number. Otherwise, return
  53. # DIVERSION-NAME which is supposed to be an actual diversion number.
  54. # Of course it would be nicer to use m4_case here, instead of zillions
  55. # of little macros, but it then takes twice longer to run `autoconf'!
  56. m4_define([_m4_divert(BINSH)], 0)
  57. m4_define([_m4_divert(HEADER-REVISION)], 1)
  58. m4_define([_m4_divert(HEADER-COMMENT)], 2)
  59. m4_define([_m4_divert(HEADER-COPYRIGHT)], 3)
  60. m4_define([_m4_divert(M4SH-SANITIZE)], 4)
  61. m4_define([_m4_divert(M4SH-INIT-FN)], 5)
  62. m4_define([_m4_divert(M4SH-INIT)], 6)
  63. m4_define([_m4_divert(BODY)], 1000)
  64. # Aaarg. Yet it starts with compatibility issues... Libtool wants to
  65. # use NOTICE to insert its own LIBTOOL-INIT stuff. People should ask
  66. # before diving into our internals :(
  67. m4_copy([_m4_divert(M4SH-INIT)], [_m4_divert(NOTICE)])
  68. ## ------------------------- ##
  69. ## 1. Sanitizing the shell. ##
  70. ## ------------------------- ##
  71. # Please maintain lexicographic sorting of this section, ignoring leading _.
  72. # AS_BOURNE_COMPATIBLE
  73. # --------------------
  74. # Try to be as Bourne and/or POSIX as possible.
  75. #
  76. # This does not set BIN_SH, due to the problems described in
  77. # <http://lists.gnu.org/archive/html/autoconf-patches/2006-03/msg00081.html>.
  78. # People who need BIN_SH should set it in their environment before invoking
  79. # configure; apparently this would include UnixWare, as described in
  80. # <http://lists.gnu.org/archive/html/bug-autoconf/2006-06/msg00025.html>.
  81. m4_define([AS_BOURNE_COMPATIBLE],
  82. [# Be more Bourne compatible
  83. DUALCASE=1; export DUALCASE # for MKS sh
  84. _$0
  85. ])
  86. # _AS_BOURNE_COMPATIBLE
  87. # ---------------------
  88. # This is the part of AS_BOURNE_COMPATIBLE which has to be repeated inside
  89. # each instance.
  90. m4_define([_AS_BOURNE_COMPATIBLE],
  91. [AS_IF([test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1],
  92. [emulate sh
  93. NULLCMD=:
  94. [#] Pre-4.2 versions of Zsh do word splitting on ${1+"$[@]"}, which
  95. # is contrary to our usage. Disable this feature.
  96. alias -g '${1+"$[@]"}'='"$[@]"'
  97. setopt NO_GLOB_SUBST],
  98. [AS_CASE([`(set -o) 2>/dev/null`], [*posix*], [set -o posix])])
  99. ])
  100. # _AS_CLEANUP
  101. # -----------
  102. # Expanded as the last thing before m4sugar cleanup begins. Macros
  103. # may append m4sh cleanup hooks to this as appropriate.
  104. m4_define([_AS_CLEANUP],
  105. [m4_divert_text([M4SH-SANITIZE], [_AS_DETECT_BETTER_SHELL])])
  106. # AS_COPYRIGHT(TEXT)
  107. # ------------------
  108. # Emit TEXT, a copyright notice, as a shell comment near the top of the
  109. # script. TEXT is evaluated once; to accomplish that, we do not prepend
  110. # `# ' but `@%:@ '.
  111. m4_define([AS_COPYRIGHT],
  112. [m4_divert_text([HEADER-COPYRIGHT],
  113. [m4_bpatsubst([
  114. $1], [^], [@%:@ ])])])
  115. # _AS_DETECT_EXPAND(VAR, SET)
  116. # ---------------------------
  117. # Assign the contents of VAR from the contents of SET, expanded in such
  118. # a manner that VAR can be passed to _AS_RUN. In order to make
  119. # _AS_LINENO_WORKS operate correctly, we must specially handle the
  120. # first instance of $LINENO within any line being expanded (the first
  121. # instance is important to tests using the current shell, leaving
  122. # remaining instances for tests using a candidate shell). Bash loses
  123. # track of line numbers if a double quote contains a newline, hence,
  124. # we must piece-meal the assignment of VAR such that $LINENO expansion
  125. # occurs in a single line.
  126. m4_define([_AS_DETECT_EXPAND],
  127. [$1="m4_bpatsubst(m4_dquote(AS_ESCAPE(_m4_expand(m4_set_contents([$2], [
  128. ])))), [\\\$LINENO\(.*\)$], [";$1=$$1$LINENO;$1=$$1"\1])"])
  129. # _AS_DETECT_REQUIRED(TEST)
  130. # -------------------------
  131. # Refuse to execute under a shell that does not pass the given TEST.
  132. # Does not do AS_REQUIRE for the better-shell detection code.
  133. #
  134. # M4sh should never require something not required by POSIX, although
  135. # other clients are free to do so.
  136. m4_defun([_AS_DETECT_REQUIRED],
  137. [m4_set_add([_AS_DETECT_REQUIRED_BODY], [$1 || AS_EXIT])])
  138. # _AS_DETECT_SUGGESTED(TEST)
  139. # --------------------------
  140. # Prefer to execute under a shell that passes the given TEST.
  141. # Does not do AS_REQUIRE for the better-shell detection code.
  142. #
  143. # M4sh should never suggest something not required by POSIX, although
  144. # other clients are free to do so.
  145. m4_defun([_AS_DETECT_SUGGESTED],
  146. [m4_set_add([_AS_DETECT_SUGGESTED_BODY], [$1 || AS_EXIT])])
  147. # _AS_DETECT_SUGGESTED_PRUNE(TEST)
  148. # --------------------------------
  149. # If TEST is also a required test, remove it from the set of suggested tests.
  150. m4_define([_AS_DETECT_SUGGESTED_PRUNE],
  151. [m4_set_contains([_AS_DETECT_REQUIRED_BODY], [$1],
  152. [m4_set_remove([_AS_DETECT_SUGGESTED_BODY], [$1])])])
  153. # _AS_DETECT_BETTER_SHELL
  154. # -----------------------
  155. # The real workhorse for detecting a shell with the correct
  156. # features.
  157. #
  158. # In previous versions, we prepended /usr/posix/bin to the path, but that
  159. # caused a regression on OpenServer 6.0.0
  160. # <http://lists.gnu.org/archive/html/bug-autoconf/2006-06/msg00017.html>
  161. # and on HP-UX 11.11, see the failure of test 120 in
  162. # <http://lists.gnu.org/archive/html/bug-autoconf/2006-10/msg00003.html>
  163. #
  164. # FIXME: The code should test for the OSF bug described in
  165. # <http://lists.gnu.org/archive/html/autoconf-patches/2006-03/msg00081.html>.
  166. #
  167. # This code is run outside any trap 0 context, hence we can simplify AS_EXIT.
  168. m4_defun([_AS_DETECT_BETTER_SHELL],
  169. dnl
  170. dnl By default, do not force re-execution of the script just because
  171. dnl the user has pre-set $CONFIG_SHELL; do so only if the m4sh client has
  172. dnl defined the internal variable `_AS_FORCE_REEXEC_WITH_CONFIG_SHELL' to
  173. dnl "yes".
  174. dnl FIXME: This interface is acceptable for the moment, as a private,
  175. dnl FIXME: internal one; but if we want to make the "always re-execute"
  176. dnl FIXME: feature public, we should find a better interface!
  177. [m4_if(_AS_FORCE_REEXEC_WITH_CONFIG_SHELL, [yes],
  178. [# Use a proper internal environment variable to ensure we don't fall
  179. # into an infinite loop, continuously re-executing ourselves.
  180. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
  181. _as_can_reexec=no; export _as_can_reexec;
  182. _AS_REEXEC_WITH_SHELL([$CONFIG_SHELL])
  183. fi
  184. # We don't want this to propagate to other subprocesses.
  185. dnl This might be especially important in case an m4sh-generated script
  186. dnl is used to later execute other m4sh-generated scripts. This happens
  187. dnl for example in autoconf's own testsuite (and happens *a lot* there,
  188. dnl in fact).
  189. AS_UNSET([_as_can_reexec])
  190. ])]dnl
  191. dnl Remove any tests from suggested that are also required
  192. [m4_set_map([_AS_DETECT_SUGGESTED_BODY], [_AS_DETECT_SUGGESTED_PRUNE])]dnl
  193. [m4_pushdef([AS_EXIT], [exit m4_default(]m4_dquote([$][1])[, 1)])]dnl
  194. [if test "x$CONFIG_SHELL" = x; then
  195. as_bourne_compatible="AS_ESCAPE(_m4_expand([_AS_BOURNE_COMPATIBLE]))"
  196. _AS_DETECT_EXPAND([as_required], [_AS_DETECT_REQUIRED_BODY])
  197. _AS_DETECT_EXPAND([as_suggested], [_AS_DETECT_SUGGESTED_BODY])
  198. AS_IF([_AS_RUN(["$as_required"])],
  199. [as_have_required=yes],
  200. [as_have_required=no])
  201. AS_IF([test x$as_have_required = xyes && _AS_RUN(["$as_suggested"])],
  202. [],
  203. [_AS_PATH_WALK([/bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH],
  204. [case $as_dir in @%:@(
  205. /*)
  206. for as_base in bash sh ksh sh5; do
  207. # Try only shells that exist, to save several forks.
  208. as_shell=$as_dir/$as_base
  209. AS_IF([{ test -f "$as_shell" || test -f "$as_shell.exe"; } &&
  210. _AS_RUN(["$as_required"], ["$as_shell"])],
  211. [CONFIG_SHELL=$as_shell as_have_required=yes
  212. m4_set_empty([_AS_DETECT_SUGGESTED_BODY], [break 2],
  213. [AS_IF([_AS_RUN(["$as_suggested"], ["$as_shell"])],
  214. [break 2])])])
  215. done;;
  216. esac],
  217. [AS_IF([{ test -f "$SHELL" || test -f "$SHELL.exe"; } &&
  218. _AS_RUN(["$as_required"], ["$SHELL"])],
  219. [CONFIG_SHELL=$SHELL as_have_required=yes])])
  220. AS_IF([test "x$CONFIG_SHELL" != x],
  221. [export CONFIG_SHELL
  222. _AS_REEXEC_WITH_SHELL([$CONFIG_SHELL])])
  223. dnl Unfortunately, $as_me isn't available here.
  224. AS_IF([test x$as_have_required = xno],
  225. [AS_ECHO(["$[]0: This script requires a shell more modern than all"])
  226. AS_ECHO(["$[]0: the shells that I found on your system."])
  227. if test x${ZSH_VERSION+set} = xset ; then
  228. AS_ECHO(["$[]0: In particular, zsh $ZSH_VERSION has bugs and should"])
  229. AS_ECHO(["$[]0: be upgraded to zsh 4.3.4 or later."])
  230. else
  231. AS_ECHO("m4_text_wrap([Please tell ]_m4_defn([m4_PACKAGE_BUGREPORT])
  232. m4_ifset([AC_PACKAGE_BUGREPORT], [m4_if(_m4_defn([m4_PACKAGE_BUGREPORT]),
  233. _m4_defn([AC_PACKAGE_BUGREPORT]), [], [and _m4_defn([AC_PACKAGE_BUGREPORT])])])
  234. [about your system, including any error possibly output before this message.
  235. Then install a modern shell, or manually run the script under such a
  236. shell if you do have one.], [$[]0: ], [], [62])")
  237. fi
  238. AS_EXIT])])
  239. fi
  240. SHELL=${CONFIG_SHELL-/bin/sh}
  241. export SHELL
  242. # Unset more variables known to interfere with behavior of common tools.
  243. CLICOLOR_FORCE= GREP_OPTIONS=
  244. unset CLICOLOR_FORCE GREP_OPTIONS
  245. _m4_popdef([AS_EXIT])])# _AS_DETECT_BETTER_SHELL
  246. # _AS_REEXEC_WITH_SHELL(SHELL)
  247. # ----------------------------
  248. # Re-execute the current script with the given shell, trying to preserve
  249. # portable settings (e.g., the `xtrace' and `verbose' shell flag).
  250. m4_defun([_AS_REEXEC_WITH_SHELL], [dnl
  251. # We cannot yet assume a decent shell, so we have to provide a
  252. # neutralization value for shells without unset; and this also
  253. # works around shells that cannot unset nonexistent variables.
  254. # Preserve -v and -x to the replacement shell.
  255. BASH_ENV=/dev/null
  256. ENV=/dev/null
  257. (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
  258. case $- in @%:@ ((((
  259. *v*x* | *x*v* ) as_opts=-vx ;;
  260. *v* ) as_opts=-v ;;
  261. *x* ) as_opts=-x ;;
  262. * ) as_opts= ;;
  263. esac
  264. exec $1 $as_opts "$as_myself" ${1+"$[@]"}
  265. # Admittedly, this is quite paranoid, since all the known shells bail
  266. # out after a failed `exec'.
  267. AS_ECHO(["$[]0: could not re-execute with $1"]) >&2
  268. AS_EXIT([255])])# _AS_REEXEC_WITH_SHELL
  269. # _AS_PREPARE
  270. # -----------
  271. # This macro has a very special status. Normal use of M4sh relies
  272. # heavily on AS_REQUIRE, so that needed initializations (such as
  273. # _AS_TEST_PREPARE) are performed on need, not on demand. But
  274. # Autoconf is the first client of M4sh, and for two reasons: configure
  275. # and config.status. Relying on AS_REQUIRE is of course fine for
  276. # configure, but fails for config.status (which is created by
  277. # configure). So we need a means to force the inclusion of the
  278. # various _AS_*_PREPARE on top of config.status. That's basically why
  279. # there are so many _AS_*_PREPARE below, and that's also why it is
  280. # important not to forget some: config.status needs them.
  281. # List any preparations that create shell functions first, then
  282. # topologically sort the others by their dependencies.
  283. #
  284. # Special case: we do not need _AS_LINENO_PREPARE, because the
  285. # parent will have substituted $LINENO for us when processing its
  286. # own invocation of _AS_LINENO_PREPARE.
  287. #
  288. # Special case: the full definition of _AS_ERROR_PREPARE is not output
  289. # unless AS_MESSAGE_LOG_FD is non-empty, although the value of
  290. # AS_MESSAGE_LOG_FD is not relevant.
  291. m4_defun([_AS_PREPARE],
  292. [m4_pushdef([AS_REQUIRE])]dnl
  293. [m4_pushdef([AS_REQUIRE_SHELL_FN], _m4_defn([_AS_REQUIRE_SHELL_FN])
  294. )]dnl
  295. [m4_pushdef([AS_MESSAGE_LOG_FD], [-1])]dnl
  296. [_AS_ERROR_PREPARE
  297. _m4_popdef([AS_MESSAGE_LOG_FD])]dnl
  298. [_AS_EXIT_PREPARE
  299. _AS_UNSET_PREPARE
  300. _AS_VAR_APPEND_PREPARE
  301. _AS_VAR_ARITH_PREPARE
  302. _AS_EXPR_PREPARE
  303. _AS_BASENAME_PREPARE
  304. _AS_DIRNAME_PREPARE
  305. _AS_ME_PREPARE
  306. _AS_CR_PREPARE
  307. _AS_ECHO_N_PREPARE
  308. _AS_LN_S_PREPARE
  309. _AS_MKDIR_P_PREPARE
  310. _AS_TEST_PREPARE
  311. _AS_TR_CPP_PREPARE
  312. _AS_TR_SH_PREPARE
  313. _m4_popdef([AS_REQUIRE], [AS_REQUIRE_SHELL_FN])])
  314. # AS_PREPARE
  315. # ----------
  316. # Output all the M4sh possible initialization into the initialization
  317. # diversion. We do not use _AS_PREPARE so that the m4_provide symbols for
  318. # AS_REQUIRE and AS_REQUIRE_SHELL_FN are defined properly, and so that
  319. # shell functions are placed in M4SH-INIT-FN.
  320. m4_defun([AS_PREPARE],
  321. [m4_divert_push([KILL])
  322. m4_append_uniq([_AS_CLEANUP],
  323. [m4_divert_text([M4SH-INIT-FN], [_AS_ERROR_PREPARE[]])])
  324. AS_REQUIRE([_AS_EXPR_PREPARE])
  325. AS_REQUIRE([_AS_BASENAME_PREPARE])
  326. AS_REQUIRE([_AS_DIRNAME_PREPARE])
  327. AS_REQUIRE([_AS_ME_PREPARE])
  328. AS_REQUIRE([_AS_CR_PREPARE])
  329. AS_REQUIRE([_AS_LINENO_PREPARE])
  330. AS_REQUIRE([_AS_ECHO_N_PREPARE])
  331. AS_REQUIRE([_AS_EXIT_PREPARE])
  332. AS_REQUIRE([_AS_LN_S_PREPARE])
  333. AS_REQUIRE([_AS_MKDIR_P_PREPARE])
  334. AS_REQUIRE([_AS_TEST_PREPARE])
  335. AS_REQUIRE([_AS_TR_CPP_PREPARE])
  336. AS_REQUIRE([_AS_TR_SH_PREPARE])
  337. AS_REQUIRE([_AS_UNSET_PREPARE])
  338. AS_REQUIRE([_AS_VAR_APPEND_PREPARE], [], [M4SH-INIT-FN])
  339. AS_REQUIRE([_AS_VAR_ARITH_PREPARE], [], [M4SH-INIT-FN])
  340. m4_divert_pop[]])
  341. # AS_REQUIRE(NAME-TO-CHECK, [BODY-TO-EXPAND = NAME-TO-CHECK],
  342. # [DIVERSION = M4SH-INIT])
  343. # -----------------------------------------------------------
  344. # BODY-TO-EXPAND is some initialization which must be expanded in the
  345. # given diversion when expanded (required or not). The expansion
  346. # goes in the named diversion or an earlier one.
  347. #
  348. # Since $2 can be quite large, this is factored for faster execution, giving
  349. # either m4_require([$1], [$2]) or m4_divert_require(desired, [$1], [$2]).
  350. m4_defun([AS_REQUIRE],
  351. [m4_define([_m4_divert_desired], [m4_default_quoted([$3], [M4SH-INIT])])]dnl
  352. [m4_if(m4_eval(_m4_divert_dump - 0 <= _m4_divert(_m4_divert_desired, [-])),
  353. 1, [m4_require(],
  354. [m4_divert_require(_m4_divert_desired,]) [$1], [$2])])
  355. # _AS_REQUIRE_SHELL_FN(NAME-TO-CHECK, COMMENT, BODY-TO-EXPAND)
  356. # ------------------------------------------------------------
  357. # Core of AS_REQUIRE_SHELL_FN, but without diversion support.
  358. m4_define([_AS_REQUIRE_SHELL_FN], [
  359. m4_n([$2])$1 ()
  360. {
  361. $3
  362. } @%:@ $1[]])
  363. # AS_REQUIRE_SHELL_FN(NAME-TO-CHECK, COMMENT, BODY-TO-EXPAND,
  364. # [DIVERSION = M4SH-INIT-FN])
  365. # -----------------------------------------------------------
  366. # BODY-TO-EXPAND is the body of a shell function to be emitted in the
  367. # given diversion when expanded (required or not). Unlike other
  368. # xx_REQUIRE macros, BODY-TO-EXPAND is mandatory. If COMMENT is
  369. # provided (often via AS_FUNCTION_DESCRIBE), it is listed with a
  370. # newline before the function name.
  371. m4_define([AS_REQUIRE_SHELL_FN],
  372. [m4_provide_if([AS_SHELL_FN_$1], [],
  373. [AS_REQUIRE([AS_SHELL_FN_$1],
  374. [m4_provide([AS_SHELL_FN_$1])_$0($@)],
  375. m4_default_quoted([$4], [M4SH-INIT-FN]))])])
  376. # _AS_RUN(TEST, [SHELL])
  377. # ----------------------
  378. # Run TEST under the current shell (if one parameter is used)
  379. # or under the given SHELL, protecting it from syntax errors.
  380. # Set as_run in order to assist _AS_LINENO_WORKS.
  381. m4_define([_AS_RUN],
  382. [m4_ifval([$2], [{ $as_echo "$as_bourne_compatible"$1 | as_run=a $2; }],
  383. [(eval $1)]) 2>/dev/null])
  384. # _AS_SHELL_FN_WORK
  385. # -----------------
  386. # This is a spy to detect "in the wild" shells that do not support shell
  387. # functions correctly. It is based on the m4sh.at Autotest testcases.
  388. m4_define([_AS_SHELL_FN_WORK],
  389. [as_fn_return () { (exit [$]1); }
  390. as_fn_success () { as_fn_return 0; }
  391. as_fn_failure () { as_fn_return 1; }
  392. as_fn_ret_success () { return 0; }
  393. as_fn_ret_failure () { return 1; }
  394. exitcode=0
  395. as_fn_success || { exitcode=1; echo as_fn_success failed.; }
  396. as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
  397. as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
  398. as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
  399. AS_IF([( set x; as_fn_ret_success y && test x = "[$]1" )], [],
  400. [exitcode=1; echo positional parameters were not saved.])
  401. test x$exitcode = x0[]])# _AS_SHELL_FN_WORK
  402. # _AS_SHELL_SANITIZE
  403. # ------------------
  404. # This is the prolog that is emitted by AS_INIT and AS_INIT_GENERATED;
  405. # it is executed prior to shell function definitions, hence the
  406. # temporary redefinition of AS_EXIT.
  407. m4_defun([_AS_SHELL_SANITIZE],
  408. [m4_pushdef([AS_EXIT], [exit m4_default(]m4_dquote([$][1])[, 1)])]dnl
  409. [m4_text_box([M4sh Initialization.])
  410. AS_BOURNE_COMPATIBLE
  411. _AS_ECHO_PREPARE
  412. _AS_PATH_SEPARATOR_PREPARE
  413. # IFS
  414. # We need space, tab and new line, in precisely that order. Quoting is
  415. # there to prevent editors from complaining about space-tab.
  416. # (If _AS_PATH_WALK were called with IFS unset, it would disable word
  417. # splitting by setting IFS to empty value.)
  418. IFS=" "" $as_nl"
  419. # Find who we are. Look in the path if we contain no directory separator.
  420. as_myself=
  421. case $[0] in @%:@((
  422. *[[\\/]]* ) as_myself=$[0] ;;
  423. *) _AS_PATH_WALK([],
  424. [test -r "$as_dir/$[0]" && as_myself=$as_dir/$[0] && break])
  425. ;;
  426. esac
  427. # We did not find ourselves, most probably we were run as `sh COMMAND'
  428. # in which case we are not to be found in the path.
  429. if test "x$as_myself" = x; then
  430. as_myself=$[0]
  431. fi
  432. if test ! -f "$as_myself"; then
  433. AS_ECHO(["$as_myself: error: cannot find myself; rerun with an absolute file name"]) >&2
  434. AS_EXIT
  435. fi
  436. # Unset variables that we do not need and which cause bugs (e.g. in
  437. # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
  438. # suppresses any "Segmentation fault" message there. '((' could
  439. # trigger a bug in pdksh 5.2.14.
  440. for as_var in BASH_ENV ENV MAIL MAILPATH
  441. do eval test x\${$as_var+set} = xset \
  442. && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
  443. done
  444. PS1='$ '
  445. PS2='> '
  446. PS4='+ '
  447. # NLS nuisances.
  448. LC_ALL=C
  449. export LC_ALL
  450. LANGUAGE=C
  451. export LANGUAGE
  452. # CDPATH.
  453. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
  454. _m4_popdef([AS_EXIT])])# _AS_SHELL_SANITIZE
  455. # AS_SHELL_SANITIZE
  456. # -----------------
  457. # This is only needed for the sake of Libtool, which screws up royally
  458. # in its usage of M4sh internals.
  459. m4_define([AS_SHELL_SANITIZE],
  460. [_AS_SHELL_SANITIZE
  461. m4_provide_if([AS_INIT], [],
  462. [m4_provide([AS_INIT])
  463. _AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])
  464. _AS_DETECT_REQUIRED([_AS_TEST_X_WORKS])
  465. _AS_DETECT_BETTER_SHELL
  466. _AS_UNSET_PREPARE
  467. ])])
  468. ## ----------------------------- ##
  469. ## 2. Wrappers around builtins. ##
  470. ## ----------------------------- ##
  471. # This section is lexicographically sorted.
  472. # AS_CASE(WORD, [PATTERN1], [IF-MATCHED1]...[DEFAULT])
  473. # ----------------------------------------------------
  474. # Expand into
  475. # | case WORD in #(
  476. # | PATTERN1) IF-MATCHED1 ;; #(
  477. # | ...
  478. # | *) DEFAULT ;;
  479. # | esac
  480. # The shell comments are intentional, to work around people who don't
  481. # realize the impacts of using insufficient m4 quoting. This macro
  482. # always uses : and provides a default case, to work around Solaris
  483. # /bin/sh bugs regarding the exit status.
  484. m4_define([_AS_CASE],
  485. [ [@%:@(]
  486. $1[)] :
  487. $2 ;;])
  488. m4_define([_AS_CASE_DEFAULT],
  489. [ [@%:@(]
  490. *[)] :
  491. $1 ;;])
  492. m4_defun([AS_CASE],
  493. [case $1 in[]m4_map_args_pair([_$0], [_$0_DEFAULT],
  494. m4_shift($@m4_if(m4_eval([$# & 1]), [1], [,])))
  495. esac])# AS_CASE
  496. # _AS_EXIT_PREPARE
  497. # ----------------
  498. # Ensure AS_EXIT and AS_SET_STATUS will work.
  499. #
  500. # We cannot simply use "exit N" because some shells (zsh and Solaris sh)
  501. # will not set $? to N while running the code set by "trap 0"
  502. # Some shells fork even for (exit N), so we use a helper function
  503. # to set $? prior to the exit.
  504. # Then there are shells that don't inherit $? correctly into the start of
  505. # a shell function, so we must always be given an argument.
  506. # Other shells don't use `$?' as default for `exit', hence just repeating
  507. # the exit value can only help improving portability.
  508. m4_defun([_AS_EXIT_PREPARE],
  509. [AS_REQUIRE_SHELL_FN([as_fn_set_status],
  510. [AS_FUNCTION_DESCRIBE([as_fn_set_status], [STATUS],
  511. [Set $? to STATUS, without forking.])], [ return $[]1])]dnl
  512. [AS_REQUIRE_SHELL_FN([as_fn_exit],
  513. [AS_FUNCTION_DESCRIBE([as_fn_exit], [STATUS],
  514. [Exit the shell with STATUS, even in a "trap 0" or "set -e" context.])],
  515. [ set +e
  516. as_fn_set_status $[1]
  517. exit $[1]])])#_AS_EXIT_PREPARE
  518. # AS_EXIT([EXIT-CODE = $?])
  519. # -------------------------
  520. # Exit, with status set to EXIT-CODE in the way that it's seen
  521. # within "trap 0", and without interference from "set -e". If
  522. # EXIT-CODE is omitted, then use $?.
  523. m4_defun([AS_EXIT],
  524. [AS_REQUIRE([_AS_EXIT_PREPARE])[]as_fn_exit m4_ifval([$1], [$1], [$][?])])
  525. # AS_FOR(MACRO, SHELL-VAR, [LIST = "$@"], [BODY = :])
  526. # ---------------------------------------------------
  527. # Expand to a shell loop that assigns SHELL-VAR to each of the
  528. # whitespace-separated entries in LIST (or "$@" if LIST is empty),
  529. # then executes BODY. BODY may call break to abort the loop, or
  530. # continue to proceed with the next element of LIST. Requires that
  531. # IFS be set to the normal space-tab-newline. As an optimization,
  532. # BODY should access MACRO rather than $SHELL-VAR. Normally, MACRO
  533. # expands to $SHELL-VAR, but if LIST contains only a single element
  534. # that needs no additional shell quoting, then MACRO will expand to
  535. # that element, thus providing a direct value rather than a shell
  536. # variable indirection.
  537. #
  538. # Only use the optimization if LIST can be used without additional
  539. # shell quoting in either a literal or double-quoted context (that is,
  540. # we give up on default IFS chars, parameter expansion, command
  541. # substitution, shell quoting, globs, or quadrigraphs). Inline the
  542. # m4_defn for speed.
  543. m4_defun([AS_FOR],
  544. [m4_pushdef([$1], m4_if([$3], [], [[$$2]], m4_translit([$3], ]dnl
  545. m4_dquote(_m4_defn([m4_cr_symbols2]))[[%+=:,./-]), [], [[$3]], [[$$2]]))]dnl
  546. [for $2[]m4_ifval([$3], [ in $3])
  547. do :
  548. $4
  549. done[]_m4_popdef([$1])])
  550. # AS_IF(TEST1, [IF-TRUE1 = :]...[IF-FALSE = :])
  551. # ---------------------------------------------
  552. # Expand into
  553. # | if TEST1; then
  554. # | IF-TRUE1
  555. # | elif TEST2; then
  556. # | IF-TRUE2
  557. # [...]
  558. # | else
  559. # | IF-FALSE
  560. # | fi
  561. # with simplifications when IF-TRUE1 and/or IF-FALSE are empty.
  562. #
  563. m4_define([_AS_IF],
  564. [elif $1; then :
  565. $2
  566. ])
  567. m4_define([_AS_IF_ELSE],
  568. [m4_ifnblank([$1],
  569. [else
  570. $1
  571. ])])
  572. m4_defun([AS_IF],
  573. [if $1; then :
  574. $2
  575. m4_map_args_pair([_$0], [_$0_ELSE], m4_shift2($@))]dnl
  576. [fi[]])# AS_IF
  577. # AS_SET_STATUS(STATUS)
  578. # ---------------------
  579. # Set the shell status ($?) to STATUS, without forking.
  580. m4_defun([AS_SET_STATUS],
  581. [AS_REQUIRE([_AS_EXIT_PREPARE])[]as_fn_set_status $1])
  582. # _AS_UNSET_PREPARE
  583. # -----------------
  584. # Define $as_unset to execute AS_UNSET, for backwards compatibility
  585. # with older versions of M4sh.
  586. m4_defun([_AS_UNSET_PREPARE],
  587. [AS_FUNCTION_DESCRIBE([as_fn_unset], [VAR], [Portably unset VAR.])
  588. as_fn_unset ()
  589. {
  590. AS_UNSET([$[1]])
  591. }
  592. as_unset=as_fn_unset])
  593. # AS_UNSET(VAR)
  594. # -------------
  595. # Unset the env VAR, working around shells that do not allow unsetting
  596. # a variable that is not already set. You should not unset MAIL and
  597. # MAILCHECK, as that triggers a bug in Bash 2.01.
  598. m4_defun([AS_UNSET],
  599. [{ AS_LITERAL_WORD_IF([$1], [], [eval ])$1=; unset $1;}])
  600. ## ------------------------------------------ ##
  601. ## 3. Error and warnings at the shell level. ##
  602. ## ------------------------------------------ ##
  603. # AS_MESSAGE_FD
  604. # -------------
  605. # Must expand to the fd where messages will be sent. Defaults to 1,
  606. # although a script may reassign this value and use exec to either
  607. # copy stdout to the new fd, or open the new fd on /dev/null.
  608. m4_define([AS_MESSAGE_FD], [1])
  609. # AS_MESSAGE_LOG_FD
  610. # -----------------
  611. # Must expand to either the empty string (when no logging is
  612. # performed), or to the fd of a log file. Defaults to empty, although
  613. # a script may reassign this value and use exec to open a log. When
  614. # not empty, messages to AS_MESSAGE_FD are duplicated to the log,
  615. # along with a LINENO reference.
  616. m4_define([AS_MESSAGE_LOG_FD])
  617. # AS_ORIGINAL_STDIN_FD
  618. # --------------------
  619. # Must expand to the fd of the script's original stdin. Defaults to
  620. # 0, although the script may reassign this value and use exec to
  621. # shuffle fd's.
  622. m4_define([AS_ORIGINAL_STDIN_FD], [0])
  623. # AS_ESCAPE(STRING, [CHARS = `\"$])
  624. # ---------------------------------
  625. # Add backslash escaping to the CHARS in STRING. In an effort to
  626. # optimize use of this macro inside double-quoted shell constructs,
  627. # the behavior is intentionally undefined if CHARS is longer than 4
  628. # bytes, or contains bytes outside of the set [`\"$]. However,
  629. # repeated bytes within the set are permissible (AS_ESCAPE([$1], [""])
  630. # being a common way to be nice to syntax highlighting).
  631. #
  632. # Avoid the m4_bpatsubst if there are no interesting characters to escape.
  633. # _AS_ESCAPE bypasses argument defaulting.
  634. m4_define([AS_ESCAPE],
  635. [_$0([$1], m4_if([$2], [], [[`], [\"$]], [m4_substr([$2], [0], [1]), [$2]]))])
  636. # _AS_ESCAPE(STRING, KEY, SET)
  637. # ----------------------------
  638. # Backslash-escape all instances of the single byte KEY or up to four
  639. # bytes in SET occurring in STRING. Although a character can occur
  640. # multiple times, optimum efficiency occurs when KEY and SET are
  641. # distinct, and when SET does not exceed two bytes. These particular
  642. # semantics allow for the fewest number of parses of STRING, as well
  643. # as taking advantage of the optimizations in m4 1.4.13+ when
  644. # m4_translit is passed SET of size 2 or smaller.
  645. m4_define([_AS_ESCAPE],
  646. [m4_if(m4_index(m4_translit([[$1]], [$3], [$2$2$2$2]), [$2]), [-1],
  647. [$0_], [m4_bpatsubst])([$1], [[$2$3]], [\\\&])])
  648. m4_define([_AS_ESCAPE_], [$1])
  649. # _AS_QUOTE(STRING)
  650. # -----------------
  651. # If there are quoted (via backslash) backquotes, output STRING
  652. # literally and warn; otherwise, output STRING with ` and " quoted.
  653. #
  654. # Compatibility glue between the old AS_MSG suite which did not
  655. # quote anything, and the modern suite which quotes the quotes.
  656. # If STRING contains `\\' or `\$', it's modern.
  657. # If STRING contains `\"' or `\`', it's old.
  658. # Otherwise it's modern.
  659. #
  660. # Profiling shows that m4_index is 5 to 8x faster than m4_bregexp. The
  661. # slower implementation used:
  662. # m4_bmatch([$1],
  663. # [\\[\\$]], [$2],
  664. # [\\[`"]], [$3],
  665. # [$2])
  666. # The current implementation caters to the common case of no backslashes,
  667. # to minimize m4_index expansions (hence the nested if).
  668. m4_define([_AS_QUOTE],
  669. [m4_cond([m4_index([$1], [\])], [-1], [_AS_QUOTE_MODERN],
  670. [m4_eval(m4_index(m4_translit([[$1]], [$], [\]), [\\]) >= 0)],
  671. [1], [_AS_QUOTE_MODERN],
  672. [m4_eval(m4_index(m4_translit([[$1]], ["], [`]), [\`]) >= 0)],dnl"
  673. [1], [_AS_QUOTE_OLD],
  674. [_AS_QUOTE_MODERN])([$1])])
  675. m4_define([_AS_QUOTE_MODERN],
  676. [_AS_ESCAPE([$1], [`], [""])])
  677. m4_define([_AS_QUOTE_OLD],
  678. [m4_warn([obsolete],
  679. [back quotes and double quotes must not be escaped in: $1])$1])
  680. # _AS_ECHO_UNQUOTED(STRING, [FD = AS_MESSAGE_FD])
  681. # -----------------------------------------------
  682. # Perform shell expansions on STRING and echo the string to FD.
  683. m4_define([_AS_ECHO_UNQUOTED],
  684. [AS_ECHO(["$1"]) >&m4_default([$2], [AS_MESSAGE_FD])])
  685. # _AS_ECHO(STRING, [FD = AS_MESSAGE_FD])
  686. # --------------------------------------
  687. # Protect STRING from backquote expansion, echo the result to FD.
  688. m4_define([_AS_ECHO],
  689. [_AS_ECHO_UNQUOTED([_AS_QUOTE([$1])], [$2])])
  690. # _AS_ECHO_LOG(STRING)
  691. # --------------------
  692. # Log the string to AS_MESSAGE_LOG_FD.
  693. m4_defun_init([_AS_ECHO_LOG],
  694. [AS_REQUIRE([_AS_LINENO_PREPARE])],
  695. [_AS_ECHO([$as_me:${as_lineno-$LINENO}: $1], AS_MESSAGE_LOG_FD)])
  696. # _AS_ECHO_N_PREPARE
  697. # ------------------
  698. # Check whether to use -n, \c, or newline-tab to separate
  699. # checking messages from result messages.
  700. # Don't try to cache, since the results of this macro are needed to
  701. # display the checking message. In addition, caching something used once
  702. # has little interest.
  703. # Idea borrowed from dist 3.0. Use `*c*,', not `*c,' because if `\c'
  704. # failed there is also a newline to match. Use `xy' because `\c' echoed
  705. # in a command substitution prints only the first character of the output
  706. # with ksh version M-11/16/88f on AIX 6.1; it needs to be reset by another
  707. # backquoted echo.
  708. m4_defun([_AS_ECHO_N_PREPARE],
  709. [ECHO_C= ECHO_N= ECHO_T=
  710. case `echo -n x` in @%:@(((((
  711. -n*)
  712. case `echo 'xy\c'` in
  713. *c*) ECHO_T=' ';; # ECHO_T is single tab character.
  714. xy) ECHO_C='\c';;
  715. *) echo `echo ksh88 bug on AIX 6.1` > /dev/null
  716. ECHO_T=' ';;
  717. esac;;
  718. *)
  719. ECHO_N='-n';;
  720. esac
  721. ])# _AS_ECHO_N_PREPARE
  722. # _AS_ECHO_N(STRING, [FD = AS_MESSAGE_FD])
  723. # ----------------------------------------
  724. # Same as _AS_ECHO, but echo doesn't return to a new line.
  725. m4_define([_AS_ECHO_N],
  726. [AS_ECHO_N(["_AS_QUOTE([$1])"]) >&m4_default([$2], [AS_MESSAGE_FD])])
  727. # AS_MESSAGE(STRING, [FD = AS_MESSAGE_FD])
  728. # ----------------------------------------
  729. # Output "`basename $0`: STRING" to the open file FD, and if logging
  730. # is enabled, copy it to the log with a reference to LINENO.
  731. m4_defun_init([AS_MESSAGE],
  732. [AS_REQUIRE([_AS_ME_PREPARE])],
  733. [m4_ifval(AS_MESSAGE_LOG_FD,
  734. [{ _AS_ECHO_LOG([$1])
  735. _AS_ECHO([$as_me: $1], [$2]);}],
  736. [_AS_ECHO([$as_me: $1], [$2])])[]])
  737. # AS_WARN(PROBLEM)
  738. # ----------------
  739. # Output "`basename $0`: WARNING: PROBLEM" to stderr.
  740. m4_define([AS_WARN],
  741. [AS_MESSAGE([WARNING: $1], [2])])# AS_WARN
  742. # _AS_ERROR_PREPARE
  743. # -----------------
  744. # Output the shell function used by AS_ERROR. This is designed to be
  745. # expanded during the m4_wrap cleanup.
  746. #
  747. # If AS_MESSAGE_LOG_FD is non-empty at the end of the script, then
  748. # make this function take optional parameters that use LINENO at the
  749. # points where AS_ERROR was expanded with non-empty AS_MESSAGE_LOG_FD;
  750. # otherwise, assume the entire script does not do logging.
  751. m4_define([_AS_ERROR_PREPARE],
  752. [AS_REQUIRE_SHELL_FN([as_fn_error],
  753. [AS_FUNCTION_DESCRIBE([as_fn_error], [STATUS ERROR]m4_ifval(AS_MESSAGE_LOG_FD,
  754. [[ [[LINENO LOG_FD]]]]),
  755. [Output "`basename @S|@0`: error: ERROR" to stderr.]
  756. m4_ifval(AS_MESSAGE_LOG_FD,
  757. [[If LINENO and LOG_FD are provided, also output the error to LOG_FD,
  758. referencing LINENO.]])
  759. [Then exit the script with STATUS, using 1 if that was 0.])],
  760. [ as_status=$[1]; test $as_status -eq 0 && as_status=1
  761. m4_ifval(AS_MESSAGE_LOG_FD,
  762. [m4_pushdef([AS_MESSAGE_LOG_FD], [$[4]])dnl
  763. if test "$[4]"; then
  764. AS_LINENO_PUSH([$[3]])
  765. _AS_ECHO_LOG([error: $[2]])
  766. fi
  767. m4_define([AS_MESSAGE_LOG_FD])], [m4_pushdef([AS_MESSAGE_LOG_FD])])dnl
  768. AS_MESSAGE([error: $[2]], [2])
  769. _m4_popdef([AS_MESSAGE_LOG_FD])dnl
  770. AS_EXIT([$as_status])])])
  771. # AS_ERROR(ERROR, [EXIT-STATUS = max($?/1)])
  772. # ------------------------------------------
  773. # Output "`basename $0`: error: ERROR" to stderr, then exit the
  774. # script with EXIT-STATUS.
  775. m4_defun_init([AS_ERROR],
  776. [m4_append_uniq([_AS_CLEANUP],
  777. [m4_divert_text([M4SH-INIT-FN], [_AS_ERROR_PREPARE[]])])],
  778. [as_fn_error m4_default([$2], [$?]) "_AS_QUOTE([$1])"m4_ifval(AS_MESSAGE_LOG_FD,
  779. [ "$LINENO" AS_MESSAGE_LOG_FD])])
  780. # AS_LINENO_PUSH([LINENO])
  781. # ------------------------
  782. # If this is the outermost call to AS_LINENO_PUSH, make sure that
  783. # AS_MESSAGE will print LINENO as the line number.
  784. m4_defun([AS_LINENO_PUSH],
  785. [as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack])
  786. # AS_LINENO_POP([LINENO])
  787. # -----------------------
  788. # If this is call balances the outermost call to AS_LINENO_PUSH,
  789. # AS_MESSAGE will restart printing $LINENO as the line number.
  790. #
  791. # No need to use AS_UNSET, since as_lineno is necessarily set.
  792. m4_defun([AS_LINENO_POP],
  793. [eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno])
  794. ## -------------------------------------- ##
  795. ## 4. Portable versions of common tools. ##
  796. ## -------------------------------------- ##
  797. # This section is lexicographically sorted.
  798. # AS_BASENAME(FILE-NAME)
  799. # ----------------------
  800. # Simulate the command 'basename FILE-NAME'. Not all systems have basename.
  801. # Also see the comments for AS_DIRNAME.
  802. m4_defun([_AS_BASENAME_EXPR],
  803. [$as_expr X/[]$1 : '.*/\([[^/][^/]*]\)/*$' \| \
  804. X[]$1 : 'X\(//\)$' \| \
  805. X[]$1 : 'X\(/\)' \| .])
  806. m4_defun([_AS_BASENAME_SED],
  807. [AS_ECHO([X/[]$1]) |
  808. sed ['/^.*\/\([^/][^/]*\)\/*$/{
  809. s//\1/
  810. q
  811. }
  812. /^X\/\(\/\/\)$/{
  813. s//\1/
  814. q
  815. }
  816. /^X\/\(\/\).*/{
  817. s//\1/
  818. q
  819. }
  820. s/.*/./; q']])
  821. m4_defun_init([AS_BASENAME],
  822. [AS_REQUIRE([_$0_PREPARE])],
  823. [$as_basename -- $1 ||
  824. _AS_BASENAME_EXPR([$1]) 2>/dev/null ||
  825. _AS_BASENAME_SED([$1])])
  826. # _AS_BASENAME_PREPARE
  827. # --------------------
  828. # Avoid Solaris 9 /usr/ucb/basename, as `basename /' outputs an empty line.
  829. # Also, traditional basename mishandles --. Require here _AS_EXPR_PREPARE,
  830. # to avoid problems when _AS_BASENAME is called from the M4SH-INIT diversion.
  831. m4_defun([_AS_BASENAME_PREPARE],
  832. [AS_REQUIRE([_AS_EXPR_PREPARE])]dnl
  833. [if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
  834. as_basename=basename
  835. else
  836. as_basename=false
  837. fi
  838. ])# _AS_BASENAME_PREPARE
  839. # AS_DIRNAME(FILE-NAME)
  840. # ---------------------
  841. # Simulate the command 'dirname FILE-NAME'. Not all systems have dirname.
  842. # This macro must be usable from inside ` `.
  843. #
  844. # Prefer expr to echo|sed, since expr is usually faster and it handles
  845. # backslashes and newlines correctly. However, older expr
  846. # implementations (e.g. SunOS 4 expr and Solaris 8 /usr/ucb/expr) have
  847. # a silly length limit that causes expr to fail if the matched
  848. # substring is longer than 120 bytes. So fall back on echo|sed if
  849. # expr fails.
  850. m4_defun_init([_AS_DIRNAME_EXPR],
  851. [AS_REQUIRE([_AS_EXPR_PREPARE])],
  852. [$as_expr X[]$1 : 'X\(.*[[^/]]\)//*[[^/][^/]]*/*$' \| \
  853. X[]$1 : 'X\(//\)[[^/]]' \| \
  854. X[]$1 : 'X\(//\)$' \| \
  855. X[]$1 : 'X\(/\)' \| .])
  856. m4_defun([_AS_DIRNAME_SED],
  857. [AS_ECHO([X[]$1]) |
  858. sed ['/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
  859. s//\1/
  860. q
  861. }
  862. /^X\(\/\/\)[^/].*/{
  863. s//\1/
  864. q
  865. }
  866. /^X\(\/\/\)$/{
  867. s//\1/
  868. q
  869. }
  870. /^X\(\/\).*/{
  871. s//\1/
  872. q
  873. }
  874. s/.*/./; q']])
  875. m4_defun_init([AS_DIRNAME],
  876. [AS_REQUIRE([_$0_PREPARE])],
  877. [$as_dirname -- $1 ||
  878. _AS_DIRNAME_EXPR([$1]) 2>/dev/null ||
  879. _AS_DIRNAME_SED([$1])])
  880. # _AS_DIRNAME_PREPARE
  881. # -------------------
  882. m4_defun([_AS_DIRNAME_PREPARE],
  883. [AS_REQUIRE([_AS_EXPR_PREPARE])]dnl
  884. [if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
  885. as_dirname=dirname
  886. else
  887. as_dirname=false
  888. fi
  889. ])# _AS_DIRNAME_PREPARE
  890. # AS_ECHO(WORD)
  891. # -------------
  892. # Output WORD followed by a newline. WORD must be a single shell word
  893. # (typically a quoted string). The bytes of WORD are output as-is, even
  894. # if it starts with "-" or contains "\".
  895. m4_defun_init([AS_ECHO],
  896. [AS_REQUIRE([_$0_PREPARE])],
  897. [$as_echo $1])
  898. # AS_ECHO_N(WORD)
  899. # ---------------
  900. # Like AS_ECHO(WORD), except do not output the trailing newline.
  901. m4_defun_init([AS_ECHO_N],
  902. [AS_REQUIRE([_AS_ECHO_PREPARE])],
  903. [$as_echo_n $1])
  904. # _AS_ECHO_PREPARE
  905. # ----------------
  906. # Arrange for $as_echo 'FOO' to echo FOO without escape-interpretation;
  907. # and similarly for $as_echo_n, which omits the trailing newline.
  908. # 'FOO' is an optional single argument; a missing FOO is treated as empty.
  909. m4_defun([_AS_ECHO_PREPARE],
  910. [[as_nl='
  911. '
  912. export as_nl
  913. as_echo='printf %s\n'
  914. as_echo_n='printf %s'
  915. ]])# _AS_ECHO_PREPARE
  916. # AS_TEST_X
  917. # ---------
  918. # Check whether a file has executable or search permissions.
  919. # FIXME: This macro is no longer useful; consider deleting it in 2014
  920. # after we ensure m4sh scripts can always find a shell with test -x.
  921. m4_defun_init([AS_TEST_X],
  922. [AS_REQUIRE([_AS_TEST_PREPARE])],
  923. [test -x $1[]])# AS_TEST_X
  924. # AS_EXECUTABLE_P
  925. # ---------------
  926. # Check whether a file is a regular file that has executable permissions.
  927. m4_defun_init([AS_EXECUTABLE_P],
  928. [AS_REQUIRE([_AS_TEST_PREPARE])],
  929. [as_fn_executable_p $1])# AS_EXECUTABLE_P
  930. # _AS_EXPR_PREPARE
  931. # ----------------
  932. # QNX 4.25 expr computes and issue the right result but exits with failure.
  933. # Tru64 expr mishandles leading zeros in numeric strings.
  934. # Detect these flaws.
  935. m4_defun([_AS_EXPR_PREPARE],
  936. [if expr a : '\(a\)' >/dev/null 2>&1 &&
  937. test "X`expr 00001 : '.*\(...\)'`" = X001; then
  938. as_expr=expr
  939. else
  940. as_expr=false
  941. fi
  942. ])# _AS_EXPR_PREPARE
  943. # _AS_ME_PREPARE
  944. # --------------
  945. # Define $as_me to the basename of the executable file's name.
  946. m4_defun([AS_ME_PREPARE], [AS_REQUIRE([_$0])])
  947. m4_defun([_AS_ME_PREPARE],
  948. [AS_REQUIRE([_AS_BASENAME_PREPARE])]dnl
  949. [as_me=`AS_BASENAME("$[0]")`
  950. ])
  951. # _AS_LINENO_WORKS
  952. # ----------------
  953. # Succeed if the currently executing shell supports LINENO.
  954. # This macro does not expand to a single shell command, so be careful
  955. # when using it. Surrounding the body of this macro with {} would
  956. # cause "bash -c '_ASLINENO_WORKS'" to fail (with Bash 2.05, anyway),
  957. # but that bug is irrelevant to our use of LINENO. We can't use
  958. # AS_VAR_ARITH, as this is expanded prior to shell functions.
  959. #
  960. # Testing for LINENO support is hard; we use _AS_LINENO_WORKS inside
  961. # _AS_RUN, which sometimes eval's its argument (pdksh gives false
  962. # negatives if $LINENO is expanded by eval), and sometimes passes the
  963. # argument to another shell (if the current shell supports LINENO,
  964. # then expanding $LINENO prior to the string leads to false
  965. # positives). Hence, we perform two tests, and coordinate with
  966. # _AS_DETECT_EXPAND (which ensures that only the first of two LINENO
  967. # is expanded in advance) and _AS_RUN (which sets $as_run to 'a' when
  968. # handing the test to another shell), so that we know which test to
  969. # trust.
  970. m4_define([_AS_LINENO_WORKS],
  971. [ as_lineno_1=$LINENO as_lineno_1a=$LINENO
  972. as_lineno_2=$LINENO as_lineno_2a=$LINENO
  973. eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
  974. test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"'])
  975. # _AS_LINENO_PREPARE
  976. # ------------------
  977. # If LINENO is not supported by the shell, produce a version of this
  978. # script where LINENO is hard coded.
  979. # Comparing LINENO against _oline_ is not a good solution, since in
  980. # the case of embedded executables (such as config.status within
  981. # configure) you'd compare LINENO wrt config.status vs. _oline_ wrt
  982. # configure.
  983. #
  984. # AS_ERROR normally uses LINENO if logging, but AS_LINENO_PREPARE uses
  985. # AS_ERROR. Besides, if the logging fd is open, we don't want to use
  986. # $LINENO in the log complaining about broken LINENO. We break the
  987. # circular require by changing AS_ERROR and AS_MESSAGE_LOG_FD.
  988. m4_defun([AS_LINENO_PREPARE], [AS_REQUIRE([_$0])])
  989. m4_defun([_AS_LINENO_PREPARE],
  990. [AS_REQUIRE([_AS_CR_PREPARE])]dnl
  991. [AS_REQUIRE([_AS_ME_PREPARE])]dnl
  992. [_AS_DETECT_SUGGESTED([_AS_LINENO_WORKS])]dnl
  993. [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl
  994. [m4_pushdef([AS_ERROR],
  995. [{ AS_MESSAGE(]m4_dquote([error: $][1])[, [2]); AS_EXIT([1]); }])]dnl
  996. dnl Create $as_me.lineno as a copy of $as_myself, but with $LINENO
  997. dnl uniformly replaced by the line number. The first 'sed' inserts a
  998. dnl line-number line after each line using $LINENO; the second 'sed'
  999. dnl does the real work. The second script uses 'N' to pair each
  1000. dnl line-number line with the line containing $LINENO, and appends
  1001. dnl trailing '-' during substitution so that $LINENO is not a special
  1002. dnl case at line end. (Raja R Harinath suggested sed '=', and Paul
  1003. dnl Eggert wrote the scripts with optimization help from Paolo Bonzini).
  1004. [_AS_LINENO_WORKS || {
  1005. [ # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-)
  1006. sed -n '
  1007. p
  1008. /[$]LINENO/=
  1009. ' <$as_myself |
  1010. sed '
  1011. s/[$]LINENO.*/&-/
  1012. t lineno
  1013. b
  1014. :lineno
  1015. N
  1016. :loop
  1017. s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
  1018. t loop
  1019. s/-\n.*//
  1020. ' >$as_me.lineno &&
  1021. chmod +x "$as_me.lineno"] ||
  1022. AS_ERROR([cannot create $as_me.lineno; rerun with a POSIX shell])
  1023. # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
  1024. # already done that, so ensure we don't try to do so again and fall
  1025. # in an infinite loop. This has already happened in practice.
  1026. _as_can_reexec=no; export _as_can_reexec
  1027. # Don't try to exec as it changes $[0], causing all sort of problems
  1028. # (the dirname of $[0] is not the place where we might find the
  1029. # original and so on. Autoconf is especially sensitive to this).
  1030. . "./$as_me.lineno"
  1031. # Exit status is that of the last command.
  1032. exit
  1033. }
  1034. _m4_popdef([AS_MESSAGE_LOG_FD], [AS_ERROR])])# _AS_LINENO_PREPARE
  1035. # _AS_LN_S_PREPARE
  1036. # ----------------
  1037. # Don't use conftest.sym to avoid file name issues on DJGPP, where this
  1038. # would yield conftest.sym.exe for DJGPP < 2.04. And don't use `conftest'
  1039. # as base name to avoid prohibiting concurrency (e.g., concurrent
  1040. # config.statuses). On read-only media, assume 'cp -pR' and hope we
  1041. # are just running --help anyway.
  1042. m4_defun([_AS_LN_S_PREPARE],
  1043. [rm -f conf$$ conf$$.exe conf$$.file
  1044. if test -d conf$$.dir; then
  1045. rm -f conf$$.dir/conf$$.file
  1046. else
  1047. rm -f conf$$.dir
  1048. mkdir conf$$.dir 2>/dev/null
  1049. fi
  1050. if (echo >conf$$.file) 2>/dev/null; then
  1051. if ln -s conf$$.file conf$$ 2>/dev/null; then
  1052. as_ln_s='ln -s'
  1053. # ... but there are two gotchas:
  1054. # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
  1055. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
  1056. # In both cases, we have to default to `cp -pR'.
  1057. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
  1058. as_ln_s='cp -pR'
  1059. elif ln conf$$.file conf$$ 2>/dev/null; then
  1060. as_ln_s=ln
  1061. else
  1062. as_ln_s='cp -pR'
  1063. fi
  1064. else
  1065. as_ln_s='cp -pR'
  1066. fi
  1067. rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
  1068. rmdir conf$$.dir 2>/dev/null
  1069. ])# _AS_LN_S_PREPARE
  1070. # AS_LN_S(FILE, LINK)
  1071. # -------------------
  1072. # FIXME: Should we add the glue code to handle properly relative symlinks
  1073. # simulated with `ln' or `cp'?
  1074. m4_defun_init([AS_LN_S],
  1075. [AS_REQUIRE([_AS_LN_S_PREPARE])],
  1076. [$as_ln_s $1 $2])
  1077. # _AS_MKDIR_P
  1078. # -----------
  1079. # Emit code that can be used to emulate `mkdir -p` with plain `mkdir';
  1080. # the code assumes that "$as_dir" contains the directory to create.
  1081. # $as_dir is normalized, so there is no need to worry about using --.
  1082. m4_define([_AS_MKDIR_P],
  1083. [case $as_dir in #(
  1084. -*) as_dir=./$as_dir;;
  1085. esac
  1086. test -d "$as_dir" || eval $as_mkdir_p || {
  1087. as_dirs=
  1088. while :; do
  1089. case $as_dir in #(
  1090. *\'*) as_qdir=`AS_ECHO(["$as_dir"]) | sed "s/'/'\\\\\\\\''/g"`;; #'(
  1091. *) as_qdir=$as_dir;;
  1092. esac
  1093. as_dirs="'$as_qdir' $as_dirs"
  1094. as_dir=`AS_DIRNAME("$as_dir")`
  1095. test -d "$as_dir" && break
  1096. done
  1097. test -z "$as_dirs" || eval "mkdir $as_dirs"
  1098. } || test -d "$as_dir" || AS_ERROR([cannot create directory $as_dir])
  1099. ])
  1100. # AS_MKDIR_P(DIR)
  1101. # ---------------
  1102. # Emulate `mkdir -p' with plain `mkdir' if needed.
  1103. m4_defun_init([AS_MKDIR_P],
  1104. [AS_REQUIRE([_$0_PREPARE])],
  1105. [as_dir=$1; as_fn_mkdir_p])# AS_MKDIR_P
  1106. # _AS_MKDIR_P_PREPARE
  1107. # -------------------
  1108. m4_defun([_AS_MKDIR_P_PREPARE],
  1109. [AS_REQUIRE_SHELL_FN([as_fn_mkdir_p],
  1110. [AS_FUNCTION_DESCRIBE([as_fn_mkdir_p], [],
  1111. [Create "$as_dir" as a directory, including parents if necessary.])],
  1112. [
  1113. _AS_MKDIR_P
  1114. ])]dnl
  1115. [if mkdir -p . 2>/dev/null; then
  1116. as_mkdir_p='mkdir -p "$as_dir"'
  1117. else
  1118. test -d ./-p && rmdir ./-p
  1119. as_mkdir_p=false
  1120. fi
  1121. ])# _AS_MKDIR_P_PREPARE
  1122. # _AS_PATH_SEPARATOR_PREPARE
  1123. # --------------------------
  1124. # Compute the path separator.
  1125. m4_defun([_AS_PATH_SEPARATOR_PREPARE],
  1126. [# The user is always right.
  1127. if test "${PATH_SEPARATOR+set}" != set; then
  1128. PATH_SEPARATOR=:
  1129. (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
  1130. (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
  1131. PATH_SEPARATOR=';'
  1132. }
  1133. fi
  1134. ])# _AS_PATH_SEPARATOR_PREPARE
  1135. # _AS_PATH_WALK([PATH = $PATH], BODY, [IF-NOT-FOUND])
  1136. # ---------------------------------------------------
  1137. # Walk through PATH running BODY for each `as_dir'. If BODY never does a
  1138. # `break', evaluate IF-NOT-FOUND.
  1139. #
  1140. # Still very private as its interface looks quite bad.
  1141. #
  1142. # `$as_dummy' forces splitting on constant user-supplied paths.
  1143. # POSIX.2 field splitting is done only on the result of word
  1144. # expansions, not on literal text. This closes a longstanding sh security
  1145. # hole. Optimize it away when not needed, i.e., if there are no literal
  1146. # path separators.
  1147. m4_defun_init([_AS_PATH_WALK],
  1148. [AS_REQUIRE([_AS_PATH_SEPARATOR_PREPARE])],
  1149. [as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
  1150. m4_ifvaln([$3], [as_found=false])dnl
  1151. m4_bmatch([$1], [[:;]],
  1152. [as_dummy="$1"
  1153. for as_dir in $as_dummy],
  1154. [for as_dir in m4_default([$1], [$PATH])])
  1155. do
  1156. IFS=$as_save_IFS
  1157. test -z "$as_dir" && as_dir=.
  1158. m4_ifvaln([$3], [as_found=:])dnl
  1159. $2
  1160. m4_ifvaln([$3], [as_found=false])dnl
  1161. done
  1162. m4_ifvaln([$3], [$as_found || { $3; }])dnl
  1163. IFS=$as_save_IFS
  1164. ])
  1165. # AS_SET_CATFILE(VAR, DIR-NAME, FILE-NAME)
  1166. # ----------------------------------------
  1167. # Set VAR to DIR-NAME/FILE-NAME.
  1168. # Optimize the common case where $2 or $3 is '.'.
  1169. m4_define([AS_SET_CATFILE],
  1170. [case $2 in @%:@((
  1171. .) AS_VAR_SET([$1], [$3]);;
  1172. *)
  1173. case $3 in @%:@(((
  1174. .) AS_VAR_SET([$1], [$2]);;
  1175. [[\\/]]* | ?:[[\\/]]* ) AS_VAR_SET([$1], [$3]);;
  1176. *) AS_VAR_SET([$1], [$2/$3]);;
  1177. esac;;
  1178. esac[]])# AS_SET_CATFILE
  1179. # _AS_TEST_X_WORKS
  1180. # ----------------
  1181. # These days, we require that `test -x' works.
  1182. m4_define([_AS_TEST_X_WORKS], [test -x /])
  1183. # _AS_TEST_PREPARE
  1184. # ----------------
  1185. # Provide back-compat to people that hooked into our undocumented
  1186. # internals (here's looking at you, libtool).
  1187. m4_defun([_AS_TEST_PREPARE],
  1188. [AS_REQUIRE_SHELL_FN([as_fn_executable_p],
  1189. [AS_FUNCTION_DESCRIBE([as_fn_executable_p], [FILE],
  1190. [Test if FILE is an executable regular file.])],
  1191. [ test -f "$[]1" && test -x "$[]1"])]dnl
  1192. [as_test_x='test -x'
  1193. as_executable_p=as_fn_executable_p
  1194. ])# _AS_TEST_PREPARE
  1195. ## ------------------ ##
  1196. ## 5. Common idioms. ##
  1197. ## ------------------ ##
  1198. # This section is lexicographically sorted.
  1199. # AS_BOX(MESSAGE, [FRAME-CHARACTER = `-'])
  1200. # ----------------------------------------
  1201. # Output MESSAGE, a single line text, framed with FRAME-CHARACTER (which
  1202. # must not be `/').
  1203. m4_define([AS_BOX],
  1204. [_$0(m4_expand([$1]), [$2])])
  1205. m4_define([_AS_BOX],
  1206. [m4_if(m4_index(m4_translit([[$1]], [`\"], [$$$]), [$]),
  1207. [-1], [$0_LITERAL], [$0_INDIR])($@)])
  1208. # _AS_BOX_LITERAL(MESSAGE, [FRAME-CHARACTER = `-'])
  1209. # -------------------------------------------------
  1210. m4_define([_AS_BOX_LITERAL],
  1211. [AS_ECHO(["_AS_ESCAPE(m4_dquote(m4_expand([m4_text_box($@)])), [`], [\"$])"])])
  1212. # _AS_BOX_INDIR(MESSAGE, [FRAME-CHARACTER = `-'])
  1213. # -----------------------------------------------
  1214. m4_define([_AS_BOX_INDIR],
  1215. [sed 'h;s/./m4_default([$2], [-])/g;s/^.../@%:@@%:@ /;s/...$/ @%:@@%:@/;p;x;p;x' <<_ASBOX
  1216. @%:@@%:@ $1 @%:@@%:@
  1217. _ASBOX])
  1218. # _AS_CLEAN_DIR(DIR)
  1219. # ------------------
  1220. # Remove all contents from within DIR, including any unwritable
  1221. # subdirectories, but leave DIR itself untouched.
  1222. m4_define([_AS_CLEAN_DIR],
  1223. [if test -d $1; then
  1224. find $1 -type d ! -perm -700 -exec chmod u+rwx {} \;
  1225. rm -fr $1/* $1/.[[!.]] $1/.??*
  1226. fi])
  1227. # AS_FUNCTION_DESCRIBE(NAME, [ARGS], DESCRIPTION, [WRAP-COLUMN = 79])
  1228. # -------------------------------------------------------------------
  1229. # Output a shell comment describing NAME and its arguments ARGS, then
  1230. # a separator line, then the DESCRIPTION wrapped at a decimal
  1231. # WRAP-COLUMN. The output resembles:
  1232. # # NAME ARGS
  1233. # # ---------
  1234. # # Wrapped DESCRIPTION text
  1235. # NAME and ARGS are expanded, while DESCRIPTION is treated as a
  1236. # whitespace-separated list of strings that are not expanded.
  1237. m4_define([AS_FUNCTION_DESCRIBE],
  1238. [@%:@ $1[]m4_ifval([$2], [ $2])
  1239. @%:@ m4_translit(m4_format([%*s],
  1240. m4_decr(m4_qlen(_m4_expand([$1[]m4_ifval([$2], [ $2])
  1241. ]))), []), [ ], [-])
  1242. m4_text_wrap([$3], [@%:@ ], [], [$4])])
  1243. # AS_HELP_STRING(LHS, RHS, [INDENT-COLUMN = 26], [WRAP-COLUMN = 79])
  1244. # ------------------------------------------------------------------
  1245. #
  1246. # Format a help string so that it looks pretty when the user executes
  1247. # "script --help". This macro takes up to four arguments, a
  1248. # "left hand side" (LHS), a "right hand side" (RHS), a decimal
  1249. # INDENT-COLUMN which is the column where wrapped lines should begin
  1250. # (the default of 26 is recommended), and a decimal WRAP-COLUMN which is
  1251. # the column where lines should wrap (the default of 79 is recommended).
  1252. # LHS is expanded, RHS is not.
  1253. #
  1254. # For backwards compatibility not documented in the manual, INDENT-COLUMN
  1255. # can also be specified as a string of white spaces, whose width
  1256. # determines the indentation column. Using TABs in INDENT-COLUMN is not
  1257. # recommended, since screen width of TAB is not computed.
  1258. #
  1259. # The resulting string is suitable for use in other macros that require
  1260. # a help string (e.g. AC_ARG_WITH).
  1261. #
  1262. # Here is the sample string from the Autoconf manual (Node: External
  1263. # Software) which shows the proper spacing for help strings.
  1264. #
  1265. # --with-readline support fancy command line editing
  1266. # ^ ^ ^
  1267. # | | |
  1268. # | column 2 column 26
  1269. # |
  1270. # column 0
  1271. #
  1272. # A help string is made up of a "left hand side" (LHS) and a "right
  1273. # hand side" (RHS). In the example above, the LHS is
  1274. # "--with-readline", while the RHS is "support fancy command line
  1275. # editing".
  1276. #
  1277. # If the LHS contains more than (INDENT-COLUMN - 3) characters, then the
  1278. # LHS is terminated with a newline so that the RHS starts on a line of its
  1279. # own beginning at INDENT-COLUMN. In the default case, this corresponds to an
  1280. # LHS with more than 23 characters.
  1281. #
  1282. # Therefore, in the example, if the LHS were instead
  1283. # "--with-readline-blah-blah-blah", then the AS_HELP_STRING macro would
  1284. # expand into:
  1285. #
  1286. #
  1287. # --with-readline-blah-blah-blah
  1288. # ^ ^ support fancy command line editing
  1289. # | | ^
  1290. # | column 2 |
  1291. # column 0 column 26
  1292. #
  1293. #
  1294. # m4_text_wrap hacks^Wworks around the fact that m4_format does not
  1295. # know quadrigraphs.
  1296. #
  1297. m4_define([AS_HELP_STRING],
  1298. [m4_text_wrap([$2], m4_cond([[$3]], [], [ ],
  1299. [m4_eval([$3]+0)], [0], [[$3]],
  1300. [m4_format([[%*s]], [$3], [])]),
  1301. m4_expand([ $1 ]), [$4])])# AS_HELP_STRING
  1302. # AS_IDENTIFIER_IF(EXPRESSION, IF-IDENT, IF-NOT-IDENT)
  1303. # ----------------------------------------------------
  1304. # If EXPRESSION serves as an identifier (ie, after removal of @&t@, it
  1305. # matches the regex `^[a-zA-Z_][a-zA-Z_0-9]*$'), execute IF-IDENT,
  1306. # otherwise IF-NOT-IDENT.
  1307. #
  1308. # This is generally faster than the alternative:
  1309. # m4_bmatch(m4_bpatsubst([[$1]], [@&t@]), ^m4_defn([m4_re_word])$,
  1310. # [$2], [$3])
  1311. #
  1312. # Rather than expand m4_defn every time AS_IDENTIFIER_IF is expanded, we
  1313. # inline its expansion up front. Only use a regular expression if we
  1314. # detect a potential quadrigraph.
  1315. #
  1316. # First, check if the entire string matches m4_cr_symbol2. Only then do
  1317. # we worry if the first character also matches m4_cr_symbol1 (ie. does not
  1318. # match m4_cr_digit).
  1319. m4_define([AS_IDENTIFIER_IF],
  1320. [m4_if(_$0(m4_if(m4_index([$1], [@]), [-1],
  1321. [[$1]], [m4_bpatsubst([[$1]], [@&t@])])), [-], [$2], [$3])])
  1322. m4_define([_AS_IDENTIFIER_IF],
  1323. [m4_cond([[$1]], [], [],
  1324. [m4_eval(m4_len(m4_translit([[$1]], ]]dnl
  1325. m4_dquote(m4_dquote(m4_defn([m4_cr_symbols2])))[[)) > 0)], [1], [],
  1326. [m4_len(m4_translit(m4_format([[%.1s]], [$1]), ]]dnl
  1327. m4_dquote(m4_dquote(m4_defn([m4_cr_symbols1])))[[))], [0], [-])])
  1328. # AS_LITERAL_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL,
  1329. # [IF-SIMPLE-REF = IF-NOT-LITERAL])
  1330. # -----------------------------------------------------
  1331. # If EXPRESSION has no shell indirections ($var or `expr`), expand
  1332. # IF-LITERAL, else IF-NOT-LITERAL. In some cases, IF-NOT-LITERAL
  1333. # must be complex to safely deal with ``, while a simpler
  1334. # expression IF-SIMPLE-REF can be used if the indirection
  1335. # involves only shell variable expansion (as in ${varname}).
  1336. #
  1337. # EXPRESSION is treated as a literal if it results in the same
  1338. # interpretation whether it is unquoted or contained within double
  1339. # quotes, with the exception that whitespace is ignored (on the
  1340. # assumption that it will be flattened to _). Therefore, neither `\$'
  1341. # nor `a''b' is a literal, since both backslash and single quotes have
  1342. # different quoting behavior in the two contexts; and `a*' is not a
  1343. # literal, because it has different globbing. Note, however, that
  1344. # while `${a+b}' is neither a literal nor a simple ref, `a+b' is a
  1345. # literal. This macro is an *approximation*: it is possible that
  1346. # there are some EXPRESSIONs which the shell would treat as literals,
  1347. # but which this macro does not recognize.
  1348. #
  1349. # Why do we reject EXPRESSION expanding with `[' or `]' as a literal?
  1350. # Because AS_TR_SH is MUCH faster if it can use m4_translit on literals
  1351. # instead of m4_bpatsubst; but m4_translit is much tougher to do safely
  1352. # if `[' is translated. That, and file globbing matters.
  1353. #
  1354. # Note that the quadrigraph @S|@ can result in non-literals, but outright
  1355. # rejecting all @ would make AC_INIT complain on its bug report address.
  1356. #
  1357. # We used to use m4_bmatch(m4_quote($1), [[`$]], [$3], [$2]), but
  1358. # profiling shows that it is faster to use m4_translit.
  1359. #
  1360. # Because the translit is stripping quotes, it must also neutralize
  1361. # anything that might be in a macro name, as well as comments, commas,
  1362. # or unbalanced parentheses. Valid shell variable characters and
  1363. # unambiguous literal characters are deleted (`a.b'), and remaining
  1364. # characters are normalized into `$' if they can form simple refs
  1365. # (${a}), `+' if they can potentially form literals (a+b), ``' if they
  1366. # can interfere with m4 parsing, or left alone otherwise. If both `$'
  1367. # and `+' are left, it is treated as a complex reference (${a+b}),
  1368. # even though it could technically be a simple reference (${a}+b).
  1369. # _AS_LITERAL_IF_ only has to check for an empty string after removing
  1370. # one of the two normalized characters.
  1371. #
  1372. # Rather than expand m4_defn every time AS_LITERAL_IF is expanded, we
  1373. # inline its expansion up front. _AS_LITERAL_IF expands to the name
  1374. # of a macro that takes three arguments: IF-SIMPLE-REF,
  1375. # IF-NOT-LITERAL, IF-LITERAL. It also takes an optional argument of
  1376. # any additional characters to allow as literals (useful for AS_TR_SH
  1377. # and AS_TR_CPP to perform inline conversion of whitespace to _). The
  1378. # order of the arguments allows reuse of m4_default.
  1379. m4_define([AS_LITERAL_IF],
  1380. [_$0(m4_expand([$1]), [ ][
  1381. ])([$4], [$3], [$2])])
  1382. m4_define([_AS_LITERAL_IF],
  1383. [m4_if(m4_index([$1], [@S|@]), [-1], [$0_(m4_translit([$1],
  1384. [-:=%/@{}[]#(),.$2]]]m4_dquote(m4_dquote(m4_defn([m4_cr_symbols2])))[[,
  1385. [++++++$$`````]))], [$0_NO])])
  1386. m4_define([_AS_LITERAL_IF_],
  1387. [m4_if(m4_translit([$1], [+]), [], [$0YES],
  1388. m4_translit([$1], [$]), [], [m4_default], [$0NO])])
  1389. m4_define([_AS_LITERAL_IF_YES], [$3])
  1390. m4_define([_AS_LITERAL_IF_NO], [$2])
  1391. # AS_LITERAL_WORD_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL,
  1392. # [IF-SIMPLE-REF = IF-NOT-LITERAL])
  1393. # ----------------------------------------------------------
  1394. # Like AS_LITERAL_IF, except that spaces and tabs in EXPRESSION
  1395. # are treated as non-literal.
  1396. m4_define([AS_LITERAL_WORD_IF],
  1397. [_AS_LITERAL_IF(m4_expand([$1]))([$4], [$3], [$2])])
  1398. # AS_LITERAL_HEREDOC_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL)
  1399. # -------------------------------------------------------------
  1400. # Like AS_LITERAL_IF, except that a string is considered literal
  1401. # if it results in the same output in both quoted and unquoted
  1402. # here-documents.
  1403. m4_define([AS_LITERAL_HEREDOC_IF],
  1404. [_$0(m4_expand([$1]))([$2], [$3])])
  1405. m4_define([_AS_LITERAL_HEREDOC_IF],
  1406. [m4_if(m4_index([$1], [@S|@]), [-1],
  1407. [m4_if(m4_index(m4_translit([[$1]], [\`], [$]), [$]), [-1],
  1408. [$0_YES], [$0_NO])],
  1409. [$0_NO])])
  1410. m4_define([_AS_LITERAL_HEREDOC_IF_YES], [$1])
  1411. m4_define([_AS_LITERAL_HEREDOC_IF_NO], [$2])
  1412. # AS_TMPDIR(PREFIX, [DIRECTORY = $TMPDIR [= /tmp]])
  1413. # -------------------------------------------------
  1414. # Create as safely as possible a temporary directory in DIRECTORY
  1415. # which name is inspired by PREFIX (should be 2-4 chars max).
  1416. #
  1417. # Even though $tmp does not fit our normal naming scheme of $as_*,
  1418. # it is a documented part of the public API and must not be changed.
  1419. m4_define([AS_TMPDIR],
  1420. [# Create a (secure) tmp directory for tmp files.
  1421. m4_if([$2], [], [: "${TMPDIR:=/tmp}"])
  1422. {
  1423. tmp=`(umask 077 && mktemp -d "m4_default([$2],
  1424. [$TMPDIR])/$1XXXXXX") 2>/dev/null` &&
  1425. test -d "$tmp"
  1426. } ||
  1427. {
  1428. tmp=m4_default([$2], [$TMPDIR])/$1$$-$RANDOM
  1429. (umask 077 && mkdir "$tmp")
  1430. } || AS_ERROR([cannot create a temporary directory in m4_default([$2],
  1431. [$TMPDIR])])])# AS_TMPDIR
  1432. # AS_UNAME
  1433. # --------
  1434. # Try to describe this machine. Meant for logs.
  1435. m4_define([AS_UNAME],
  1436. [{
  1437. cat <<_ASUNAME
  1438. m4_text_box([Platform.])
  1439. hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
  1440. uname -m = `(uname -m) 2>/dev/null || echo unknown`
  1441. uname -r = `(uname -r) 2>/dev/null || echo unknown`
  1442. uname -s = `(uname -s) 2>/dev/null || echo unknown`
  1443. uname -v = `(uname -v) 2>/dev/null || echo unknown`
  1444. /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
  1445. /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
  1446. /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
  1447. /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
  1448. /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
  1449. /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown`
  1450. /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
  1451. /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
  1452. /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
  1453. _ASUNAME
  1454. _AS_PATH_WALK([$PATH], [AS_ECHO(["PATH: $as_dir"])])
  1455. }])
  1456. # _AS_VERSION_COMPARE_PREPARE
  1457. # ---------------------------
  1458. # Output variables for comparing version numbers.
  1459. m4_defun([_AS_VERSION_COMPARE_PREPARE],
  1460. [[as_awk_strverscmp='
  1461. # Use only awk features that work with 7th edition Unix awk (1978).
  1462. # My, what an old awk you have, Mr. Solaris!
  1463. END {
  1464. while (length(v1) && length(v2)) {
  1465. # Set d1 to be the next thing to compare from v1, and likewise for d2.
  1466. # Normally this is a single character, but if v1 and v2 contain digits,
  1467. # compare them as integers and fractions as strverscmp does.
  1468. if (v1 ~ /^[0-9]/ && v2 ~ /^[0-9]/) {
  1469. # Split v1 and v2 into their leading digit string components d1 and d2,
  1470. # and advance v1 and v2 past the leading digit strings.
  1471. for (len1 = 1; substr(v1, len1 + 1) ~ /^[0-9]/; len1++) continue
  1472. for (len2 = 1; substr(v2, len2 + 1) ~ /^[0-9]/; len2++) continue
  1473. d1 = substr(v1, 1, len1); v1 = substr(v1, len1 + 1)
  1474. d2 = substr(v2, 1, len2); v2 = substr(v2, len2 + 1)
  1475. if (d1 ~ /^0/) {
  1476. if (d2 ~ /^0/) {
  1477. # Compare two fractions.
  1478. while (d1 ~ /^0/ && d2 ~ /^0/) {
  1479. d1 = substr(d1, 2); len1--
  1480. d2 = substr(d2, 2); len2--
  1481. }
  1482. if (len1 != len2 && ! (len1 && len2 && substr(d1, 1, 1) == substr(d2, 1, 1))) {
  1483. # The two components differ in length, and the common prefix
  1484. # contains only leading zeros. Consider the longer to be less.
  1485. d1 = -len1
  1486. d2 = -len2
  1487. } else {
  1488. # Otherwise, compare as strings.
  1489. d1 = "x" d1
  1490. d2 = "x" d2
  1491. }
  1492. } else {
  1493. # A fraction is less than an integer.
  1494. exit 1
  1495. }
  1496. } else {
  1497. if (d2 ~ /^0/) {
  1498. # An integer is greater than a fraction.
  1499. exit 2
  1500. } else {
  1501. # Compare two integers.
  1502. d1 += 0
  1503. d2 += 0
  1504. }
  1505. }
  1506. } else {
  1507. # The normal case, without worrying about digits.
  1508. d1 = substr(v1, 1, 1); v1 = substr(v1, 2)
  1509. d2 = substr(v2, 1, 1); v2 = substr(v2, 2)
  1510. }
  1511. if (d1 < d2) exit 1
  1512. if (d1 > d2) exit 2
  1513. }
  1514. # Beware Solaris /usr/xgp4/bin/awk (at least through Solaris 10),
  1515. # which mishandles some comparisons of empty strings to integers.
  1516. if (length(v2)) exit 1
  1517. if (length(v1)) exit 2
  1518. }
  1519. ']])# _AS_VERSION_COMPARE_PREPARE
  1520. # AS_VERSION_COMPARE(VERSION-1, VERSION-2,
  1521. # [ACTION-IF-LESS], [ACTION-IF-EQUAL], [ACTION-IF-GREATER])
  1522. # ----------------------------------------------------------------------------
  1523. # Compare two strings possibly containing shell variables as version strings.
  1524. #
  1525. # This usage is portable even to ancient awk,
  1526. # so don't worry about finding a "nice" awk version.
  1527. m4_defun_init([AS_VERSION_COMPARE],
  1528. [AS_REQUIRE([_$0_PREPARE])],
  1529. [as_arg_v1=$1
  1530. as_arg_v2=$2
  1531. awk "$as_awk_strverscmp" v1="$as_arg_v1" v2="$as_arg_v2" /dev/null
  1532. AS_CASE([$?],
  1533. [1], [$3],
  1534. [0], [$4],
  1535. [2], [$5])])# AS_VERSION_COMPARE
  1536. ## --------------------------------------- ##
  1537. ## 6. Common m4/sh character translation. ##
  1538. ## --------------------------------------- ##
  1539. # The point of this section is to provide high level macros comparable
  1540. # to m4's `translit' primitive, but m4/sh polymorphic.
  1541. # Transliteration of literal strings should be handled by m4, while
  1542. # shell variables' content will be translated at runtime (tr or sed).
  1543. # _AS_CR_PREPARE
  1544. # --------------
  1545. # Output variables defining common character ranges.
  1546. # See m4_cr_letters etc.
  1547. m4_defun([_AS_CR_PREPARE],
  1548. [# Avoid depending upon Character Ranges.
  1549. as_cr_letters='abcdefghijklmnopqrstuvwxyz'
  1550. as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  1551. as_cr_Letters=$as_cr_letters$as_cr_LETTERS
  1552. as_cr_digits='0123456789'
  1553. as_cr_alnum=$as_cr_Letters$as_cr_digits
  1554. ])
  1555. # _AS_TR_SH_PREPARE
  1556. # -----------------
  1557. m4_defun([_AS_TR_SH_PREPARE],
  1558. [AS_REQUIRE([_AS_CR_PREPARE])]dnl
  1559. [# Sed expression to map a string onto a valid variable name.
  1560. as_tr_sh="eval sed 'y%*+%pp%;s%[[^_$as_cr_alnum]]%_%g'"
  1561. ])
  1562. # AS_TR_SH(EXPRESSION)
  1563. # --------------------
  1564. # Transform EXPRESSION into a valid shell variable name.
  1565. # sh/m4 polymorphic.
  1566. # Be sure to update the definition of `$as_tr_sh' if you change this.
  1567. #
  1568. # AS_LITERAL_IF guarantees that a literal does not have any nested quotes,
  1569. # once $1 is expanded. m4_translit silently uses only the first occurrence
  1570. # of a character that appears multiple times in argument 2, since we know
  1571. # that m4_cr_not_symbols2 also contains [ and ]. m4_translit also silently
  1572. # ignores characters in argument 3 that do not match argument 2; we use this
  1573. # fact to skip worrying about the length of m4_cr_not_symbols2.
  1574. #
  1575. # For speed, we inline the literal definitions that can be computed up front.
  1576. m4_defun_init([AS_TR_SH],
  1577. [AS_REQUIRE([_$0_PREPARE])],
  1578. [_$0(m4_expand([$1]))])
  1579. m4_define([_AS_TR_SH],
  1580. [_AS_LITERAL_IF([$1], [*][ ][
  1581. ])([], [$0_INDIR], [$0_LITERAL])([$1])])
  1582. m4_define([_AS_TR_SH_LITERAL],
  1583. [m4_translit([[$1]],
  1584. [*+[]]]m4_dquote(m4_defn([m4_cr_not_symbols2]))[,
  1585. [pp[]]]m4_dquote(m4_for(,1,255,,[[_]]))[)])
  1586. m4_define([_AS_TR_SH_INDIR],
  1587. [`AS_ECHO(["_AS_ESCAPE([[$1]], [`], [\])"]) | $as_tr_sh`])
  1588. # _AS_TR_CPP_PREPARE
  1589. # ------------------
  1590. m4_defun([_AS_TR_CPP_PREPARE],
  1591. [AS_REQUIRE([_AS_CR_PREPARE])]dnl
  1592. [# Sed expression to map a string onto a valid CPP name.
  1593. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[[^_$as_cr_alnum]]%_%g'"
  1594. ])
  1595. # AS_TR_CPP(EXPRESSION)
  1596. # ---------------------
  1597. # Map EXPRESSION to an upper case string which is valid as rhs for a
  1598. # `#define'. sh/m4 polymorphic. Be sure to update the definition
  1599. # of `$as_tr_cpp' if you change this.
  1600. #
  1601. # See implementation comments in AS_TR_SH.
  1602. m4_defun_init([AS_TR_CPP],
  1603. [AS_REQUIRE([_$0_PREPARE])],
  1604. [_$0(m4_expand([$1]))])
  1605. m4_define([_AS_TR_CPP],
  1606. [_AS_LITERAL_IF([$1], [*][ ][
  1607. ])([], [$0_INDIR], [$0_LITERAL])([$1])])
  1608. m4_define([_AS_TR_CPP_LITERAL],
  1609. [m4_translit([[$1]],
  1610. [*[]]]m4_dquote(m4_defn([m4_cr_letters])m4_defn([m4_cr_not_symbols2]))[,
  1611. [P[]]]m4_dquote(m4_defn([m4_cr_LETTERS])m4_for(,1,255,,[[_]]))[)])
  1612. m4_define([_AS_TR_CPP_INDIR],
  1613. [`AS_ECHO(["_AS_ESCAPE([[$1]], [`], [\])"]) | $as_tr_cpp`])
  1614. # _AS_TR_PREPARE
  1615. # --------------
  1616. m4_defun([_AS_TR_PREPARE],
  1617. [AS_REQUIRE([_AS_TR_SH_PREPARE])AS_REQUIRE([_AS_TR_CPP_PREPARE])])
  1618. ## ------------------------------------------------------ ##
  1619. ## 7. Common m4/sh handling of variables (indirections). ##
  1620. ## ------------------------------------------------------ ##
  1621. # The purpose of this section is to provide a uniform API for
  1622. # reading/setting sh variables with or without indirection.
  1623. # Typically, one can write
  1624. # AS_VAR_SET(var, val)
  1625. # or
  1626. # AS_VAR_SET(as_$var, val)
  1627. # and expect the right thing to happen. In the descriptions below,
  1628. # a literal name matches the regex [a-zA-Z_][a-zA-Z0-9_]*, an
  1629. # indirect name is a shell expression that produces a literal name
  1630. # when passed through eval, and a polymorphic name is either type.
  1631. # _AS_VAR_APPEND_PREPARE
  1632. # ----------------------
  1633. # Define as_fn_append to the optimum definition for the current
  1634. # shell (bash and zsh provide the += assignment operator to avoid
  1635. # quadratic append growth over repeated appends).
  1636. m4_defun([_AS_VAR_APPEND_PREPARE],
  1637. [AS_FUNCTION_DESCRIBE([as_fn_append], [VAR VALUE],
  1638. [Append the text in VALUE to the end of the definition contained in
  1639. VAR. Take advantage of any shell optimizations that allow amortized
  1640. linear growth over repeated appends, instead of the typical quadratic
  1641. growth present in naive implementations.])
  1642. AS_IF([_AS_RUN(["AS_ESCAPE(m4_quote(_AS_VAR_APPEND_WORKS))"])],
  1643. [eval 'as_fn_append ()
  1644. {
  1645. eval $[]1+=\$[]2
  1646. }'],
  1647. [as_fn_append ()
  1648. {
  1649. eval $[]1=\$$[]1\$[]2
  1650. }]) # as_fn_append
  1651. ])
  1652. # _AS_VAR_APPEND_WORKS
  1653. # --------------------
  1654. # Output a shell test to discover whether += works.
  1655. m4_define([_AS_VAR_APPEND_WORKS],
  1656. [as_var=1; as_var+=2; test x$as_var = x12])
  1657. # AS_VAR_APPEND(VAR, VALUE)
  1658. # -------------------------
  1659. # Append the shell expansion of VALUE to the end of the existing
  1660. # contents of the polymorphic shell variable VAR, taking advantage of
  1661. # any shell optimizations that allow repeated appends to result in
  1662. # amortized linear scaling rather than quadratic behavior. This macro
  1663. # is not worth the overhead unless the expected final size of the
  1664. # contents of VAR outweigh the typical VALUE size of repeated appends.
  1665. # Note that unlike AS_VAR_SET, VALUE must be properly quoted to avoid
  1666. # field splitting and file name expansion.
  1667. m4_defun_init([AS_VAR_APPEND],
  1668. [AS_REQUIRE([_AS_VAR_APPEND_PREPARE], [], [M4SH-INIT-FN])],
  1669. [as_fn_append $1 $2])
  1670. # _AS_VAR_ARITH_PREPARE
  1671. # ---------------------
  1672. # Define as_fn_arith to the optimum definition for the current
  1673. # shell (using POSIX $(()) where supported).
  1674. m4_defun([_AS_VAR_ARITH_PREPARE],
  1675. [AS_FUNCTION_DESCRIBE([as_fn_arith], [ARG...],
  1676. [Perform arithmetic evaluation on the ARGs, and store the result in
  1677. the global $as_val. Take advantage of shells that can avoid forks.
  1678. The arguments must be portable across $(()) and expr.])
  1679. AS_IF([_AS_RUN(["AS_ESCAPE(m4_quote(_AS_VAR_ARITH_WORKS))"])],
  1680. [eval 'as_fn_arith ()
  1681. {
  1682. as_val=$(( $[]* ))
  1683. }'],
  1684. [as_fn_arith ()
  1685. {
  1686. as_val=`expr "$[]@" || test $? -eq 1`
  1687. }]) # as_fn_arith
  1688. ])
  1689. # _AS_VAR_ARITH_WORKS
  1690. # -------------------
  1691. # Output a shell test to discover whether $(()) works.
  1692. m4_define([_AS_VAR_ARITH_WORKS],
  1693. [test $(( 1 + 1 )) = 2])
  1694. # AS_VAR_ARITH(VAR, EXPR)
  1695. # -----------------------
  1696. # Perform the arithmetic evaluation of the arguments in EXPR, and set
  1697. # contents of the polymorphic shell variable VAR to the result, taking
  1698. # advantage of any shell optimizations that perform arithmetic without
  1699. # forks. Note that numbers occurring within EXPR must be written in
  1700. # decimal, and without leading zeroes; variables containing numbers
  1701. # must be expanded prior to arithmetic evaluation; the first argument
  1702. # must not be a negative number; there is no portable equality
  1703. # operator; and operators must be given as separate arguments and
  1704. # properly quoted.
  1705. m4_defun_init([AS_VAR_ARITH],
  1706. [_AS_DETECT_SUGGESTED([_AS_VAR_ARITH_WORKS])]dnl
  1707. [AS_REQUIRE([_AS_VAR_ARITH_PREPARE], [], [M4SH-INIT-FN])],
  1708. [as_fn_arith $2 && AS_VAR_SET([$1], [$as_val])])
  1709. # AS_VAR_COPY(DEST, SOURCE)
  1710. # -------------------------
  1711. # Set the polymorphic shell variable DEST to the contents of the polymorphic
  1712. # shell variable SOURCE.
  1713. m4_define([AS_VAR_COPY],
  1714. [AS_LITERAL_WORD_IF([$1[]$2], [$1=$$2], [eval $1=\$$2])])
  1715. # AS_VAR_GET(VARIABLE)
  1716. # --------------------
  1717. # Get the value of the shell VARIABLE.
  1718. # Evaluates to $VARIABLE if there is no indirection in VARIABLE,
  1719. # else to the appropriate `eval' sequence.
  1720. # This macro is deprecated because it sometimes mishandles trailing newlines;
  1721. # use AS_VAR_COPY instead.
  1722. m4_define([AS_VAR_GET],
  1723. [AS_LITERAL_WORD_IF([$1],
  1724. [$$1],
  1725. [`eval 'as_val=${'_AS_ESCAPE([[$1]], [`], [\])'};AS_ECHO(["$as_val"])'`])])
  1726. # AS_VAR_IF(VARIABLE, VALUE, IF-TRUE, IF-FALSE)
  1727. # ---------------------------------------------
  1728. # Implement a shell `if test $VARIABLE = VALUE; then-else'.
  1729. # Polymorphic, and avoids sh expansion error upon interrupt or term signal.
  1730. m4_define([AS_VAR_IF],
  1731. [AS_LITERAL_WORD_IF([$1],
  1732. [AS_IF(m4_ifval([$2], [[test "x$$1" = x[]$2]], [[${$1:+false} :]])],
  1733. [AS_VAR_COPY([as_val], [$1])
  1734. AS_IF(m4_ifval([$2], [[test "x$as_val" = x[]$2]], [[${as_val:+false} :]])],
  1735. [AS_IF(m4_ifval([$2],
  1736. [[eval test \"x\$"$1"\" = x"_AS_ESCAPE([$2], [`], [\"$])"]],
  1737. [[eval \${$1:+false} :]])]),
  1738. [$3], [$4])])
  1739. # AS_VAR_PUSHDEF and AS_VAR_POPDEF
  1740. # --------------------------------
  1741. #
  1742. # Sometimes we may have to handle literals (e.g. `stdlib.h'), while at
  1743. # other moments, the same code may have to get the value from a
  1744. # variable (e.g., `ac_header'). To have a uniform handling of both
  1745. # cases, when a new value is about to be processed, declare a local
  1746. # variable, e.g.:
  1747. #
  1748. # AS_VAR_PUSHDEF([header], [ac_cv_header_$1])
  1749. #
  1750. # and then in the body of the macro, use `header' as is. It is of
  1751. # first importance to use `AS_VAR_*' to access this variable.
  1752. #
  1753. # If the value `$1' was a literal (e.g. `stdlib.h'), then `header' is
  1754. # in fact the value `ac_cv_header_stdlib_h'. If `$1' was indirect,
  1755. # then `header's value in m4 is in fact `$as_header', the shell
  1756. # variable that holds all of the magic to get the expansion right.
  1757. #
  1758. # At the end of the block, free the variable with
  1759. #
  1760. # AS_VAR_POPDEF([header])
  1761. # AS_VAR_POPDEF(VARNAME)
  1762. # ----------------------
  1763. # Free the shell variable accessor VARNAME. To be dnl'ed.
  1764. m4_define([AS_VAR_POPDEF],
  1765. [m4_popdef([$1])])
  1766. # AS_VAR_PUSHDEF(VARNAME, VALUE)
  1767. # ------------------------------
  1768. # Define the m4 macro VARNAME to an accessor to the shell variable
  1769. # named VALUE. VALUE does not need to be a valid shell variable name:
  1770. # the transliteration is handled here. To be dnl'ed.
  1771. #
  1772. # AS_TR_SH attempts to play with diversions if _AS_TR_SH_PREPARE has
  1773. # not been expanded. However, users are expected to do subsequent
  1774. # calls that trigger AS_LITERAL_IF([VARNAME]), and that macro performs
  1775. # expansion inside an argument collection context, where diversions
  1776. # don't work. Therefore, we must require the preparation ourselves.
  1777. m4_defun_init([AS_VAR_PUSHDEF],
  1778. [AS_REQUIRE([_AS_TR_SH_PREPARE])],
  1779. [_$0([$1], m4_expand([$2]))])
  1780. m4_define([_AS_VAR_PUSHDEF],
  1781. [_AS_LITERAL_IF([$2], [ ][
  1782. ])([], [as_$1=_AS_TR_SH_INDIR([$2])
  1783. m4_pushdef([$1], [$as_[$1]])],
  1784. [m4_pushdef([$1], [_AS_TR_SH_LITERAL([$2])])])])
  1785. # AS_VAR_SET(VARIABLE, VALUE)
  1786. # ---------------------------
  1787. # Set the contents of the polymorphic shell VARIABLE to the shell
  1788. # expansion of VALUE. VALUE is immune to field splitting and file
  1789. # name expansion.
  1790. m4_define([AS_VAR_SET],
  1791. [AS_LITERAL_WORD_IF([$1],
  1792. [$1=$2],
  1793. [eval "$1=_AS_ESCAPE([$2], [`], [\"$])"])])
  1794. # AS_VAR_SET_IF(VARIABLE, IF-TRUE, IF-FALSE)
  1795. # ------------------------------------------
  1796. # Implement a shell `if-then-else' depending whether VARIABLE is set
  1797. # or not. Polymorphic.
  1798. m4_define([AS_VAR_SET_IF],
  1799. [AS_IF([AS_VAR_TEST_SET([$1])], [$2], [$3])])
  1800. # AS_VAR_TEST_SET(VARIABLE)
  1801. # -------------------------
  1802. # Expands into an expression which is true if VARIABLE
  1803. # is set. Polymorphic.
  1804. m4_define([AS_VAR_TEST_SET],
  1805. [AS_LITERAL_WORD_IF([$1],
  1806. [${$1+:} false],
  1807. [{ as_var=$1; eval \${$as_var+:} false; }],
  1808. [eval \${$1+:} false])])
  1809. ## -------------------- ##
  1810. ## 8. Setting M4sh up. ##
  1811. ## -------------------- ##
  1812. # AS_INIT_GENERATED(FILE, [COMMENT])
  1813. # ----------------------------------
  1814. # Generate a child script FILE with all initialization necessary to
  1815. # reuse the environment learned by the parent script, and make the
  1816. # file executable. If COMMENT is supplied, it is inserted after the
  1817. # `#!' sequence but before initialization text begins. After this
  1818. # macro, additional text can be appended to FILE to form the body of
  1819. # the child script. The macro ends with non-zero status if the
  1820. # file could not be fully written (such as if the disk is full).
  1821. m4_defun([AS_INIT_GENERATED],
  1822. [m4_require([AS_PREPARE])]dnl
  1823. [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl
  1824. [as_write_fail=0
  1825. cat >$1 <<_ASEOF || as_write_fail=1
  1826. #! $SHELL
  1827. # Generated by $as_me.
  1828. $2
  1829. SHELL=\${CONFIG_SHELL-$SHELL}
  1830. export SHELL
  1831. _ASEOF
  1832. cat >>$1 <<\_ASEOF || as_write_fail=1
  1833. _AS_SHELL_SANITIZE
  1834. _AS_PREPARE
  1835. m4_if(AS_MESSAGE_FD, [1], [], [exec AS_MESSAGE_FD>&1
  1836. ])]dnl
  1837. [m4_text_box([Main body of $1 script.])
  1838. _ASEOF
  1839. test $as_write_fail = 0 && chmod +x $1[]dnl
  1840. _m4_popdef([AS_MESSAGE_LOG_FD])])# AS_INIT_GENERATED
  1841. # AS_INIT
  1842. # -------
  1843. # Initialize m4sh.
  1844. m4_define([AS_INIT],
  1845. [# Wrap our cleanup prior to m4sugar's cleanup.
  1846. m4_wrap([_AS_CLEANUP])
  1847. m4_init
  1848. m4_provide([AS_INIT])
  1849. # Forbidden tokens and exceptions.
  1850. m4_pattern_forbid([^_?AS_])
  1851. # Bangshe and minimal initialization.
  1852. m4_divert_text([BINSH], [@%:@! /bin/sh])
  1853. m4_divert_text([HEADER-COMMENT],
  1854. [@%:@ Generated from __file__ by m4_PACKAGE_STRING.])
  1855. m4_divert_text([M4SH-SANITIZE], [_AS_SHELL_SANITIZE])
  1856. m4_divert_text([M4SH-INIT-FN], [m4_text_box([M4sh Shell Functions.])])
  1857. # Let's go!
  1858. m4_divert([BODY])dnl
  1859. m4_text_box([Main body of script.])
  1860. _AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])dnl
  1861. _AS_DETECT_REQUIRED([_AS_TEST_X_WORKS])dnl
  1862. AS_REQUIRE([_AS_UNSET_PREPARE], [], [M4SH-INIT-FN])dnl
  1863. ])