torture.at 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835
  1. # -*- Autotest -*-
  2. # Copyright (C) 2000-2012 Free Software Foundation, Inc.
  3. # This program is free software: you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation, either version 3 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. AT_BANNER([[Testing config.status.]])
  16. ## ---------------------------------------- ##
  17. ## AC_CONFIG_COMMANDS with empty commands. ##
  18. ## ---------------------------------------- ##
  19. AT_CHECK_MACRO([AC_CONFIG_COMMANDS with empty commands],
  20. [[AC_CONFIG_COMMANDS([foo], [], [:])
  21. ]])
  22. ## --------------------------------------------- ##
  23. ## AC_CONFIG_COMMANDS with temporary directory. ##
  24. ## --------------------------------------------- ##
  25. AT_CHECK_MACRO([AC_CONFIG_COMMANDS with temporary directory],
  26. [[AC_CONFIG_COMMANDS([foo], [
  27. case $ACTION in
  28. use)
  29. echo "$tmp" > tmpdir
  30. test -d "$tmp" || AC_MSG_ERROR([No $tmp directory])
  31. echo garbage-in > "$tmp/garbage-out"
  32. ;;
  33. corrupt)
  34. echo "$tmp" > tmpdir
  35. tmp=./nosuch
  36. ;;
  37. *) ;;
  38. esac
  39. ])
  40. ]], [
  41. AT_CHECK([test ! -f tmpdir])
  42. AT_CHECK([ACTION=use ./config.status], [], [ignore])
  43. AT_CHECK([test -s tmpdir && test ! -d "`cat tmpdir`"])
  44. AT_CHECK([ACTION=corrupt ./config.status], [], [ignore])
  45. AT_CHECK([test -s tmpdir && test ! -d "`cat tmpdir`"])
  46. ])
  47. ## -------------------------- ##
  48. ## Multiple AC_CONFIG_FILES. ##
  49. ## -------------------------- ##
  50. AT_SETUP([Multiple AC_CONFIG_FILES])
  51. AT_CONFIGURE_AC([[AC_CONFIG_FILES([foo foo])]])
  52. AT_CHECK_AUTOCONF([], 1, [], [ignore])
  53. AT_CLEANUP
  54. ## ------------------------------- ##
  55. ## parameterized AC_CONFIG_FILES. ##
  56. ## ------------------------------- ##
  57. AT_SETUP([Parameterized AC_CONFIG_FILES])
  58. AT_CONFIGURE_AC([[
  59. files="foo
  60. bar"
  61. AC_CONFIG_FILES([$files])]])
  62. AT_CHECK_AUTOCONF([], [], [], [ignore])
  63. touch foo.in bar.in config.hin
  64. AT_CHECK_CONFIGURE
  65. AT_CLEANUP
  66. ## ------------ ##
  67. ## AC_ARG_VAR. ##
  68. ## ------------ ##
  69. # AT_CHECK_AC_ARG_VAR(FIRST-VALUE, SECOND-VALUE, [STATUS = 1])
  70. # ------------------------------------------------------------
  71. # Check that AC_ARG_VAR caches the latest values, diagnoses
  72. # inconsistencies, and arms config.status. Check that recheck
  73. # returns STATUS, save configure output in files 'stdout' and 'stderr'
  74. # for further inspection.
  75. m4_define([AT_CHECK_AC_ARG_VAR],
  76. [rm -f config.cache
  77. # Initial value.
  78. m4_ifval([$1],
  79. [precious='m4_bpatsubst([$1], [[']], ['\\''])'; export precious],
  80. [unset precious])
  81. AT_CHECK_CONFIGURE([--config-cache -q])
  82. AT_CHECK([cat file], [], [`$1'
  83. ])
  84. # Testing --recheck: 1. have the environment `forget' about PRECIOUS.
  85. unset precious
  86. # 2. Rerun config.status to recreate `file'.
  87. AT_CHECK([./config.status --recheck], [], [ignore])
  88. AT_CHECK([./config.status], [], [ignore])
  89. # 3. Check that file contains the old value of PRECIOUS.
  90. AT_CHECK([cat file], [], [`$1'
  91. ])
  92. # Second value: we should issue an error here: the value
  93. # has changed!
  94. m4_ifval([$2],
  95. [precious='$2'; export precious],
  96. [unset precious])
  97. AT_CHECK_CONFIGURE([--config-cache], [m4_default([$3], [1])], [stdout], [stderr])
  98. ])# AT_CHECK_AC_ARG_VAR
  99. AT_SETUP([AC_ARG_VAR])
  100. # We don't want to run this test if this shell doesn't support
  101. # `unset'.
  102. AT_CHECK([
  103. if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
  104. exit 0
  105. else
  106. exit 77
  107. fi
  108. ])
  109. AT_DATA([configure.ac],
  110. [[AC_INIT
  111. AC_ARG_VAR([precious], [this variable costs a lot])
  112. echo "precious:$precious"
  113. AC_OUTPUT(file)
  114. ]])
  115. AT_DATA([file.in],
  116. [[`@precious@'
  117. ]])
  118. AT_CHECK_AUTOCONF
  119. # Set a precious variable
  120. AT_CHECK_AC_ARG_VAR([], [apple of my eye])
  121. # Unset a precious variable
  122. AT_CHECK_AC_ARG_VAR([apple of my eye], [])
  123. # Change a precious variable
  124. AT_CHECK_AC_ARG_VAR([apple of my eye], [orange of my eye])
  125. # Change a precious variable that contains braces
  126. AT_CHECK_AC_ARG_VAR([apple of my {eye}], [orange of my eye])
  127. # Change a precious variable that contains all kinds of fun
  128. AT_CHECK_AC_ARG_VAR(['p r ec"iou$], [orange of my eye])
  129. dnl restore font-lock: "
  130. # Warn (but do not fail) about a whitespace-only change
  131. AT_CHECK_AC_ARG_VAR([ apple of my eye ], [apple of my eye],
  132. [0], ["has whitespace changes"])
  133. mv stdout configure-output
  134. AT_CHECK([grep "ignoring whitespace changes" stderr], [], [ignore])
  135. AT_CHECK([grep "precious: apple" configure-output], [], [ignore])
  136. AT_CLEANUP
  137. ## ---------------------------------------------- ##
  138. ## AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS. ##
  139. ## ---------------------------------------------- ##
  140. AT_SETUP([[AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS]])
  141. AT_DATA([configure.ac],
  142. [[AC_INIT
  143. AC_PROG_FGREP
  144. rm -f -r header var-header file var-file link var-link command var-command
  145. echo 'OK' >input
  146. # Be sure to also stress the associated INIT-CMDS.
  147. case $what_to_test in
  148. header)
  149. AC_CONFIG_HEADERS(header:input);;
  150. var-header)
  151. AC_CONFIG_HEADERS(var-header:$header_in, [], [header_in=input]);;
  152. file)
  153. AC_CONFIG_FILES(file:input);;
  154. var-file)
  155. AC_CONFIG_FILES(var-file:$file_in, [], [file_in=input]);;
  156. command)
  157. AC_CONFIG_COMMANDS(command,
  158. [cp input command]);;
  159. var-command)
  160. AC_CONFIG_COMMANDS(var-command,
  161. [cp $command_in var-command], [command_in=input]);;
  162. link)
  163. AC_CONFIG_LINKS(link:input);;
  164. var-link)
  165. AC_CONFIG_LINKS(var-link:$link_in, [], [link_in=input]);;
  166. esac
  167. AC_OUTPUT
  168. ]])
  169. AT_CHECK_AUTOCONF
  170. # AT_CHECK_CONFIG_CREATION(THING = (header | link | file | command))
  171. # ------------------------------------------------------------------
  172. # Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
  173. # are properly created, with the right content.
  174. # Use `grep OK' instead of a simple `cat' to avoid banners such as in
  175. # AC_CONFIG_HEADERS.
  176. m4_define([AT_CHECK_CONFIG_CREATION],
  177. [AT_CHECK_CONFIGURE([what_to_test=$1])
  178. AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
  179. [ignore], [$1
  180. ])
  181. AT_CHECK([grep OK $1], [], [OK
  182. ])
  183. AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
  184. # config.status might be stupidly expecting data on stdin, if it's
  185. # really broken...
  186. AT_CHECK([./config.status var-$1 </dev/null], [], [ignore])
  187. AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
  188. [ignore], [var-$1
  189. ])
  190. AT_CHECK([grep OK var-$1], [], [OK
  191. ])
  192. ])# AT_CHECK_CONFIG_CREATION
  193. # AT_CHECK_CONFIG_CREATION_NOWRITE(THING = (header | link | file | command))
  194. # --------------------------------------------------------------------------
  195. # Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
  196. # are properly created, with the right content.
  197. # Use `grep OK' instead of a simple `cat' to avoid banners such as in
  198. # AC_CONFIG_HEADERS.
  199. m4_define([AT_CHECK_CONFIG_CREATION_NOWRITE],
  200. [AT_CHECK_CONFIGURE([what_to_test=$1])
  201. AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
  202. [ignore], [$1
  203. ])
  204. AT_CHECK([grep OK $1], [], [OK
  205. ])
  206. AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
  207. # config.status might be stupidly expecting data on stdin, if it's
  208. # really broken...
  209. # Skip check if user can rename files into a read-only directory (when
  210. # run by root or on w32).
  211. touch t
  212. chmod a-w .
  213. mv t t1 >/dev/null 2>&1 \
  214. || AT_CHECK([./config.status var-$1 </dev/null || exit 1],
  215. [1], [ignore], [ignore])
  216. chmod u+w .
  217. rm -rf t t1
  218. ])# AT_CHECK_CONFIG_CREATION_NOWRITE
  219. # Create a file
  220. AT_CHECK_CONFIG_CREATION(file)
  221. # Create a header
  222. AT_CHECK_CONFIG_CREATION(header)
  223. # Execute a command
  224. AT_CHECK_CONFIG_CREATION(command)
  225. # Create a link
  226. AT_CHECK_CONFIG_CREATION(link)
  227. # Now check for write errors
  228. # Create a file
  229. AT_CHECK_CONFIG_CREATION_NOWRITE(file)
  230. # Create a file with bits from stdin
  231. AT_CHECK([echo from-stdin | ./config.status --file=file:-],
  232. [0], [ignore])
  233. AT_CHECK([grep from-stdin file], [], [from-stdin
  234. ])
  235. # Force write error creating a file on stdout
  236. if test -w /dev/full && test -c /dev/full; then
  237. AT_CHECK([./config.status --file=-:input </dev/null >/dev/full || exit 1],
  238. [1], [ignore], [ignore])
  239. fi
  240. # Validate that --file requires an argument
  241. AT_CHECK([./config.status --file], [1], [ignore], [stderr])
  242. AT_CHECK([grep 'missing file argument' stderr], [0], [ignore])
  243. AT_CHECK([./config.status --file=], [1], [ignore], [stderr])
  244. AT_CHECK([grep 'missing file argument' stderr], [0], [ignore])
  245. # Create a header
  246. AT_CHECK_CONFIG_CREATION_NOWRITE(header)
  247. # Create a header on stdout
  248. AT_CHECK([./config.status --header=-:input </dev/null],
  249. [0], [stdout], [ignore])
  250. AT_CHECK([grep OK stdout], [], [OK
  251. ])
  252. # Force write error creating a header on stdout
  253. if test -w /dev/full && test -c /dev/full; then
  254. AT_CHECK([./config.status --header=-:input </dev/null >/dev/full || exit 1],
  255. [1], [ignore], [ignore])
  256. fi
  257. # Execute a command
  258. AT_CHECK_CONFIG_CREATION_NOWRITE(command)
  259. # Create a link
  260. AT_CHECK_CONFIG_CREATION_NOWRITE(link)
  261. # Check that no use of `ac_write_fail' escaped into config.status
  262. AT_CHECK([grep ac_write_fail config.status], [1])
  263. # Check that --file and --header accept funny file names
  264. AT_DATA([fgrep.in],
  265. [[FGREP="@FGREP@"
  266. ]])
  267. ./config.status --file=fgrep:fgrep.in
  268. . ./fgrep
  269. x=
  270. export x
  271. for file in \
  272. 'with funny '\'' $x & #! name' \
  273. 'file with funny \ '\'' \'\'' $ & #!*? name' \
  274. 'with funny \ '\'' \'\'' " | <a >b & * ? name ' # "restore font-lock
  275. do
  276. # The function func_sanitize_file_name comes from tools.at
  277. file=`func_sanitize_file_name "$file"`
  278. cat >"$file.in" <<'END'
  279. @configure_input@
  280. END
  281. AT_CHECK([./config.status "--file=$file:$file.in"],
  282. [0], [ignore])
  283. AT_CHECK([$FGREP "$file" "$file"], [0], [ignore])
  284. AT_CHECK([./config.status "--header=$file:$file.in"],
  285. [0], [ignore])
  286. # Run the same test a 2nd time to see that config.status does not recreate
  287. # the header (regression test)
  288. AT_CHECK_UNQUOTED([./config.status "--header=$file:$file.in"],
  289. [0], [config.status: creating $file
  290. config.status: $file is unchanged
  291. ])
  292. AT_CHECK_UNQUOTED([grep ' & ' "$file"], [],
  293. [/* $file. Generated from $file.in by configure. */
  294. ])
  295. AT_CHECK([$FGREP "$file" "$file"], [0], [ignore])
  296. done
  297. AT_CLEANUP
  298. ## ---------------------------------------- ##
  299. ## Macro calls in AC_CONFIG_COMMANDS tags. ##
  300. ## ---------------------------------------- ##
  301. AT_SETUP([Macro calls in AC_CONFIG_COMMANDS tags])
  302. AT_DATA_M4SUGAR([configure.ac],
  303. [[AC_INIT
  304. AC_CONFIG_COMMANDS([m4_if(1,1,mytag)])
  305. AC_OUTPUT
  306. ]])
  307. AT_CHECK_AUTOCONF
  308. AT_CHECK_CONFIGURE
  309. AT_CLEANUP
  310. ## ------------------- ##
  311. ## Missing templates. ##
  312. ## ------------------- ##
  313. # Check that config.status detects missing input files
  314. AT_SETUP([Missing templates])
  315. AT_DATA([configure.ac],
  316. [[AC_INIT
  317. AC_CONFIG_FILES([nonexistent])
  318. AC_OUTPUT
  319. ]])
  320. AT_CHECK_AUTOCONF
  321. mkdir build
  322. AT_CAPTURE_FILE([build/config.log])[]dnl
  323. cd build
  324. AT_CHECK([../configure], [1], [ignore],
  325. [[config.status: error: cannot find input file: `nonexistent.in'
  326. ]])
  327. # Make sure that the output file doesn't exist
  328. AT_CHECK([test -f nonexistent], 1)
  329. cd ..
  330. AT_CHECK_CONFIGURE([], [1], [],
  331. [[config.status: error: cannot find input file: `nonexistent.in'
  332. ]])
  333. # Make sure that the output file doesn't exist
  334. AT_CHECK([test -f nonexistent], 1)
  335. AT_CLEANUP
  336. ## ---------------------- ##
  337. ## configure invocation. ##
  338. ## ---------------------- ##
  339. # Check that `configure' and `config.status' honor their interface.
  340. #
  341. # We run `./configure one=val1 --enable-two=val2 --with-three=val3'
  342. # and verify that (i) `configure' correctly receives the arguments,
  343. # (ii) correctly passes them to `config.status', which we check by
  344. # running `config.status --recheck', (iii) correctly passes them
  345. # to sub-configure scripts, and (iv) correctly reproduces them with
  346. # `config.status --config'.
  347. AT_SETUP([configure invocation])
  348. mkdir sub
  349. AT_DATA([configure.ac],
  350. [[AC_INIT
  351. AC_CONFIG_SUBDIRS([sub])
  352. echo "result=$one$enable_two$with_three"
  353. AC_OUTPUT
  354. ]])
  355. AT_DATA([sub/configure.ac],
  356. [[AC_INIT
  357. echo "result=$one$enable_two$with_three"
  358. AC_OUTPUT
  359. ]])
  360. echo fake install-sh script >install-sh
  361. AT_CHECK_AUTOCONF
  362. cd sub
  363. AT_CHECK_AUTOCONF
  364. cd ..
  365. AT_CHECK_CONFIGURE([one=one --enable-two=two --with-three=three |
  366. sed -n -e 's/^result=//p'], 0,
  367. [m4_do([onetwothree
  368. ], [onetwothree
  369. ])])
  370. AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
  371. [onetwothree
  372. ])
  373. AT_CHECK([args=`./config.status --config` && eval ./configure \$configure_options "$args" |
  374. sed -n -e 's/^result=//p'], 0,
  375. [m4_do([onetwothree
  376. ], [onetwothree
  377. ])])
  378. AT_CHECK_CONFIGURE([one="\"'$ " --enable-two="\" ' $" --with-three=" \"'$"|
  379. sed -n -e 's/^result=//p'], 0,
  380. [m4_do(["'$ " ' $ "'$
  381. ], ["'$ " ' $ "'$
  382. ])])
  383. AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
  384. ["'$ " ' $ "'$
  385. ])
  386. dnl restore font-lock: "
  387. AT_CHECK([args=`./config.status --config` && eval ./configure \$configure_options "$args" |
  388. sed -n -e 's/^result=//p'], 0,
  389. [m4_do(["'$ " ' $ "'$
  390. ], ["'$ " ' $ "'$
  391. ])])
  392. AT_CLEANUP
  393. ## -------------------------------------------- ##
  394. ## Check that `#define' templates are honored. ##
  395. ## -------------------------------------------- ##
  396. # Use various forms of `#define' templates, and make sure there are no
  397. # problems when a symbol is prefix of another.
  398. AT_SETUP([@%:@define header templates])
  399. AT_KEYWORDS([AC@&t@_DEFINE])
  400. AT_DATA([configure.ac],
  401. [[AC_INIT
  402. AC_CONFIG_HEADERS(config.h:config.hin)
  403. # I18n of dummy variables: their French translations.
  404. AC_DEFINE(foo, toto)
  405. AC_DEFINE(bar, tata)
  406. AC_DEFINE(baz, titi)
  407. AC_DEFINE(fubar, tutu)
  408. # Symbols which are prefixes of another.
  409. AC_DEFINE(a, A)
  410. AC_DEFINE(aaa, AAA)
  411. AC_DEFINE(aa, AA)
  412. # backslash-newline combinations
  413. AC_DEFINE([multiline], [line1\
  414. line2\
  415. line3 \
  416. line4])
  417. AC_DEFINE([multiline_args(ARG1, ARG2)], [ARG2 \
  418. ARG1])
  419. AC_CONFIG_FILES(defs)
  420. # underquoted #
  421. AC_DEFINE([paste(a,b)], [a##b])
  422. # Things included in confdefs.h, but which make no sense in
  423. # config.h, nor in $DEFS.
  424. cat <<\EOF >>confdefs.h
  425. /* Hi Mum! Look, I am doing C++! */
  426. #ifdef __cplusplus
  427. void exit (int status);
  428. #endif
  429. EOF
  430. # In addition of config.h output a full DEFS
  431. AC_OUTPUT_MAKE_DEFS
  432. DEFS_SAVED=$DEFS
  433. AC_SUBST(DEFS_SAVED)
  434. AC_OUTPUT
  435. ]])
  436. AT_DATA([defs.in],
  437. [[@DEFS_SAVED@
  438. ]])
  439. AT_DATA([config.hin],
  440. [[#define foo 0
  441. # define bar bar
  442. # define baz "Archimedes was sinking in his baz"
  443. # define fubar tutu
  444. #define a B
  445. #define aa BB
  446. # define aaa BBB
  447. #undef a
  448. # undef aa
  449. #undef aaa
  450. #define aaa(a, aa) aa a
  451. #define aaab
  452. #define aaac(a, aa) aa a
  453. #undef multiline
  454. # undef multiline_args
  455. #define paste(a,b) a##b
  456. /* an ugly one: */
  457. #define str(define) \
  458. #define
  459. #define stringify(arg) str(arg)
  460. #undef aaa /* with comments */
  461. #undef not_substed /* with comments */
  462. ]])
  463. AT_CHECK_AUTOCONF
  464. AT_CHECK_CONFIGURE
  465. AT_DATA([expout],
  466. [[/* config.h. Generated from config.hin by configure. */
  467. #define foo toto
  468. # define bar tata
  469. # define baz titi
  470. # define fubar tutu
  471. #define a A
  472. #define aa AA
  473. # define aaa AAA
  474. #define a A
  475. # define aa AA
  476. #define aaa AAA
  477. #define aaa AAA
  478. #define aaab
  479. #define aaac(a, aa) aa a
  480. #define multiline line1\
  481. line2\
  482. line3 \
  483. line4
  484. # define multiline_args(ARG1, ARG2) ARG2 \
  485. ARG1
  486. #define paste(a,b) a##b
  487. /* an ugly one: */
  488. #define str(define) \
  489. #define
  490. #define stringify(arg) str(arg)
  491. #define aaa AAA
  492. /* #undef not_substed */
  493. ]])
  494. AT_CHECK([cat config.h], 0, expout)
  495. # Check the value of DEFS.
  496. AT_DATA([expout],
  497. [[-DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -Dfoo=toto -Dbar=tata -Dbaz=titi -Dfubar=tutu -Da=A -Daaa=AAA -Daa=AA -Dmultiline=line1line2line3\ line4 -Dmultiline_args\(ARG1,\ ARG2\)=ARG2\ ARG1 -Dpaste\(a,b\)=a\#\#b
  498. ]])
  499. # Because we strip trailing spaces in `testsuite' we can't leave one in
  500. # expout, hence nuke the one left by AC_OUTPUT_MAKE_DEFS.
  501. AT_CHECK([sed -e 's/ $//' defs], 0, expout)
  502. AT_CLEANUP
  503. ## ------------------------- ##
  504. ## Torturing config.status. ##
  505. ## ------------------------- ##
  506. ## Require 100 AC_DEFINE and AC_SUBST and AC_SUBST_FILE with a significantly
  507. ## big value. This is mostly to check that Autoconf produces portable sed
  508. ## scripts in config.status. sed is used to skip the first two lines
  509. ## `Generated by ...'.
  510. # We use m4_for many times.
  511. m4_pattern_allow([^m4_for$])
  512. AT_SETUP([Torturing config.status])
  513. dnl The value used as a big value for AC_DEFINE.
  514. dnl Don't use sh active chars here, below it is also used in a sh
  515. dnl assignment.
  516. m4_define([AT_BIG_VALUE],
  517. [This value should be long enough to torture the various limits of sed and other tools used by Autoconf.])
  518. m4_define([AT_DESCRIPTION],
  519. [Define to a long string if your `Autoconf' works properly.])
  520. # AT_DUMMY_VAR(NUMBER)
  521. # --------------------
  522. # Build a name used for AC_SUBST and AC_DEFINE. Put ac_ in it
  523. # so that the check for user name space invasion does not complain
  524. # of the new variables defined.
  525. #
  526. # Note that you should not use the name ac_dummy, because it will be
  527. # turned into ac_uummy during the construction of config.status. Yes,
  528. # this is admittedly a bug, but it would be too hard to fix this.
  529. # There is really no point in AC_DEFINE a var named ac_d.*.
  530. m4_pattern_allow([^m4_bpatsubst$])
  531. m4_define([AT_DUMMY_VAR],
  532. [ac_Dummy_[]m4_bpatsubst([000$1], [.*\(...\)$], [\1])])
  533. AT_DATA([dummy.in],
  534. [m4_for([AT_Count], 1, 100, 1,
  535. [@AT_DUMMY_VAR(AT_Count)@
  536. @[f]AT_Count@
  537. ])])
  538. i=1
  539. while test $i != 101; do
  540. echo "content of file $i" > file_$i
  541. AS_VAR_ARITH([i], [$i + 1])
  542. done
  543. # ------------ #
  544. # configure.ac #
  545. # ------------ #
  546. m4_pattern_allow([^m4_(define|defun)$])
  547. AT_DATA([configure.ac],
  548. dnl The following lines transfer AT_DUMMY_VAR, AT_DESCRIPTION, and
  549. dnl AT_BIG_VALUE into the configure.ac as AC_DUMMY_VAR etc.
  550. [[m4_define([AC_DUMMY_VAR],]
  551. m4_dquote(m4_defn([AT_DUMMY_VAR]))[)]]
  552. [[m4_define([AC_DESCRIPTION],]
  553. m4_dquote(m4_defn([AT_DESCRIPTION]))[)]]
  554. [[m4_define([AC_BIG_VALUE],]
  555. m4_dquote(m4_defn([AT_BIG_VALUE]))[)]]
  556. [[# AC_DEFUBST(NAME)
  557. # ----------------
  558. # Related VALUE to NAME both with AC_SUBST and AC_DEFINE. This is
  559. # used in the torture tests.
  560. m4_defun([AC_DEFUBST],
  561. [AC_DUMMY_VAR($1)="AC_BIG_VALUE"
  562. AC_DEFINE_UNQUOTED(AC_DUMMY_VAR($1), "$AC_DUMMY_VAR($1) $AC_DUMMY_VAR($1)",
  563. AC_DESCRIPTION)
  564. AC_SUBST(AC_DUMMY_VAR($1))
  565. AC_SUBST_FILE([f]$1)
  566. f$1=file_$1
  567. ])
  568. AC_INIT
  569. AC_CONFIG_HEADERS(config.h:config.hin)
  570. AC_CONFIG_FILES(dummy)
  571. m4_for(AC_Count, 1, 100, 1,
  572. [AC_DEFUBST(AC_Count)])
  573. AC_PROG_AWK
  574. AC_OUTPUT
  575. ]])# configure.ac
  576. AT_CHECK_AUTOCONF
  577. AT_CHECK_AUTOHEADER
  578. # Check both awk and the result of AC_PROG_AWK.
  579. # Quote the first word in the for list for Solaris sh.
  580. for awk_arg in "FOO=" AWK=awk; do
  581. AT_CHECK_CONFIGURE([$awk_arg])
  582. # Checking that AC_DEFINE worked properly.
  583. AT_DATA([expout],
  584. [/* Define to the address where bug reports for this package should be sent. */
  585. #define PACKAGE_BUGREPORT ""
  586. /* Define to the full name of this package. */
  587. #define PACKAGE_NAME ""
  588. /* Define to the full name and version of this package. */
  589. #define PACKAGE_STRING ""
  590. /* Define to the one symbol short name of this package. */
  591. #define PACKAGE_TARNAME ""
  592. /* Define to the home page for this package. */
  593. #define PACKAGE_URL ""
  594. /* Define to the version of this package. */
  595. #define PACKAGE_VERSION ""
  596. m4_for(AT_Count, 1, 100, 1,
  597. [
  598. /* AT_DESCRIPTION */
  599. [#define] AT_DUMMY_VAR(AT_Count) "AT_BIG_VALUE AT_BIG_VALUE"
  600. ])])
  601. AT_CHECK([sed -n '4,$ p' config.h], 0, expout)
  602. # Checking that AC_SUBST worked properly.
  603. AT_DATA([expout],
  604. [m4_for(AT_Count, 1, 100, 1,
  605. [AT_BIG_VALUE
  606. content of file AT_Count
  607. ])])
  608. AT_CHECK([cat dummy], 0, expout)
  609. done
  610. AT_CLEANUP
  611. ## ------------------------------- ##
  612. ## Substitute a 2000-byte string. ##
  613. ## ------------------------------- ##
  614. # Solaris 9 /usr/ucb/sed that rejects commands longer than 4000 bytes. HP/UX
  615. # sed dumps core around 8 KiB. However, POSIX says that sed need not
  616. # handle lines longer than 2048 bytes (including the trailing newline).
  617. # So we'll just test a 2000-byte value, and for awk, we test a line with
  618. # almost 1000 words, and one variable with 5 lines of 2000 bytes each:
  619. # multi-line values should allow to get around the limitations.
  620. # We also test runs of around 148 backslashes: they need to be escaped,
  621. # and 148 is the portable limit for awk string literals. config.status
  622. # uses concatenation to generate longer strings.
  623. AT_SETUP([Substitute a 2000-byte string])
  624. AT_DATA([Foo.in], [@foo@
  625. ])
  626. AT_DATA([Bar.in], [@bar@
  627. ])
  628. AT_DATA([Baz.in], [@baz@
  629. ])
  630. AT_DATA([Boo.in], [@b147@
  631. @b148@
  632. @b149@
  633. @b295@
  634. @b296@
  635. @b297@
  636. ])
  637. AT_DATA([configure.ac],
  638. [[AC_INIT
  639. AC_SUBST([foo], ]m4_for([n], 1, 100,, ....................)[)
  640. AC_SUBST([bar], "]m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)[")
  641. baz="]m4_for([m], 1, 100,, ... ... ... ... ....)[
  642. "
  643. baz=$baz$baz$baz$baz$baz
  644. AC_SUBST([baz])
  645. b29='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
  646. b147=$b29$b29$b29$b29$b29'\\'
  647. b148=$b147'\'
  648. b149=$b148'\'
  649. b295=$b147$b147'\'
  650. b296=$b295'\'
  651. b297=$b296'\'
  652. AC_SUBST([b147])
  653. AC_SUBST([b148])
  654. AC_SUBST([b149])
  655. AC_SUBST([b295])
  656. AC_SUBST([b296])
  657. AC_SUBST([b297])
  658. AC_PROG_AWK
  659. AC_CONFIG_FILES([Foo Bar Baz Boo])
  660. AC_OUTPUT
  661. ]])
  662. cp "$abs_top_srcdir/build-aux/install-sh" .
  663. b29='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
  664. b147=$b29$b29$b29$b29$b29'\\'
  665. b295=$b147$b147'\'
  666. cat >Boo-exp <<EOF
  667. $b147
  668. $b147\\
  669. $b147\\\\
  670. $b295
  671. $b295\\
  672. $b295\\\\
  673. EOF
  674. AT_CHECK_AUTOCONF
  675. # Check both awk and the result of AC_PROG_AWK
  676. # Quote the first word in the for list for Solaris sh.
  677. for awk_arg in "Foo=" AWK=awk; do
  678. AT_CHECK_CONFIGURE([$awk_arg])
  679. AT_CHECK([cat Foo], 0, m4_for([n], 1, 100,, ....................)
  680. )
  681. AT_CHECK([cat Bar], 0, m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)
  682. )
  683. AT_DATA([stdout],
  684. [m4_for([n], 1, 5,, m4_for([m], 1, 100,, ... ... ... ... ....)
  685. )])
  686. AT_CHECK([cat Baz], 0, [stdout])
  687. AT_CHECK([diff Boo-exp Boo])
  688. done
  689. AT_CLEANUP
  690. ## ------------------------------ ##
  691. ## Define to a 2000-byte string. ##
  692. ## ------------------------------ ##
  693. AT_SETUP([Define to a 2000-byte string])
  694. AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
  695. AT_CONFIGURE_AC(
  696. [[
  697. AC_DEFINE_UNQUOTED([foo], ]m4_for([n], 1, 100,, ....................)[, [desc])
  698. AC_DEFINE([fooq], ]m4_for([n], 1, 100,, ....................)[, [desc])
  699. ]])
  700. AT_CHECK_AUTOCONF
  701. AT_CHECK_AUTOHEADER
  702. AT_CHECK_CONFIGURE
  703. AT_CHECK_DEFINES([@%:@define foo m4_for([n], 1, 100,, ....................)
  704. @%:@define fooq m4_for([n], 1, 100,, ....................)
  705. ])
  706. AT_CLEANUP
  707. ## ------------------------------------------ ##
  708. ## Substitute and define special characters. ##
  709. ## ------------------------------------------ ##
  710. # Use characters special to the shell, sed, awk, and M4.
  711. AT_SETUP([Substitute and define special characters])
  712. AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
  713. AT_XFAIL_IF([byte=\\200s; dnl
  714. test `{ printf $byte; echo; } | sed -n '/^./p' | wc -l` = 0])
  715. AT_DATA([Foo.in], [@foo@
  716. @bar@@notsubsted@@baz@ stray @ and more@@@baz@
  717. abc@bar@baz@baz
  718. abc@bar@@baz@baz
  719. abc@bar@@baz@baz@
  720. abc@bar @baz@baz
  721. abc@bar @baz@baz@
  722. abc@bar @baz@@baz@
  723. @file@
  724. @file@
  725. X@file@
  726. @file@X
  727. ])
  728. AT_DATA([File],
  729. [@foo@@bar@
  730. ])
  731. AT_DATA([Zardoz.in], [@zardoz@
  732. ])
  733. AT_CONFIGURE_AC(
  734. [[foo="AS@&t@_ESCAPE([[X*'[]+ ", & &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !]])"
  735. #"
  736. bar="@foo@ @baz@"
  737. baz=bla
  738. ( for i in 0 1 2 3; do
  739. for j in 0 1 2 3 4 5 6 7; do
  740. for k in 0 1 2 3 4 5 6 7; do
  741. case $i$j$k in #(
  742. 000 | 015 | 377) ;; # MinGW awk dislikes 0xFF, and the test does
  743. # the wrong thing for CR on MinGW.
  744. #(
  745. *) printf \\$i$j$k's' ;; # The 's' works around a Solaris 8 /bin/bash bug.
  746. esac
  747. done
  748. done
  749. done
  750. printf \\n
  751. ) >allowed-chars
  752. zardoz=`cat allowed-chars`
  753. AC_SUBST([foo])
  754. AC_SUBST([bar])
  755. AC_SUBST([baz])
  756. AC_SUBST([zardoz])
  757. file=File
  758. AC_SUBST_FILE([file])
  759. AC_DEFINE([fooq], [[X*'[]+ ", & &`\($foo !]], [Awful value.])
  760. AC_DEFINE([barq], [[%!_!# X]], [Value that is used as special delimiter.])
  761. AC_DEFINE_UNQUOTED([foo], [[X*'[]+ ", & &\`\\(\$foo !]], [Awful value.])
  762. AC_DEFINE_UNQUOTED([bar], [[%!_!# X]], [Value that is used as special delimiter.])
  763. AC_DEFINE_UNQUOTED([unq1], [$baz], [unquoted, test 1])
  764. AC_DEFINE_UNQUOTED([unq2], [\$baz], [unquoted, test 2])
  765. AC_DEFINE_UNQUOTED([unq3], ["$baz"], [unquoted, test 3])
  766. AC_DEFINE_UNQUOTED([unq4], [${baz+set}], [unquoted, test 4])
  767. AC_DEFINE_UNQUOTED([unq5], ["${baz+`echo "a "' b'`}"], [unquoted, test 5])
  768. AC_DEFINE_UNQUOTED([unq6], [`echo hi`], [unquoted, test 6])
  769. AC_DEFINE_UNQUOTED([unq7], ['\\"'], [unquoted, test 7])
  770. AC_PROG_AWK
  771. AC_CONFIG_FILES([Foo Zardoz])]])
  772. AT_CHECK_AUTOCONF
  773. AT_CHECK_AUTOHEADER
  774. # Check both awk and the result of AC_PROG_AWK
  775. # Quote the first word in the for list for Solaris sh.
  776. for awk_arg in "FOO=" AWK=awk; do
  777. AT_CHECK_CONFIGURE([$awk_arg])
  778. AT_CHECK([cat Foo], 0, [[X*'[]+ ", & &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !
  779. @foo@ @baz@@notsubsted@bla stray @ and more@@bla
  780. abc@foo@ @baz@baz@baz
  781. abc@foo@ @baz@blabaz
  782. abc@foo@ @baz@blabaz@
  783. abc@bar blabaz
  784. abc@bar blabaz@
  785. abc@bar blabla
  786. @foo@@bar@
  787. @foo@@bar@
  788. X@file@
  789. @file@X
  790. ]])
  791. AT_CHECK([cmp allowed-chars Zardoz])
  792. AT_CHECK_DEFINES([[#define bar %!_!# X
  793. #define barq %!_!# X
  794. #define foo X*'[]+ ", & &`\($foo !
  795. #define fooq X*'[]+ ", & &`\($foo !
  796. #define unq1 bla
  797. #define unq2 $baz
  798. #define unq3 "bla"
  799. #define unq4 set
  800. #define unq5 "a b"
  801. #define unq6 hi
  802. #define unq7 '\"'
  803. ]])
  804. done
  805. AT_CLEANUP
  806. ## ---------------------- ##
  807. ## Substitute a newline. ##
  808. ## ---------------------- ##
  809. AT_SETUP([Substitute a newline])
  810. AT_DATA([Foo.in],
  811. [@foo@
  812. @bar@
  813. ])
  814. AT_DATA([configure.ac],
  815. [[AC_INIT
  816. foo='one
  817. two'
  818. bar='%!_!# ''
  819. x'
  820. AC_SUBST([foo])
  821. AC_SUBST([bar])
  822. AC_CONFIG_FILES([Foo])
  823. AC_PROG_AWK
  824. AC_OUTPUT
  825. ]])
  826. cp "$abs_top_srcdir/build-aux/install-sh" .
  827. echo 'one
  828. two
  829. %!_!# ''
  830. x' >expout
  831. AT_CHECK_AUTOCONF
  832. # Check both awk and the result of AC_PROG_AWK
  833. # Quote the first word in the for list for Solaris sh.
  834. for awk_arg in "FOO=" AWK=awk; do
  835. AT_CHECK_CONFIGURE([$awk_arg])
  836. AT_CHECK([cat Foo], 0, [expout])
  837. done
  838. AT_CLEANUP
  839. ## ------------------ ##
  840. ## Define a newline. ##
  841. ## ------------------ ##
  842. AT_SETUP([Define a newline])
  843. AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
  844. AT_CONFIGURE_AC([[AC_DEFINE([foo], [one
  845. two], [This spans two lines.])
  846. ]])
  847. AT_CHECK_AUTOCONF([], [], [], [stderr])
  848. dnl Older versions of m4 report error at line 5 (end of macro);
  849. dnl newer versions report it at line 4 (start of macro).
  850. AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
  851. [[warning: AC_DEFINE: `one
  852. two' is not a valid preprocessor define value
  853. ]])
  854. AT_CHECK_AUTOHEADER([], [], [], [stderr])
  855. AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
  856. [[warning: AC_DEFINE: `one
  857. two' is not a valid preprocessor define value
  858. ]])
  859. AT_CHECK_CONFIGURE
  860. AT_CHECK_DEFINES([[#define foo one
  861. ]])
  862. AT_CONFIGURE_AC([[AC_DEFINE_UNQUOTED([foo], [one
  863. two], [This spans two lines.])
  864. ]])
  865. AT_CHECK_AUTOCONF([], [], [], [stderr])
  866. AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
  867. [[warning: AC_DEFINE_UNQUOTED: `one
  868. two' is not a valid preprocessor define value
  869. ]])
  870. AT_CHECK_AUTOHEADER([], [], [], [stderr])
  871. AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
  872. [[warning: AC_DEFINE_UNQUOTED: `one
  873. two' is not a valid preprocessor define value
  874. ]])
  875. AT_CHECK_CONFIGURE
  876. AT_CHECK_DEFINES([[#define foo one
  877. ]])
  878. AT_CLEANUP
  879. ## ------------------------------------ ##
  880. ## AC_SUBST: variable name validation. ##
  881. ## ------------------------------------ ##
  882. AT_SETUP([AC_SUBST: variable name validation])
  883. AT_CONFIGURE_AC([[AC_SUBST(, [])
  884. AC_CONFIG_FILES([Makefile])
  885. ]])
  886. AT_DATA([Makefile.in], [[
  887. ]])
  888. mv -f configure.ac configure.tmpl
  889. # Invalid names.
  890. for var in ['' ab\~ ab\( ab[] ab\' ab\" ab\\\\]; do
  891. sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
  892. AT_CHECK_AUTOCONF([], [1], [], [ignore])
  893. done
  894. # Valid names.
  895. for var in ab a4 'a@@&t@\&t@b'; do
  896. sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
  897. AT_CHECK_AUTOCONF
  898. AT_CHECK_AUTOHEADER
  899. AT_CHECK_CONFIGURE
  900. done
  901. AT_CLEANUP
  902. ## ------------------------ ##
  903. ## datarootdir workaround. ##
  904. ## ------------------------ ##
  905. AT_SETUP([datarootdir workaround])
  906. AT_DATA([Foo.in],
  907. [@datadir@
  908. @docdir@
  909. @infodir@
  910. @localedir@
  911. @mandir@
  912. ])
  913. AT_DATA([Bar.in],
  914. [@mydatadir@
  915. ])
  916. AT_DATA([configure.ac],
  917. [[AC_INIT
  918. d@&t@nl The following line silences the warnings, if uncommented:
  919. d@&t@nl AC_DEFUN([AC_DATAROOTDIR_CHECKED])
  920. # This substitution is wrong and bogus! Don't use it in your own code!
  921. # Read `info Autoconf "Defining Directories"'!
  922. AC_SUBST([mydatadir], [${datadir}/my])
  923. AC_CONFIG_FILES([Foo Bar])
  924. AC_OUTPUT
  925. ]])
  926. cp "$abs_top_srcdir/build-aux/install-sh" .
  927. AT_CHECK_AUTOCONF
  928. AT_CHECK_CONFIGURE([], [], [],
  929. [config.status: WARNING: 'Foo.in' seems to ignore the --datarootdir setting
  930. config.status: WARNING: Bar contains a reference to the variable `datarootdir'
  931. which seems to be undefined. Please make sure it is defined
  932. ])
  933. AT_CHECK([grep datarootdir Foo], 1, [])
  934. rm configure
  935. sed '/AC_DEFUN/s/^d@&t@nl //' configure.ac >t
  936. mv t configure.ac
  937. AT_CHECK_AUTOCONF
  938. AT_CHECK_CONFIGURE
  939. AT_CLEANUP
  940. ## -------- ##
  941. ## srcdir. ##
  942. ## -------- ##
  943. AT_SETUP([srcdir])
  944. rm -f -r at-dir
  945. mkdir at-dir
  946. : >at-dir/bar.in
  947. : >foo.in
  948. AT_DATA([configure.ac],
  949. [[AC_INIT
  950. AC_CONFIG_FILES([foo at-dir/bar])
  951. # Use quotes in the INIT-COMMANDS to accommodate a value of $srcdir
  952. # containing e.g., spaces or shell meta-characters.
  953. # Use *single* quotes because the context is an unquoted here-doc.
  954. AC_CONFIG_COMMANDS([report],
  955. [test -f "$srcdir/configure.ac" ||
  956. AC_MSG_ERROR([cannot find $srcdir/configure.ac])],
  957. [srcdir='$srcdir'])
  958. AC_OUTPUT
  959. rm -f -r foo at-dir/bar
  960. ]])
  961. AT_CHECK_AUTOCONF
  962. # In place.
  963. AT_CHECK([./configure $configure_options], [], [ignore])
  964. # Relative name.
  965. AT_CHECK([cd at-dir && ../configure $configure_options], [], [ignore])
  966. # Absolute name.
  967. at_here=`pwd`
  968. AT_CHECK([cd at-dir && "$at_here/configure" $configure_options], [], [ignore])
  969. AT_CLEANUP
  970. ## ------- ##
  971. ## VPATH. ##
  972. ## ------- ##
  973. AT_SETUP([VPATH])
  974. dirs='at paren brace space'
  975. for dir in $dirs; do
  976. mkdir $dir $dir/s1 $dir/s2
  977. touch $dir/f $dir/s1/f1 $dir/s2/f2
  978. done
  979. AT_DATA([configure.ac],
  980. [[AC_INIT
  981. AC_CONFIG_FILES([at/Makefile paren/Makefile brace/Makefile space/Makefile])
  982. AC_OUTPUT
  983. ]])
  984. AT_DATA([at/Makefile.in],
  985. [[# This is what you should use in order to be portable to old makes.
  986. srcdir = @srcdir@
  987. VPATH = @srcdir@/s1:@srcdir@:@srcdir@/s2
  988. all: f f1 f2
  989. @echo ok
  990. ]])
  991. AT_DATA([paren/Makefile.in],
  992. [[# This works with some makes but not with old ones.
  993. srcdir = @srcdir@
  994. VPATH = $(srcdir)/s1:$(srcdir):$(srcdir)/s2
  995. all: f f1 f2
  996. @echo ok
  997. ]])
  998. AT_DATA([brace/Makefile.in],
  999. [[# This works with some makes but not with old ones.
  1000. srcdir = @srcdir@
  1001. VPATH = ${srcdir}/s1:${srcdir}:${srcdir}/s2
  1002. all: f f1 f2
  1003. @echo ok
  1004. ]])
  1005. AT_DATA([space/Makefile.in],
  1006. [[# This fails with FreeBSD make, for example.
  1007. srcdir = @srcdir@
  1008. VPATH = @srcdir@/s1 @srcdir@ @srcdir@/s2
  1009. all: f f1 f2
  1010. @echo ok
  1011. ]])
  1012. AT_CHECK_AUTOCONF
  1013. : "${MAKE=make}"
  1014. # In place.
  1015. AT_CHECK([./configure $configure_options], [], [ignore])
  1016. # Treat BSD make separately, afterwards, for maximal coverage.
  1017. dirs='at paren brace'
  1018. for dir in $dirs; do
  1019. AT_CHECK([cd $dir && $MAKE], [], [ignore], [ignore])
  1020. done
  1021. rm -f config.status
  1022. mkdir build absbuild
  1023. # Relative name.
  1024. AT_CHECK([cd build && ../configure $configure_options], [], [ignore])
  1025. for dir in $dirs; do
  1026. AT_CHECK([cd build/$dir && $MAKE], [], [ignore], [ignore])
  1027. done
  1028. # Absolute name.
  1029. at_here=`pwd`
  1030. AT_CHECK([cd absbuild && "$at_here/configure" $configure_options], [], [ignore])
  1031. for dir in $dirs; do
  1032. AT_CHECK([cd absbuild/$dir && $MAKE], [], [ignore], [ignore])
  1033. done
  1034. # These will not pass with BSD make.
  1035. AT_CHECK([cd space && { $MAKE || exit 77; }], [], [ignore], [ignore])
  1036. AT_CHECK([cd build/space && $MAKE], [], [ignore], [ignore])
  1037. AT_CHECK([cd absbuild/space && $MAKE], [], [ignore], [ignore])
  1038. AT_CLEANUP
  1039. ## ----------------- ##
  1040. ## Signal handling. ##
  1041. ## ----------------- ##
  1042. AT_SETUP([Signal handling])
  1043. AT_DATA([configure.ac],
  1044. [[AC_INIT
  1045. kill -2 $$
  1046. exit 77
  1047. ]])
  1048. AT_CHECK_AUTOCONF
  1049. AT_CHECK_CONFIGURE([], 1, ignore, ignore)
  1050. AT_CLEANUP
  1051. ## ----------------- ##
  1052. ## AC_CONFIG_LINKS. ##
  1053. ## ----------------- ##
  1054. AT_SETUP([AC_CONFIG_LINKS])
  1055. AT_DATA([configure.ac],
  1056. [[AC_INIT([config links to config files test], [1.0])
  1057. AC_CONFIG_SRCDIR([sub1/file1.in])
  1058. AC_CONFIG_FILES([sub1/file1 file2])
  1059. AC_CONFIG_LINKS([file1:sub1/file1 sub2/file2:file2])
  1060. AC_OUTPUT
  1061. ]])
  1062. mkdir sub1
  1063. AT_DATA([sub1/file1.in],
  1064. [[/* @configure_input@ */
  1065. #define PACKAGE_STRING "@PACKAGE_STRING@"
  1066. ]])
  1067. AT_DATA([file2.in],
  1068. [[/* @configure_input@ */
  1069. #define PACKAGE_STRING "@PACKAGE_STRING@"
  1070. ]])
  1071. mkdir build
  1072. AT_CHECK_AUTOCONF
  1073. cd build
  1074. AT_CHECK([../configure && ../configure], 0, [ignore])
  1075. AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
  1076. ])
  1077. AT_CHECK([../configure && ../configure], 0, [ignore])
  1078. AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
  1079. ])
  1080. cd ..
  1081. rm -rf build
  1082. mkdir build
  1083. cd build
  1084. cwd=`pwd`
  1085. AT_CHECK(["$cwd"/../configure && "$cwd"/../configure], 0, [ignore])
  1086. AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
  1087. ])
  1088. cd ..
  1089. AT_CHECK([./configure && ./configure], 0, [ignore], [stderr])
  1090. AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
  1091. ])
  1092. cwd=`pwd`
  1093. AT_CHECK(["$cwd"/configure && "$cwd"/configure], 0, [ignore], [ignore])
  1094. AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
  1095. ])
  1096. AT_CLEANUP
  1097. ## ------------------------------------- ##
  1098. ## AC_CONFIG_LINKS and identical files. ##
  1099. ## ------------------------------------- ##
  1100. AT_SETUP([AC_CONFIG_LINKS and identical files])
  1101. AT_DATA([configure.ac],
  1102. [[AC_INIT
  1103. AC_CONFIG_LINKS([src/s:src/s])
  1104. test "$srcdir" != '.' && AC_CONFIG_LINKS([src/t:src/t])
  1105. AC_OUTPUT
  1106. ]])
  1107. mkdir src build
  1108. echo file1 > src/s
  1109. echo file2 > src/t
  1110. AT_CHECK_AUTOCONF
  1111. cd build
  1112. AT_CHECK([../configure $configure_options && ../configure $configure_options],
  1113. 0, [ignore])
  1114. AT_CHECK([cat src/s src/t], 0, [file1
  1115. file2
  1116. ])
  1117. cd ..
  1118. rm -rf build
  1119. mkdir build
  1120. cd build
  1121. cwd=`pwd`
  1122. AT_CHECK(["$cwd"/../configure], 0, [ignore])
  1123. AT_CHECK([cat src/s src/t], 0, [file1
  1124. file2
  1125. ])
  1126. AT_CHECK(["$cwd"/../configure], 0, [ignore])
  1127. AT_CHECK([cat src/s src/t], 0, [file1
  1128. file2
  1129. ])
  1130. cd ..
  1131. AT_CHECK([./configure $configure_options && ./configure $configure_options],
  1132. 0, [ignore], [stderr])
  1133. AT_CHECK([grep src/t stderr], 1)
  1134. AT_CHECK([cat src/s src/t], 0, [file1
  1135. file2
  1136. ])
  1137. cwd=`pwd`
  1138. AT_CHECK(["$cwd"/configure && "$cwd"/configure], 0, [ignore], [ignore])
  1139. AT_CHECK([cat src/s src/t], 0, [file1
  1140. file2
  1141. ])
  1142. AT_CLEANUP
  1143. AT_BANNER([autoreconf.])
  1144. ## ---------------------------- ##
  1145. ## Configuring subdirectories. ##
  1146. ## ---------------------------- ##
  1147. # .
  1148. # |-- builddir
  1149. # | |-- config.log
  1150. # | |-- config.status
  1151. # | `-- inner
  1152. # | |-- config.log
  1153. # | |-- config.status
  1154. # | `-- innermost
  1155. # | `-- config
  1156. # |-- configure
  1157. # |-- configure.ac
  1158. # |-- inner
  1159. # | |-- configure
  1160. # | |-- configure.ac
  1161. # | `-- innermost
  1162. # | `-- config.in
  1163. # `-- install-sh
  1164. #
  1165. AT_SETUP([Configuring subdirectories])
  1166. AT_KEYWORDS(autoreconf)
  1167. # We use aclocal (via autoreconf).
  1168. AT_CHECK([aclocal --version || exit 77], [], [stdout], [ignore])
  1169. AT_CHECK([[grep '[1-9]\.[0-9]' stdout || exit 77]], [], [ignore])
  1170. # It should understand configure.ac.
  1171. AT_CHECK([[grep '[^0-9]1\.[01234][^0-9]' stdout && exit 77]], [1], [ignore])
  1172. # Set CONFIG_SITE to a nonexistent file, so that there are
  1173. # no worries about nonstandard values for 'prefix'.
  1174. CONFIG_SITE=no-such-file
  1175. export CONFIG_SITE
  1176. # The contents of `inner/', and `inner/innermost/'.
  1177. AS_MKDIR_P([inner/innermost])
  1178. # We have to use configure.in, not configure.ac, if we still want to
  1179. # be compatible with Automake 1.4: aclocal (run by autoreconf) would
  1180. # die because it can't find configure.in.
  1181. AT_DATA([inner/configure.in],
  1182. [[AC_INIT(GNU Inner, 1.0)
  1183. AC_CONFIG_SRCDIR([innermost/config.in])
  1184. AC_ARG_VAR([INNER], [an inner variable])
  1185. AC_SUBST([INNER])
  1186. if test "x$INNER" = x; then
  1187. INNER=inner
  1188. fi
  1189. AC_CONFIG_FILES([innermost/config])
  1190. AC_OUTPUT
  1191. ]])
  1192. AT_DATA([inner/innermost/config.in],
  1193. [INNER=@INNER@
  1194. srcdir=@srcdir@
  1195. top_srcdir=@top_srcdir@
  1196. prefix=@prefix@
  1197. ])
  1198. # The contents of `.'
  1199. AT_DATA([install-sh], [])
  1200. # nonexistent is allowed not to exist.
  1201. AT_DATA([configure.in],
  1202. [[AC_INIT(GNU Outer, 1.0)
  1203. AC_ARG_VAR([OUTER], [an outer variable])
  1204. if false; then
  1205. AC_CONFIG_SUBDIRS([nonexistent])
  1206. fi
  1207. AC_CONFIG_SUBDIRS([inner])
  1208. AC_OUTPUT
  1209. ]])
  1210. # If there are improperly quoted AC_DEFUN installed in share/aclocal,
  1211. # they trigger warnings from aclocal 1.8, so ignore stderr.
  1212. AT_CHECK([autoreconf], [], [], [ignore])
  1213. AT_CHECK([test -f inner/configure])
  1214. # Running the outer configure recursively should provide the innermost
  1215. # help strings.
  1216. chmod a-w inner/innermost inner .
  1217. AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep INNER], 0,
  1218. [ignore], [stderr],
  1219. [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
  1220. chmod u+w . inner inner/innermost
  1221. # Running the outer configure should trigger the inner.
  1222. AT_CHECK_CONFIGURE
  1223. AT_CHECK([cat inner/innermost/config], 0,
  1224. [INNER=inner
  1225. srcdir=.
  1226. top_srcdir=..
  1227. prefix=/usr/local
  1228. ])
  1229. # The same, but from a builddir.
  1230. AS_MKDIR_P([builddir])
  1231. AT_CHECK([cd builddir && ../configure $configure_options], 0, [ignore])
  1232. AT_CHECK([cat builddir/inner/innermost/config], 0,
  1233. [INNER=inner
  1234. srcdir=../../../inner/innermost
  1235. top_srcdir=../../../inner
  1236. prefix=/usr/local
  1237. ])
  1238. # Make sure precious variables and command line options are properly
  1239. # passed, even when there are duplicates.
  1240. AT_CHECK([cd builddir && ../configure $configure_options --prefix /bad --prefix /good INNER=bad INNER=good],
  1241. 0, [ignore])
  1242. AT_CHECK([cat builddir/inner/innermost/config], 0,
  1243. [INNER=good
  1244. srcdir=../../../inner/innermost
  1245. top_srcdir=../../../inner
  1246. prefix=/good
  1247. ])
  1248. # Make sure --prefix is properly quoted
  1249. AT_CHECK([cd builddir && ../configure --prefix "/a b c$ 'd"], 0, [ignore])
  1250. AT_CHECK([cat builddir/inner/innermost/config], 0,
  1251. [INNER=inner
  1252. srcdir=../../../inner/innermost
  1253. top_srcdir=../../../inner
  1254. prefix=/a b c$ 'd
  1255. ])
  1256. # Make sure --silent is properly passed...
  1257. AT_CHECK([cd builddir && ../configure $configure_options --silent], 0, [])
  1258. # ...but not stored in config.status.
  1259. AT_CHECK([cd builddir && ./config.status --recheck], 0, [stdout])
  1260. AT_CHECK([grep 'creating \./config.status' stdout], 0, [ignore])
  1261. # --cache-file is adjusted for subdirectories, so the cache is shared.
  1262. AT_CHECK([cd builddir && ../configure $configure_options --config-cache],
  1263. [], [stdout])
  1264. AT_CHECK([grep 'loading .*\.\./config.cache' stdout], [], [ignore])
  1265. # Make sure we can run autoreconf on a subdirectory
  1266. rm -f configure configure.in
  1267. AT_CHECK([autoreconf inner], [], [], [ignore])
  1268. # Make sure we can pass a configure.ac name
  1269. AT_CHECK([cd inner && autoreconf configure.in], [], [], [ignore])
  1270. AT_CHECK([autoreconf inner/configure.in], [], [], [ignore])
  1271. AT_CLEANUP
  1272. ## -------------- ##
  1273. ## Deep Package. ##
  1274. ## -------------- ##
  1275. AT_SETUP([Deep Package])
  1276. AT_KEYWORDS(autoreconf)
  1277. # We use aclocal (via autoreconf).
  1278. AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
  1279. # The contents of `.'
  1280. AT_DATA([install-sh], [])
  1281. AT_DATA([configure.in],
  1282. [[AC_INIT(GNU Outer, 1.0)
  1283. AC_ARG_VAR([OUTER], [an outer variable])
  1284. AC_CONFIG_SUBDIRS([
  1285. inner
  1286. inner2
  1287. ])
  1288. AC_OUTPUT
  1289. ]])
  1290. # The contents of `inner/', and `inner/innermost/'.
  1291. AS_MKDIR_P([inner/innermost])
  1292. AS_MKDIR_P([inner2])
  1293. AT_DATA([inner/configure.in],
  1294. [[AC_INIT(GNU Inner, 1.0)
  1295. AC_ARG_VAR([INNER], [an inner variable])
  1296. AC_CONFIG_SUBDIRS(innermost)
  1297. AC_OUTPUT
  1298. ]])
  1299. AT_DATA([inner/innermost/configure.in],
  1300. [[AC_INIT(GNU Innermost, 1.0)
  1301. AC_ARG_VAR([INNERMOST], [an innermost variable])
  1302. AC_CONFIG_HEADERS(config.h:config.hin)
  1303. AC_DEFINE_UNQUOTED([INNERMOST], [$INNERMOST], [an innermost variable])
  1304. if test -n "$innermost_error"; then
  1305. AC_MSG_FAILURE([error in $PACKAGE_NAME])
  1306. fi
  1307. AC_OUTPUT
  1308. ]])
  1309. AT_DATA([inner2/configure.in],
  1310. [[AC_INIT(GNU Inner 2, 1.0)
  1311. AC_ARG_VAR([INNER2], [an inner2 variable])
  1312. AC_OUTPUT
  1313. ]])
  1314. AT_CHECK([autoreconf -Wall -v], [0], [ignore], [stderr])
  1315. # We should not warn about nonliteral argument to AC_CONFIG_SUBDIRS here.
  1316. AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [1])
  1317. AT_CHECK([test -f inner/configure])
  1318. AT_CHECK([test -f inner/innermost/configure])
  1319. AT_CHECK([test -f inner/innermost/config.hin])
  1320. AT_CHECK([test -f inner2/configure])
  1321. # Running the outer configure recursively should provide the innermost
  1322. # help strings.
  1323. chmod a-w inner/innermost inner
  1324. AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER "],
  1325. 0, [ignore], [stderr],
  1326. [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
  1327. chmod a-w .
  1328. AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER2 "],
  1329. 0, [ignore], [stderr],
  1330. [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
  1331. chmod a-w .
  1332. AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
  1333. 0, [ignore], [stderr],
  1334. [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
  1335. chmod a-w .
  1336. AT_CHECK([{ /bin/sh ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
  1337. 0, [ignore], [stderr],
  1338. [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
  1339. chmod a-w .
  1340. AT_CHECK([PATH=.$PATH_SEPARATOR$PATH; export PATH; { /bin/sh configure $configure_options --help=recursive; chmod +w .; } | grep " INNERMOST "],
  1341. 0, [ignore], [stderr],
  1342. [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
  1343. chmod a-w .
  1344. AT_CHECK([PATH=.$PATH_SEPARATOR$PATH; export PATH; { configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
  1345. 0, [ignore], [stderr],
  1346. [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
  1347. chmod u+w inner inner/innermost
  1348. # Running the outer configure should trigger the inner.
  1349. AT_CHECK_CONFIGURE([INNERMOST=tsomrenni])
  1350. AT_CHECK([grep INNERMOST inner/innermost/config.h], 0,
  1351. [[#define INNERMOST tsomrenni
  1352. ]])
  1353. # Ensure we point to the right config.log file for errors.
  1354. AT_CHECK_CONFIGURE([innermost_error=:], [1], [], [stderr])
  1355. AT_CHECK([grep 'inner/innermost' stderr], [], [ignore])
  1356. cd inner
  1357. AT_CHECK_CONFIGURE([innermost_error=:], [1], [], [stderr])
  1358. AT_CHECK([grep 'innermost' stderr], [], [ignore])
  1359. cd ..
  1360. # The same, but from a builddir.
  1361. AS_MKDIR_P([builddir])
  1362. chmod a-w builddir inner/innermost inner
  1363. AT_CHECK([cd builddir && { ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER "],
  1364. 0, [ignore], [stderr],
  1365. [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
  1366. chmod a-w builddir
  1367. AT_CHECK([cd builddir && { ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER2 "],
  1368. 0, [ignore], [stderr],
  1369. [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
  1370. chmod a-w builddir
  1371. AT_CHECK([cd builddir && { ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
  1372. 0, [ignore], [stderr],
  1373. [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
  1374. chmod a-w builddir
  1375. AT_CHECK([cd builddir && { /bin/sh ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
  1376. 0, [ignore], [stderr],
  1377. [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
  1378. chmod a-w builddir
  1379. # Not all shells search $PATH for scripts.
  1380. if (cd builddir && PATH=`pwd`/..$PATH_SEPARATOR$PATH /bin/sh configure $configure_options --help) >/dev/null 2>&1; then
  1381. AT_CHECK([cd builddir && PATH=`pwd`/..$PATH_SEPARATOR$PATH /bin/sh configure $configure_options --help=recursive | grep " INNERMOST "], 0, [ignore])
  1382. fi
  1383. AT_CHECK([PATH=`pwd`$PATH_SEPARATOR$PATH; export PATH; cd builddir && { configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
  1384. 0, [ignore], [stderr],
  1385. [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
  1386. chmod u+w builddir inner inner/innermost
  1387. AT_CHECK([cd builddir && ../configure $configure_options INNERMOST=build/tsomrenni], 0, [ignore])
  1388. AT_CHECK([grep INNERMOST builddir/inner/innermost/config.h], 0,
  1389. [[#define INNERMOST build/tsomrenni
  1390. ]])
  1391. AT_CLEANUP
  1392. ## -------------------------------- ##
  1393. ## Non-Autoconf AC_CONFIG_SUBDIRS. ##
  1394. ## -------------------------------- ##
  1395. AT_SETUP([Non-Autoconf AC_CONFIG_SUBDIRS])
  1396. AT_KEYWORDS([autoreconf])
  1397. # We use aclocal (via autoreconf).
  1398. AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
  1399. AT_DATA([install-sh], [])
  1400. AT_DATA([configure.in],
  1401. [[AC_INIT(GNU Outer, 1.0)
  1402. AC_CONFIG_SUBDIRS([inner])
  1403. AC_OUTPUT
  1404. ]])
  1405. AS_MKDIR_P([inner])
  1406. AT_DATA([inner/configure],
  1407. [[#! /bin/sh
  1408. case "$*" in
  1409. *--help*) echo 'No Autoconf here, folks!' ;;
  1410. *) echo got_it >myfile ;;
  1411. esac
  1412. exit 0
  1413. ]])
  1414. chmod +x inner/configure
  1415. AT_CHECK([autoreconf -Wall -v], 0, [ignore], [ignore])
  1416. # Running the outer configure recursively should provide the innermost
  1417. # help strings.
  1418. AT_CHECK([./configure $configure_options --help=recursive | grep "folks"], 0, [ignore])
  1419. # Running the outer configure should trigger the inner.
  1420. AT_CHECK([./configure $configure_options], 0, [ignore])
  1421. AT_CHECK([test -f inner/myfile], 0)
  1422. AT_CLEANUP
  1423. ## ------------------------------- ##
  1424. ## Non-literal AC_CONFIG_SUBDIRS. ##
  1425. ## ------------------------------- ##
  1426. AT_SETUP([Non-literal AC_CONFIG_SUBDIRS])
  1427. AT_KEYWORDS([autoreconf])
  1428. AT_DATA([install-sh], [])
  1429. AT_DATA([configure.in],
  1430. [[AC_INIT(GNU Outer, 1.0)
  1431. my_subdirs=
  1432. # Taken from autoconf.texi:Subdirectories.
  1433. if test "x$package_foo_enabled" = xyes; then
  1434. my_subdirs="$my_subdirs foo"
  1435. fi
  1436. AC_CONFIG_SUBDIRS([$my_subdirs])
  1437. AC_OUTPUT
  1438. ]])
  1439. # Hand-written aclocal.m4, so we don't invoke `aclocal -Werror' which
  1440. # could barf over warnings in third-party macro files, or fail over
  1441. # warnings with older aclocal which didn't yet understand -W*.
  1442. AT_DATA([aclocal.m4])
  1443. AS_MKDIR_P([foo])
  1444. AT_DATA([foo/configure],
  1445. [[#! /bin/sh
  1446. touch innerfile
  1447. exit 0
  1448. ]])
  1449. chmod +x foo/configure
  1450. # autoreconf should warn without -Wno-syntax, but should not fail without -Werror.
  1451. AT_CHECK([autoreconf -Werror -v], [1], [ignore], [stderr])
  1452. AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [0], [ignore])
  1453. AT_CHECK([autoreconf -v], [0], [ignore], [stderr])
  1454. AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [0], [ignore])
  1455. AT_CHECK([autoreconf -v --force -Wno-syntax], 0, [ignore], [stderr])
  1456. AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [1])
  1457. AT_CHECK([./configure $configure_options], [0], [ignore])
  1458. AT_CHECK([test ! -f foo/innerfile])
  1459. # Running the outer configure should trigger the inner.
  1460. AT_CHECK([./configure $configure_options package_foo_enabled=yes], [0], [ignore])
  1461. AT_CHECK([test -f foo/innerfile])
  1462. AT_CLEANUP
  1463. ## ----------------- ##
  1464. ## Empty directory. ##
  1465. ## ----------------- ##
  1466. AT_SETUP([Empty directory])
  1467. AT_KEYWORDS([autoreconf])
  1468. # We use aclocal (via autoreconf).
  1469. AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
  1470. # The test group directory is not necessarily _empty_, but it does not contain
  1471. # files meaningful to `autoreconf'.
  1472. AT_CHECK([autoreconf -Wall -v], 1, [ignore], [ignore])
  1473. AT_CLEANUP
  1474. ## ------------------------------ ##
  1475. ## Unusual Automake input files. ##
  1476. ## ------------------------------ ##
  1477. # This parallels gnumake.test in Automake.
  1478. AT_SETUP([Unusual Automake input files])
  1479. AT_KEYWORDS([autoreconf])
  1480. # We use aclocal and automake via autoreconf.
  1481. AT_CHECK([automake --version || exit 77], [], [stdout], [ignore])
  1482. AT_CHECK([[grep '[1-9]\.[0-9]' stdout || exit 77]], [], [ignore])
  1483. AT_DATA([configure.in],
  1484. [[AC_INIT(GNU foo, 1.0)
  1485. AM_INIT_AUTOMAKE
  1486. AC_CONFIG_FILES([HeeHee])
  1487. AC_OUTPUT
  1488. ]])
  1489. AT_DATA([HeeHee.am],
  1490. [[# Humans do no worse than `GNUmakefile.am'.
  1491. AUTOMAKE_OPTIONS = foreign 1.8
  1492. ]])
  1493. AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [stderr],
  1494. [AT_CHECK([grep 'require.*1\.8' stderr && exit 77], [1])])
  1495. AT_CHECK([test -f HeeHee.in])
  1496. AT_CLEANUP