-# Gettext.
-AM_GNU_GETTEXT(external, need-ngettext)
-AM_GNU_GETTEXT_VERSION(0.11.5)
+# gnulib and gettext.
+GNULIB_AUTOCONF_SNIPPET
+# We use po/Makevars.template, so we need at least gettext 0.12.
+AM_GNU_GETTEXT_VERSION([0.12])
+
+# Initialize the test suite.
+AC_CONFIG_TESTDIR(tests)
+AC_CONFIG_FILES([tests/Makefile tests/atlocal])
+AC_CONFIG_FILES([tests/bison], [chmod +x tests/bison])
+AC_CHECK_PROGS([VALGRIND], [valgrind])
+AC_PROG_CXX
+BISON_TEST_FOR_WORKING_CXX_COMPILER
+AM_MISSING_PROG([AUTOM4TE], [autom4te])
+# Needed by tests/atlocal.in.
+AC_SUBST([GCC])
+O0CFLAGS=`echo $CFLAGS | sed 's/-O[0-9] *//'`
+AC_SUBST([O0CFLAGS])
+O0CXXFLAGS=`echo $CXXFLAGS | sed 's/-O[0-9] *//'`
+AC_SUBST([O0CXXFLAGS])