#! /bin/sh
-# Copyright (C) 2012 Free Software Foundation, Inc.
+# Copyright (C) 2012-2013 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
am_create_testdir=empty
. test-init.sh
-{ $AUTOCONF -o /dev/null - <<END
- AC_INIT([x], [0])
- AC_CONFIG_MACRO_DIRS([.])
-END
-} || skip_all_ "autoconf doesn't define the AC_CONFIG_MACRO_DIRS macro"
-
-plan_ 14
+plan_ 15
ocwd=$(pwd) || fatal_ "getting current working directory"
-ACLOCAL_PATH=; unset ACLOCAL_PATH
+unset ACLOCAL_PATH
#
# General utility functions and variables.
#---------------------------------------------------------------------------
-test_begin "AC_CONFIG_MACRO_DIRS([non-existent]) errors out (1)"
+test_begin "AC_CONFIG_MACRO_DIRS([non-existent]) warns (1)"
cat > configure.ac << 'END'
AC_INIT([oops], [1.0])
AC_CONFIG_MACRO_DIRS([non-existent])
+AM_INIT_AUTOMAKE
END
-not $ACLOCAL 2>stderr \
+$ACLOCAL -Wno-error 2>stderr \
&& cat stderr >&2 \
&& grep "couldn't open directory 'non-existent'" stderr \
+ && test -f aclocal.m4 \
+ || r='not ok'
+
+rm -rf aclocal.m4 autom4te*.cache
+
+$ACLOCAL -Werror -Wno-unsupported \
+ && test -f aclocal.m4 \
|| r='not ok'
test_end
#---------------------------------------------------------------------------
-test_begin "AC_CONFIG_MACRO_DIRS([non-existent]) errors out (2)"
+test_begin "AC_CONFIG_MACRO_DIRS([non-existent]) warns (2)"
cat > configure.ac << 'END'
AC_INIT([oops], [1.0])
&& cat stderr >&2 \
&& grep "couldn't open directory 'dir-ko'" stderr \
&& not grep "dir-ok" stderr \
+ && test ! -e aclocal.m4 \
|| r='not ok'
test_end
#---------------------------------------------------------------------------
-test_begin "AC_CONFIG_MACRO_DIRS([non-existent]) errors out (tricky setup)"
+test_begin "AC_CONFIG_MACRO_DIRS([existent non-existent]) errors out"
cat > configure.ac << 'END'
AC_INIT([oops], [1.0])
#---------------------------------------------------------------------------
-test_begin "AC_CONFIG_MACRO_DIRS interaction with AC_REQUIRE"
+test_begin "AC_CONFIG_MACRO_DIRS([not-exist]) and ACLOCAL_AMFLAGS = -I not-exist"
-cat > configure.ac <<'END'
-AC_INIT([req], [1.0])
-AC_CONFIG_MACRO_DIRS([m1 m2])
-AC_DEFUN([MY_FOO], [
- AC_REQUIRE([MY_BAR])
- AC_REQUIRE([MY_BAZ])
-])
-MY_FOO
+cat > configure.ac << 'END'
+AC_INIT([oops], [1.0])
+AC_CONFIG_MACRO_DIRS([not-exist])
END
-mkdir m1 m2
-echo 'AC_DEFUN([MY_BAR], [^^my^^bar^^])' > m1/x.m4
-echo 'AC_DEFUN([MY_BAZ], [~~my~~baz~~])' > m2/x.m4
-
-st=0; $ACLOCAL 2>stderr || st=$?
-cat stderr >&2
+cat > Makefile.am << 'END'
+ACLOCAL_AMFLAGS = -I not-exist
+END
-test $st -eq 0 \
- && test ! -s stderr \
- && $FGREP 'm4_include([m1/x.m4])' aclocal.m4 \
- && $FGREP 'm4_include([m2/x.m4])' aclocal.m4 \
- && $AUTOCONF \
- && not $EGREP 'MY_(FOO|BAR|BAZ)' configure \
- && $FGREP '^^my^^bar^^' configure \
- && $FGREP '~~my~~baz~~' configure \
+$ACLOCAL -Wno-error 2>stderr \
+ && cat stderr >&2 \
+ && test $(grep -c "couldn't open directory 'not-exist'" stderr) -eq 1 \
|| r='not ok'
test_end
+#---------------------------------------------------------------------------
+
+# Avoid spurious failures with pre-2.70 autoconf.
+# FIXME: remove this in automake 2.0, once we require Autoconf 2.70.
+if echo 'AC_INIT AC_CONFIG_MACRO_DIRS' | $AUTOCONF -o/dev/null -; then
+
+ test_begin "AC_CONFIG_MACRO_DIRS interaction with AC_REQUIRE"
+
+ unindent > configure.ac <<'END'
+ AC_INIT([req], [1.0])
+ AC_CONFIG_MACRO_DIRS([m1 m2])
+ AC_DEFUN([MY_FOO], [
+ AC_REQUIRE([MY_BAR])
+ AC_REQUIRE([MY_BAZ])
+ ])
+ MY_FOO
+END
+
+ mkdir m1 m2
+ echo 'AC_DEFUN([MY_BAR], [^^my^^bar^^])' > m1/x.m4
+ echo 'AC_DEFUN([MY_BAZ], [~~my~~baz~~])' > m2/x.m4
+
+ st=0; $ACLOCAL 2>stderr || st=$?
+ cat stderr >&2
+
+ test $st -eq 0 \
+ && test ! -s stderr \
+ && $FGREP 'm4_include([m1/x.m4])' aclocal.m4 \
+ && $FGREP 'm4_include([m2/x.m4])' aclocal.m4 \
+ && $AUTOCONF \
+ && not $EGREP 'MY_(FOO|BAR|BAZ)' configure \
+ && $FGREP '^^my^^bar^^' configure \
+ && $FGREP '~~my~~baz~~' configure \
+ || r='not ok'
+
+ test_end
+
+else
+
+ skip_ -r "autoconf is too old (AC_CONFIG_MACRO_DIRS not defined)"
+
+fi
+
: