X-Git-Url: https://git.draconx.ca/gitweb/dxcommon.git/blobdiff_plain/ed04bed43efece46d2b476fbb0260f1d1b8aa1fe..6405aa895740d960d6f6e70976eeb44bd403f952:/tests/macros.at diff --git a/tests/macros.at b/tests/macros.at index a085ad6..9aadd03 100644 --- a/tests/macros.at +++ b/tests/macros.at @@ -1,4 +1,4 @@ -dnl Copyright © 2014-2015, 2018-2019, 2021-2022 Nick Bowler +dnl Copyright © 2014-2015, 2018-2019, 2021-2023 Nick Bowler dnl dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2. dnl This is free software: you are free to do what the fuck you want to. @@ -597,3 +597,80 @@ done exit 1]) AT_CLEANUP + +# TEST_FIND_AUTOCONF_VER([to-check], [test-action]) +# +# For each whitespace-separated version token in to-check, check if we can +# run program autoconf-VER. The special token 'default' also checks the +# unversioned autoconf (or, if set in the environment, $AUTOCONF). +# +# Then test-action is expanded such that the shell variable $ac refers +# to the autoconf program, and $acver is the actual version reported by +# $ac --version. The action should do nothing if the version is acceptable, +# or "continue" if the version is unacceptable. +# +# If an acceptable version is found, the AUTOCONF environment variable is +# set accordingly. Otherwise, the test group is skipped. +m4_define([TEST_FIND_AUTOCONF], +[have_ac=false +for ac in $1; do + AS_CASE([$ac], [default], [ac=${AUTOCONF-autoconf}], [ac=autoconf-$ac]) + acver=`$ac --version | sed -n '1s/.* //p'` + set x $acver; test x"$[#]" = x"2" || continue + $2 + have_ac=:; break +done +AT_CHECK([$have_ac || exit 77]) +AUTOCONF=$ac; export AUTOCONF +AT_CHECK([$AUTOCONF --version], [0], [ignore]) +]) + +m4_define([TEST_DX_C_FOR_DECLARATIONS], +[cat "$srcdir/m4/fordecl.m4" >aclocal.m4 +AT_DATA([config.h.in], +[[#undef HAVE_FOR_DECLS +]]) +TEST_CONFIGURE_AC([m4_ifnblank([$1], [$1]) +[AC_CONFIG_HEADERS([config.h]) +DX_C_FOR_DECLARATIONS +]]) +AT_CHECK([$AUTOCONF], [0], [], [stderr]) +AT_DATA([test.c], +[[#if __STDC_VERSION__ < 199901 +#error nope +char nope[-1]; +#endif +char yup; +]]) +AT_CHECK([$CC -c -std=gnu99 test.c || exit 77], [0], [ignore], [ignore]) +TEST_CONFIGURE([CC="$CC" CFLAGS="-std=gnu89"]) +AT_CHECK([grep HAVE_FOR_DECLS config.h], [0], +[[/* #undef HAVE_FOR_DECLS */ +]]) +TEST_CONFIGURE([CC="$CC -std=gnu99"]) +AT_CHECK([grep HAVE_FOR_DECLS config.h], [0], +[[#define HAVE_FOR_DECLS 1 +]]) +]) + +AT_SETUP([DX_C_FOR_DECLARATIONS (autoconf-2.70)]) +AT_KEYWORDS([DX_C_FOR_DECLARATIONS macro]) +TEST_FIND_AUTOCONF([default 2.71 2.72 2.73 2.74], + [AS_VERSION_COMPARE(["$acver"], [2.70], [continue], [continue], [])]) +TEST_DX_C_FOR_DECLARATIONS +AT_CLEANUP