+
+AT_SETUP([GOB2_CHECK min-version test])
+
+AT_DATA([configure.ac],
+[[AC_PREREQ([2.62])
+AC_INIT([test], [0])
+AC_OUTPUT
+]])
+AT_CHECK([$AUTOCONF && test -f configure || exit 77], [0], [ignore], [ignore])
+
+m4_define([MYVER],
+ m4_bpatsubst(m4_dquote(m4_defn([AT_PACKAGE_VERSION])), [[^][0-9.]]))
+m4_if(m4_defn([MYVER]), m4_defn([AT_PACKAGE_VERSION]), [], [AT_XFAIL_IF([:])])
+
+m4_define([MYVER_P1], m4_dquote(m4_reverse(m4_unquote(
+ m4_split(m4_defn([MYVER]), [[.]])))))
+m4_define([MYVER_P1], m4_join([.], m4_reverse(
+ m4_eval(m4_car(MYVER_P1)+1), m4_shift(MYVER_P1))))
+
+AT_DATA([test.in], [[@GOB2@
+]])
+
+cat >configure.ac <<EOF
+[m4@&t@_include([$srcdir/gob2.m4])]
+[m4@&t@_pattern_forbid([^GOB2_])]
+[AC_INIT([gob2_check], [0])]
+[GOB2_CHECK(]m4_dquote(m4_defn([MYVER]))[)]
+GOB2=\`command -v \$GOB2\`
+[AC_CONFIG_FILES([test])]
+[AC_OUTPUT]
+EOF
+AT_CHECK([$AUTOCONF --force])
+AT_CHECK([./configure], [0], [ignore])
+
+command -v gob2 >expout
+AT_CHECK([cat test], [0], [expout], [ignore])
+
+sed '/GOB2_CHECK/c\
+[GOB2_CHECK(]m4_dquote(m4_defn([MYVER_P1]))[)]' configure.ac >configure.new
+mv -f configure.new configure.ac
+AT_CHECK([$AUTOCONF --force])
+AT_CHECK([./configure], [1], [ignore], [ignore])
+
+AT_CLEANUP