1 # Macro to find an working autotest installation.
3 # Copyright © 2015, 2021, 2023-2024 Nick Bowler
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <https://www.gnu.org/licenses/>.
20 # Determine a command which works to compile Autotest testsuites.
22 # If found, the AUTOTEST variable (which is substituted by AC_SUBST)
23 # is set with the result, and the cache variable dx_cv_autotest_works
24 # is set to "yes". Otherwise, dx_cv_autotest_works is set to "no".
25 AC_DEFUN_ONCE([DX_PROG_AUTOTEST],
26 [AC_ARG_VAR([AUTOTEST], [command to compile Autotest testsuites])dnl
28 AS_IF([$dx_cv_autotest_found],
29 [AC_CACHE_CHECK([whether $AUTOTEST works],
30 [dx_cv_autotest_works], [_DX_PROG_AUTOTEST_CHECK])])])
34 # Like DX_PROG_AUTOTEST, but also define various additional things
35 # needed to use the autotest.mk snippet.
36 AC_DEFUN_ONCE([DX_PROG_AUTOTEST_AM],
37 [AC_REQUIRE([DX_PROG_AUTOTEST])AC_REQUIRE([DX_AUTOMAKE_COMPAT])dnl
38 AM_CONDITIONAL([HAVE_AUTOTEST], [test x"$dx_cv_autotest_works" = xyes])])
40 m4_define([_DX_PROG_AUTOTEST],
41 [AC_CACHE_CHECK([for autotest], [dx_cv_autotest_cmd],
42 [dx_cv_autotest_found=false
43 AS_VAR_SET_IF([AUTOTEST],
44 [dx_cv_autotest_cmd=$AUTOTEST dx_cv_autotest_found=:],
45 [for dx_cv_autotest_cmd
46 in ${AUTOM4TE:+"$AUTOM4TE -l autotest"} "autom4te -l autotest"
48 _DX_PROG_AUTOTEST_CHECK([dx_cv_autotest_found=:; break])
50 $dx_cv_autotest_found || dx_cv_autotest_cmd=no])
51 $dx_cv_autotest_found && AUTOTEST=$dx_cv_autotest_cmd])
53 m4_define([_DX_PROG_AUTOTEST_CHECK],
54 [cat >conftest.at <<'EOF'
55 [m4@&t@_define([AT_PACKAGE_STRING], [mypackage])]
56 [m4@&t@_define([AT_PACKAGE_BUGREPORT], [nobody])]
62 dx_cv_autotest_works=no
64 [DX_RUN_LOG([$dx_cv_autotest_cmd conftest.at >conftest.sh &&
65 $SHELL conftest.sh --version >conftest.out &&
66 grep '[(]mypackage[)]' conftest.out >/dev/null 2>&1])],
67 [dx_cv_autotest_works=yes])
68 rm -f conftest.at conftest.sh conftest.out[]m4_ifnblank([$1], [
69 AS_CASE([$dx_cv_autotest_works], [yes], [$1])])])