Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

890 lines
40KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_gnu_autotest.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_GNU_AUTOTEST([testdir = `tests'], [testsuites = `testsuite'],
  8. # [atlocal-sources = `'], [gen-package = `yes'],
  9. # [force = `no'])
  10. #
  11. # DESCRIPTION
  12. #
  13. # Sets up one or multiple GNU Autotest test suites [1].
  14. #
  15. # TL;DR:
  16. #
  17. # * Write tests/testsuite.at as normal
  18. # * Add to configure.ac: AX_GNU_AUTOTEST
  19. # * Add to Makefile.am or Makefile.in in top_srcdir:
  20. # @AX_GNU_AUTOTEST_DEFAULT@
  21. # * autoreconf && ./configure && make check
  22. #
  23. # GNU Autotest is a very powerful testing framework to script executing
  24. # binaries, observing their output and logging failures, all in the same
  25. # portable manner as configure itself. But the only help given the
  26. # developer in setting up the framework is the AC_CONFIG_TESTDIR()
  27. # command, which leaves several additional steps up to the developer
  28. # copying examples from the manual:
  29. #
  30. # * generating the "package.m4" file used in generating the "testsuite"
  31. # * generating the "testsuite" executable by calling autom4te
  32. # * adding Makefile rules to keep both "package.m4" and "testsuite"
  33. # current
  34. # * figuring out how to do all the above if the Makefile does not reside
  35. # in the testdir
  36. #
  37. # This command takes care of all of the above. It is designed to be called
  38. # multiple times for different testdir directories, to have multiple
  39. # testsuites scripts per directory and to handle the optional "package.m4"
  40. # and "atlocal" (re)generation.
  41. #
  42. # The various actions taken by this command happen in different phases of
  43. # the build process:
  44. #
  45. # 1) During the autoconf execution, generate the testsuites and any
  46. # "package.m4" files. So these are already available before configure
  47. # ran. The reasoning for deviating from the examples in [1] is that
  48. # these files are distributed and must be placed in the srcdir: it
  49. # seems cleaner to not generate anything in srcdir during any of the
  50. # later phases.
  51. # 2) During the config.status execution (following the configure
  52. # execution), generate "atconfig" and any "atlocal" files in the
  53. # buildir. The "atconfig" generation is handled by calling
  54. # AC_CONFIG_TESTDIR() so the developer does not have to do so
  55. # themselves.
  56. # 3) During the execution of make, several additional rules and file
  57. # lists are made available via AC_SUBST(). The rules are intended
  58. # to be called where appropriate (e.g. make check can depend on
  59. # check-autotest) and the file lists are intended to be added
  60. # to the appropriate lists (i.e. to DISTCLEANFILES and EXTRA_DIST).
  61. #
  62. # Description of AX_GNU_AUTOTEST() arguments:
  63. #
  64. # * testdir: directory-name containing the testsuites. AX_GNU_AUTOTEST()
  65. # must be called exactly once for each directory containing testsuites.
  66. # If empty, defaults to "tests".
  67. # * testsuites: space-separated list of words, where each word is the
  68. # name of a test suite script optionally followed by a colon and the
  69. # name of the scripts source file. If the source file is not given,
  70. # it defaults to the script name suffixed by ".at". So these words
  71. # are all equivalent: "foo", "foo:" and "foo:foo.at". If the argument
  72. # is empty, it defaults to "testsuite". The script filenames must not
  73. # contain any path, but that is allowed for the source filenames.
  74. # * atlocal-sources: space- or colon-separated list of filenames, which
  75. # are registered with AC_CONFIG_FILES() as the sources of atlocal.
  76. # If empty, no atlocal file is generated.
  77. # * gen-package: boolean ("yes" or "no") indicating whether "package.m4"
  78. # should be generated. If empty, defaults to "yes".
  79. # * force: boolean ("yes" or "no") whether to treat errors in arguments
  80. # as errors and abort (for "no") or whether to ignore any such errors
  81. # (for "yes"). If empty, defaults to "no".
  82. #
  83. # All filenames above must be relative. The testdir name is interpreted
  84. # relative to top_srcdir. All other names are interpreted relative to the
  85. # testdir. The boolean values are interpreted as "yes" for any non-empty
  86. # value except "0", "n", "no" and their mixed-case variants.
  87. #
  88. # Description of Makefile.am / Makefile.in substitutions:
  89. #
  90. # * AX_GNU_AUTOTEST_RULES: the make rules provided here. Substitute this
  91. # in a separate line.
  92. # * AX_GNU_AUTOTEST_DCLEAN: the list of files to be added to
  93. # DISTCLEANFILES.
  94. # * AX_GNU_AUTOTEST_DIST: the list of files to be added to EXTRA_DIST.
  95. # * AX_GNU_AUTOTEST_DEFAULT: includes all other substitutions and uses
  96. # them in a "default" way.
  97. #
  98. # All must be used as a substitution (@...@) instead of as a variable
  99. # ($(...) or ${...}). These substitutions are generated multiple times,
  100. # once for each directory where an affected Makefile may be located. All
  101. # substitutions start with the base as given above but may have suffixes
  102. # for the directories. Assuming this example in configure.ac:
  103. #
  104. # AX_GNU_AUTOTEST([foo/bar])
  105. # AX_GNU_AUTOTEST([baz])
  106. #
  107. # Then the following substitutions are available (where <base> stands for
  108. # one of the above prefixes):
  109. #
  110. # * <base> : for use in top_srcdir/Makefile
  111. # * <base>_foo : for use in top_srcdir/foo/Makefile
  112. # * <base>_foo_bar : for use in top_srcdir/foo/bar/Makefile
  113. # * <base>_baz : for use in top_srcdir/baz/Makefile
  114. #
  115. # The <base> substitutions cover both foo/bar and baz, so none of the
  116. # other substitutions should be used. Indeed, no Makefiles are needed in
  117. # the other directories. But if sub-directory Makefiles are used, then
  118. # both <base>_baz and either of <base>_foo or <base>_foo_bar must be used
  119. # in their respective Makefiles.
  120. #
  121. # Description of Makefile targets defined by AX_GNU_AUTOTEST_RULES*:
  122. #
  123. # * check-autotest: The equivalent of check.
  124. # * installcheck-autotest: The equivalent of installcheck.
  125. # * clean-autotest: The equivalent of clean.
  126. #
  127. # The developer can either define the above targets as dependencies of
  128. # their appropriate equivalent rule or of their *-local equivalent rule
  129. # for automake or they can define a rule with a sub-make call as they
  130. # wish.
  131. #
  132. # All rules are dependent on like-named rules for each sub-directory and
  133. # for each testsuite. Only the testsuite rules actually do any work, the
  134. # rest are just collectors and convenience names. Assuming this example in
  135. # configure.ac:
  136. #
  137. # AX_GNU_AUTOTEST([foo], [testsuite bar])
  138. # AX_GNU_AUTOTEST([baz])
  139. #
  140. # Then AX_GNU_AUTOTEST_RULES defines these check rules (likewise for
  141. # installcheck and clean):
  142. #
  143. # check-autotest: check-autotest-foo check-autotest-baz
  144. # check-autotest-foo: check-autotest-foo-testsuite check-autotest-foo-bar
  145. # check-autotest-baz: check-autotest-baz-testsuite
  146. # check-autotest-foo-testsuite # Executes foo/testsuite -C foo
  147. # check-autotest-foo-bar # Executes foo/bar -C foo
  148. # check-autotest-baz-testsuite # Executes baz/testsuite -C baz
  149. #
  150. # And AX_GNU_AUTOTEST_RULES_baz defines these check rules:
  151. #
  152. # check-autotest: check-autotest-testsuite
  153. # check-autotest-testsuite # Executes testsuite (which is baz/testsuite)
  154. #
  155. # Note how the rule names only contain the directory and testsuite paths
  156. # relative to the Makefile location. Also note how each testsuite is
  157. # executed in its respective testdir.
  158. #
  159. # In addition to the above, AX_GNU_AUTOTEST_RULES* also contains the rules
  160. # to keep the testsuites, "package.m4" and "atconfig" updated. The
  161. # matching rules to keep "atlocal" updated are generated by automake if
  162. # that is used or are the responsibility of the developer.
  163. #
  164. # All testsuite executions (except for clean) use variables
  165. # AX_GNU_AUTOTEST_FLAGS, AX_GNU_AUTOTEST_CHECK_FLAGS,
  166. # AX_GNU_AUTOTEST_INSTALLCHECK_FLAGS and more path-and-script-specific
  167. # variants for additional command line options. These variables can be
  168. # defined by the developer to pass options to the testsuite. In the
  169. # example above, the rule check-autotest-foo-bar would look like this:
  170. #
  171. # check-autotest-foo-bar:
  172. # foo/bar -C foo $(AX_GNU_AUTOTEST_FLAGS) \
  173. # $(AX_GNU_AUTOTEST_CHECK_FLAGS) \
  174. # $(AX_GNU_AUTOTEST_FLAGS_foo) \
  175. # $(AX_GNU_AUTOTEST_CHECK_FLAGS_foo) \
  176. # $(AX_GNU_AUTOTEST_FLAGS_foo_bar) \
  177. # $(AX_GNU_AUTOTEST_CHECK_FLAGS_foo_bar)
  178. #
  179. # Description of Makefile file lists:
  180. #
  181. # These lists are intended to be added to DISTCLEANFILES and EXTRA_DIST.
  182. # The *_DCLEAN list contains all "atconfig" files and the *_DIST list
  183. # contains all testsuites and "package.m4" files. The lists are again
  184. # generated per directory: so AX_GNU_AUTOTEST_DCLEAN contains all
  185. # "atconfig" files while e.g. AX_GNU_AUTOTEST_DIST_foo contains only files
  186. # below the "foo" directory. These file lists are prevented from becoming
  187. # Makefile variables by calling AM_SUBST_NOTMAKE(): that way, only the
  188. # single version used by the Makefile is substituted, not all lists for
  189. # all other paths as well. So use either like this:
  190. #
  191. # DISTCLEANFILES = @AX_GNU_AUTOTEST_DCLEAN@
  192. # EXTRA_DIST = @AX_GNU_AUTOTEST_DIST_foo@
  193. #
  194. # Or like this:
  195. #
  196. # AX_GNU_AUTOTEST_DCLEAN_foo = @AX_GNU_AUTOTEST_DCLEAN_foo@
  197. # AX_GNU_AUTOTEST_DIST_foo = @AX_GNU_AUTOTEST_DIST_foo@
  198. # DISTCLEANFILES = ${AX_GNU_AUTOTEST_DCLEAN_foo}
  199. # EXTRA_DIST = ${AX_GNU_AUTOTEST_DIST_foo}
  200. #
  201. # Description of shorthand default Makefile contents defined by
  202. # AX_GNU_AUTOTEST_DEFAULT*:
  203. #
  204. # This shorthand defines the appropriate rules, adds the file lists to the
  205. # proper variables and makes the new targets dependencies of the standard
  206. # "check", "installcheck" and "clean" targets. AX_GNU_AUTOTEST_DEFAULT is
  207. # for example equivalent to:
  208. #
  209. # @AX_GNU_AUTOTEST_RULES@
  210. # check: check-autotest
  211. # installcheck: installcheck-autotest
  212. # clean: clean-autotest
  213. # distclean: distclean-autotest
  214. # distclean-autotest: clean-autotest
  215. # -rm -f @AX_GNU_AUTOTEST_DCLEAN@
  216. # .PHONY: distclean-autotest
  217. # EXTRA_DIST += @AX_GNU_AUTOTEST_DIST@
  218. #
  219. # Note that this is copied verbatim into the Makefile (after expansion of
  220. # the contained @...@ substitutions): it does not shadow the default
  221. # targets as would happen if the same lines were written in a Makefile.am
  222. # file. And also note the use of the += operator: this will not be
  223. # compatible with all versions of Make. Finally, the DISTCLEANFILES list
  224. # is not used because automake only uses that list if it saw the variable
  225. # in the Makefile.am file: in a substitution, it gets ignored unless the
  226. # user already used the list.
  227. #
  228. # Alternative standard GNU test suites not supported here:
  229. #
  230. # * Automake test suites configured by the TESTS variable [2]
  231. # * DejaGnu test suites [3,4]
  232. #
  233. # [1]:
  234. # <https://www.gnu.org/software/autoconf/manual/html_node/Using-Autotest.html>
  235. #
  236. # [2]: <https://www.gnu.org/software/automake/manual/html_node/Tests.html>
  237. #
  238. # [3]: <https://www.gnu.org/software/dejagnu/>
  239. #
  240. # [4]:
  241. # <https://www.gnu.org/software/automake/manual/html_node/DejaGnu-Tests.html>
  242. #
  243. # LICENSE
  244. #
  245. # Copyright (c) 2015 Olaf Mandel <olaf@mandel.name>
  246. #
  247. # Copying and distribution of this file, with or without modification, are
  248. # permitted in any medium without royalty provided the copyright notice
  249. # and this notice are preserved. This file is offered as-is, without any
  250. # warranty.
  251. #serial 7
  252. # _AX_GNU_AUTOTEST_remove_parent(filename)
  253. # ----------------------------------------
  254. # Remove all sequences of foo/.. from the filename, recursively (so e.g.
  255. # foo/bar/../.. is empty)
  256. # normal input, quoted output!
  257. # replacement: 1st pattern removes in middle of string
  258. # 2nd pattern removes at beginning: string starts with [[ !
  259. # 3rd pattern removes at end of string: string ends in ]] !
  260. # 4th pattern handles complete collapse: string is surrounded
  261. # by [[ ... ]] !
  262. m4_define([_AX_GNU_AUTOTEST_remove_parent],
  263. [m4_bmatch([$1], [./\.\.\(/\|$\)],
  264. [_AX_GNU_AUTOTEST_remove_parent(m4_bpatsubsts([[$1]],
  265. [/[^/]*\([^.]\|[^.]\.\|[^/]\.\.\)/\.\./], [/],
  266. [^\(..\)[^/]*\([^.]\|[^.]\.\|[^/]\.\.\)/\.\./], [\1],
  267. [/[^/]*\([^.]\|[^.]\.\|[^/]\.\.\)/\.\.\(..\)$], [\2],
  268. [^\(..\)[^/]*\([^.]\|[^.]\.\|[^/]\.\.\)/\.\.\(..\)$], [\1.\3]))],
  269. [[$1]])dnl
  270. ])# _AX_GNU_AUTOTEST_remove_parent
  271. # _AX_GNU_AUTOTEST_canonicalize(filename)
  272. # ---------------------------------------
  273. # Canonicalize filename: see below for replacements
  274. # normal input, quoted output!
  275. # replacement: 1st pattern removes runs of /
  276. # 2nd pattern removes runs of ./ from middle
  277. # 3rd pattern removes ./ from beginning: string starts with [[ !
  278. # 4th pattern removes / and /. from end: string ends in ]] !
  279. m4_define([_AX_GNU_AUTOTEST_canonicalize],
  280. [_AX_GNU_AUTOTEST_remove_parent(dnl
  281. m4_bpatsubsts([[$1]],
  282. [//+], [/],
  283. [/\(\./\)+], [/],
  284. [^\(..\)\./], [\1],
  285. [/\.?\(..\)$], [\1]))dnl
  286. ])# _AX_GNU_AUTOTEST_canonicalize
  287. # _AX_GNU_AUTOTEST_check_filename(filename)
  288. # -----------------------------------------
  289. # Checks and warns if filename contains invalid characters
  290. m4_define([_AX_GNU_AUTOTEST_check_filename],
  291. [m4_bmatch([$1],
  292. [\[\|\]], [m4_fatal([Overquoted file name '$1'])],
  293. [,], [m4_fatal([Comma in file name '$1'])],
  294. [:], [m4_fatal([Colon in file name '$1'])],
  295. ['], [m4_fatal([Quote in file name '$1'])],
  296. [ ], [m4_fatal([Whitespace in file name '$1'])])dnl
  297. ])# _AX_GNU_AUTOTEST_check_filename
  298. # _AX_GNU_AUTOTEST_suite_split(suite)
  299. # -----------------------------------
  300. # Convert string [foo:bar] into list [[foo],[bar]] and string [foo] to
  301. # list [[foo],[]]
  302. # Output is quoted
  303. # For the m4_bpatsubst, the string starts and ends with [ ]
  304. m4_define([_AX_GNU_AUTOTEST_suite_split],
  305. [m4_bmatch([$1],
  306. [:], [m4_dquote(m4_bpatsubst([[$1]], [:.*\(.\)$], [\1]),
  307. m4_bpatsubst([[$1]], [^\(.\)[^:]*:], [\1]))],
  308. [m4_dquote([$1], [])])dnl
  309. ])# _AX_GNU_AUTOTEST_suite_split
  310. # _AX_GNU_AUTOTEST_check_suite1(suite, source)
  311. # --------------------------------------------
  312. # Checks both suite and source with _AX_GNU_AUTOTEST_check_filename
  313. m4_define([_AX_GNU_AUTOTEST_check_suite1],
  314. [_AX_GNU_AUTOTEST_check_filename([$1])dnl
  315. _AX_GNU_AUTOTEST_check_filename([$2])dnl
  316. ])# _AX_GNU_AUTOTEST_suite_canon1
  317. # _AX_GNU_AUTOTEST_suite_canon(suite, source)
  318. # -------------------------------------------
  319. # Returns a quoted list of canonicalized suite and source
  320. m4_define([_AX_GNU_AUTOTEST_suite_canon],
  321. [m4_dquote(_AX_GNU_AUTOTEST_canonicalize([$1]),
  322. _AX_GNU_AUTOTEST_canonicalize([$2]))dnl
  323. ])# _AX_GNU_AUTOTEST_suite_canon
  324. # _AX_GNU_AUTOTEST_check_suite2(suite)
  325. # ------------------------------------
  326. # Check for and warn about the presence of a slash (path-separator)
  327. m4_define([_AX_GNU_AUTOTEST_check_suite2],
  328. [m4_bmatch([$1],
  329. [/], [m4_fatal([Path in test suite file name '$1'])])dnl
  330. ])# _AX_GNU_AUTOTEST_check_suite2
  331. # _AX_GNU_AUTOTEST_suite_expand(suite, source)
  332. # --------------------------------------------
  333. # Returns a quoted list of default values: suite defaults to [testsuite] and
  334. # source defaults to suite[.at]
  335. m4_define([_AX_GNU_AUTOTEST_suite_expand],
  336. [m4_dquote(m4_ifblank([$1], [[testsuite]], [[$1]]),
  337. m4_ifblank([$2], [m4_ifblank([$1], [[testsuite.at]], [[$1.at]])],
  338. [[$2]]))dnl
  339. ])# _AX_GNU_AUTOTEST_suite_expand
  340. # _AX_GNU_AUTOTEST_add_suite(dir, [suite, source], gen_package, force)
  341. # --------------------------------------------------------------------
  342. # Add dir/suite to the _AX_GNU_AUTOTEST_suites variable, warning about
  343. # duplicates unless force is non-blank. And add the source and if
  344. # gen_package is true also package.m4 to _AX_GNU_AUTOTEST_suite_srcs
  345. # Global variables used:
  346. # - _AX_GNU_AUTOTEST_suites
  347. # - _AX_GNU_AUTOTEST_suite_srcs
  348. m4_define([_AX_GNU_AUTOTEST_add_suite],
  349. [m4_set_add([_AX_GNU_AUTOTEST_suites], [$1/]m4_car($2), [],
  350. [m4_ifblank([$4], [m4_fatal([Multiple mentions of testsuite ']dnl
  351. [$1/]m4_car($2)['])])])dnl
  352. m4_define([_AX_GNU_AUTOTEST_suite_srcs]m4_dquote([$1/]m4_car($2)),
  353. m4_dquote(m4_unquote(m4_cdr($2))dnl
  354. m4_ifnblank($3, [,[package.m4]])))dnl
  355. ])# _AX_GNU_AUTOTEST_add_suite
  356. # _AX_GNU_AUTOTEST_gen_package(file)
  357. # ----------------------------------
  358. # Generate a package.m4 file if out of date wrt/ configure.am
  359. # TODO: what other dependencies to check?
  360. m4_define([_AX_GNU_AUTOTEST_gen_package],
  361. [m4_if(m4_esyscmd_s([test -f '$1' -a ! '$1' -ot ']__file__['; echo $?]), 1,
  362. [m4_errprintn(m4_location[: generating `$1' ]dnl
  363. m4_esyscmd_s([mkdir -p "`dirname '$1'`" && cat >'$1' <<"EOFpackage.m4"
  364. # Signature of the current package.
  365. m4_define([AT_PACKAGE_NAME],
  366. ]m4_dquote(m4_defn([AC_PACKAGE_NAME]))[)
  367. m4_define([AT_PACKAGE_TARNAME],
  368. ]m4_dquote(m4_defn([AC_PACKAGE_TARNAME]))[)
  369. m4_define([AT_PACKAGE_VERSION],
  370. ]m4_dquote(m4_defn([AC_PACKAGE_VERSION]))[)
  371. m4_define([AT_PACKAGE_STRING],
  372. ]m4_dquote(m4_defn([AC_PACKAGE_STRING]))[)
  373. m4_define([AT_PACKAGE_BUGREPORT],
  374. ]m4_dquote(m4_defn([AC_PACKAGE_BUGREPORT]))[)
  375. m4_define([AT_PACKAGE_URL],
  376. ]m4_dquote(m4_defn([AC_PACKAGE_URL]))[)
  377. EOFpackage.m4]))])dnl
  378. ])# _AX_GNU_AUTOTEST_gen_package
  379. # _AX_GNU_AUTOTEST_gen_suite(dir, [suite, source], package)
  380. # ---------------------------------------------------------
  381. # Generate a testscript file dir/suite if out of date wrt/ dir/source (or
  382. # dir/package.m4 if package-var is non-zero)
  383. m4_define([_AX_GNU_AUTOTEST_gen_suite],
  384. [m4_pushdef([suite], [$1/]m4_car($2))dnl
  385. m4_pushdef([source], [$1/]m4_argn(2, $2))dnl
  386. m4_if(m4_esyscmd_s([test -f ']m4_defn([suite])[' -a ! ']dnl
  387. m4_defn([suite])[' -ot ']m4_defn([source])[']m4_ifnblank($3,
  388. m4_dquote([ -a ! ']m4_defn([suite])[' -ot '$1/package.m4']))dnl
  389. [; echo $?]), 1,
  390. [m4_errprintn(m4_location[: generating `]m4_defn([suite])[' ]dnl
  391. m4_esyscmd_s([mkdir -p '$1' && autom4te --language=autotest -I '$1' -o ']dnl
  392. m4_defn([suite])[' ']m4_defn([source])[']))])dnl
  393. m4_popdef([suite], [source])dnl
  394. ])# _AX_GNU_AUTOTEST_gen_suite
  395. # _AX_GNU_AUTOTEST_dist_suite(dir, [suite, source])
  396. # -------------------------------------------------
  397. # Add dir/suite and dir/source to _AX_GNU_AUTOTEST_dist
  398. # Global variables used:
  399. # - _AX_GNU_AUTOTEST_dist
  400. m4_define([_AX_GNU_AUTOTEST_dist_suite],
  401. [m4_set_add([_AX_GNU_AUTOTEST_dist], [$1/]m4_car($2))dnl
  402. m4_set_add([_AX_GNU_AUTOTEST_dist], [$1/]m4_argn(2, $2))dnl
  403. ])# _AX_GNU_AUTOTEST_dist_suite
  404. # _AX_GNU_AUTOTEST_acsubst_shared()
  405. # ---------------------------------
  406. # Generates rules and Makefile snippets shared between all directories
  407. # shared1 is used for silencing builds and included in all RULES,
  408. # shared2 is used in the DEFAULT substitution
  409. m4_define([_AX_GNU_AUTOTEST_acsubst_shared],
  410. [AC_SUBST([_AX_GNU_AUTOTEST_shared1],
  411. [['AX_GNU_AUTOTEST_V_RUN = $(_AX_GNU_AUTOTEST_v_RUN_$(V))
  412. _AX_GNU_AUTOTEST_v_RUN_ = $(_AX_GNU_AUTOTEST_v_RUN_$(AM_DEFAULT_VERBOSITY))
  413. _AX_GNU_AUTOTEST_v_RUN_0 = @echo " RUN " $<;
  414. AX_GNU_AUTOTEST_V_quiet_flag = $(_AX_GNU_AUTOTEST_v_quiet_flag_$(V))
  415. _AX_GNU_AUTOTEST_v_quiet_flag_ = ]dnl
  416. [$(_AX_GNU_AUTOTEST_v_quiet_flag_$(AM_DEFAULT_VERBOSITY))
  417. _AX_GNU_AUTOTEST_v_quiet_flag_0 = -q # <- Note: trailing whitespace']])dnl
  418. AM_SUBST_NOTMAKE([_AX_GNU_AUTOTEST_shared1])dnl
  419. AC_SUBST([_AX_GNU_AUTOTEST_shared2],
  420. [['check: check-autotest
  421. installcheck: installcheck-autotest
  422. clean: clean-autotest
  423. distclean: distclean-autotest
  424. .PHONY: distclean-autotest
  425. distclean-autotest: clean-autotest']])dnl
  426. AM_SUBST_NOTMAKE([_AX_GNU_AUTOTEST_shared2])dnl
  427. ])# _AX_GNU_AUTOTEST_acsubst_shared
  428. # _AX_GNU_AUTOTEST_cleanname(char, name)
  429. # --------------------------------------
  430. # Output name with all non-alphanumeric characters replaced with char
  431. # Output is quoted
  432. # For the m4_bpatsubsts the string starts and ends in [[ ]] and
  433. # the repetition catches all possible sequences of non-alnum chars
  434. m4_define([_AX_GNU_AUTOTEST_cleanname],
  435. [m4_bpatsubsts([[$2]], [\(..\)[^0-9A-Za-z$1]\(..\)], [\1$1\2],
  436. [\(..\)[^0-9A-Za-z$1]\(..\)], [\1$1\2],
  437. [\(..\)[^0-9A-Za-z$1]\(..\)], [\1$1\2],
  438. [\(..\)[^0-9A-Za-z$1]\(..\)], [\1$1\2],
  439. [\(..\)[^0-9A-Za-z$1]\(..\)], [\1$1\2])dnl
  440. ])# _AX_GNU_AUTOTEST_cleanname
  441. # _AX_GNU_AUTOTEST_substr(str, start, [len])
  442. # ------------------------------------------
  443. # Like m4_substr(), but with quoted output
  444. # For m4_bpatsubst the string starts and ends in [ ]
  445. # TODO: RE repetition does not work, so need to use loops... Why?
  446. # TODO: What about out-of-range start or len
  447. m4_define([_AX_GNU_AUTOTEST_substr],
  448. [m4_pushdef([i])dnl
  449. m4_if($#, 2, [m4_bpatsubst([[$1]], [^\(.\)]m4_if(m4_eval([($2) > 0]), [0],,
  450. [m4_for([i], 0, m4_eval([($2)-1]),,
  451. [[.]])])[\(.*\)], [\1\2])],
  452. [m4_bpatsubst([[$1]], [^\(.\)]m4_if(m4_eval([($2) > 0]), [0],,
  453. [m4_for([i], 0, m4_eval([($2)-1]),,
  454. [[.]])])[\(]m4_if(m4_eval([($3) > 0]), [0],,
  455. [m4_for([i], 0, m4_eval([($3)-1]),,
  456. [[.]])])[\).*\(.\)], [\1\2\3])])dnl
  457. m4_popdef([i])dnl
  458. ])# _AX_GNU_AUTOTEST_substr
  459. # _AX_GNU_AUTOTEST_list_prependc(prefix, arg1, ...)
  460. # -------------------------------------------------
  461. # Returns unquoted list of ,prefixarg1,prefixarg2, ...
  462. # Output starts with a comma if at least one arg
  463. m4_define([_AX_GNU_AUTOTEST_list_prependc],
  464. [m4_pushdef([i])dnl
  465. m4_foreach([i], m4_cdr($@),
  466. [,[$1]m4_defn([i])])dnl
  467. m4_popdef([i])dnl
  468. ])# _AX_GNU_AUTOTEST_list_prependc
  469. # _AX_GNU_AUTOTEST_list_appendc(postfix, arg1, ...)
  470. # -------------------------------------------------
  471. # Returns unquoted list of ,arg1postfix,arg2postfix, ...
  472. # Output starts with a comma if at least one arg
  473. m4_define([_AX_GNU_AUTOTEST_list_appendc],
  474. [m4_pushdef([i])dnl
  475. m4_foreach([i], m4_cdr($@),
  476. [,m4_defn([i])[$1]])dnl
  477. m4_popdef([i])dnl
  478. ])# _AX_GNU_AUTOTEST_list_appendc
  479. # _AX_GNU_AUTOTEST_filter_listc(prefix, arg1, ...)
  480. # ------------------------------------------------
  481. # Returns unquoted list of all args starting with prefix, but the prefix is
  482. # stripped in the output. Output starts with a comma if at least one arg
  483. m4_define([_AX_GNU_AUTOTEST_filter_listc],
  484. [m4_pushdef([n], m4_len([$1]))dnl
  485. m4_pushdef([i])dnl
  486. m4_foreach([i], m4_cdr($@),
  487. [m4_if([$1], _AX_GNU_AUTOTEST_substr(m4_defn([i]), 0, n),
  488. [,_AX_GNU_AUTOTEST_substr(m4_defn([i]), n)])])dnl
  489. m4_popdef([n], [i])dnl
  490. ])# _AX_GNU_AUTOTEST_filter_listc
  491. # _AX_GNU_AUTOTEST_filterout_listc(rx, arg1, ...)
  492. # -----------------------------------------------
  493. # Returns unquoted list of all args not matching regular expression rx
  494. # The arguments are not modified (unlike filter_listc). Output starts with
  495. # a comma if at least one arg
  496. m4_define([_AX_GNU_AUTOTEST_filterout_listc],
  497. [m4_pushdef([i])dnl
  498. m4_foreach([i], m4_cdr($@),
  499. [m4_bmatch(m4_defn([i]), [$1], [], [,m4_defn([i])])])dnl
  500. m4_popdef([i])dnl
  501. ])# _AX_GNU_AUTOTEST_filterout_listc
  502. # _AX_GNU_AUTOTEST_filterpref_listc(prefix, arg1, ...)
  503. # ----------------------------------------------------
  504. # Returns unquoted list of all args that do not start with any of the other
  505. # args followed by the prefix. Output starts with a comma if at least one
  506. # arg. Example:
  507. # filterpref([/], [foo], [foo/bar], [baz/bar])
  508. # => ,[foo],[baz/baz]
  509. # Uses a set variable _AX_GNU_AUTOTEST_filterpref_var, which interferes with
  510. # other variables of the same name elsewhere (pushdef / popdef do not work
  511. # fully for sets).
  512. m4_define([_AX_GNU_AUTOTEST_filterpref_listc],
  513. [m4_pushdef([_AX_GNU_AUTOTEST_filterpref_var])dnl
  514. m4_set_delete([_AX_GNU_AUTOTEST_filterpref_var])dnl
  515. m4_if([$#], [1], [], [m4_set_add_all([_AX_GNU_AUTOTEST_filterpref_var],
  516. m4_unquote(m4_cdr($@)))])dnl
  517. m4_pushdef([i])dnl
  518. m4_pushdef([j])dnl
  519. m4_pushdef([m], m4_len([$1]))dnl
  520. m4_pushdef([n])dnl
  521. m4_foreach([i], m4_cdr($@),
  522. [m4_define([n], m4_eval(m4_defn([m]) + m4_len(m4_defn([i]))))dnl
  523. m4_set_foreach([_AX_GNU_AUTOTEST_filterpref_var], [j],
  524. [m4_if(m4_defn([i])[$1],
  525. _AX_GNU_AUTOTEST_substr(m4_defn([j]), 0, n),
  526. [m4_set_remove([_AX_GNU_AUTOTEST_filterpref_var],
  527. m4_defn([j]))])])])dnl
  528. m4_set_listc([_AX_GNU_AUTOTEST_filterpref_var])dnl
  529. m4_popdef([_AX_GNU_AUTOTEST_filterpref_var], [i], [j], [m], [n])dnl
  530. ])# _AX_GNU_AUTOTEST_filterpref_listc
  531. # _AX_GNU_AUTOTEST_rules_flags(dirsuite, target)
  532. # ----------------------------------------------
  533. # Outputs the list of flag variables for the Makefile rules, specific to
  534. # the suite / dir and target
  535. # Recurses into all parent-directories (parent-first)
  536. # For m4_bpatsubsts the string starts and ends in [[ ]]
  537. m4_define([_AX_GNU_AUTOTEST_rules_flags],
  538. [m4_pushdef([name], _AX_GNU_AUTOTEST_cleanname([_], [$1]))dnl
  539. m4_bmatch([$1], [^\.?$],
  540. [[ $(AX_GNU_AUTOTEST_FLAGS) $(AX_GNU_AUTOTEST_$2_FLAGS)]],
  541. [_AX_GNU_AUTOTEST_rules_flags(m4_bpatsubsts([[$1]],
  542. [^\(..\)[^/]*\(..\)$], [\1\2],
  543. [/[^/]*\(..\)$], [\1]),
  544. [$2])dnl
  545. [ $(AX_GNU_AUTOTEST_FLAGS_]m4_defn([name])[) $(AX_GNU_AUTOTEST_$2_FLAGS_]dnl
  546. m4_defn([name])[)]])dnl
  547. m4_popdef([name])dnl
  548. ])# _AX_GNU_AUTOTEST_rules_flags
  549. # _AX_GNU_AUTOTEST_acsubst_rules_suite_deps(suite, dep1, ...)
  550. # -----------------------------------------------------------
  551. # Generates the three rules for one suite, output as string
  552. # The suite and dependencies are already relative to the source-dir.
  553. # For the m4_bpatsubst, the string starts and ends with [ ]
  554. # The two quotes ('') in AM_V_GEN obviate the need for m4_pattern_allow
  555. m4_define([_AX_GNU_AUTOTEST_acsubst_rules_suite_deps],
  556. [m4_pushdef([name], _AX_GNU_AUTOTEST_cleanname([-], [$1]))dnl
  557. m4_pushdef([atconf], [atconfig])dnl
  558. m4_bmatch([$1],
  559. [/], [m4_define([atconf], m4_bpatsubst([[$1]], [/[^/]*\(.\)$],
  560. [/atconfig\1]))])dnl
  561. m4_pushdef([cdir])dnl
  562. m4_bmatch([$1],
  563. [/], [m4_define([cdir], [ -C ]m4_bpatsubst([[$1]], [/[^/]*\(.\)$],
  564. [\1]))])dnl
  565. m4_dquote([$(srcdir)/$1: $(top_srcdir)/]__file__[]dnl
  566. m4_mapall([[ $(srcdir)/]m4_quote], m4_cdr($@))[
  567. $(A''M_V_GEN)cd $(top_srcdir) && $(AUTOCONF) -f
  568. ]m4_defn([atconf])[:
  569. $(A''M_V_GEN)cd $(top_builddir) && $(SHELL) ./config.status ]dnl
  570. $(AX_GNU_AUTOTEST_V_quiet_flag)[$][@
  571. check-autotest-]m4_defn([name])[: $(srcdir)/$1 ]m4_defn([atconf])[
  572. $(AX_GNU_AUTOTEST_V_RUN)$(SHELL) $(srcdir)/$1]m4_defn([cdir])dnl
  573. _AX_GNU_AUTOTEST_rules_flags([$1], [CHECK])[
  574. installcheck-autotest-]m4_defn([name])[: $(srcdir)/$1 ]m4_defn([atconf])[
  575. $(AX_GNU_AUTOTEST_V_RUN)$(SHELL) $(srcdir)/$1]m4_defn([cdir])dnl
  576. [ AUTOTEST_PATH=$(DESTDIR)$(bindir)]dnl
  577. _AX_GNU_AUTOTEST_rules_flags([$1], [INSTALLCHECK])[
  578. clean-autotest-]m4_defn([name])[: $(srcdir)/$1
  579. -$(SHELL) $(srcdir)/$1]m4_defn([cdir])[ -c
  580. ])dnl
  581. m4_popdef([name], [atconf], [cdir])dnl
  582. ])# _AX_GNU_AUTOTEST_acsubst_rules_suite_deps
  583. # _AX_GNU_AUTOTEST_acsubst_rules_suite(dir, suite)
  584. # ------------------------------------------------
  585. # Generates the three rules for one suite, output as string
  586. # The suite is supplied still containing the dir prefix.
  587. # Global variables used:
  588. # - _AX_GNU_AUTOTEST_suite_srcs
  589. m4_define([_AX_GNU_AUTOTEST_acsubst_rules_suite],
  590. [m4_pushdef([suite], [$2])dnl
  591. m4_ifnblank([$1], [m4_define([suite], m4_unquote(m4_cdr(dnl
  592. _AX_GNU_AUTOTEST_filter_listc([$1/], [$2]))))])dnl
  593. m4_pushdef([sdir])dnl
  594. m4_bmatch([$2], [/], [m4_define([sdir],
  595. m4_bpatsubst([[$2]], [/[^/]*\(.\)$], [\1]))])dnl
  596. m4_pushdef([deps], m4_dquote(,
  597. m4_unquote(m4_defn([_AX_GNU_AUTOTEST_suite_srcs[$2]]))))dnl
  598. m4_ifnblank(m4_defn([sdir]), [m4_define([deps], m4_dquote(dnl
  599. _AX_GNU_AUTOTEST_list_prependc(m4_defn([sdir])[/]deps)))])dnl
  600. m4_ifnblank([$1], [m4_define([deps],
  601. m4_dquote(_AX_GNU_AUTOTEST_filter_listc([$1/]deps)))])dnl
  602. _AX_GNU_AUTOTEST_acsubst_rules_suite_deps(m4_defn([suite])deps)dnl
  603. m4_popdef([deps], [sdir], [suite])dnl
  604. ])# _AX_GNU_AUTOTEST_acsubst_rules_suite
  605. # _AX_GNU_AUTOTEST_acsubst_rules_dir(base, dir)
  606. # ---------------------------------------------
  607. # Generates the dependency rules for one directory relative to base, output
  608. # as string
  609. # For the m4_bpatsubst, the string starts and ends with [ ]
  610. # Global variables used:
  611. # - _AX_GNU_AUTOTEST_suites
  612. # - _AX_GNU_AUTOTEST_testdirs
  613. m4_define([_AX_GNU_AUTOTEST_acsubst_rules_dir],
  614. [m4_pushdef([name])dnl
  615. m4_ifnblank([$2],
  616. [m4_define([name], [-]_AX_GNU_AUTOTEST_cleanname([-], [$2]))])dnl
  617. m4_pushdef([suites], m4_dquote(m4_set_listc([_AX_GNU_AUTOTEST_suites])))dnl
  618. m4_ifnblank([$1], [m4_define([suites], m4_dquote(dnl
  619. _AX_GNU_AUTOTEST_filter_listc([$1/]suites)))])dnl
  620. m4_ifblank([$2], [m4_define([suites], m4_dquote(dnl
  621. _AX_GNU_AUTOTEST_filterout_listc([/]suites)))],
  622. [m4_define([suites], m4_dquote(dnl
  623. _AX_GNU_AUTOTEST_list_prependc([$2/]dnl
  624. _AX_GNU_AUTOTEST_filterout_listc([/]dnl
  625. _AX_GNU_AUTOTEST_filter_listc([$2/]suites)))))])dnl
  626. m4_pushdef([testdirs], m4_dquote(m4_set_listc(dnl
  627. [_AX_GNU_AUTOTEST_testdirs])))dnl
  628. m4_ifnblank([$1], [m4_define([testdirs], m4_dquote(dnl
  629. _AX_GNU_AUTOTEST_filter_listc([$1/]testdirs)))])dnl
  630. m4_ifblank([$2], [m4_define([testdirs], m4_dquote(dnl
  631. _AX_GNU_AUTOTEST_filterpref_listc([/]testdirs)))],
  632. [m4_define([testdirs], m4_dquote(dnl
  633. _AX_GNU_AUTOTEST_list_prependc([$2/]dnl
  634. _AX_GNU_AUTOTEST_filterpref_listc([/]dnl
  635. _AX_GNU_AUTOTEST_filter_listc([$2/]testdirs)))))])dnl
  636. m4_pushdef([deps], m4_quote(m4_cdr(testdirs[]suites)))dnl
  637. m4_define([deps], m4_dquote(m4_mapall_sep(dnl
  638. [[-autotest-]m4_curry([_AX_GNU_AUTOTEST_cleanname], [-])], [,],
  639. m4_defn([deps]))))dnl
  640. m4_dquote([check-autotest]m4_defn([name])[:]m4_mapall([[ check]m4_quote],
  641. m4_defn([deps]))[
  642. installcheck-autotest]m4_defn([name])[:]m4_mapall([[ installcheck]m4_quote],
  643. m4_defn([deps]))[
  644. clean-autotest]m4_defn([name])[:]m4_mapall([[ clean]m4_quote],
  645. m4_defn([deps]))[
  646. ])dnl
  647. m4_popdef([deps], [name], [suites], [testdirs])dnl
  648. ])# _AX_GNU_AUTOTEST_acsubst_rules_dir
  649. # _AX_GNU_AUTOTEST_acsubst_rules_phony(element)
  650. # ---------------------------------------------
  651. # Generates the names of the three targets for one element as string
  652. m4_define([_AX_GNU_AUTOTEST_acsubst_rules_phony],
  653. [m4_pushdef([name])dnl
  654. m4_ifnblank([$1], [m4_define([name],
  655. _AX_GNU_AUTOTEST_cleanname([-], [-$1]))])dnl
  656. m4_dquote([ check-autotest]m4_defn([name])dnl
  657. [ installcheck-autotest]m4_defn([name])dnl
  658. [ clean-autotest]m4_defn([name]))dnl
  659. m4_popdef([name])dnl
  660. ])# _AX_GNU_AUTOTEST_acsubst_rules_phony
  661. # _AX_GNU_AUTOTEST_acsubst_rules_one(name, dir)
  662. # ---------------------------------------------
  663. # AC_SUBSTs one variable called "name" to contain the rules for all suites
  664. # in or below dir
  665. # Global variables used:
  666. # - _AX_GNU_AUTOTEST_suites
  667. # - _AX_GNU_AUTOTEST_testdirs
  668. m4_define([_AX_GNU_AUTOTEST_acsubst_rules_one],
  669. [m4_pushdef([suites])dnl
  670. m4_ifblank([$2], [m4_define([suites], m4_dquote(dnl
  671. m4_set_listc([_AX_GNU_AUTOTEST_suites])))],
  672. [m4_define([suites], m4_dquote(dnl
  673. _AX_GNU_AUTOTEST_list_prependc([$2/]dnl
  674. _AX_GNU_AUTOTEST_filter_listc([$2/]dnl
  675. m4_set_listc([_AX_GNU_AUTOTEST_suites])))))])dnl
  676. m4_pushdef([testdirs])dnl
  677. m4_ifblank([$2], [m4_define([testdirs], m4_dquote([],
  678. m4_set_listc([_AX_GNU_AUTOTEST_testdirs])))],
  679. [m4_define([testdirs], m4_dquote([],
  680. _AX_GNU_AUTOTEST_filter_listc([$2/]dnl
  681. m4_set_listc([_AX_GNU_AUTOTEST_testdirs]))))])dnl
  682. AC_SUBST([$1],
  683. [["${_AX_GNU_AUTOTEST_shared1}"'
  684. ]]m4_map_args([m4_curry([_AX_GNU_AUTOTEST_acsubst_rules_suite],
  685. [$2])]suites)dnl
  686. m4_map_args([m4_curry([_AX_GNU_AUTOTEST_acsubst_rules_dir], [$2])]testdirs)dnl
  687. [[.PHONY:]]m4_map_args_sep([_AX_GNU_AUTOTEST_acsubst_rules_phony(], [)], [\
  688. ]testdirs[]suites)[[']])dnl
  689. AM_SUBST_NOTMAKE([$1])dnl
  690. m4_popdef([suites], [testdirs])dnl
  691. ])# _AX_GNU_AUTOTEST_acsubst_rules_one
  692. # _AX_GNU_AUTOTEST_acsubst_rules(dir)
  693. # -----------------------------------
  694. # AC_SUBSTs the rules variable for dir and recurses for all parent-dirs
  695. # Recurses into all parent-directories
  696. # For m4_bpatsubsts the string starts and ends in [[ ]]
  697. m4_define([_AX_GNU_AUTOTEST_acsubst_rules],
  698. [m4_bmatch([$1], [^\.?$],
  699. [_AX_GNU_AUTOTEST_acsubst_rules_one([AX_GNU_AUTOTEST_RULES],
  700. [])],
  701. [_AX_GNU_AUTOTEST_acsubst_rules_one(dnl
  702. [AX_GNU_AUTOTEST_RULES_]_AX_GNU_AUTOTEST_cleanname([_], [$1]), [$1])dnl
  703. _AX_GNU_AUTOTEST_acsubst_rules(m4_bpatsubsts([[$1]], [^\(..\)[^/]*\(..\)$],
  704. [\1\2], [/[^/]*\(..\)$], [\1]))])dnl
  705. ])# _AX_GNU_AUTOTEST_acsubst_rules
  706. # _AX_GNU_AUTOTEST_acsubst_list(name, arg1, ...)
  707. # ----------------------------------------------
  708. # AC_SUBSTs the name variable to contain all arg1, ...
  709. m4_define([_AX_GNU_AUTOTEST_acsubst_list],
  710. [AC_SUBST([$1], [[']]m4_dquote(m4_mapall_sep([m4_quote], [[\
  711. ]], m4_dquote(m4_dquote_elt(m4_unquote(m4_cdr($@))))))[[']])dnl
  712. AM_SUBST_NOTMAKE([$1])dnl
  713. ])# _AX_GNU_AUTOTEST_acsubst_list
  714. # _AX_GNU_AUTOTEST_acsubst_dclean(dir)
  715. # ------------------------------------
  716. # AC_SUBSTs the dclean variable for dir and recurses for all parent-dirs
  717. # Global variables used:
  718. # - _AX_GNU_AUTOTEST_testdirs
  719. # Recurses into all parent-directories
  720. # For m4_bpatsubsts the string starts and ends in [[ ]]
  721. m4_define([_AX_GNU_AUTOTEST_acsubst_dclean],
  722. [m4_bmatch([$1], [^\.?$],
  723. [_AX_GNU_AUTOTEST_acsubst_list([AX_GNU_AUTOTEST_DCLEAN]dnl
  724. _AX_GNU_AUTOTEST_list_appendc([/atconfig]dnl
  725. m4_set_listc([_AX_GNU_AUTOTEST_testdirs])))],
  726. [_AX_GNU_AUTOTEST_acsubst_list(dnl
  727. [AX_GNU_AUTOTEST_DCLEAN_]_AX_GNU_AUTOTEST_cleanname([_], [$1])dnl
  728. _AX_GNU_AUTOTEST_filter_listc([$1/]dnl
  729. _AX_GNU_AUTOTEST_list_appendc([/atconfig]dnl
  730. m4_set_listc([_AX_GNU_AUTOTEST_testdirs]))))dnl
  731. _AX_GNU_AUTOTEST_acsubst_dclean(m4_bpatsubsts([[$1]], [^\(..\)[^/]*\(..\)$],
  732. [\1\2], [/[^/]*\(..\)$], [\1]))])dnl
  733. ])# _AX_GNU_AUTOTEST_acsubst_dclean
  734. # _AX_GNU_AUTOTEST_acsubst_dist(dir)
  735. # ----------------------------------
  736. # AC_SUBSTs the dist variable for dir and recurses for all parent-dirs
  737. # Global variables used:
  738. # - _AX_GNU_AUTOTEST_dist
  739. # Recurses into all parent-directories
  740. # For m4_bpatsubsts the string starts and ends in [[ ]]
  741. m4_define([_AX_GNU_AUTOTEST_acsubst_dist],
  742. [m4_bmatch([$1], [^\.?$],
  743. [_AX_GNU_AUTOTEST_acsubst_list([AX_GNU_AUTOTEST_DIST]dnl
  744. m4_set_listc([_AX_GNU_AUTOTEST_dist]))],
  745. [_AX_GNU_AUTOTEST_acsubst_list(dnl
  746. [AX_GNU_AUTOTEST_DIST_]_AX_GNU_AUTOTEST_cleanname([_], [$1])dnl
  747. _AX_GNU_AUTOTEST_filter_listc([$1/]m4_set_listc([_AX_GNU_AUTOTEST_dist])))dnl
  748. _AX_GNU_AUTOTEST_acsubst_dist(m4_bpatsubsts([[$1]], [^\(..\)[^/]*\(..\)$],
  749. [\1\2], [/[^/]*\(..\)$], [\1]))])dnl
  750. ])# _AX_GNU_AUTOTEST_acsubst_dist
  751. # _AX_GNU_AUTOTEST_acsubst_default(dir)
  752. # -------------------------------------
  753. # AC_SUBSTs the rules of the "default" use-case for dir and recurses for
  754. # all parent-dirs
  755. # Recurses into all parent-directories
  756. # For m4_bpatsubsts the string starts and ends in [[ ]]
  757. m4_define([_AX_GNU_AUTOTEST_acsubst_default],
  758. [m4_pushdef([name])dnl
  759. m4_bmatch([$1], [^\.?$], [],
  760. [m4_define([name], [_]_AX_GNU_AUTOTEST_cleanname([_], [$1]))])dnl
  761. AC_SUBST([AX_GNU_AUTOTEST_DEFAULT]m4_defn([name]),
  762. [["${AX_GNU_AUTOTEST_RULES]m4_defn([name])[}
  763. ${_AX_GNU_AUTOTEST_shared2}"'
  764. -rm -f '"${AX_GNU_AUTOTEST_DCLEAN]m4_defn([name])[}"'
  765. EXTRA_DIST += '"${AX_GNU_AUTOTEST_DIST]m4_defn([name])[}"]])dnl
  766. AM_SUBST_NOTMAKE([AX_GNU_AUTOTEST_DEFAULT]m4_defn([name]))dnl
  767. m4_popdef([name])dnl
  768. m4_bmatch([$1], [^\.?$], [],
  769. [_AX_GNU_AUTOTEST_acsubst_default(m4_bpatsubsts([[$1]],
  770. [^\(..\)[^/]*\(..\)$], [\1\2], [/[^/]*\(..\)$], [\1]))])dnl
  771. ])# _AX_GNU_AUTOTEST_acsubst_default
  772. # AX_GNU_AUTOTEST([testdir = `tests'], [testsuites = `testsuite'],
  773. # [atlocal-sources = `'], [gen-package = `yes'],
  774. # [force = `no'])
  775. # ----------------------------------------------------------------
  776. # Global variables used:
  777. # - _AX_GNU_AUTOTEST_testdirs
  778. # - _AX_GNU_AUTOTEST_suites
  779. # - _AX_GNU_AUTOTEST_suite_srcs
  780. # - _AX_GNU_AUTOTEST_dist
  781. AC_DEFUN([AX_GNU_AUTOTEST],
  782. [dnl Check command arguments
  783. dnl Check $5: force
  784. m4_pushdef([force], m4_normalize([$5]))dnl
  785. m4_bmatch(m4_defn([force]), [^\([Nn][Oo]?\|0\)$], [m4_define([force], [])])dnl
  786. m4_ifnblank(m4_defn([force]), [m4_define([force], 1)])dnl
  787. dnl
  788. dnl Check $1: testdir
  789. m4_pushdef([testdir], m4_normalize([$1]))dnl
  790. m4_ifblank(m4_defn([testdir]), [m4_define([testdir], [tests])])dnl
  791. m4_ifblank(force, [_AX_GNU_AUTOTEST_check_filename(m4_defn([testdir]))])dnl
  792. m4_define([testdir], _AX_GNU_AUTOTEST_canonicalize(m4_defn([testdir])))dnl
  793. m4_set_add([_AX_GNU_AUTOTEST_testdirs], m4_defn([testdir]), [],
  794. [m4_ifblank(force,
  795. [m4_fatal([Already configured directory ']m4_defn([testdir])['])])])dnl
  796. dnl
  797. dnl Check $4: gen-package
  798. m4_pushdef([gen_package], m4_normalize([$4]))dnl
  799. m4_ifblank(m4_defn([gen_package]), [m4_define([gen_package], [yes])])dnl
  800. m4_bmatch(m4_defn([gen_package]),
  801. [^\([Nn][Oo]?\|0\)$], [m4_define([gen_package], [])])dnl
  802. m4_ifnblank(m4_defn([gen_package]), [m4_define([gen_package], 1)])dnl
  803. dnl
  804. dnl Check $2: testsuites
  805. m4_pushdef([testsuites], m4_normalize([$2]))dnl
  806. m4_ifblank(m4_defn([testsuites]), [m4_define([testsuites], [testsuite])])dnl
  807. m4_define([testsuites], m4_dquote(m4_map_args_w(m4_defn([testsuites]),
  808. [_AX_GNU_AUTOTEST_suite_split(], [)], [,])))dnl
  809. m4_ifblank(force, [m4_map([_AX_GNU_AUTOTEST_check_suite1],
  810. m4_defn([testsuites]))])dnl
  811. m4_define([testsuites], m4_dquote(m4_map_sep([_AX_GNU_AUTOTEST_suite_canon],
  812. [,], m4_defn([testsuites]))))dnl
  813. m4_ifblank(force, [m4_map([_AX_GNU_AUTOTEST_check_suite2],
  814. m4_defn([testsuites]))])dnl
  815. m4_define([testsuites], m4_dquote(m4_map_sep([_AX_GNU_AUTOTEST_suite_expand],
  816. [,], m4_defn([testsuites]))))dnl
  817. m4_map_args_sep([_AX_GNU_AUTOTEST_add_suite(]m4_quote(m4_defn([testdir]))[,],
  818. [,]m4_defn([gen_package])[,]m4_defn([force])[)], [],
  819. testsuites)dnl
  820. dnl
  821. dnl Check $3: atlocal-sources
  822. m4_pushdef([atlocal_sources], m4_normalize(m4_bpatsubst([[$3]], [:], [ ])))dnl
  823. m4_define([atlocal_sources], m4_split(m4_defn([atlocal_sources]), [ ]))dnl
  824. m4_ifnblank(m4_defn([atlocal_sources]), [m4_define([atlocal_sources],
  825. m4_dquote(m4_map_args_sep([_AX_GNU_AUTOTEST_canonicalize(],
  826. [)], [,], atlocal_sources)))])dnl
  827. m4_ifblank(force, [m4_map_args([_AX_GNU_AUTOTEST_check_filename],
  828. atlocal_sources)])dnl
  829. dnl
  830. dnl Phase 1
  831. m4_ifnblank(gen_package,
  832. [_AX_GNU_AUTOTEST_gen_package(m4_defn([testdir])[/package.m4])dnl
  833. m4_set_add([_AX_GNU_AUTOTEST_dist], m4_defn([testdir])[/package.m4])dnl
  834. ])dnl
  835. m4_map_args_sep([_AX_GNU_AUTOTEST_gen_suite([]m4_defn([testdir])[],],
  836. [,]gen_package[)], [], testsuites)dnl
  837. m4_map_args_sep([_AX_GNU_AUTOTEST_dist_suite([]m4_defn([testdir])[],],
  838. [)], [], testsuites)dnl
  839. dnl
  840. dnl Phase 2
  841. dnl The following commands fail for quotes in testdir
  842. AC_CONFIG_TESTDIR(m4_dquote(m4_defn([testdir])))dnl
  843. m4_ifnblank(m4_defn([atlocal_sources]), [AC_CONFIG_FILES(dnl
  844. m4_defn([testdir])[/atlocal:]m4_map_args_sep(m4_defn([testdir])[/],
  845. [], [:], atlocal_sources))])dnl
  846. dnl
  847. dnl Phase 3
  848. _AX_GNU_AUTOTEST_acsubst_shared()dnl
  849. _AX_GNU_AUTOTEST_acsubst_rules(m4_defn([testdir]))dnl
  850. _AX_GNU_AUTOTEST_acsubst_dclean(m4_defn([testdir]))dnl
  851. _AX_GNU_AUTOTEST_acsubst_dist(m4_defn([testdir]))dnl
  852. _AX_GNU_AUTOTEST_acsubst_default(m4_defn([testdir]))dnl
  853. dnl
  854. m4_popdef([testdir], [testsuites], [atlocal_sources], [gen_package],
  855. [force])dnl
  856. ])# AX_GNU_AUTOTEST