programs.m4 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902
  1. # This file is part of Autoconf. -*- Autoconf -*-
  2. # Checking for programs.
  3. # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
  4. # This file is part of Autoconf. This program is free
  5. # software; you can redistribute it and/or modify it under the
  6. # terms of the GNU General Public License as published by the
  7. # Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # Under Section 7 of GPL version 3, you are granted additional
  16. # permissions described in the Autoconf Configure Script Exception,
  17. # version 3.0, as published by the Free Software Foundation.
  18. #
  19. # You should have received a copy of the GNU General Public License
  20. # and a copy of the Autoconf Configure Script Exception along with
  21. # this program; see the files COPYINGv3 and COPYING.EXCEPTION
  22. # respectively. If not, see <http://www.gnu.org/licenses/>.
  23. # Written by David MacKenzie, with help from
  24. # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
  25. # Roland McGrath, Noah Friedman, david d zuhn, and many others.
  26. ## ----------------------------- ##
  27. ## Generic checks for programs. ##
  28. ## ----------------------------- ##
  29. # _AC_CHECK_PROG(VARIABLE, PROG-TO-CHECK-FOR,
  30. # [VALUE-IF-FOUND], [VALUE-IF-NOT-FOUND],
  31. # [PATH], [REJECT])
  32. # -----------------------------------------------------
  33. AC_DEFUN([_AC_CHECK_PROG],
  34. [# Extract the first word of "$2", so it can be a program name with args.
  35. set dummy $2; ac_word=$[2]
  36. AC_MSG_CHECKING([for $ac_word])
  37. AC_CACHE_VAL(ac_cv_prog_$1,
  38. [if test -n "$$1"; then
  39. ac_cv_prog_$1="$$1" # Let the user override the test.
  40. else
  41. m4_ifvaln([$6],
  42. [ ac_prog_rejected=no])dnl
  43. _AS_PATH_WALK([$5],
  44. [for ac_exec_ext in '' $ac_executable_extensions; do
  45. if AS_EXECUTABLE_P(["$as_dir/$ac_word$ac_exec_ext"]); then
  46. m4_ifvaln([$6],
  47. [ if test "$as_dir/$ac_word$ac_exec_ext" = "$6"; then
  48. ac_prog_rejected=yes
  49. continue
  50. fi])dnl
  51. ac_cv_prog_$1="$3"
  52. _AS_ECHO_LOG([found $as_dir/$ac_word$ac_exec_ext])
  53. break 2
  54. fi
  55. done])
  56. m4_ifvaln([$6],
  57. [if test $ac_prog_rejected = yes; then
  58. # We found a bogon in the path, so make sure we never use it.
  59. set dummy $ac_cv_prog_$1
  60. shift
  61. if test $[@%:@] != 0; then
  62. # We chose a different compiler from the bogus one.
  63. # However, it has the same basename, so the bogon will be chosen
  64. # first if we set $1 to just the basename; use the full file name.
  65. shift
  66. ac_cv_prog_$1="$as_dir/$ac_word${1+' '}$[@]"
  67. m4_if([$2], [$4],
  68. [ else
  69. # Default is a loser.
  70. AC_MSG_ERROR([$1=$6 unacceptable, but no other $4 found in dnl
  71. m4_default([$5], [\$PATH])])
  72. ])dnl
  73. fi
  74. fi])dnl
  75. dnl If no 4th arg is given, leave the cache variable unset,
  76. dnl so AC_CHECK_PROGS will keep looking.
  77. m4_ifvaln([$4],
  78. [ test -z "$ac_cv_prog_$1" && ac_cv_prog_$1="$4"])dnl
  79. fi])dnl
  80. $1=$ac_cv_prog_$1
  81. if test -n "$$1"; then
  82. AC_MSG_RESULT([$$1])
  83. else
  84. AC_MSG_RESULT([no])
  85. fi
  86. ])# _AC_CHECK_PROG
  87. # AC_CHECK_PROG(VARIABLE, PROG-TO-CHECK-FOR,
  88. # [VALUE-IF-FOUND], [VALUE-IF-NOT-FOUND],
  89. # [PATH], [REJECT])
  90. # -----------------------------------------------------
  91. AC_DEFUN([AC_CHECK_PROG],
  92. [_AC_CHECK_PROG($@)
  93. AC_SUBST([$1])dnl
  94. ])
  95. # AC_CHECK_PROGS(VARIABLE, PROGS-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND],
  96. # [PATH])
  97. # ------------------------------------------------------------------
  98. AC_DEFUN([AC_CHECK_PROGS],
  99. [for ac_prog in $2
  100. do
  101. AC_CHECK_PROG([$1], [$ac_prog], [$ac_prog], , [$4])
  102. test -n "$$1" && break
  103. done
  104. m4_ifvaln([$3], [test -n "$$1" || $1="$3"])])
  105. # _AC_PATH_PROG(VARIABLE, PROG-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND], [PATH])
  106. # ------------------------------------------------------------------------
  107. AC_DEFUN([_AC_PATH_PROG],
  108. [# Extract the first word of "$2", so it can be a program name with args.
  109. set dummy $2; ac_word=$[2]
  110. AC_MSG_CHECKING([for $ac_word])
  111. AC_CACHE_VAL([ac_cv_path_$1],
  112. [case $$1 in
  113. [[\\/]]* | ?:[[\\/]]*)
  114. ac_cv_path_$1="$$1" # Let the user override the test with a path.
  115. ;;
  116. *)
  117. _AS_PATH_WALK([$4],
  118. [for ac_exec_ext in '' $ac_executable_extensions; do
  119. if AS_EXECUTABLE_P(["$as_dir/$ac_word$ac_exec_ext"]); then
  120. ac_cv_path_$1="$as_dir/$ac_word$ac_exec_ext"
  121. _AS_ECHO_LOG([found $as_dir/$ac_word$ac_exec_ext])
  122. break 2
  123. fi
  124. done])
  125. dnl If no 3rd arg is given, leave the cache variable unset,
  126. dnl so AC_PATH_PROGS will keep looking.
  127. m4_ifvaln([$3],
  128. [ test -z "$ac_cv_path_$1" && ac_cv_path_$1="$3"])dnl
  129. ;;
  130. esac])dnl
  131. $1=$ac_cv_path_$1
  132. if test -n "$$1"; then
  133. AC_MSG_RESULT([$$1])
  134. else
  135. AC_MSG_RESULT([no])
  136. fi
  137. ])# _AC_PATH_PROG
  138. # AC_PATH_PROG(VARIABLE, PROG-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND], [PATH])
  139. # -----------------------------------------------------------------------
  140. AC_DEFUN([AC_PATH_PROG],
  141. [_AC_PATH_PROG($@)
  142. AC_SUBST([$1])dnl
  143. ])
  144. # AC_PATH_PROGS(VARIABLE, PROGS-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND],
  145. # [PATH])
  146. # -----------------------------------------------------------------
  147. AC_DEFUN([AC_PATH_PROGS],
  148. [for ac_prog in $2
  149. do
  150. AC_PATH_PROG([$1], [$ac_prog], , [$4])
  151. test -n "$$1" && break
  152. done
  153. m4_ifvaln([$3], [test -n "$$1" || $1="$3"])dnl
  154. ])
  155. ## -------------------------- ##
  156. ## Generic checks for tools. ##
  157. ## -------------------------- ##
  158. # AC_CHECK_TOOL_PREFIX
  159. # --------------------
  160. AU_DEFUN([AC_CHECK_TOOL_PREFIX])
  161. # _AC_TOOL_WARN
  162. # -------------
  163. AC_DEFUN([_AC_TOOL_WARN],
  164. [case $cross_compiling:$ac_tool_warned in
  165. yes:)
  166. AC_MSG_WARN([using cross tools not prefixed with host triplet])
  167. ac_tool_warned=yes ;;
  168. esac])
  169. # AC_PATH_TOOL(VARIABLE, PROG-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND], [PATH])
  170. # -----------------------------------------------------------------------
  171. # (Use different variables $1 and ac_pt_$1 so that cache vars don't conflict.)
  172. AC_DEFUN([AC_PATH_TOOL],
  173. [if test -n "$ac_tool_prefix"; then
  174. AC_PATH_PROG([$1], [${ac_tool_prefix}$2], , [$4])
  175. fi
  176. if test -z "$ac_cv_path_$1"; then
  177. ac_pt_$1=$$1
  178. _AC_PATH_PROG([ac_pt_$1], [$2], [], [$4])
  179. if test "x$ac_pt_$1" = x; then
  180. $1="$3"
  181. else
  182. _AC_TOOL_WARN
  183. $1=$ac_pt_$1
  184. fi
  185. else
  186. $1="$ac_cv_path_$1"
  187. fi
  188. ])# AC_PATH_TOOL
  189. # AC_CHECK_TOOL(VARIABLE, PROG-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND], [PATH])
  190. # ------------------------------------------------------------------------
  191. # (Use different variables $1 and ac_ct_$1 so that cache vars don't conflict.)
  192. AC_DEFUN([AC_CHECK_TOOL],
  193. [if test -n "$ac_tool_prefix"; then
  194. AC_CHECK_PROG([$1], [${ac_tool_prefix}$2], [${ac_tool_prefix}$2], , [$4])
  195. fi
  196. if test -z "$ac_cv_prog_$1"; then
  197. ac_ct_$1=$$1
  198. _AC_CHECK_PROG([ac_ct_$1], [$2], [$2], [], [$4])
  199. if test "x$ac_ct_$1" = x; then
  200. $1="$3"
  201. else
  202. _AC_TOOL_WARN
  203. $1=$ac_ct_$1
  204. fi
  205. else
  206. $1="$ac_cv_prog_$1"
  207. fi
  208. ])# AC_CHECK_TOOL
  209. # AC_CHECK_TOOLS(VARIABLE, PROGS-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND],
  210. # [PATH])
  211. # ------------------------------------------------------------------
  212. # Check for each tool in PROGS-TO-CHECK-FOR with the cross prefix. If
  213. # none can be found with a cross prefix, then use the first one that
  214. # was found without the cross prefix.
  215. AC_DEFUN([AC_CHECK_TOOLS],
  216. [if test -n "$ac_tool_prefix"; then
  217. for ac_prog in $2
  218. do
  219. AC_CHECK_PROG([$1],
  220. [$ac_tool_prefix$ac_prog], [$ac_tool_prefix$ac_prog],,
  221. [$4])
  222. test -n "$$1" && break
  223. done
  224. fi
  225. if test -z "$$1"; then
  226. ac_ct_$1=$$1
  227. AC_CHECK_PROGS([ac_ct_$1], [$2], [], [$4])
  228. if test "x$ac_ct_$1" = x; then
  229. $1="$3"
  230. else
  231. _AC_TOOL_WARN
  232. $1=$ac_ct_$1
  233. fi
  234. fi
  235. ])# AC_CHECK_TOOLS
  236. # AC_PATH_TARGET_TOOL(VARIABLE, PROG-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND], [PATH])
  237. # ------------------------------------------------------------------------------
  238. # (Use different variables $1 and ac_pt_$1 so that cache vars don't conflict.)
  239. AC_DEFUN([AC_PATH_TARGET_TOOL],
  240. [AC_REQUIRE([AC_CANONICAL_TARGET])dnl
  241. AC_PATH_PROG([$1], [$target_alias-$2], , [$4])
  242. if test -z "$ac_cv_path_$1"; then
  243. if test "$build" = "$target"; then
  244. ac_pt_$1=$$1
  245. _AC_PATH_PROG([ac_pt_$1], [$2], [$3], [$4])
  246. $1=$ac_pt_$1
  247. else
  248. $1="$3"
  249. fi
  250. else
  251. $1="$ac_cv_path_$1"
  252. fi
  253. ])# AC_PATH_TARGET_TOOL
  254. # AC_CHECK_TARGET_TOOL(VARIABLE, PROG-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND], [PATH])
  255. # -------------------------------------------------------------------------------
  256. # (Use different variables $1 and ac_ct_$1 so that cache vars don't conflict.)
  257. AC_DEFUN([AC_CHECK_TARGET_TOOL],
  258. [AC_REQUIRE([AC_CANONICAL_TARGET])dnl
  259. AC_CHECK_PROG([$1], [$target_alias-$2], [$target_alias-$2], , [$4])
  260. if test -z "$ac_cv_prog_$1"; then
  261. if test "$build" = "$target"; then
  262. ac_ct_$1=$$1
  263. _AC_CHECK_PROG([ac_ct_$1], [$2], [$2], [$3], [$4])
  264. $1=$ac_ct_$1
  265. else
  266. $1="$3"
  267. fi
  268. else
  269. $1="$ac_cv_prog_$1"
  270. fi
  271. ])# AC_CHECK_TARGET_TOOL
  272. # AC_CHECK_TARGET_TOOLS(VARIABLE, PROGS-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND],
  273. # [PATH])
  274. # -------------------------------------------------------------------------
  275. # Check for each tool in PROGS-TO-CHECK-FOR with the cross prefix. If
  276. # none can be found with a cross prefix, then use the first one that
  277. # was found without the cross prefix.
  278. AC_DEFUN([AC_CHECK_TARGET_TOOLS],
  279. [AC_REQUIRE([AC_CANONICAL_TARGET])dnl
  280. for ac_prog in $2
  281. do
  282. AC_CHECK_PROG([$1],
  283. [$target_alias-$ac_prog], [$target_alias-$ac_prog],,
  284. [$4])
  285. test -n "$$1" && break
  286. done
  287. if test -z "$$1"; then
  288. if test "$build" = "$target"; then
  289. ac_ct_$1=$$1
  290. AC_CHECK_PROGS([ac_ct_$1], [$2], [$3], [$4])
  291. $1=$ac_ct_$1
  292. else
  293. $1="$3"
  294. fi
  295. fi
  296. ])# AC_CHECK_TARGET_TOOLS
  297. ## ---------------- ##
  298. ## Specific tests. ##
  299. ## ---------------- ##
  300. # Please, keep this section sorted.
  301. # (But of course when keeping related things together).
  302. # Check for gawk first since it's generally better.
  303. AN_MAKEVAR([AWK], [AC_PROG_AWK])
  304. AN_PROGRAM([awk], [AC_PROG_AWK])
  305. AN_PROGRAM([gawk], [AC_PROG_AWK])
  306. AN_PROGRAM([mawk], [AC_PROG_AWK])
  307. AN_PROGRAM([nawk], [AC_PROG_AWK])
  308. AC_DEFUN([AC_PROG_AWK],
  309. [AC_CHECK_PROGS(AWK, gawk mawk nawk awk, )])
  310. # AC_PROG_EGREP
  311. # -------------
  312. AC_DEFUN([AC_PROG_EGREP],
  313. [AC_REQUIRE([AC_PROG_GREP])dnl
  314. AC_CACHE_CHECK([for egrep], ac_cv_path_EGREP,
  315. [if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
  316. then ac_cv_path_EGREP="$GREP -E"
  317. else
  318. _AC_PROG_GREP(EGREP, egrep, ['EGREP$'])
  319. fi])
  320. EGREP="$ac_cv_path_EGREP"
  321. AC_SUBST([EGREP])
  322. ])# AC_PROG_EGREP
  323. # AC_PROG_FGREP
  324. # -------------
  325. AC_DEFUN([AC_PROG_FGREP],
  326. [AC_REQUIRE([AC_PROG_GREP])dnl
  327. AC_CACHE_CHECK([for fgrep], ac_cv_path_FGREP,
  328. [if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1
  329. then ac_cv_path_FGREP="$GREP -F"
  330. else
  331. _AC_PROG_GREP(FGREP, fgrep, [FGREP])
  332. fi])
  333. FGREP="$ac_cv_path_FGREP"
  334. AC_SUBST([FGREP])
  335. ])# AC_PROG_FGREP
  336. # AC_PROG_GREP
  337. # ------------
  338. # Check for a fully functional grep program that handles
  339. # the longest lines possible and which respects multiple -e options.
  340. # Prefer GNU grep if found.
  341. AC_DEFUN([AC_PROG_GREP],
  342. [AC_CACHE_CHECK([for grep that handles long lines and -e], ac_cv_path_GREP,
  343. [_$0(GREP, [grep ggrep], [-e 'GREP$' -e '-(cannot match)-'])])
  344. GREP="$ac_cv_path_GREP"
  345. AC_SUBST([GREP])
  346. ])
  347. # _AC_PROG_GREP(VARIABLE, PROGNAME-LIST, PROG-ARGUMENTS)
  348. # ------------------------------------------------------
  349. # Solaris 9 /usr/xpg4/bin/*grep is suitable, but /usr/bin/*grep lacks -e.
  350. # AIX silently truncates long lines before matching.
  351. # NeXT understands only one -e and truncates long lines.
  352. m4_define([_AC_PROG_GREP],
  353. [_AC_PATH_PROGS_FEATURE_CHECK([$1], [$2],
  354. [_AC_FEATURE_CHECK_LENGTH([ac_path_$1], [ac_cv_path_$1],
  355. ["$ac_path_$1" $3], [$1])], [],
  356. [$PATH$PATH_SEPARATOR/usr/xpg4/bin])dnl
  357. ])
  358. # _AC_PATH_PROGS_FEATURE_CHECK(VARIABLE, PROGNAME-LIST, FEATURE-TEST,
  359. # [ACTION-IF-NOT-FOUND], [PATH=$PATH])
  360. # -------------------------------------------------------------------
  361. # FEATURE-TEST is called repeatedly with $ac_path_VARIABLE set to the
  362. # name of a program in PROGNAME-LIST found in PATH. FEATURE-TEST must set
  363. # $ac_cv_path_VARIABLE to the path of an acceptable program, or else
  364. # ACTION-IF-NOT-FOUND is executed; the default action (for internal use
  365. # only) issues a fatal error message. If a suitable $ac_path_VARIABLE is
  366. # found in the FEATURE-TEST macro, it can set $ac_path_VARIABLE_found=':'
  367. # to accept that value without any further checks.
  368. m4_define([_AC_PATH_PROGS_FEATURE_CHECK],
  369. [if test -z "$$1"; then
  370. ac_path_$1_found=false
  371. # Loop through the user's path and test for each of PROGNAME-LIST
  372. _AS_PATH_WALK([$5],
  373. [for ac_prog in $2; do
  374. for ac_exec_ext in '' $ac_executable_extensions; do
  375. ac_path_$1="$as_dir/$ac_prog$ac_exec_ext"
  376. AS_EXECUTABLE_P(["$ac_path_$1"]) || continue
  377. $3
  378. $ac_path_$1_found && break 3
  379. done
  380. done])dnl
  381. if test -z "$ac_cv_path_$1"; then
  382. m4_default([$4],
  383. [AC_MSG_ERROR([no acceptable m4_bpatsubst([$2], [ .*]) could be dnl
  384. found in m4_default([$5], [\$PATH])])])
  385. fi
  386. else
  387. ac_cv_path_$1=$$1
  388. fi
  389. ])
  390. # AC_PATH_PROGS_FEATURE_CHECK(VARIABLE, PROGNAME-LIST,
  391. # FEATURE-TEST, [ACTION-IF-NOT-FOUND=:],
  392. # [PATH=$PATH])
  393. # ------------------------------------------------------------------
  394. # Designed to be used inside AC_CACHE_VAL. It is recommended,
  395. # but not required, that the user also use AC_ARG_VAR([VARIABLE]).
  396. # If VARIABLE is not empty, set the cache variable
  397. # $ac_cv_path_VARIABLE to VARIABLE without any further tests.
  398. # Otherwise, call FEATURE_TEST repeatedly with $ac_path_VARIABLE
  399. # set to the name of a program in PROGNAME-LIST found in PATH. If
  400. # no invocation of FEATURE-TEST sets $ac_cv_path_VARIABLE to the
  401. # path of an acceptable program, ACTION-IF-NOT-FOUND is executed.
  402. # FEATURE-TEST is invoked even when $ac_cv_path_VARIABLE is set,
  403. # in case a better candidate occurs later in PATH; to accept the
  404. # current setting and bypass further checks, FEATURE-TEST can set
  405. # $ac_path_VARIABLE_found=':'. Note that, unlike AC_CHECK_PROGS,
  406. # this macro does not have any side effect on the current value
  407. # of VARIABLE.
  408. m4_define([AC_PATH_PROGS_FEATURE_CHECK],
  409. [_$0([$1], [$2], [$3], m4_default([$4], [:]), [$5])dnl
  410. ])
  411. # _AC_FEATURE_CHECK_LENGTH(PROGPATH, CACHE-VAR, CHECK-CMD, [MATCH-STRING])
  412. # ------------------------------------------------------------------------
  413. # For use as the FEATURE-TEST argument to _AC_PATH_PROGS_FEATURE_TEST.
  414. # On each iteration run CHECK-CMD on an input file, storing the value
  415. # of PROGPATH in CACHE-VAR if the CHECK-CMD succeeds. The input file
  416. # is always one line, starting with only 10 characters, and doubling
  417. # in length at each iteration until approx 10000 characters or the
  418. # feature check succeeds. The feature check is called at each
  419. # iteration by appending (optionally, MATCH-STRING and) a newline
  420. # to the file, and using the result as input to CHECK-CMD.
  421. m4_define([_AC_FEATURE_CHECK_LENGTH],
  422. [# Check for GNU $1 and select it if it is found.
  423. _AC_PATH_PROG_FLAVOR_GNU([$$1],
  424. [$2="$$1" $1_found=:],
  425. [ac_count=0
  426. AS_ECHO_N([0123456789]) >"conftest.in"
  427. while :
  428. do
  429. cat "conftest.in" "conftest.in" >"conftest.tmp"
  430. mv "conftest.tmp" "conftest.in"
  431. cp "conftest.in" "conftest.nl"
  432. AS_ECHO(['$4']) >> "conftest.nl"
  433. $3 < "conftest.nl" >"conftest.out" 2>/dev/null || break
  434. diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
  435. AS_VAR_ARITH([ac_count], [$ac_count + 1])
  436. if test $ac_count -gt ${$1_max-0}; then
  437. # Best one so far, save it but keep looking for a better one
  438. $2="$$1"
  439. dnl # Using $1_max so that each tool feature checked gets its
  440. dnl # own variable. Don't reset it otherwise the implied search
  441. dnl # for best performing tool in a list breaks down.
  442. $1_max=$ac_count
  443. fi
  444. # 10*(2^10) chars as input seems more than enough
  445. test $ac_count -gt 10 && break
  446. done
  447. rm -f conftest.in conftest.tmp conftest.nl conftest.out])dnl
  448. ])
  449. # _AC_PATH_PROG_FLAVOR_GNU(PROGRAM-PATH, IF-SUCCESS, [IF-FAILURE])
  450. # ----------------------------------------------------------------
  451. m4_define([_AC_PATH_PROG_FLAVOR_GNU],
  452. [# Check for GNU $1
  453. case `"$1" --version 2>&1` in
  454. *GNU*)
  455. $2;;
  456. m4_ifval([$3],
  457. [*)
  458. $3;;
  459. ])esac
  460. ])# _AC_PATH_PROG_FLAVOR_GNU
  461. # AC_PROG_INSTALL
  462. # ---------------
  463. AN_MAKEVAR([INSTALL], [AC_PROG_INSTALL])
  464. AN_PROGRAM([install], [AC_PROG_INSTALL])
  465. AC_DEFUN_ONCE([AC_PROG_INSTALL],
  466. [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
  467. AC_REQUIRE_AUX_FILE([install-sh])dnl
  468. # Find a good install program. We prefer a C program (faster),
  469. # so one script is as good as another. But avoid the broken or
  470. # incompatible versions:
  471. # SysV /etc/install, /usr/sbin/install
  472. # SunOS /usr/etc/install
  473. # IRIX /sbin/install
  474. # AIX /bin/install
  475. # AmigaOS /C/install, which installs bootblocks on floppy discs
  476. # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
  477. # AFS /usr/afsws/bin/install, which mishandles nonexistent args
  478. # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
  479. # OS/2's system install, which has a completely different semantic
  480. # ./install, which can be erroneously created by make from ./install.sh.
  481. # Reject install programs that cannot install multiple files.
  482. AC_MSG_CHECKING([for a BSD-compatible install])
  483. if test -z "$INSTALL"; then
  484. AC_CACHE_VAL(ac_cv_path_install,
  485. [_AS_PATH_WALK([$PATH],
  486. [[# Account for people who put trailing slashes in PATH elements.
  487. case $as_dir/ in @%:@((
  488. ./ | .// | /[cC]/* | \
  489. /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
  490. ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
  491. /usr/ucb/* ) ;;
  492. *)]
  493. # OSF1 and SCO ODT 3.0 have their own names for install.
  494. # Don't use installbsd from OSF since it installs stuff as root
  495. # by default.
  496. for ac_prog in ginstall scoinst install; do
  497. for ac_exec_ext in '' $ac_executable_extensions; do
  498. if AS_EXECUTABLE_P(["$as_dir/$ac_prog$ac_exec_ext"]); then
  499. if test $ac_prog = install &&
  500. grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
  501. # AIX install. It has an incompatible calling convention.
  502. :
  503. elif test $ac_prog = install &&
  504. grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
  505. # program-specific install script used by HP pwplus--don't use.
  506. :
  507. else
  508. rm -rf conftest.one conftest.two conftest.dir
  509. echo one > conftest.one
  510. echo two > conftest.two
  511. mkdir conftest.dir
  512. if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
  513. test -s conftest.one && test -s conftest.two &&
  514. test -s conftest.dir/conftest.one &&
  515. test -s conftest.dir/conftest.two
  516. then
  517. ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
  518. break 3
  519. fi
  520. fi
  521. fi
  522. done
  523. done
  524. ;;
  525. esac
  526. ])
  527. rm -rf conftest.one conftest.two conftest.dir
  528. ])dnl
  529. if test "${ac_cv_path_install+set}" = set; then
  530. INSTALL=$ac_cv_path_install
  531. else
  532. # As a last resort, use the slow shell script. Don't cache a
  533. # value for INSTALL within a source directory, because that will
  534. # break other packages using the cache if that directory is
  535. # removed, or if the value is a relative name.
  536. INSTALL=$ac_install_sh
  537. fi
  538. fi
  539. dnl Do special magic for INSTALL instead of AC_SUBST, to get
  540. dnl relative names right.
  541. AC_MSG_RESULT([$INSTALL])
  542. # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
  543. # It thinks the first close brace ends the variable substitution.
  544. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
  545. AC_SUBST(INSTALL_PROGRAM)dnl
  546. test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
  547. AC_SUBST(INSTALL_SCRIPT)dnl
  548. test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
  549. AC_SUBST(INSTALL_DATA)dnl
  550. ])# AC_PROG_INSTALL
  551. # AC_PROG_MKDIR_P
  552. # ---------------
  553. # Check whether `mkdir -p' is known to be thread-safe, and fall back to
  554. # install-sh -d otherwise.
  555. #
  556. # Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories
  557. # created by `make install' are always world readable, even if the
  558. # installer happens to have an overly restrictive umask (e.g. 077).
  559. # This was a mistake. There are at least two reasons why we must not
  560. # use `-m 0755':
  561. # - it causes special bits like SGID to be ignored,
  562. # - it may be too restrictive (some setups expect 775 directories).
  563. #
  564. # Do not use -m 0755 and let people choose whatever they expect by
  565. # setting umask.
  566. #
  567. # We cannot accept any implementation of `mkdir' that recognizes `-p'.
  568. # Some implementations (such as Solaris 8's) are vulnerable to race conditions:
  569. # if a parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c'
  570. # concurrently, both version can detect that a/ is missing, but only
  571. # one can create it and the other will error out. Consequently we
  572. # restrict ourselves to known race-free implementations.
  573. #
  574. # Automake used to define mkdir_p as `mkdir -p .', in order to
  575. # allow $(mkdir_p) to be used without argument. As in
  576. # $(mkdir_p) $(somedir)
  577. # where $(somedir) is conditionally defined. However we don't do
  578. # that for MKDIR_P.
  579. # 1. before we restricted the check to GNU mkdir, `mkdir -p .' was
  580. # reported to fail in read-only directories. The system where this
  581. # happened has been forgotten.
  582. # 2. in practice we call $(MKDIR_P) on directories such as
  583. # $(MKDIR_P) "$(DESTDIR)$(somedir)"
  584. # and we don't want to create $(DESTDIR) if $(somedir) is empty.
  585. # To support the latter case, we have to write
  586. # test -z "$(somedir)" || $(MKDIR_P) "$(DESTDIR)$(somedir)"
  587. # so $(MKDIR_P) always has an argument.
  588. # We will have better chances of detecting a missing test if
  589. # $(MKDIR_P) complains about missing arguments.
  590. # 3. $(MKDIR_P) is named after `mkdir -p' and we don't expect this
  591. # to accept no argument.
  592. # 4. having something like `mkdir .' in the output is unsightly.
  593. #
  594. # On NextStep and OpenStep, the `mkdir' command does not
  595. # recognize any option. It will interpret all options as
  596. # directories to create.
  597. AN_MAKEVAR([MKDIR_P], [AC_PROG_MKDIR_P])
  598. AC_DEFUN_ONCE([AC_PROG_MKDIR_P],
  599. [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
  600. AC_REQUIRE_AUX_FILE([install-sh])dnl
  601. AC_MSG_CHECKING([for a thread-safe mkdir -p])
  602. if test -z "$MKDIR_P"; then
  603. AC_CACHE_VAL([ac_cv_path_mkdir],
  604. [_AS_PATH_WALK([$PATH$PATH_SEPARATOR/opt/sfw/bin],
  605. [for ac_prog in mkdir gmkdir; do
  606. for ac_exec_ext in '' $ac_executable_extensions; do
  607. AS_EXECUTABLE_P(["$as_dir/$ac_prog$ac_exec_ext"]) || continue
  608. case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
  609. 'mkdir (GNU coreutils) '* | \
  610. 'mkdir (coreutils) '* | \
  611. 'mkdir (fileutils) '4.1*)
  612. ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext
  613. break 3;;
  614. esac
  615. done
  616. done])])
  617. test -d ./--version && rmdir ./--version
  618. if test "${ac_cv_path_mkdir+set}" = set; then
  619. MKDIR_P="$ac_cv_path_mkdir -p"
  620. else
  621. # As a last resort, use the slow shell script. Don't cache a
  622. # value for MKDIR_P within a source directory, because that will
  623. # break other packages using the cache if that directory is
  624. # removed, or if the value is a relative name.
  625. MKDIR_P="$ac_install_sh -d"
  626. fi
  627. fi
  628. dnl status.m4 does special magic for MKDIR_P instead of AC_SUBST,
  629. dnl to get relative names right. However, also AC_SUBST here so
  630. dnl that Automake versions before 1.10 will pick it up (they do not
  631. dnl trace AC_SUBST_TRACE).
  632. dnl FIXME: Remove this once we drop support for Automake < 1.10.
  633. AC_SUBST([MKDIR_P])dnl
  634. AC_MSG_RESULT([$MKDIR_P])
  635. ])# AC_PROG_MKDIR_P
  636. # AC_PROG_LEX
  637. # -----------
  638. # Look for flex or lex. Set its associated library to LEXLIB.
  639. # Check if lex declares yytext as a char * by default, not a char[].
  640. AN_MAKEVAR([LEX], [AC_PROG_LEX])
  641. AN_PROGRAM([lex], [AC_PROG_LEX])
  642. AN_PROGRAM([flex], [AC_PROG_LEX])
  643. AC_DEFUN_ONCE([AC_PROG_LEX],
  644. [AC_CHECK_PROGS(LEX, flex lex, :)
  645. if test "x$LEX" != "x:"; then
  646. _AC_PROG_LEX_YYTEXT_DECL
  647. fi])
  648. # _AC_PROG_LEX_YYTEXT_DECL
  649. # ------------------------
  650. # Check for the Lex output root, the Lex library, and whether Lex
  651. # declares yytext as a char * by default.
  652. m4_define([_AC_PROG_LEX_YYTEXT_DECL],
  653. [cat >conftest.l <<_ACEOF[
  654. %%
  655. a { ECHO; }
  656. b { REJECT; }
  657. c { yymore (); }
  658. d { yyless (1); }
  659. e { /* IRIX 6.5 flex 2.5.4 underquotes its yyless argument. */
  660. yyless ((input () != 0)); }
  661. f { unput (yytext[0]); }
  662. . { BEGIN INITIAL; }
  663. %%
  664. #ifdef YYTEXT_POINTER
  665. extern char *yytext;
  666. #endif
  667. int
  668. main (void)
  669. {
  670. return ! yylex () + ! yywrap ();
  671. }
  672. ]_ACEOF
  673. _AC_DO_VAR(LEX conftest.l)
  674. AC_CACHE_CHECK([lex output file root], [ac_cv_prog_lex_root], [
  675. if test -f lex.yy.c; then
  676. ac_cv_prog_lex_root=lex.yy
  677. elif test -f lexyy.c; then
  678. ac_cv_prog_lex_root=lexyy
  679. else
  680. AC_MSG_ERROR([cannot find output from $LEX; giving up])
  681. fi])
  682. AC_SUBST([LEX_OUTPUT_ROOT], [$ac_cv_prog_lex_root])dnl
  683. if test -z "${LEXLIB+set}"; then
  684. AC_CACHE_CHECK([lex library], [ac_cv_lib_lex], [
  685. ac_save_LIBS=$LIBS
  686. ac_cv_lib_lex='none needed'
  687. for ac_lib in '' -lfl -ll; do
  688. LIBS="$ac_lib $ac_save_LIBS"
  689. AC_LINK_IFELSE([AC_LANG_DEFINES_PROVIDED[`cat $LEX_OUTPUT_ROOT.c`]],
  690. [ac_cv_lib_lex=$ac_lib])
  691. test "$ac_cv_lib_lex" != 'none needed' && break
  692. done
  693. LIBS=$ac_save_LIBS
  694. ])
  695. test "$ac_cv_lib_lex" != 'none needed' && LEXLIB=$ac_cv_lib_lex
  696. fi
  697. AC_SUBST(LEXLIB)
  698. AC_CACHE_CHECK(whether yytext is a pointer, ac_cv_prog_lex_yytext_pointer,
  699. [# POSIX says lex can declare yytext either as a pointer or an array; the
  700. # default is implementation-dependent. Figure out which it is, since
  701. # not all implementations provide the %pointer and %array declarations.
  702. ac_cv_prog_lex_yytext_pointer=no
  703. ac_save_LIBS=$LIBS
  704. LIBS="$LEXLIB $ac_save_LIBS"
  705. AC_LINK_IFELSE([AC_LANG_DEFINES_PROVIDED
  706. [#define YYTEXT_POINTER 1
  707. `cat $LEX_OUTPUT_ROOT.c`]],
  708. [ac_cv_prog_lex_yytext_pointer=yes])
  709. LIBS=$ac_save_LIBS
  710. ])
  711. dnl
  712. if test $ac_cv_prog_lex_yytext_pointer = yes; then
  713. AC_DEFINE(YYTEXT_POINTER, 1,
  714. [Define to 1 if `lex' declares `yytext' as a `char *' by default,
  715. not a `char[]'.])
  716. fi
  717. rm -f conftest.l $LEX_OUTPUT_ROOT.c
  718. ])# _AC_PROG_LEX_YYTEXT_DECL
  719. # Require AC_PROG_LEX in case some people were just calling this macro.
  720. AU_DEFUN([AC_DECL_YYTEXT], [AC_PROG_LEX])
  721. # AC_PROG_LN_S
  722. # ------------
  723. AN_MAKEVAR([LN], [AC_PROG_LN_S])
  724. AN_PROGRAM([ln], [AC_PROG_LN_S])
  725. AC_DEFUN([AC_PROG_LN_S],
  726. [AC_MSG_CHECKING([whether ln -s works])
  727. AC_SUBST([LN_S], [$as_ln_s])dnl
  728. if test "$LN_S" = "ln -s"; then
  729. AC_MSG_RESULT([yes])
  730. else
  731. AC_MSG_RESULT([no, using $LN_S])
  732. fi
  733. ])# AC_PROG_LN_S
  734. # AC_PROG_MAKE_SET
  735. # ----------------
  736. # Define SET_MAKE to set ${MAKE} if Make does not do so automatically. If Make
  737. # does not run the test Makefile, we assume that the Make program the user will
  738. # invoke does set $(MAKE). This is typical, and emitting `MAKE=foomake' is
  739. # always wrong if `foomake' is not available or does not work.
  740. AN_MAKEVAR([MAKE], [AC_PROG_MAKE_SET])
  741. AN_PROGRAM([make], [AC_PROG_MAKE_SET])
  742. AC_DEFUN([AC_PROG_MAKE_SET],
  743. [AC_MSG_CHECKING([whether ${MAKE-make} sets \$(MAKE)])
  744. set x ${MAKE-make}
  745. ac_make=`AS_ECHO(["$[2]"]) | sed 's/+/p/g; s/[[^a-zA-Z0-9_]]/_/g'`
  746. AC_CACHE_VAL(ac_cv_prog_make_${ac_make}_set,
  747. [cat >conftest.make <<\_ACEOF
  748. SHELL = /bin/sh
  749. all:
  750. @echo '@@@%%%=$(MAKE)=@@@%%%'
  751. _ACEOF
  752. # GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
  753. case `${MAKE-make} -f conftest.make 2>/dev/null` in
  754. *@@@%%%=?*=@@@%%%*)
  755. eval ac_cv_prog_make_${ac_make}_set=yes;;
  756. *)
  757. eval ac_cv_prog_make_${ac_make}_set=no;;
  758. esac
  759. rm -f conftest.make])dnl
  760. if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
  761. AC_MSG_RESULT([yes])
  762. SET_MAKE=
  763. else
  764. AC_MSG_RESULT([no])
  765. SET_MAKE="MAKE=${MAKE-make}"
  766. fi
  767. AC_SUBST([SET_MAKE])dnl
  768. ])# AC_PROG_MAKE_SET
  769. # AC_PROG_RANLIB
  770. # --------------
  771. AN_MAKEVAR([RANLIB], [AC_PROG_RANLIB])
  772. AN_PROGRAM([ranlib], [AC_PROG_RANLIB])
  773. AC_DEFUN([AC_PROG_RANLIB],
  774. [AC_CHECK_TOOL(RANLIB, ranlib, :)])
  775. # AC_RSH
  776. # ------
  777. # I don't know what it used to do, but it no longer does.
  778. AU_DEFUN([AC_RSH], [],
  779. [$0 is no longer supported. Remove this warning when you
  780. adjust the code.])
  781. # AC_PROG_SED
  782. # -----------
  783. # Check for a fully functional sed program that truncates
  784. # as few characters as possible. Prefer GNU sed if found.
  785. AC_DEFUN([AC_PROG_SED],
  786. [AC_CACHE_CHECK([for a sed that does not truncate output], ac_cv_path_SED,
  787. [dnl ac_script should not contain more than 99 commands (for HP-UX sed),
  788. dnl but more than about 7000 bytes, to catch a limit in Solaris 8 /usr/ucb/sed.
  789. ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
  790. for ac_i in 1 2 3 4 5 6 7; do
  791. ac_script="$ac_script$as_nl$ac_script"
  792. done
  793. echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed
  794. AS_UNSET([ac_script])
  795. _AC_PATH_PROGS_FEATURE_CHECK(SED, [sed gsed],
  796. [_AC_FEATURE_CHECK_LENGTH([ac_path_SED], [ac_cv_path_SED],
  797. ["$ac_path_SED" -f conftest.sed])])])
  798. SED="$ac_cv_path_SED"
  799. AC_SUBST([SED])dnl
  800. rm -f conftest.sed
  801. ])# AC_PROG_SED
  802. # AC_PROG_YACC
  803. # ------------
  804. AN_MAKEVAR([BISON], [AC_PROG_YACC])
  805. AN_MAKEVAR([YACC], [AC_PROG_YACC])
  806. AN_MAKEVAR([YFLAGS], [AC_PROG_YACC])
  807. AN_PROGRAM([yacc], [AC_PROG_YACC])
  808. AN_PROGRAM([byacc], [AC_PROG_YACC])
  809. AN_PROGRAM([bison], [AC_PROG_YACC])
  810. AC_DEFUN([AC_PROG_YACC],
  811. [AC_CHECK_PROGS(YACC, 'bison -y' byacc, yacc)dnl
  812. AC_ARG_VAR(YACC,
  813. [The `Yet Another Compiler Compiler' implementation to use. Defaults to
  814. the first program found out of: `bison -y', `byacc', `yacc'.])dnl
  815. AC_ARG_VAR(YFLAGS,
  816. [The list of arguments that will be passed by default to $YACC. This script
  817. will default YFLAGS to the empty string to avoid a default value of `-d' given
  818. by some make applications.])])