]> git.draconx.ca Git - dxcommon.git/blob - m4/autotest.m4
DX_C_ALIGNAS: Work around bash-5 parsing bug.
[dxcommon.git] / m4 / autotest.m4
1 # Copyright © 2015, 2021, 2023 Nick Bowler
2 #
3 # Macro to find an working autotest installation.
4 #
5 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
6 # This is free software: you are free to do what the fuck you want to.
7 # There is NO WARRANTY, to the extent permitted by law.
8
9 # DX_PROG_AUTOTEST
10 #
11 # Determine a command which works to compile Autotest testsuites.
12 #
13 # If found, the AUTOTEST variable (which is substituted by AC_SUBST)
14 # is set with the result, and the cache variable dx_cv_autotest_works
15 # is set to "yes".  Otherwise, dx_cv_autotest_works is set to "no".
16 AC_DEFUN_ONCE([DX_PROG_AUTOTEST],
17 [AC_ARG_VAR([AUTOTEST], [command to compile Autotest testsuites])dnl
18 _DX_PROG_AUTOTEST
19 AS_IF([$dx_cv_autotest_found],
20   [AC_CACHE_CHECK([whether $AUTOTEST works],
21     [dx_cv_autotest_works], [_DX_PROG_AUTOTEST_CHECK])])])
22
23 # DX_PROG_AUTOTEST_AM
24 #
25 # Like DX_PROG_AUTOTEST, but also define various additional things
26 # needed to use the autotest.mk snippet.
27 AC_DEFUN_ONCE([DX_PROG_AUTOTEST_AM],
28 [AC_REQUIRE([DX_PROG_AUTOTEST])AC_REQUIRE([DX_AUTOMAKE_COMPAT])dnl
29 AM_CONDITIONAL([HAVE_AUTOTEST], [test x"$dx_cv_autotest_works" = xyes])])
30
31 m4_define([_DX_PROG_AUTOTEST],
32 [AC_CACHE_CHECK([for autotest], [dx_cv_autotest_cmd],
33 [dx_cv_autotest_found=false
34 AS_VAR_SET_IF([AUTOTEST],
35   [dx_cv_autotest_cmd=$AUTOTEST dx_cv_autotest_found=:],
36 [for dx_cv_autotest_cmd
37 in ${AUTOM4TE:+"$AUTOM4TE -l autotest"} "autom4te -l autotest"
38 do
39   _DX_PROG_AUTOTEST_CHECK([dx_cv_autotest_found=:; break])
40 done])
41 $dx_cv_autotest_found || dx_cv_autotest_cmd=no])
42 $dx_cv_autotest_found && AUTOTEST=$dx_cv_autotest_cmd])
43
44 m4_define([_DX_PROG_AUTOTEST_CHECK],
45 [cat >conftest.at <<'EOF'
46 [m4@&t@_define([AT_PACKAGE_STRING], [mypackage])]
47 [m4@&t@_define([AT_PACKAGE_BUGREPORT], [nobody])]
48 AT_INIT
49 EOF
50 dx_cv_autotest_works=no
51 AS_IF(
52   [DX_RUN_LOG([$dx_cv_autotest_cmd conftest.at >conftest.sh &&
53     $SHELL conftest.sh --version >conftest.out &&
54       grep '[(]mypackage[)]' conftest.out >/dev/null 2>&1])],
55   [dx_cv_autotest_works=yes])
56 rm -f conftest.at conftest.sh conftest.out[]m4_ifnblank([$1], [
57 AS_CASE([$dx_cv_autotest_works], [yes], [$1])])])