2
0

base.at 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  1. # -*- Autotest -*-
  2. AT_BANNER([Autoconf base layer.])
  3. # Copyright (C) 2000-2001, 2003, 2005-2012 Free Software Foundation,
  4. # Inc.
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. ## ------------------------------- ##
  19. ## AC_REQUIRE: topological sort.. ##
  20. ## ------------------------------- ##
  21. # Check that dependencies are always properly honored.
  22. AT_SETUP([AC_REQUIRE: topological sort])
  23. AT_KEYWORDS([m4@&t@_require])
  24. AT_DATA([configure.ac],
  25. [[define([REQUIRE_AND_CHECK],
  26. [AC_REQUIRE([$1])
  27. test -z "$m4@&t@_translit([$1], [A-Z], [a-z])" && AS_EXIT(1)])
  28. AC_DEFUN([TEST1],
  29. [REQUIRE_AND_CHECK([TEST2a])
  30. REQUIRE_AND_CHECK([TEST2b])
  31. test1=set])
  32. AC_DEFUN([TEST2a],
  33. [test2a=set])
  34. AC_DEFUN([TEST2b],
  35. [REQUIRE_AND_CHECK([TEST3])
  36. test2b=set])
  37. AC_DEFUN([TEST3],
  38. [REQUIRE_AND_CHECK([TEST2a])
  39. test3=set])
  40. AS@&t@_INIT
  41. TEST1
  42. test -z "$test1" &&
  43. AC_MSG_ERROR([\$test1 is empty])
  44. AS_EXIT(0)
  45. ]])
  46. AT_CHECK_AUTOCONF
  47. AT_CHECK_CONFIGURE
  48. AT_CLEANUP
  49. ## --------------------------- ##
  50. ## AC_REQUIRE: error message. ##
  51. ## --------------------------- ##
  52. # Check that the message mentions AC_DEFUN, not m4_defun.
  53. AT_SETUP([AC_REQUIRE: error message])
  54. AT_KEYWORDS([m4@&t@_require])
  55. AT_DATA([configure.ac],
  56. [[AC_REQUIRE([AC_PROG_CC])
  57. ]])
  58. AT_CHECK_AUTOCONF([], [1], [],
  59. [[configure.ac:1: error: AC_REQUIRE(AC_PROG_CC): cannot be used outside of an AC_DEFUN'd macro
  60. configure.ac:1: the top level
  61. autom4te: m4 failed with exit status: 1
  62. ]])
  63. AT_CLEANUP
  64. ## ----------------------------------------------- ##
  65. ## AC_REQUIRE and AC_DEFUN_ONCE: Require, expand. ##
  66. ## ----------------------------------------------- ##
  67. AT_SETUP([AC_REQUIRE & AC_DEFUN_ONCE: [Require, expand]])
  68. AT_KEYWORDS([m4@&t@_require m4@&t@_require_once])
  69. AT_DATA([configure.ac],
  70. [[AC_DEFUN([TEST],
  71. [AC_REQUIRE([MULTI_TEST])
  72. AC_REQUIRE([SINGLE_TEST])])
  73. AC_DEFUN([MULTI_TEST],
  74. [multi_test=".$multi_test"])
  75. AC_DEFUN_ONCE([SINGLE_TEST],
  76. [single_test=".$single_test"])
  77. AS@&t@_INIT
  78. TEST
  79. TEST
  80. MULTI_TEST
  81. MULTI_TEST
  82. SINGLE_TEST
  83. SINGLE_TEST
  84. case $multi_test:$single_test in
  85. ...:. ) AS_EXIT(0);;
  86. ...:* ) AC_MSG_ERROR([DEFUN_ONCE is broken]);;
  87. *:. ) AC_MSG_ERROR([DEFUN is broken (Wow, congrats!)]);;
  88. esac
  89. ]])
  90. AT_CHECK_AUTOCONF([], 0, [])
  91. AT_CHECK_CONFIGURE
  92. AT_CLEANUP
  93. ## ----------------------------------------------- ##
  94. ## AC_REQUIRE and AC_DEFUN_ONCE: Expand, require. ##
  95. ## ----------------------------------------------- ##
  96. AT_SETUP([AC_REQUIRE & AC_DEFUN_ONCE: [Expand, require]])
  97. AT_KEYWORDS([m4@&t@_require m4@&t@_require_once])
  98. AT_DATA([configure.ac],
  99. [[AC_DEFUN([TEST],
  100. [AC_REQUIRE([MULTI_TEST])
  101. AC_REQUIRE([SINGLE_TEST])])
  102. AC_DEFUN([MULTI_TEST],
  103. [multi_test=".$multi_test"])
  104. AC_DEFUN_ONCE([SINGLE_TEST],
  105. [single_test=".$single_test"])
  106. AS@&t@_INIT
  107. MULTI_TEST
  108. MULTI_TEST
  109. SINGLE_TEST
  110. SINGLE_TEST
  111. TEST
  112. TEST
  113. case $multi_test:$single_test in
  114. ..:. ) AS_EXIT(0);;
  115. ..:* ) AC_MSG_ERROR([DEFUN_ONCE is broken]);;
  116. *:. ) AC_MSG_ERROR([DEFUN is broken (Wow, congrats!)]);;
  117. * ) AC_MSG_ERROR([received `$multi_test:$single_test']);;
  118. esac
  119. ]])
  120. AT_CHECK_AUTOCONF([], 0, [])
  121. AT_CHECK_CONFIGURE
  122. AT_CLEANUP
  123. ## ------------------------- ##
  124. ## AC_REQUIRE & AC_PROVIDE. ##
  125. ## ------------------------- ##
  126. AT_SETUP([AC_REQUIRE & AC_PROVIDE])
  127. AT_KEYWORDS([m4@&t@_require])
  128. AT_DATA([configure.ac],
  129. [[AC_DEFUN([TEST],
  130. [AC_REQUIRE([INNER_TEST])])
  131. AC_DEFUN([INNER_TEST],
  132. [inner_test=".$inner_test"])
  133. AS@&t@_INIT
  134. AC_PROVIDE([INNER_TEST])
  135. TEST
  136. case $inner_test in
  137. "" ) AS_EXIT(0);;
  138. * ) AC_MSG_ERROR([received `$inner_test']);;
  139. esac
  140. ]])
  141. AT_CHECK_AUTOCONF
  142. AT_CHECK_CONFIGURE
  143. AT_CLEANUP
  144. ## -------- ##
  145. ## AC_INIT. ##
  146. ## -------- ##
  147. # Make sure AC_INIT sets PACKAGE_TARNAME properly.
  148. AT_SETUP([AC_INIT])
  149. AT_DATA([configure.ac],
  150. [[AC_INIT([GNU fu], [1.0], [bug-fu@gnu.org])
  151. ]])
  152. AT_CHECK_AUTOCONF
  153. AT_CHECK_CONFIGURE([-q])
  154. # Ensure we get the expected definition:
  155. AT_CHECK([grep "^PACKAGE_TARNAME='fu'\$" configure], [], [ignore])
  156. AT_CLEANUP
  157. ## ------------------------------------- ##
  158. ## AC_INIT with unusual version strings. ##
  159. ## ------------------------------------- ##
  160. AT_SETUP([AC_INIT with unusual version strings])
  161. AT_DATA([configure.ac],
  162. [[AC_INIT([GNU String++ with spaces (foo)],
  163. [2.48++ (2010-07-03)], [[http://example.com/?a=b&c=d#e]], [clisp])
  164. AC_OUTPUT
  165. ]])
  166. if echo 'ab*c' | grep -F 'ab*c' >/dev/null 2>&1; then
  167. FGREP="grep -F"
  168. else
  169. FGREP=fgrep
  170. fi
  171. AT_CHECK_AUTOCONF([-Werror])
  172. AT_CHECK_CONFIGURE([-q])
  173. AT_CHECK_CONFIGURE([--help], [], [stdout])
  174. AT_CHECK([[$FGREP 'com/?a=b&c=d#e' stdout]], [], [ignore])
  175. AT_CHECK_CONFIGURE([--version], [], [stdout])
  176. AT_CHECK([$FGREP 'GNU String++ with spaces (foo)' stdout], [], [ignore])
  177. AT_CHECK([$FGREP '2.48++ (2010-07-03)' stdout], [], [ignore])
  178. AT_CHECK([./config.status --help], [], [stdout])
  179. AT_CHECK([[$FGREP 'com/?a=b&c=d#e' stdout]], [], [ignore])
  180. AT_CHECK([./config.status --version], [], [stdout])
  181. AT_CHECK([$FGREP 'GNU String++ with spaces (foo)' stdout], [], [ignore])
  182. AT_CHECK([$FGREP '2.48++ (2010-07-03)' stdout], [], [ignore])
  183. AT_DATA([configure.ac],
  184. [[AC_INIT([GNU "String++"],
  185. [2.48], [http://example.com/], [clisp])
  186. AC_OUTPUT
  187. ]])
  188. AT_CHECK_AUTOCONF([-Werror], [1], [ignore], [stderr])
  189. AT_CHECK([grep 'AC_INIT: not a literal: ' stderr], [], [ignore])
  190. AT_DATA([configure.ac],
  191. [[AC_INIT([GNU String++],
  192. ['codename' 2.48], [http://example.com/], [clisp])
  193. AC_OUTPUT
  194. ]])
  195. AT_CHECK_AUTOCONF([-Werror], [1], [ignore], [stderr])
  196. AT_CHECK([grep 'AC_INIT: not a literal: ' stderr], [], [ignore])
  197. AT_DATA([configure.ac],
  198. [[AC_INIT([GNU
  199. String++], [2.48], [http://example.com/], [clisp])
  200. AC_OUTPUT
  201. ]])
  202. AT_CHECK_AUTOCONF([-Werror], [1], [ignore], [stderr])
  203. AT_CHECK([grep 'AC_INIT: not a literal: ' stderr], [], [ignore])
  204. AT_CLEANUP
  205. ## -------------- ##
  206. ## AC_COPYRIGHT. ##
  207. ## -------------- ##
  208. # Ensure the FSF notice as well as the user-provided one are present
  209. # in the head of the testsuite as well as the --version output.
  210. AT_SETUP([AC@&t@_COPYRIGHT])
  211. AT_DATA([configure.ac],
  212. [[AC_INIT([GNU fu], [1.0])
  213. AC_COPYRIGHT([[This is just a test notice, not a real one, so let's avoid
  214. words that may be matched by scanners for legal things,
  215. causing extra work for distributors.
  216. Multi-line values should be supported.
  217. ]])
  218. ]])
  219. AT_CHECK_AUTOCONF
  220. AT_CHECK_CONFIGURE([--version], [], [stdout])
  221. AT_CHECK([grep 'Copyright.*Free Software Foundation' stdout], [], [ignore])
  222. AT_CHECK([grep 'This is just a test notice' stdout], [], [ignore])
  223. AT_CHECK([sed -ne 50q -e '/Copyright/{' -e N -e N -e N -e N -e 's/#//g' ]dnl
  224. [ -e 's/\n//g' -e p -e '}' configure ]dnl
  225. [ | grep 'Copyright.*Free Software Foundation'],
  226. [], [ignore])
  227. AT_CHECK([sed 50q configure | grep 'This is just a test notice'], [], [ignore])
  228. AT_CLEANUP
  229. ## ---------------- ##
  230. ## AC_CACHE_CHECK. ##
  231. ## ---------------- ##
  232. # Make sure AC_CACHE_CHECK is silent with -q.
  233. # Also make sure we warn about cache id's not named with `_cv_'.
  234. AT_SETUP([AC_CACHE_CHECK])
  235. AT_KEYWORDS([CONFIG_SITE])
  236. # Don't let a config.site file affect this test.
  237. AS_UNSET([CONFIG_SITE])
  238. AT_DATA([configure.ac],
  239. [[AC_INIT
  240. # m4_define([ac_nothing], [ac_cv_absolutely_nothing])
  241. AC_CACHE_CHECK([for nothing],
  242. [ac_nothing],
  243. [ac_nothing=found])
  244. AC_MSG_CHECKING([for some other variable])
  245. commands_to_set_it_was_run=false
  246. AC_CACHE_VAL([my_cv_variable], [
  247. # FOO
  248. commands_to_set_it_was_run=true
  249. my_cv_variable=true
  250. ])
  251. AC_MSG_RESULT([$my_cv_variable])
  252. # Ensure that the result is available at this point.
  253. if test ${my_cv_variable+set} != set; then
  254. AC_MSG_ERROR([AC@&@&t@t@_CACHE_VAL did not ensure that the cache variable was set])
  255. fi
  256. # AC_CACHE_SAVE should be enough here, no need for AC_OUTPUT.
  257. AC_CACHE_SAVE
  258. ]])
  259. AT_CHECK_AUTOCONF([], [], [], [stderr])
  260. AT_CHECK([grep 'must contain _cv_ to be cached' stderr], [], [ignore])
  261. # Do not warn about defines:
  262. sed 's/^# m4_define/m4_define/' configure.ac > t
  263. mv -f t configure.ac
  264. AT_CHECK_AUTOCONF
  265. AT_CHECK_CONFIGURE([-q])
  266. sed '/m4_define/d; s/ac_nothing/ac_cv_nothing/' configure.ac > t
  267. mv -f t configure.ac
  268. AT_CHECK_AUTOCONF
  269. AT_CHECK_CONFIGURE([-q])
  270. # Print a message saying that the result was cached, iff it was cached.
  271. AT_CHECK_CONFIGURE([], [], [stdout])
  272. AT_CHECK([grep 'cached' stdout], [1])
  273. AT_CHECK_CONFIGURE([my_cv_variable='yes it is set'], [], [stdout])
  274. AT_CHECK([grep 'cached.*yes it is set' stdout], [], [ignore])
  275. # --cache-file is honored and has caching semantics.
  276. AT_CHECK_CONFIGURE([--cache-file=foobar.cache], [], [stdout])
  277. AT_CHECK([grep 'cached' stdout], [1])
  278. AT_CHECK([test ! -f config.cache])
  279. AT_CHECK([grep 'my_cv_variable.*true' foobar.cache], [], [ignore])
  280. AT_CHECK_CONFIGURE([--cache-file=foobar.cache], [], [stdout])
  281. AT_CHECK([grep 'some other variable.*cached.*true' stdout], [], [ignore])
  282. # A setting on the command line overrides the cache.
  283. AT_CHECK_CONFIGURE([--cache-file=foobar.cache my_cv_variable='override'], [], [stdout])
  284. AT_CHECK([grep 'cached.*override' stdout], [], [ignore])
  285. AT_CHECK([grep 'my_cv_variable.*override' foobar.cache], [], [ignore])
  286. # Values containing braces need special internal treatment.
  287. AT_CHECK_CONFIGURE([-C ac_cv_nothing='{' my_cv_variable='contains } brace'],
  288. [], [stdout])
  289. AT_CHECK([grep 'ac_cv_nothing.*{' config.cache], [], [ignore])
  290. AT_CHECK([grep 'my_cv_variable.*contains } brace' config.cache], [], [ignore])
  291. AT_CHECK_CONFIGURE([-C], [], [stdout])
  292. AT_CHECK([grep 'nothing.*{' stdout], [], [ignore])
  293. AT_CHECK([grep 'some other variable.*contains } brace' stdout], [], [ignore])
  294. rm -f config.cache
  295. # Diagnose common side-effects that are errors in COMMANDS-TO-SET-IT:
  296. sed 's/^# FOO/AC_DEFINE([some-define], [1], [oooh.])/' configure.ac > t
  297. mv -f t configure.ac
  298. AT_CHECK_AUTOCONF([], [], [], [stderr])
  299. AT_CHECK([grep 'suspicious.*AC_DEFINE' stderr], [], [ignore])
  300. sed 's/^AC_DEFINE.*/AC_SUBST([some_substitution], [oooh.])/' configure.ac > t
  301. mv -f t configure.ac
  302. AT_CHECK_AUTOCONF([], [], [], [stderr])
  303. AT_CHECK([grep 'suspicious.*AC_SUBST' stderr], [], [ignore])
  304. # Ensure the examples from the manual work as intended.
  305. # Taken from autoconf.texi:Caching Results
  306. AT_DATA([configure.ac],
  307. [[AC_INIT
  308. AC_DEFUN([AC_SHELL_TRUE],
  309. [AC_CACHE_CHECK([whether true(1) works], [my_cv_shell_true_works],
  310. [my_cv_shell_true_works=no
  311. (true) 2>/dev/null && my_cv_shell_true_works=yes
  312. if test "x$my_cv_shell_true_works" = xyes; then
  313. AC_DEFINE([TRUE_WORKS], [1],
  314. [Define if `true(1)' works properly.])
  315. fi])
  316. ])
  317. AC_SHELL_TRUE
  318. ]])
  319. AT_CHECK_AUTOCONF([-Werror], [1], [], [stderr])
  320. AT_CHECK([grep 'suspicious.*AC_DEFINE' stderr], [], [ignore])
  321. # Taken from autoconf.texi:Caching Results
  322. AT_DATA([configure.ac],
  323. [[AC_INIT
  324. AC_DEFUN([AC_SHELL_TRUE],
  325. [AC_CACHE_CHECK([whether true(1) works], [my_cv_shell_true_works],
  326. [my_cv_shell_true_works=no
  327. (true) 2>/dev/null && my_cv_shell_true_works=yes])
  328. if test "x$my_cv_shell_true_works" = xyes; then
  329. AC_DEFINE([TRUE_WORKS], [1],
  330. [Define if `true(1)' works properly.])
  331. fi
  332. ])
  333. AC_SHELL_TRUE
  334. AC_OUTPUT
  335. ]])
  336. AT_CHECK_AUTOCONF([-Werror])
  337. AT_CHECK_CONFIGURE([-C], [], [stdout])
  338. AT_CHECK([grep my_cv_shell_true_works config.cache], [], [ignore])
  339. AT_CHECK([grep 'true.*works.*yes' stdout], [], [ignore])
  340. AT_CHECK_CONFIGURE([--config-cache], [], [stdout])
  341. AT_CHECK([grep 'true.*works.*cached.*yes' stdout], [], [ignore])
  342. # config.status only pays attention to the cache file with --recheck.
  343. AT_CHECK([./config.status], [], [stdout])
  344. AT_CHECK([grep cache stdout], [1])
  345. AT_CHECK([./config.status --recheck], [], [stdout])
  346. AT_CHECK([grep cache stdout], [0], [ignore])
  347. # By default, configure uses no cache file, neither loading nor updating it.
  348. : > a-stamp-file
  349. AT_CHECK_CONFIGURE([], [], [stdout])
  350. AT_CHECK([grep cache stdout], [1])
  351. AT_CHECK([LC_ALL=C ls -t config.cache a-stamp-file | sed 1q | grep config.cache], [1])
  352. # Using a symlinked cache file works.
  353. : > cache
  354. rm -f config.cache
  355. AS_LN_S([cache], [config.cache])
  356. AT_CHECK_CONFIGURE([-C])
  357. # Either the system does not support symlinks, or the symlinked-to file
  358. # should be updated.
  359. AT_CHECK([test -s cache || test ! -h config.cache])
  360. # config.site can specify a site-wide cache, accumulating information.
  361. # Also test that we don't run afoul of sourcing a file with leading -.
  362. AT_DATA([-config.site],
  363. [[cache_file=sitecache
  364. ]])
  365. AT_DATA([sitecache],
  366. [[my_cv_some_preset_cache_var=yes
  367. ]])
  368. CONFIG_SITE=-config.site
  369. export CONFIG_SITE
  370. AT_CHECK_CONFIGURE
  371. AT_CHECK([grep my_cv_some_preset_cache_var sitecache], [], [ignore])
  372. AT_CHECK([grep my_cv_shell_true_works sitecache], [], [ignore])
  373. AT_CHECK_CONFIGURE([], [], [stdout])
  374. AT_CHECK([grep 'whether true.*works.*cached' stdout], [], [ignore])
  375. dnl Until we can find a way to avoid catastrophic failure,
  376. dnl skip the rest of this test on such shells.
  377. echo 'if' > syntax
  378. AT_CHECK([${CONFIG_SHELL-$SHELL} -c 'case `. ./syntax; echo $?` in
  379. 0|"") exit 77;; esac'], [0], [ignore], [ignore])
  380. # Check that config cache scripts must be well-formed.
  381. AT_DATA([bad.site],
  382. [[fi
  383. ]])
  384. CONFIG_SITE=$PWD/bad.site
  385. AT_CHECK_CONFIGURE([ || exit 1], [1], [stdout], [stderr])
  386. AT_CHECK([grep 'failed to load site script' stderr], [], [ignore], [ignore],
  387. [AT_CHECK([grep 'whether true' stdout], [1])])
  388. # However, a missing file is ignored.
  389. CONFIG_SITE=./no-such-file
  390. AT_CHECK_CONFIGURE
  391. AT_CLEANUP
  392. ## --------------- ##
  393. ## AC_CACHE_LOAD. ##
  394. ## --------------- ##
  395. # Test AC_CACHE_LOAD.
  396. AT_SETUP([AC_CACHE_LOAD])
  397. AT_DATA([configure.ac],
  398. [[AC_INIT
  399. $some_test_code
  400. AC_CACHE_LOAD
  401. AC_MSG_NOTICE([some_cv_variable is $some_cv_variable])
  402. AC_OUTPUT
  403. ]])
  404. AT_CHECK_AUTOCONF
  405. AS_UNSET([some_test_code])
  406. AT_DATA([new-cache],
  407. [[some_cv_variable=value-from-new-cache
  408. ]])
  409. AT_CHECK_CONFIGURE([some_test_code='eval cache_file=new-cache'], [], [stdout])
  410. AT_CHECK([grep 'some_cv_variable.*value-from-new-cache' stdout], [], [ignore])
  411. AT_CLEANUP
  412. ## ---------------- ##
  413. ## AC_COMPUTE_INT. ##
  414. ## ---------------- ##
  415. # Make sure AC_COMPUTE_INT fails properly.
  416. AT_SETUP([AC_COMPUTE_INT])
  417. AT_DATA([configure.ac],
  418. [[AC_INIT
  419. AC_COMPUTE_INT([invalid_expression],
  420. [**0**],
  421. [],
  422. [invalid_expression=failed])
  423. test "$invalid_expression" = failed ||
  424. AC_MSG_ERROR([**0** evaluated to $invalid_expression instead of failing])
  425. ]])
  426. AT_CHECK_AUTOCONF
  427. AT_CHECK_CONFIGURE
  428. AT_CLEANUP
  429. ## ---------------- ##
  430. ## AC_TRY_COMMAND. ##
  431. ## ---------------- ##
  432. AT_SETUP([AC_TRY_COMMAND])
  433. AT_DATA([configure.ac],
  434. [[AC_INIT
  435. if AC_TRY_COMMAND([(echo "The Cat in the Hat";
  436. echo "The Hat in the Cat" >&2) |
  437. grep \^The\ Cat\ in\ the\ Hat\$ >/dev/null]); then
  438. :
  439. else
  440. AC_MSG_ERROR([didn't see the Cat in the Hat])
  441. fi
  442. if AC_TRY_COMMAND([(echo "The Cat in the Hat";
  443. echo "The Hat in the Cat" >&2) |
  444. grep \^The\ Hat\ in\ the\ Cat\$ >/dev/null]); then
  445. AC_MSG_ERROR([saw the Hat in the Cat])
  446. fi
  447. ]])
  448. AT_CHECK_AUTOCONF
  449. AT_CHECK_CONFIGURE([-q])
  450. AT_CLEANUP
  451. ## ------------ ##
  452. ## Input/Output ##
  453. ## ------------ ##
  454. AT_SETUP([Input/Output])
  455. AT_DATA([configure.ac],
  456. [[AC_INIT
  457. cat <&AS@&t@_ORIGINAL_STDIN_FD >&AS@&t@_MESSAGE_FD
  458. ]])
  459. AT_CHECK_AUTOCONF
  460. AT_CHECK([echo Hello | CONFIG_SITE=/dev/null ./configure $configure_options | grep -v 'configure: loading site script '],, [Hello
  461. ])
  462. AT_CHECK([echo Hello | CONFIG_SITE=/dev/null ./configure $configure_options --silent])
  463. AT_CLEANUP
  464. ## ------------------- ##
  465. ## configure arguments ##
  466. ## ------------------- ##
  467. AT_SETUP([configure arguments])
  468. AT_DATA([configure.ac],
  469. [[AC_INIT
  470. echo "$@"
  471. ]])
  472. AT_CHECK_AUTOCONF
  473. AT_CHECK_CONFIGURE([FOO=bar --enable-baz --without-zork --silent], [0], [stdout], [ignore])
  474. AT_CHECK([grep 'FOO=bar --enable-baz --without-zork --silent' stdout], [0], [ignore], [ignore])
  475. dnl check that syntax error is detected
  476. AT_CHECK_CONFIGURE([=], [1], [], [ignore], [ignore])
  477. AT_CHECK_CONFIGURE([1=2], [1], [], [ignore], [ignore])
  478. AT_CLEANUP
  479. ## ------------------------------ ##
  480. ## AC_ARG_ENABLE and AC_ARG_WITH. ##
  481. ## ------------------------------ ##
  482. AT_SETUP([AC_ARG_ENABLE and AC_ARG_WITH])
  483. AT_DATA_M4SH([configure.ac],
  484. [[AC_INIT
  485. # Taken from autoconf.texi:Pretty Help Strings.
  486. AC_ARG_WITH([foo],
  487. [AS_HELP_STRING([--with-foo],
  488. [use foo (default is no)])],
  489. [use_foo=$withval],
  490. [use_foo=no])
  491. AC_ARG_WITH([c++],
  492. [AS_HELP_STRING([--with-c++],
  493. [with c++])],
  494. [choice_with=$withval])
  495. AC_ARG_ENABLE([c++],
  496. [AS_HELP_STRING([--enable-c++],
  497. [enable c++])],
  498. [choice_enable=$enableval])
  499. echo "use_foo: $use_foo"
  500. echo "with_c++: $with_c__, $choice_with"
  501. echo "enable_c++: $enable_c__, $choice_enable"
  502. ]])
  503. AT_CHECK_AUTOCONF
  504. AT_CHECK_CONFIGURE([--help | grep foo], [0],
  505. [[ --with-foo use foo (default is no)
  506. ]], [ignore])
  507. AT_CHECK_CONFIGURE([--with-foo=yes --with-c++ --disable-c++],
  508. [], [stdout], [ignore])
  509. AT_CHECK([grep 'use_foo: yes' stdout], [], [ignore])
  510. AT_CHECK([grep 'with_c++: yes, yes' stdout], [], [ignore])
  511. AT_CHECK([grep 'enable_c++: no, no' stdout], [], [ignore])
  512. AT_CHECK([grep 'unrecognized option' stdout], [1])
  513. AT_CHECK_CONFIGURE([--without-foo --with-c++=no --enable-c++=maybe],
  514. [], [stdout], [ignore])
  515. AT_CHECK([grep 'use_foo: no' stdout], [], [ignore])
  516. AT_CHECK([grep 'with_c++: no, no' stdout], [], [ignore])
  517. AT_CHECK([grep 'enable_c++: maybe, maybe' stdout], [], [ignore])
  518. AT_CHECK([grep 'unrecognized option' stdout], [1])
  519. AT_CHECK_CONFIGURE([], [], [stdout], [ignore])
  520. AT_CHECK([grep 'use_foo: no' stdout], [], [ignore])
  521. AT_CHECK([grep 'with_c++: , $' stdout], [], [ignore])
  522. AT_CHECK([grep 'enable_c++: , $' stdout], [], [ignore])
  523. AT_CHECK([grep 'unrecognized option' stdout], [1])
  524. AT_CLEANUP
  525. ## --------------------- ##
  526. ## configure directories ##
  527. ## --------------------- ##
  528. AT_SETUP([configure directories])
  529. AT_DATA([foo.in],
  530. [[prefix=@prefix@
  531. exec_prefix=@exec_prefix@
  532. libdir=@libdir@
  533. ]])
  534. AT_DATA([configure.ac],
  535. [[AC_INIT
  536. AC_CONFIG_FILES([foo])
  537. AC_OUTPUT
  538. ]])
  539. AT_CHECK_AUTOCONF
  540. dnl check that relative paths are rejected
  541. AT_CHECK_CONFIGURE([--libdir=.], [1], [ignore], [stderr])
  542. AT_CHECK([grep 'expected an absolute directory name for --libdir: \.' stderr],
  543. [0], [ignore])
  544. dnl check that extra slashes are stripped, and that defaults are not expanded
  545. AT_CHECK_CONFIGURE([--prefix=/usr//])
  546. AT_CHECK([cat foo], [0], [[prefix=/usr
  547. exec_prefix=${prefix}
  548. libdir=${exec_prefix}/lib
  549. ]])
  550. AT_CLEANUP