2
0

m4sh.m4 74 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168
  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 sh bash 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. # Printing a long string crashes Solaris 7 /usr/bin/printf.
  914. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
  915. as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
  916. as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
  917. # Prefer a ksh shell builtin over an external printf program on Solaris,
  918. # but without wasting forks for bash or zsh.
  919. if test -z "$BASH_VERSION$ZSH_VERSION" \
  920. && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
  921. as_echo='print -r --'
  922. as_echo_n='print -rn --'
  923. elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
  924. as_echo='printf %s\n'
  925. as_echo_n='printf %s'
  926. else
  927. if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
  928. as_echo_body='eval /usr/ucb/echo -n "$][1$as_nl"'
  929. as_echo_n='/usr/ucb/echo -n'
  930. else
  931. as_echo_body='eval expr "X$][1" : "X\\(.*\\)"'
  932. as_echo_n_body='eval
  933. arg=$][1;
  934. case $arg in @%:@(
  935. *"$as_nl"*)
  936. expr "X$arg" : "X\\(.*\\)$as_nl";
  937. arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
  938. esac;
  939. expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
  940. '
  941. export as_echo_n_body
  942. as_echo_n='sh -c $as_echo_n_body as_echo'
  943. fi
  944. export as_echo_body
  945. as_echo='sh -c $as_echo_body as_echo'
  946. fi
  947. ]])# _AS_ECHO_PREPARE
  948. # AS_TEST_X
  949. # ---------
  950. # Check whether a file has executable or search permissions.
  951. # FIXME: This macro is no longer useful; consider deleting it in 2014
  952. # after we ensure m4sh scripts can always find a shell with test -x.
  953. m4_defun_init([AS_TEST_X],
  954. [AS_REQUIRE([_AS_TEST_PREPARE])],
  955. [test -x $1[]])# AS_TEST_X
  956. # AS_EXECUTABLE_P
  957. # ---------------
  958. # Check whether a file is a regular file that has executable permissions.
  959. m4_defun_init([AS_EXECUTABLE_P],
  960. [AS_REQUIRE([_AS_TEST_PREPARE])],
  961. [as_fn_executable_p $1])# AS_EXECUTABLE_P
  962. # _AS_EXPR_PREPARE
  963. # ----------------
  964. # QNX 4.25 expr computes and issue the right result but exits with failure.
  965. # Tru64 expr mishandles leading zeros in numeric strings.
  966. # Detect these flaws.
  967. m4_defun([_AS_EXPR_PREPARE],
  968. [if expr a : '\(a\)' >/dev/null 2>&1 &&
  969. test "X`expr 00001 : '.*\(...\)'`" = X001; then
  970. as_expr=expr
  971. else
  972. as_expr=false
  973. fi
  974. ])# _AS_EXPR_PREPARE
  975. # _AS_ME_PREPARE
  976. # --------------
  977. # Define $as_me to the basename of the executable file's name.
  978. m4_defun([AS_ME_PREPARE], [AS_REQUIRE([_$0])])
  979. m4_defun([_AS_ME_PREPARE],
  980. [AS_REQUIRE([_AS_BASENAME_PREPARE])]dnl
  981. [as_me=`AS_BASENAME("$[0]")`
  982. ])
  983. # _AS_LINENO_WORKS
  984. # ----------------
  985. # Succeed if the currently executing shell supports LINENO.
  986. # This macro does not expand to a single shell command, so be careful
  987. # when using it. Surrounding the body of this macro with {} would
  988. # cause "bash -c '_ASLINENO_WORKS'" to fail (with Bash 2.05, anyway),
  989. # but that bug is irrelevant to our use of LINENO. We can't use
  990. # AS_VAR_ARITH, as this is expanded prior to shell functions.
  991. #
  992. # Testing for LINENO support is hard; we use _AS_LINENO_WORKS inside
  993. # _AS_RUN, which sometimes eval's its argument (pdksh gives false
  994. # negatives if $LINENO is expanded by eval), and sometimes passes the
  995. # argument to another shell (if the current shell supports LINENO,
  996. # then expanding $LINENO prior to the string leads to false
  997. # positives). Hence, we perform two tests, and coordinate with
  998. # _AS_DETECT_EXPAND (which ensures that only the first of two LINENO
  999. # is expanded in advance) and _AS_RUN (which sets $as_run to 'a' when
  1000. # handing the test to another shell), so that we know which test to
  1001. # trust.
  1002. m4_define([_AS_LINENO_WORKS],
  1003. [ as_lineno_1=$LINENO as_lineno_1a=$LINENO
  1004. as_lineno_2=$LINENO as_lineno_2a=$LINENO
  1005. eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
  1006. test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"'])
  1007. # _AS_LINENO_PREPARE
  1008. # ------------------
  1009. # If LINENO is not supported by the shell, produce a version of this
  1010. # script where LINENO is hard coded.
  1011. # Comparing LINENO against _oline_ is not a good solution, since in
  1012. # the case of embedded executables (such as config.status within
  1013. # configure) you'd compare LINENO wrt config.status vs. _oline_ wrt
  1014. # configure.
  1015. #
  1016. # AS_ERROR normally uses LINENO if logging, but AS_LINENO_PREPARE uses
  1017. # AS_ERROR. Besides, if the logging fd is open, we don't want to use
  1018. # $LINENO in the log complaining about broken LINENO. We break the
  1019. # circular require by changing AS_ERROR and AS_MESSAGE_LOG_FD.
  1020. m4_defun([AS_LINENO_PREPARE], [AS_REQUIRE([_$0])])
  1021. m4_defun([_AS_LINENO_PREPARE],
  1022. [AS_REQUIRE([_AS_CR_PREPARE])]dnl
  1023. [AS_REQUIRE([_AS_ME_PREPARE])]dnl
  1024. [_AS_DETECT_SUGGESTED([_AS_LINENO_WORKS])]dnl
  1025. [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl
  1026. [m4_pushdef([AS_ERROR],
  1027. [{ AS_MESSAGE(]m4_dquote([error: $][1])[, [2]); AS_EXIT([1]); }])]dnl
  1028. dnl Create $as_me.lineno as a copy of $as_myself, but with $LINENO
  1029. dnl uniformly replaced by the line number. The first 'sed' inserts a
  1030. dnl line-number line after each line using $LINENO; the second 'sed'
  1031. dnl does the real work. The second script uses 'N' to pair each
  1032. dnl line-number line with the line containing $LINENO, and appends
  1033. dnl trailing '-' during substitution so that $LINENO is not a special
  1034. dnl case at line end. (Raja R Harinath suggested sed '=', and Paul
  1035. dnl Eggert wrote the scripts with optimization help from Paolo Bonzini).
  1036. [_AS_LINENO_WORKS || {
  1037. [ # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-)
  1038. sed -n '
  1039. p
  1040. /[$]LINENO/=
  1041. ' <$as_myself |
  1042. sed '
  1043. s/[$]LINENO.*/&-/
  1044. t lineno
  1045. b
  1046. :lineno
  1047. N
  1048. :loop
  1049. s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
  1050. t loop
  1051. s/-\n.*//
  1052. ' >$as_me.lineno &&
  1053. chmod +x "$as_me.lineno"] ||
  1054. AS_ERROR([cannot create $as_me.lineno; rerun with a POSIX shell])
  1055. # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
  1056. # already done that, so ensure we don't try to do so again and fall
  1057. # in an infinite loop. This has already happened in practice.
  1058. _as_can_reexec=no; export _as_can_reexec
  1059. # Don't try to exec as it changes $[0], causing all sort of problems
  1060. # (the dirname of $[0] is not the place where we might find the
  1061. # original and so on. Autoconf is especially sensitive to this).
  1062. . "./$as_me.lineno"
  1063. # Exit status is that of the last command.
  1064. exit
  1065. }
  1066. _m4_popdef([AS_MESSAGE_LOG_FD], [AS_ERROR])])# _AS_LINENO_PREPARE
  1067. # _AS_LN_S_PREPARE
  1068. # ----------------
  1069. # Don't use conftest.sym to avoid file name issues on DJGPP, where this
  1070. # would yield conftest.sym.exe for DJGPP < 2.04. And don't use `conftest'
  1071. # as base name to avoid prohibiting concurrency (e.g., concurrent
  1072. # config.statuses). On read-only media, assume 'cp -pR' and hope we
  1073. # are just running --help anyway.
  1074. m4_defun([_AS_LN_S_PREPARE],
  1075. [rm -f conf$$ conf$$.exe conf$$.file
  1076. if test -d conf$$.dir; then
  1077. rm -f conf$$.dir/conf$$.file
  1078. else
  1079. rm -f conf$$.dir
  1080. mkdir conf$$.dir 2>/dev/null
  1081. fi
  1082. if (echo >conf$$.file) 2>/dev/null; then
  1083. if ln -s conf$$.file conf$$ 2>/dev/null; then
  1084. as_ln_s='ln -s'
  1085. # ... but there are two gotchas:
  1086. # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
  1087. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
  1088. # In both cases, we have to default to `cp -pR'.
  1089. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
  1090. as_ln_s='cp -pR'
  1091. elif ln conf$$.file conf$$ 2>/dev/null; then
  1092. as_ln_s=ln
  1093. else
  1094. as_ln_s='cp -pR'
  1095. fi
  1096. else
  1097. as_ln_s='cp -pR'
  1098. fi
  1099. rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
  1100. rmdir conf$$.dir 2>/dev/null
  1101. ])# _AS_LN_S_PREPARE
  1102. # AS_LN_S(FILE, LINK)
  1103. # -------------------
  1104. # FIXME: Should we add the glue code to handle properly relative symlinks
  1105. # simulated with `ln' or `cp'?
  1106. m4_defun_init([AS_LN_S],
  1107. [AS_REQUIRE([_AS_LN_S_PREPARE])],
  1108. [$as_ln_s $1 $2])
  1109. # _AS_MKDIR_P
  1110. # -----------
  1111. # Emit code that can be used to emulate `mkdir -p` with plain `mkdir';
  1112. # the code assumes that "$as_dir" contains the directory to create.
  1113. # $as_dir is normalized, so there is no need to worry about using --.
  1114. m4_define([_AS_MKDIR_P],
  1115. [case $as_dir in #(
  1116. -*) as_dir=./$as_dir;;
  1117. esac
  1118. test -d "$as_dir" || eval $as_mkdir_p || {
  1119. as_dirs=
  1120. while :; do
  1121. case $as_dir in #(
  1122. *\'*) as_qdir=`AS_ECHO(["$as_dir"]) | sed "s/'/'\\\\\\\\''/g"`;; #'(
  1123. *) as_qdir=$as_dir;;
  1124. esac
  1125. as_dirs="'$as_qdir' $as_dirs"
  1126. as_dir=`AS_DIRNAME("$as_dir")`
  1127. test -d "$as_dir" && break
  1128. done
  1129. test -z "$as_dirs" || eval "mkdir $as_dirs"
  1130. } || test -d "$as_dir" || AS_ERROR([cannot create directory $as_dir])
  1131. ])
  1132. # AS_MKDIR_P(DIR)
  1133. # ---------------
  1134. # Emulate `mkdir -p' with plain `mkdir' if needed.
  1135. m4_defun_init([AS_MKDIR_P],
  1136. [AS_REQUIRE([_$0_PREPARE])],
  1137. [as_dir=$1; as_fn_mkdir_p])# AS_MKDIR_P
  1138. # _AS_MKDIR_P_PREPARE
  1139. # -------------------
  1140. m4_defun([_AS_MKDIR_P_PREPARE],
  1141. [AS_REQUIRE_SHELL_FN([as_fn_mkdir_p],
  1142. [AS_FUNCTION_DESCRIBE([as_fn_mkdir_p], [],
  1143. [Create "$as_dir" as a directory, including parents if necessary.])],
  1144. [
  1145. _AS_MKDIR_P
  1146. ])]dnl
  1147. [if mkdir -p . 2>/dev/null; then
  1148. as_mkdir_p='mkdir -p "$as_dir"'
  1149. else
  1150. test -d ./-p && rmdir ./-p
  1151. as_mkdir_p=false
  1152. fi
  1153. ])# _AS_MKDIR_P_PREPARE
  1154. # _AS_PATH_SEPARATOR_PREPARE
  1155. # --------------------------
  1156. # Compute the path separator.
  1157. m4_defun([_AS_PATH_SEPARATOR_PREPARE],
  1158. [# The user is always right.
  1159. if test "${PATH_SEPARATOR+set}" != set; then
  1160. PATH_SEPARATOR=:
  1161. (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
  1162. (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
  1163. PATH_SEPARATOR=';'
  1164. }
  1165. fi
  1166. ])# _AS_PATH_SEPARATOR_PREPARE
  1167. # _AS_PATH_WALK([PATH = $PATH], BODY, [IF-NOT-FOUND])
  1168. # ---------------------------------------------------
  1169. # Walk through PATH running BODY for each `as_dir'. If BODY never does a
  1170. # `break', evaluate IF-NOT-FOUND.
  1171. #
  1172. # Still very private as its interface looks quite bad.
  1173. #
  1174. # `$as_dummy' forces splitting on constant user-supplied paths.
  1175. # POSIX.2 field splitting is done only on the result of word
  1176. # expansions, not on literal text. This closes a longstanding sh security
  1177. # hole. Optimize it away when not needed, i.e., if there are no literal
  1178. # path separators.
  1179. m4_defun_init([_AS_PATH_WALK],
  1180. [AS_REQUIRE([_AS_PATH_SEPARATOR_PREPARE])],
  1181. [as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
  1182. m4_ifvaln([$3], [as_found=false])dnl
  1183. m4_bmatch([$1], [[:;]],
  1184. [as_dummy="$1"
  1185. for as_dir in $as_dummy],
  1186. [for as_dir in m4_default([$1], [$PATH])])
  1187. do
  1188. IFS=$as_save_IFS
  1189. test -z "$as_dir" && as_dir=.
  1190. m4_ifvaln([$3], [as_found=:])dnl
  1191. $2
  1192. m4_ifvaln([$3], [as_found=false])dnl
  1193. done
  1194. m4_ifvaln([$3], [$as_found || { $3; }])dnl
  1195. IFS=$as_save_IFS
  1196. ])
  1197. # AS_SET_CATFILE(VAR, DIR-NAME, FILE-NAME)
  1198. # ----------------------------------------
  1199. # Set VAR to DIR-NAME/FILE-NAME.
  1200. # Optimize the common case where $2 or $3 is '.'.
  1201. m4_define([AS_SET_CATFILE],
  1202. [case $2 in @%:@((
  1203. .) AS_VAR_SET([$1], [$3]);;
  1204. *)
  1205. case $3 in @%:@(((
  1206. .) AS_VAR_SET([$1], [$2]);;
  1207. [[\\/]]* | ?:[[\\/]]* ) AS_VAR_SET([$1], [$3]);;
  1208. *) AS_VAR_SET([$1], [$2/$3]);;
  1209. esac;;
  1210. esac[]])# AS_SET_CATFILE
  1211. # _AS_TEST_X_WORKS
  1212. # ----------------
  1213. # These days, we require that `test -x' works.
  1214. m4_define([_AS_TEST_X_WORKS], [test -x /])
  1215. # _AS_TEST_PREPARE
  1216. # ----------------
  1217. # Provide back-compat to people that hooked into our undocumented
  1218. # internals (here's looking at you, libtool).
  1219. m4_defun([_AS_TEST_PREPARE],
  1220. [AS_REQUIRE_SHELL_FN([as_fn_executable_p],
  1221. [AS_FUNCTION_DESCRIBE([as_fn_executable_p], [FILE],
  1222. [Test if FILE is an executable regular file.])],
  1223. [ test -f "$[]1" && test -x "$[]1"])]dnl
  1224. [as_test_x='test -x'
  1225. as_executable_p=as_fn_executable_p
  1226. ])# _AS_TEST_PREPARE
  1227. ## ------------------ ##
  1228. ## 5. Common idioms. ##
  1229. ## ------------------ ##
  1230. # This section is lexicographically sorted.
  1231. # AS_BOX(MESSAGE, [FRAME-CHARACTER = `-'])
  1232. # ----------------------------------------
  1233. # Output MESSAGE, a single line text, framed with FRAME-CHARACTER (which
  1234. # must not be `/').
  1235. m4_define([AS_BOX],
  1236. [_$0(m4_expand([$1]), [$2])])
  1237. m4_define([_AS_BOX],
  1238. [m4_if(m4_index(m4_translit([[$1]], [`\"], [$$$]), [$]),
  1239. [-1], [$0_LITERAL], [$0_INDIR])($@)])
  1240. # _AS_BOX_LITERAL(MESSAGE, [FRAME-CHARACTER = `-'])
  1241. # -------------------------------------------------
  1242. m4_define([_AS_BOX_LITERAL],
  1243. [AS_ECHO(["_AS_ESCAPE(m4_dquote(m4_expand([m4_text_box($@)])), [`], [\"$])"])])
  1244. # _AS_BOX_INDIR(MESSAGE, [FRAME-CHARACTER = `-'])
  1245. # -----------------------------------------------
  1246. m4_define([_AS_BOX_INDIR],
  1247. [sed 'h;s/./m4_default([$2], [-])/g;s/^.../@%:@@%:@ /;s/...$/ @%:@@%:@/;p;x;p;x' <<_ASBOX
  1248. @%:@@%:@ $1 @%:@@%:@
  1249. _ASBOX])
  1250. # _AS_CLEAN_DIR(DIR)
  1251. # ------------------
  1252. # Remove all contents from within DIR, including any unwritable
  1253. # subdirectories, but leave DIR itself untouched.
  1254. m4_define([_AS_CLEAN_DIR],
  1255. [if test -d $1; then
  1256. find $1 -type d ! -perm -700 -exec chmod u+rwx {} \;
  1257. rm -fr $1/* $1/.[[!.]] $1/.??*
  1258. fi])
  1259. # AS_FUNCTION_DESCRIBE(NAME, [ARGS], DESCRIPTION, [WRAP-COLUMN = 79])
  1260. # -------------------------------------------------------------------
  1261. # Output a shell comment describing NAME and its arguments ARGS, then
  1262. # a separator line, then the DESCRIPTION wrapped at a decimal
  1263. # WRAP-COLUMN. The output resembles:
  1264. # # NAME ARGS
  1265. # # ---------
  1266. # # Wrapped DESCRIPTION text
  1267. # NAME and ARGS are expanded, while DESCRIPTION is treated as a
  1268. # whitespace-separated list of strings that are not expanded.
  1269. m4_define([AS_FUNCTION_DESCRIBE],
  1270. [@%:@ $1[]m4_ifval([$2], [ $2])
  1271. @%:@ m4_translit(m4_format([%*s],
  1272. m4_decr(m4_qlen(_m4_expand([$1[]m4_ifval([$2], [ $2])
  1273. ]))), []), [ ], [-])
  1274. m4_text_wrap([$3], [@%:@ ], [], [$4])])
  1275. # AS_HELP_STRING(LHS, RHS, [INDENT-COLUMN = 26], [WRAP-COLUMN = 79])
  1276. # ------------------------------------------------------------------
  1277. #
  1278. # Format a help string so that it looks pretty when the user executes
  1279. # "script --help". This macro takes up to four arguments, a
  1280. # "left hand side" (LHS), a "right hand side" (RHS), a decimal
  1281. # INDENT-COLUMN which is the column where wrapped lines should begin
  1282. # (the default of 26 is recommended), and a decimal WRAP-COLUMN which is
  1283. # the column where lines should wrap (the default of 79 is recommended).
  1284. # LHS is expanded, RHS is not.
  1285. #
  1286. # For backwards compatibility not documented in the manual, INDENT-COLUMN
  1287. # can also be specified as a string of white spaces, whose width
  1288. # determines the indentation column. Using TABs in INDENT-COLUMN is not
  1289. # recommended, since screen width of TAB is not computed.
  1290. #
  1291. # The resulting string is suitable for use in other macros that require
  1292. # a help string (e.g. AC_ARG_WITH).
  1293. #
  1294. # Here is the sample string from the Autoconf manual (Node: External
  1295. # Software) which shows the proper spacing for help strings.
  1296. #
  1297. # --with-readline support fancy command line editing
  1298. # ^ ^ ^
  1299. # | | |
  1300. # | column 2 column 26
  1301. # |
  1302. # column 0
  1303. #
  1304. # A help string is made up of a "left hand side" (LHS) and a "right
  1305. # hand side" (RHS). In the example above, the LHS is
  1306. # "--with-readline", while the RHS is "support fancy command line
  1307. # editing".
  1308. #
  1309. # If the LHS contains more than (INDENT-COLUMN - 3) characters, then the
  1310. # LHS is terminated with a newline so that the RHS starts on a line of its
  1311. # own beginning at INDENT-COLUMN. In the default case, this corresponds to an
  1312. # LHS with more than 23 characters.
  1313. #
  1314. # Therefore, in the example, if the LHS were instead
  1315. # "--with-readline-blah-blah-blah", then the AS_HELP_STRING macro would
  1316. # expand into:
  1317. #
  1318. #
  1319. # --with-readline-blah-blah-blah
  1320. # ^ ^ support fancy command line editing
  1321. # | | ^
  1322. # | column 2 |
  1323. # column 0 column 26
  1324. #
  1325. #
  1326. # m4_text_wrap hacks^Wworks around the fact that m4_format does not
  1327. # know quadrigraphs.
  1328. #
  1329. m4_define([AS_HELP_STRING],
  1330. [m4_text_wrap([$2], m4_cond([[$3]], [], [ ],
  1331. [m4_eval([$3]+0)], [0], [[$3]],
  1332. [m4_format([[%*s]], [$3], [])]),
  1333. m4_expand([ $1 ]), [$4])])# AS_HELP_STRING
  1334. # AS_IDENTIFIER_IF(EXPRESSION, IF-IDENT, IF-NOT-IDENT)
  1335. # ----------------------------------------------------
  1336. # If EXPRESSION serves as an identifier (ie, after removal of @&t@, it
  1337. # matches the regex `^[a-zA-Z_][a-zA-Z_0-9]*$'), execute IF-IDENT,
  1338. # otherwise IF-NOT-IDENT.
  1339. #
  1340. # This is generally faster than the alternative:
  1341. # m4_bmatch(m4_bpatsubst([[$1]], [@&t@]), ^m4_defn([m4_re_word])$,
  1342. # [$2], [$3])
  1343. #
  1344. # Rather than expand m4_defn every time AS_IDENTIFIER_IF is expanded, we
  1345. # inline its expansion up front. Only use a regular expression if we
  1346. # detect a potential quadrigraph.
  1347. #
  1348. # First, check if the entire string matches m4_cr_symbol2. Only then do
  1349. # we worry if the first character also matches m4_cr_symbol1 (ie. does not
  1350. # match m4_cr_digit).
  1351. m4_define([AS_IDENTIFIER_IF],
  1352. [m4_if(_$0(m4_if(m4_index([$1], [@]), [-1],
  1353. [[$1]], [m4_bpatsubst([[$1]], [@&t@])])), [-], [$2], [$3])])
  1354. m4_define([_AS_IDENTIFIER_IF],
  1355. [m4_cond([[$1]], [], [],
  1356. [m4_eval(m4_len(m4_translit([[$1]], ]]dnl
  1357. m4_dquote(m4_dquote(m4_defn([m4_cr_symbols2])))[[)) > 0)], [1], [],
  1358. [m4_len(m4_translit(m4_format([[%.1s]], [$1]), ]]dnl
  1359. m4_dquote(m4_dquote(m4_defn([m4_cr_symbols1])))[[))], [0], [-])])
  1360. # AS_LITERAL_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL,
  1361. # [IF-SIMPLE-REF = IF-NOT-LITERAL])
  1362. # -----------------------------------------------------
  1363. # If EXPRESSION has no shell indirections ($var or `expr`), expand
  1364. # IF-LITERAL, else IF-NOT-LITERAL. In some cases, IF-NOT-LITERAL
  1365. # must be complex to safely deal with ``, while a simpler
  1366. # expression IF-SIMPLE-REF can be used if the indirection
  1367. # involves only shell variable expansion (as in ${varname}).
  1368. #
  1369. # EXPRESSION is treated as a literal if it results in the same
  1370. # interpretation whether it is unquoted or contained within double
  1371. # quotes, with the exception that whitespace is ignored (on the
  1372. # assumption that it will be flattened to _). Therefore, neither `\$'
  1373. # nor `a''b' is a literal, since both backslash and single quotes have
  1374. # different quoting behavior in the two contexts; and `a*' is not a
  1375. # literal, because it has different globbing. Note, however, that
  1376. # while `${a+b}' is neither a literal nor a simple ref, `a+b' is a
  1377. # literal. This macro is an *approximation*: it is possible that
  1378. # there are some EXPRESSIONs which the shell would treat as literals,
  1379. # but which this macro does not recognize.
  1380. #
  1381. # Why do we reject EXPRESSION expanding with `[' or `]' as a literal?
  1382. # Because AS_TR_SH is MUCH faster if it can use m4_translit on literals
  1383. # instead of m4_bpatsubst; but m4_translit is much tougher to do safely
  1384. # if `[' is translated. That, and file globbing matters.
  1385. #
  1386. # Note that the quadrigraph @S|@ can result in non-literals, but outright
  1387. # rejecting all @ would make AC_INIT complain on its bug report address.
  1388. #
  1389. # We used to use m4_bmatch(m4_quote($1), [[`$]], [$3], [$2]), but
  1390. # profiling shows that it is faster to use m4_translit.
  1391. #
  1392. # Because the translit is stripping quotes, it must also neutralize
  1393. # anything that might be in a macro name, as well as comments, commas,
  1394. # or unbalanced parentheses. Valid shell variable characters and
  1395. # unambiguous literal characters are deleted (`a.b'), and remaining
  1396. # characters are normalized into `$' if they can form simple refs
  1397. # (${a}), `+' if they can potentially form literals (a+b), ``' if they
  1398. # can interfere with m4 parsing, or left alone otherwise. If both `$'
  1399. # and `+' are left, it is treated as a complex reference (${a+b}),
  1400. # even though it could technically be a simple reference (${a}+b).
  1401. # _AS_LITERAL_IF_ only has to check for an empty string after removing
  1402. # one of the two normalized characters.
  1403. #
  1404. # Rather than expand m4_defn every time AS_LITERAL_IF is expanded, we
  1405. # inline its expansion up front. _AS_LITERAL_IF expands to the name
  1406. # of a macro that takes three arguments: IF-SIMPLE-REF,
  1407. # IF-NOT-LITERAL, IF-LITERAL. It also takes an optional argument of
  1408. # any additional characters to allow as literals (useful for AS_TR_SH
  1409. # and AS_TR_CPP to perform inline conversion of whitespace to _). The
  1410. # order of the arguments allows reuse of m4_default.
  1411. m4_define([AS_LITERAL_IF],
  1412. [_$0(m4_expand([$1]), [ ][
  1413. ])([$4], [$3], [$2])])
  1414. m4_define([_AS_LITERAL_IF],
  1415. [m4_if(m4_index([$1], [@S|@]), [-1], [$0_(m4_translit([$1],
  1416. [-:=%/@{}[]#(),.$2]]]m4_dquote(m4_dquote(m4_defn([m4_cr_symbols2])))[[,
  1417. [++++++$$`````]))], [$0_NO])])
  1418. m4_define([_AS_LITERAL_IF_],
  1419. [m4_if(m4_translit([$1], [+]), [], [$0YES],
  1420. m4_translit([$1], [$]), [], [m4_default], [$0NO])])
  1421. m4_define([_AS_LITERAL_IF_YES], [$3])
  1422. m4_define([_AS_LITERAL_IF_NO], [$2])
  1423. # AS_LITERAL_WORD_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL,
  1424. # [IF-SIMPLE-REF = IF-NOT-LITERAL])
  1425. # ----------------------------------------------------------
  1426. # Like AS_LITERAL_IF, except that spaces and tabs in EXPRESSION
  1427. # are treated as non-literal.
  1428. m4_define([AS_LITERAL_WORD_IF],
  1429. [_AS_LITERAL_IF(m4_expand([$1]))([$4], [$3], [$2])])
  1430. # AS_LITERAL_HEREDOC_IF(EXPRESSION, IF-LITERAL, IF-NOT-LITERAL)
  1431. # -------------------------------------------------------------
  1432. # Like AS_LITERAL_IF, except that a string is considered literal
  1433. # if it results in the same output in both quoted and unquoted
  1434. # here-documents.
  1435. m4_define([AS_LITERAL_HEREDOC_IF],
  1436. [_$0(m4_expand([$1]))([$2], [$3])])
  1437. m4_define([_AS_LITERAL_HEREDOC_IF],
  1438. [m4_if(m4_index([$1], [@S|@]), [-1],
  1439. [m4_if(m4_index(m4_translit([[$1]], [\`], [$]), [$]), [-1],
  1440. [$0_YES], [$0_NO])],
  1441. [$0_NO])])
  1442. m4_define([_AS_LITERAL_HEREDOC_IF_YES], [$1])
  1443. m4_define([_AS_LITERAL_HEREDOC_IF_NO], [$2])
  1444. # AS_TMPDIR(PREFIX, [DIRECTORY = $TMPDIR [= /tmp]])
  1445. # -------------------------------------------------
  1446. # Create as safely as possible a temporary directory in DIRECTORY
  1447. # which name is inspired by PREFIX (should be 2-4 chars max).
  1448. #
  1449. # Even though $tmp does not fit our normal naming scheme of $as_*,
  1450. # it is a documented part of the public API and must not be changed.
  1451. m4_define([AS_TMPDIR],
  1452. [# Create a (secure) tmp directory for tmp files.
  1453. m4_if([$2], [], [: "${TMPDIR:=/tmp}"])
  1454. {
  1455. tmp=`(umask 077 && mktemp -d "m4_default([$2],
  1456. [$TMPDIR])/$1XXXXXX") 2>/dev/null` &&
  1457. test -d "$tmp"
  1458. } ||
  1459. {
  1460. tmp=m4_default([$2], [$TMPDIR])/$1$$-$RANDOM
  1461. (umask 077 && mkdir "$tmp")
  1462. } || AS_ERROR([cannot create a temporary directory in m4_default([$2],
  1463. [$TMPDIR])])])# AS_TMPDIR
  1464. # AS_UNAME
  1465. # --------
  1466. # Try to describe this machine. Meant for logs.
  1467. m4_define([AS_UNAME],
  1468. [{
  1469. cat <<_ASUNAME
  1470. m4_text_box([Platform.])
  1471. hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
  1472. uname -m = `(uname -m) 2>/dev/null || echo unknown`
  1473. uname -r = `(uname -r) 2>/dev/null || echo unknown`
  1474. uname -s = `(uname -s) 2>/dev/null || echo unknown`
  1475. uname -v = `(uname -v) 2>/dev/null || echo unknown`
  1476. /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
  1477. /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
  1478. /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
  1479. /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
  1480. /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
  1481. /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown`
  1482. /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
  1483. /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
  1484. /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
  1485. _ASUNAME
  1486. _AS_PATH_WALK([$PATH], [AS_ECHO(["PATH: $as_dir"])])
  1487. }])
  1488. # _AS_VERSION_COMPARE_PREPARE
  1489. # ---------------------------
  1490. # Output variables for comparing version numbers.
  1491. m4_defun([_AS_VERSION_COMPARE_PREPARE],
  1492. [[as_awk_strverscmp='
  1493. # Use only awk features that work with 7th edition Unix awk (1978).
  1494. # My, what an old awk you have, Mr. Solaris!
  1495. END {
  1496. while (length(v1) && length(v2)) {
  1497. # Set d1 to be the next thing to compare from v1, and likewise for d2.
  1498. # Normally this is a single character, but if v1 and v2 contain digits,
  1499. # compare them as integers and fractions as strverscmp does.
  1500. if (v1 ~ /^[0-9]/ && v2 ~ /^[0-9]/) {
  1501. # Split v1 and v2 into their leading digit string components d1 and d2,
  1502. # and advance v1 and v2 past the leading digit strings.
  1503. for (len1 = 1; substr(v1, len1 + 1) ~ /^[0-9]/; len1++) continue
  1504. for (len2 = 1; substr(v2, len2 + 1) ~ /^[0-9]/; len2++) continue
  1505. d1 = substr(v1, 1, len1); v1 = substr(v1, len1 + 1)
  1506. d2 = substr(v2, 1, len2); v2 = substr(v2, len2 + 1)
  1507. if (d1 ~ /^0/) {
  1508. if (d2 ~ /^0/) {
  1509. # Compare two fractions.
  1510. while (d1 ~ /^0/ && d2 ~ /^0/) {
  1511. d1 = substr(d1, 2); len1--
  1512. d2 = substr(d2, 2); len2--
  1513. }
  1514. if (len1 != len2 && ! (len1 && len2 && substr(d1, 1, 1) == substr(d2, 1, 1))) {
  1515. # The two components differ in length, and the common prefix
  1516. # contains only leading zeros. Consider the longer to be less.
  1517. d1 = -len1
  1518. d2 = -len2
  1519. } else {
  1520. # Otherwise, compare as strings.
  1521. d1 = "x" d1
  1522. d2 = "x" d2
  1523. }
  1524. } else {
  1525. # A fraction is less than an integer.
  1526. exit 1
  1527. }
  1528. } else {
  1529. if (d2 ~ /^0/) {
  1530. # An integer is greater than a fraction.
  1531. exit 2
  1532. } else {
  1533. # Compare two integers.
  1534. d1 += 0
  1535. d2 += 0
  1536. }
  1537. }
  1538. } else {
  1539. # The normal case, without worrying about digits.
  1540. d1 = substr(v1, 1, 1); v1 = substr(v1, 2)
  1541. d2 = substr(v2, 1, 1); v2 = substr(v2, 2)
  1542. }
  1543. if (d1 < d2) exit 1
  1544. if (d1 > d2) exit 2
  1545. }
  1546. # Beware Solaris /usr/xgp4/bin/awk (at least through Solaris 10),
  1547. # which mishandles some comparisons of empty strings to integers.
  1548. if (length(v2)) exit 1
  1549. if (length(v1)) exit 2
  1550. }
  1551. ']])# _AS_VERSION_COMPARE_PREPARE
  1552. # AS_VERSION_COMPARE(VERSION-1, VERSION-2,
  1553. # [ACTION-IF-LESS], [ACTION-IF-EQUAL], [ACTION-IF-GREATER])
  1554. # ----------------------------------------------------------------------------
  1555. # Compare two strings possibly containing shell variables as version strings.
  1556. #
  1557. # This usage is portable even to ancient awk,
  1558. # so don't worry about finding a "nice" awk version.
  1559. m4_defun_init([AS_VERSION_COMPARE],
  1560. [AS_REQUIRE([_$0_PREPARE])],
  1561. [as_arg_v1=$1
  1562. as_arg_v2=$2
  1563. awk "$as_awk_strverscmp" v1="$as_arg_v1" v2="$as_arg_v2" /dev/null
  1564. AS_CASE([$?],
  1565. [1], [$3],
  1566. [0], [$4],
  1567. [2], [$5])])# AS_VERSION_COMPARE
  1568. ## --------------------------------------- ##
  1569. ## 6. Common m4/sh character translation. ##
  1570. ## --------------------------------------- ##
  1571. # The point of this section is to provide high level macros comparable
  1572. # to m4's `translit' primitive, but m4/sh polymorphic.
  1573. # Transliteration of literal strings should be handled by m4, while
  1574. # shell variables' content will be translated at runtime (tr or sed).
  1575. # _AS_CR_PREPARE
  1576. # --------------
  1577. # Output variables defining common character ranges.
  1578. # See m4_cr_letters etc.
  1579. m4_defun([_AS_CR_PREPARE],
  1580. [# Avoid depending upon Character Ranges.
  1581. as_cr_letters='abcdefghijklmnopqrstuvwxyz'
  1582. as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  1583. as_cr_Letters=$as_cr_letters$as_cr_LETTERS
  1584. as_cr_digits='0123456789'
  1585. as_cr_alnum=$as_cr_Letters$as_cr_digits
  1586. ])
  1587. # _AS_TR_SH_PREPARE
  1588. # -----------------
  1589. m4_defun([_AS_TR_SH_PREPARE],
  1590. [AS_REQUIRE([_AS_CR_PREPARE])]dnl
  1591. [# Sed expression to map a string onto a valid variable name.
  1592. as_tr_sh="eval sed 'y%*+%pp%;s%[[^_$as_cr_alnum]]%_%g'"
  1593. ])
  1594. # AS_TR_SH(EXPRESSION)
  1595. # --------------------
  1596. # Transform EXPRESSION into a valid shell variable name.
  1597. # sh/m4 polymorphic.
  1598. # Be sure to update the definition of `$as_tr_sh' if you change this.
  1599. #
  1600. # AS_LITERAL_IF guarantees that a literal does not have any nested quotes,
  1601. # once $1 is expanded. m4_translit silently uses only the first occurrence
  1602. # of a character that appears multiple times in argument 2, since we know
  1603. # that m4_cr_not_symbols2 also contains [ and ]. m4_translit also silently
  1604. # ignores characters in argument 3 that do not match argument 2; we use this
  1605. # fact to skip worrying about the length of m4_cr_not_symbols2.
  1606. #
  1607. # For speed, we inline the literal definitions that can be computed up front.
  1608. m4_defun_init([AS_TR_SH],
  1609. [AS_REQUIRE([_$0_PREPARE])],
  1610. [_$0(m4_expand([$1]))])
  1611. m4_define([_AS_TR_SH],
  1612. [_AS_LITERAL_IF([$1], [*][ ][
  1613. ])([], [$0_INDIR], [$0_LITERAL])([$1])])
  1614. m4_define([_AS_TR_SH_LITERAL],
  1615. [m4_translit([[$1]],
  1616. [*+[]]]m4_dquote(m4_defn([m4_cr_not_symbols2]))[,
  1617. [pp[]]]m4_dquote(m4_for(,1,255,,[[_]]))[)])
  1618. m4_define([_AS_TR_SH_INDIR],
  1619. [`AS_ECHO(["_AS_ESCAPE([[$1]], [`], [\])"]) | $as_tr_sh`])
  1620. # _AS_TR_CPP_PREPARE
  1621. # ------------------
  1622. m4_defun([_AS_TR_CPP_PREPARE],
  1623. [AS_REQUIRE([_AS_CR_PREPARE])]dnl
  1624. [# Sed expression to map a string onto a valid CPP name.
  1625. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[[^_$as_cr_alnum]]%_%g'"
  1626. ])
  1627. # AS_TR_CPP(EXPRESSION)
  1628. # ---------------------
  1629. # Map EXPRESSION to an upper case string which is valid as rhs for a
  1630. # `#define'. sh/m4 polymorphic. Be sure to update the definition
  1631. # of `$as_tr_cpp' if you change this.
  1632. #
  1633. # See implementation comments in AS_TR_SH.
  1634. m4_defun_init([AS_TR_CPP],
  1635. [AS_REQUIRE([_$0_PREPARE])],
  1636. [_$0(m4_expand([$1]))])
  1637. m4_define([_AS_TR_CPP],
  1638. [_AS_LITERAL_IF([$1], [*][ ][
  1639. ])([], [$0_INDIR], [$0_LITERAL])([$1])])
  1640. m4_define([_AS_TR_CPP_LITERAL],
  1641. [m4_translit([[$1]],
  1642. [*[]]]m4_dquote(m4_defn([m4_cr_letters])m4_defn([m4_cr_not_symbols2]))[,
  1643. [P[]]]m4_dquote(m4_defn([m4_cr_LETTERS])m4_for(,1,255,,[[_]]))[)])
  1644. m4_define([_AS_TR_CPP_INDIR],
  1645. [`AS_ECHO(["_AS_ESCAPE([[$1]], [`], [\])"]) | $as_tr_cpp`])
  1646. # _AS_TR_PREPARE
  1647. # --------------
  1648. m4_defun([_AS_TR_PREPARE],
  1649. [AS_REQUIRE([_AS_TR_SH_PREPARE])AS_REQUIRE([_AS_TR_CPP_PREPARE])])
  1650. ## ------------------------------------------------------ ##
  1651. ## 7. Common m4/sh handling of variables (indirections). ##
  1652. ## ------------------------------------------------------ ##
  1653. # The purpose of this section is to provide a uniform API for
  1654. # reading/setting sh variables with or without indirection.
  1655. # Typically, one can write
  1656. # AS_VAR_SET(var, val)
  1657. # or
  1658. # AS_VAR_SET(as_$var, val)
  1659. # and expect the right thing to happen. In the descriptions below,
  1660. # a literal name matches the regex [a-zA-Z_][a-zA-Z0-9_]*, an
  1661. # indirect name is a shell expression that produces a literal name
  1662. # when passed through eval, and a polymorphic name is either type.
  1663. # _AS_VAR_APPEND_PREPARE
  1664. # ----------------------
  1665. # Define as_fn_append to the optimum definition for the current
  1666. # shell (bash and zsh provide the += assignment operator to avoid
  1667. # quadratic append growth over repeated appends).
  1668. m4_defun([_AS_VAR_APPEND_PREPARE],
  1669. [AS_FUNCTION_DESCRIBE([as_fn_append], [VAR VALUE],
  1670. [Append the text in VALUE to the end of the definition contained in
  1671. VAR. Take advantage of any shell optimizations that allow amortized
  1672. linear growth over repeated appends, instead of the typical quadratic
  1673. growth present in naive implementations.])
  1674. AS_IF([_AS_RUN(["AS_ESCAPE(m4_quote(_AS_VAR_APPEND_WORKS))"])],
  1675. [eval 'as_fn_append ()
  1676. {
  1677. eval $[]1+=\$[]2
  1678. }'],
  1679. [as_fn_append ()
  1680. {
  1681. eval $[]1=\$$[]1\$[]2
  1682. }]) # as_fn_append
  1683. ])
  1684. # _AS_VAR_APPEND_WORKS
  1685. # --------------------
  1686. # Output a shell test to discover whether += works.
  1687. m4_define([_AS_VAR_APPEND_WORKS],
  1688. [as_var=1; as_var+=2; test x$as_var = x12])
  1689. # AS_VAR_APPEND(VAR, VALUE)
  1690. # -------------------------
  1691. # Append the shell expansion of VALUE to the end of the existing
  1692. # contents of the polymorphic shell variable VAR, taking advantage of
  1693. # any shell optimizations that allow repeated appends to result in
  1694. # amortized linear scaling rather than quadratic behavior. This macro
  1695. # is not worth the overhead unless the expected final size of the
  1696. # contents of VAR outweigh the typical VALUE size of repeated appends.
  1697. # Note that unlike AS_VAR_SET, VALUE must be properly quoted to avoid
  1698. # field splitting and file name expansion.
  1699. m4_defun_init([AS_VAR_APPEND],
  1700. [AS_REQUIRE([_AS_VAR_APPEND_PREPARE], [], [M4SH-INIT-FN])],
  1701. [as_fn_append $1 $2])
  1702. # _AS_VAR_ARITH_PREPARE
  1703. # ---------------------
  1704. # Define as_fn_arith to the optimum definition for the current
  1705. # shell (using POSIX $(()) where supported).
  1706. m4_defun([_AS_VAR_ARITH_PREPARE],
  1707. [AS_FUNCTION_DESCRIBE([as_fn_arith], [ARG...],
  1708. [Perform arithmetic evaluation on the ARGs, and store the result in
  1709. the global $as_val. Take advantage of shells that can avoid forks.
  1710. The arguments must be portable across $(()) and expr.])
  1711. AS_IF([_AS_RUN(["AS_ESCAPE(m4_quote(_AS_VAR_ARITH_WORKS))"])],
  1712. [eval 'as_fn_arith ()
  1713. {
  1714. as_val=$(( $[]* ))
  1715. }'],
  1716. [as_fn_arith ()
  1717. {
  1718. as_val=`expr "$[]@" || test $? -eq 1`
  1719. }]) # as_fn_arith
  1720. ])
  1721. # _AS_VAR_ARITH_WORKS
  1722. # -------------------
  1723. # Output a shell test to discover whether $(()) works.
  1724. m4_define([_AS_VAR_ARITH_WORKS],
  1725. [test $(( 1 + 1 )) = 2])
  1726. # AS_VAR_ARITH(VAR, EXPR)
  1727. # -----------------------
  1728. # Perform the arithmetic evaluation of the arguments in EXPR, and set
  1729. # contents of the polymorphic shell variable VAR to the result, taking
  1730. # advantage of any shell optimizations that perform arithmetic without
  1731. # forks. Note that numbers occurring within EXPR must be written in
  1732. # decimal, and without leading zeroes; variables containing numbers
  1733. # must be expanded prior to arithmetic evaluation; the first argument
  1734. # must not be a negative number; there is no portable equality
  1735. # operator; and operators must be given as separate arguments and
  1736. # properly quoted.
  1737. m4_defun_init([AS_VAR_ARITH],
  1738. [_AS_DETECT_SUGGESTED([_AS_VAR_ARITH_WORKS])]dnl
  1739. [AS_REQUIRE([_AS_VAR_ARITH_PREPARE], [], [M4SH-INIT-FN])],
  1740. [as_fn_arith $2 && AS_VAR_SET([$1], [$as_val])])
  1741. # AS_VAR_COPY(DEST, SOURCE)
  1742. # -------------------------
  1743. # Set the polymorphic shell variable DEST to the contents of the polymorphic
  1744. # shell variable SOURCE.
  1745. m4_define([AS_VAR_COPY],
  1746. [AS_LITERAL_WORD_IF([$1[]$2], [$1=$$2], [eval $1=\$$2])])
  1747. # AS_VAR_GET(VARIABLE)
  1748. # --------------------
  1749. # Get the value of the shell VARIABLE.
  1750. # Evaluates to $VARIABLE if there is no indirection in VARIABLE,
  1751. # else to the appropriate `eval' sequence.
  1752. # This macro is deprecated because it sometimes mishandles trailing newlines;
  1753. # use AS_VAR_COPY instead.
  1754. m4_define([AS_VAR_GET],
  1755. [AS_LITERAL_WORD_IF([$1],
  1756. [$$1],
  1757. [`eval 'as_val=${'_AS_ESCAPE([[$1]], [`], [\])'};AS_ECHO(["$as_val"])'`])])
  1758. # AS_VAR_IF(VARIABLE, VALUE, IF-TRUE, IF-FALSE)
  1759. # ---------------------------------------------
  1760. # Implement a shell `if test $VARIABLE = VALUE; then-else'.
  1761. # Polymorphic, and avoids sh expansion error upon interrupt or term signal.
  1762. m4_define([AS_VAR_IF],
  1763. [AS_LITERAL_WORD_IF([$1],
  1764. [AS_IF(m4_ifval([$2], [[test "x$$1" = x[]$2]], [[${$1:+false} :]])],
  1765. [AS_VAR_COPY([as_val], [$1])
  1766. AS_IF(m4_ifval([$2], [[test "x$as_val" = x[]$2]], [[${as_val:+false} :]])],
  1767. [AS_IF(m4_ifval([$2],
  1768. [[eval test \"x\$"$1"\" = x"_AS_ESCAPE([$2], [`], [\"$])"]],
  1769. [[eval \${$1:+false} :]])]),
  1770. [$3], [$4])])
  1771. # AS_VAR_PUSHDEF and AS_VAR_POPDEF
  1772. # --------------------------------
  1773. #
  1774. # Sometimes we may have to handle literals (e.g. `stdlib.h'), while at
  1775. # other moments, the same code may have to get the value from a
  1776. # variable (e.g., `ac_header'). To have a uniform handling of both
  1777. # cases, when a new value is about to be processed, declare a local
  1778. # variable, e.g.:
  1779. #
  1780. # AS_VAR_PUSHDEF([header], [ac_cv_header_$1])
  1781. #
  1782. # and then in the body of the macro, use `header' as is. It is of
  1783. # first importance to use `AS_VAR_*' to access this variable.
  1784. #
  1785. # If the value `$1' was a literal (e.g. `stdlib.h'), then `header' is
  1786. # in fact the value `ac_cv_header_stdlib_h'. If `$1' was indirect,
  1787. # then `header's value in m4 is in fact `$as_header', the shell
  1788. # variable that holds all of the magic to get the expansion right.
  1789. #
  1790. # At the end of the block, free the variable with
  1791. #
  1792. # AS_VAR_POPDEF([header])
  1793. # AS_VAR_POPDEF(VARNAME)
  1794. # ----------------------
  1795. # Free the shell variable accessor VARNAME. To be dnl'ed.
  1796. m4_define([AS_VAR_POPDEF],
  1797. [m4_popdef([$1])])
  1798. # AS_VAR_PUSHDEF(VARNAME, VALUE)
  1799. # ------------------------------
  1800. # Define the m4 macro VARNAME to an accessor to the shell variable
  1801. # named VALUE. VALUE does not need to be a valid shell variable name:
  1802. # the transliteration is handled here. To be dnl'ed.
  1803. #
  1804. # AS_TR_SH attempts to play with diversions if _AS_TR_SH_PREPARE has
  1805. # not been expanded. However, users are expected to do subsequent
  1806. # calls that trigger AS_LITERAL_IF([VARNAME]), and that macro performs
  1807. # expansion inside an argument collection context, where diversions
  1808. # don't work. Therefore, we must require the preparation ourselves.
  1809. m4_defun_init([AS_VAR_PUSHDEF],
  1810. [AS_REQUIRE([_AS_TR_SH_PREPARE])],
  1811. [_$0([$1], m4_expand([$2]))])
  1812. m4_define([_AS_VAR_PUSHDEF],
  1813. [_AS_LITERAL_IF([$2], [ ][
  1814. ])([], [as_$1=_AS_TR_SH_INDIR([$2])
  1815. m4_pushdef([$1], [$as_[$1]])],
  1816. [m4_pushdef([$1], [_AS_TR_SH_LITERAL([$2])])])])
  1817. # AS_VAR_SET(VARIABLE, VALUE)
  1818. # ---------------------------
  1819. # Set the contents of the polymorphic shell VARIABLE to the shell
  1820. # expansion of VALUE. VALUE is immune to field splitting and file
  1821. # name expansion.
  1822. m4_define([AS_VAR_SET],
  1823. [AS_LITERAL_WORD_IF([$1],
  1824. [$1=$2],
  1825. [eval "$1=_AS_ESCAPE([$2], [`], [\"$])"])])
  1826. # AS_VAR_SET_IF(VARIABLE, IF-TRUE, IF-FALSE)
  1827. # ------------------------------------------
  1828. # Implement a shell `if-then-else' depending whether VARIABLE is set
  1829. # or not. Polymorphic.
  1830. m4_define([AS_VAR_SET_IF],
  1831. [AS_IF([AS_VAR_TEST_SET([$1])], [$2], [$3])])
  1832. # AS_VAR_TEST_SET(VARIABLE)
  1833. # -------------------------
  1834. # Expands into an expression which is true if VARIABLE
  1835. # is set. Polymorphic.
  1836. m4_define([AS_VAR_TEST_SET],
  1837. [AS_LITERAL_WORD_IF([$1],
  1838. [${$1+:} false],
  1839. [{ as_var=$1; eval \${$as_var+:} false; }],
  1840. [eval \${$1+:} false])])
  1841. ## -------------------- ##
  1842. ## 8. Setting M4sh up. ##
  1843. ## -------------------- ##
  1844. # AS_INIT_GENERATED(FILE, [COMMENT])
  1845. # ----------------------------------
  1846. # Generate a child script FILE with all initialization necessary to
  1847. # reuse the environment learned by the parent script, and make the
  1848. # file executable. If COMMENT is supplied, it is inserted after the
  1849. # `#!' sequence but before initialization text begins. After this
  1850. # macro, additional text can be appended to FILE to form the body of
  1851. # the child script. The macro ends with non-zero status if the
  1852. # file could not be fully written (such as if the disk is full).
  1853. m4_defun([AS_INIT_GENERATED],
  1854. [m4_require([AS_PREPARE])]dnl
  1855. [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl
  1856. [as_write_fail=0
  1857. cat >$1 <<_ASEOF || as_write_fail=1
  1858. #! $SHELL
  1859. # Generated by $as_me.
  1860. $2
  1861. SHELL=\${CONFIG_SHELL-$SHELL}
  1862. export SHELL
  1863. _ASEOF
  1864. cat >>$1 <<\_ASEOF || as_write_fail=1
  1865. _AS_SHELL_SANITIZE
  1866. _AS_PREPARE
  1867. m4_if(AS_MESSAGE_FD, [1], [], [exec AS_MESSAGE_FD>&1
  1868. ])]dnl
  1869. [m4_text_box([Main body of $1 script.])
  1870. _ASEOF
  1871. test $as_write_fail = 0 && chmod +x $1[]dnl
  1872. _m4_popdef([AS_MESSAGE_LOG_FD])])# AS_INIT_GENERATED
  1873. # AS_INIT
  1874. # -------
  1875. # Initialize m4sh.
  1876. m4_define([AS_INIT],
  1877. [# Wrap our cleanup prior to m4sugar's cleanup.
  1878. m4_wrap([_AS_CLEANUP])
  1879. m4_init
  1880. m4_provide([AS_INIT])
  1881. # Forbidden tokens and exceptions.
  1882. m4_pattern_forbid([^_?AS_])
  1883. # Bangshe and minimal initialization.
  1884. m4_divert_text([BINSH], [@%:@! /bin/sh])
  1885. m4_divert_text([HEADER-COMMENT],
  1886. [@%:@ Generated from __file__ by m4_PACKAGE_STRING.])
  1887. m4_divert_text([M4SH-SANITIZE], [_AS_SHELL_SANITIZE])
  1888. m4_divert_text([M4SH-INIT-FN], [m4_text_box([M4sh Shell Functions.])])
  1889. # Let's go!
  1890. m4_divert([BODY])dnl
  1891. m4_text_box([Main body of script.])
  1892. _AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])dnl
  1893. _AS_DETECT_REQUIRED([_AS_TEST_X_WORKS])dnl
  1894. AS_REQUIRE([_AS_UNSET_PREPARE], [], [M4SH-INIT-FN])dnl
  1895. ])