Basically a backport of some tests from Automake-NG.
* t/built-sources-check.sh: Sync it with the version in the ng/master
branch. Accordingly, move part of the checks out ...
* t/built-sources-install.sh: ... into this new test, synced from
ng/master as well.
* t/built-sources-subdir.sh: Minor tweaks and enhancements to sync it
with the version in ng/master.
* t/built-sources-cond.sh: New test, synced from ng/master.
* t/built-sources.sh: Likewise, with minor edits to avoid a spurious
failure.
* t/built-sources-fork-bomb.sh: Likewise.
* t/list-of-tests.mk: Update.
Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# Make sure 'check:' and 'install:' honor $(BUILT_SOURCES).
+# Make sure 'check:' honors $(BUILT_SOURCES).
# PR/359.
# For gen-testsuite-part: ==> try-with-serial-tests <==
grep '^PASS: subrun\.sh *$' stdout
grep 'PASS.*echo\.sh' stdout && exit 1
-# check should depend directly on $(BUILT_SOURCES) (similar tests
-# are in check.sh and check2.sh).
-$EGREP '^check:.* \$\(BUILT_SOURCES\)( |$)' Makefile.in
-$EGREP '^check:.* \$\(BUILT_SOURCES\)( |$)' dir/Makefile.in
-
-$MAKE clean
-# Sanity checks
-test ! -e command1.inc
-test ! -e dir/command2.inc
-# Now make sure these two files are rebuilt during make install.
-$MAKE install
-test -f command1.inc
-test -f dir/command2.inc
+$MAKE distcheck
:
--- /dev/null
+#! /bin/sh
+# Copyright (C) 2003-2012 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Interaction of BUILT_SOURCES with conditionals.
+
+. ./defs || exit 1
+
+cat >> configure.ac <<'END'
+AM_CONDITIONAL([COND1], [test $cond1 = yes])
+AM_CONDITIONAL([COND2], [test $cond2 = yes])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+if COND1
+BUILT_SOURCES = a
+else
+BUILT_SOURCES = b
+endif
+if COND2
+BUILT_SOURCES += c
+endif
+
+a b c:
+ echo who cares > $@
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+cleanup ()
+{
+ # Files in $(BUILT_SOURCES) should be automatically removed
+ # upon maintainer-clean.
+ $MAKE maintainer-clean
+ test ! -f a
+ test ! -f b
+ test ! -f c
+}
+
+./configure cond1=yes cond2=yes
+
+$MAKE
+test -f a
+test ! -f b
+test -f c
+
+cleanup
+
+./configure cond1=no cond2=yes
+
+$MAKE
+test ! -f a
+test -f b
+test -f c
+
+cleanup
+
+./configure cond1=yes cond2=no
+
+$MAKE
+test -f a
+test ! -f b
+test ! -f c
+
+cleanup
+
+./configure cond1=no cond2=no
+
+$MAKE
+test ! -f a
+test -f b
+test ! -f c
+
+cleanup
+
+:
--- /dev/null
+#! /bin/sh
+# Copyright (C) 2012 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Due to how the handling of $(BUILT_SOURCES) is implemented in Automake-NG,
+# a recursive make call in the recipe of any $(BUILT_SOURCES) (or of any of
+# its prerequisites) might cause an infinite recursion (complete with fork
+# bomb, yuck) if not handled correctly. Verify that this doesn't happen.
+# For more background, see:
+# <http://lists.gnu.org/archive/html/help-smalltalk/2012-08/msg00027.html>
+# <http://lists.gnu.org/archive/html/automake-patches/2012-08/msg00052.html>
+# Backported to improve coverage of mainline Automake.
+
+required=GNUmake
+. ./defs || exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am << 'END'
+BUILT_SOURCES = foo
+.PHONY: build-foo
+build-foo:
+ echo OK > foo
+foo:
+ $(MAKE) build-foo
+
+# If the bug is still present, we want this test to fail, not to actually
+# go fork bomb and potentially crash the user machine. Take care of that.
+
+is_too_deep := $(shell test $(MAKELEVEL) -lt 10 && echo no)
+
+## Extra indentation here required to avoid confusing Automake.
+ ifeq ($(is_too_deep),no)
+ # All is ok.
+ else
+ $(error ::OOPS:: Recursion too deep, $(MAKELEVEL) levels)
+ endif
+END
+
+$ACLOCAL
+$AUTOMAKE -Wno-portability
+$AUTOCONF
+
+./configure
+
+$MAKE -n foo >output 2>&1 || { cat output; exit 1; }
+cat output
+test ! -f foo
+# Guard against possible infinite recursion.
+$FGREP '::OOPS::' output && exit 1
+
+$MAKE foo >output 2>&1 || { cat output; exit 1; }
+cat output
+$MAKE foo
+# Guard against possible infinite recursion.
+$FGREP '::OOPS::' output && exit 1
+
+:
--- /dev/null
+#! /bin/sh
+# Copyright (C) 2002-2012 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Make sure 'install:' honors $(BUILT_SOURCES).
+# PR/359.
+
+. ./defs || exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([dir/Makefile])
+AC_OUTPUT
+END
+
+mkdir dir
+
+cat > Makefile.am << 'END'
+BUILT_SOURCES = built1
+SUBDIRS = dir
+built1:
+ echo ok > $@
+CLEANFILES = built1
+install-data-hook:
+ $(MKDIR_P) $(DESTDIR)$(prefix)/dir2
+ cp built1 $(DESTDIR)$(prefix)/built1
+ cp dir/built2 $(DESTDIR)$(prefix)/dir2/built3
+uninstall-hook:
+ rm -f $(DESTDIR)$(prefix)/built1
+ rm -f $(DESTDIR)$(prefix)/dir2/built3
+ rmdir $(DESTDIR)$(prefix)/dir2
+installcheck-local:
+ test -f $(prefix)/built1
+ test -f $(prefix)/dir2/built3
+END
+
+cat > dir/Makefile.am << 'END'
+BUILT_SOURCES = built2
+built2:
+## The next line ensures that command1.inc has been built before
+## recurring into the subdir.
+ cp ../built1 $@
+CLEANFILES = built2
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure --prefix "$(pwd)/inst"
+
+# Now make sure these two files are rebuilt during make install.
+$MAKE install
+test -f built1
+test -f dir/built2
+$MAKE installcheck
+$MAKE distcheck
+
+:
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# Make sure when using SUBDIR that all BUILT_SOURCES are built.
+# Make sure when using SUBDIRS that all BUILT_SOURCES are built.
# A bug occurred where subdirs do not have all-recursive or
# all-recursive-am which depended on BUILT_SOURCES.
AC_OUTPUT
END
-# Files required because we are using '--gnu'.
-: > INSTALL
-: > NEWS
-: > README
-: > COPYING
-: > AUTHORS
-: > ChangeLog
-
cat > Makefile.am << 'END'
SUBDIRS = lib
END
pkgdata_DATA =
noinst_LIBRARIES = libfoo.a
libfoo_a_SOURCES = foo.c
-BUILT_SOURCES=foo.h
+BUILT_SOURCES = foo.h
foo.h:
echo \#define FOO_DEFINE 1 >$@
+CLEANFILES = $(BUILT_SOURCES)
END
cat > lib/foo.c << 'END'
#include <foo.h>
-int foo () { return !FOO_DEFINE;}
+int foo (void) { return !FOO_DEFINE; }
END
$ACLOCAL
$AUTOCONF
-$AUTOMAKE --include-deps --copy --force-missing --add-missing --gnu
+$AUTOMAKE --copy --add-missing
./configure
-
-# Remove the comment to get a successful test.
-# $MAKE -C lib foo.h
$MAKE
+$MAKE distcheck
:
--- /dev/null
+#! /bin/sh
+# Copyright (C) 2003-2012 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Basic test on BUILT_SOURCES.
+
+required=cc
+. ./defs || exit 1
+
+cat >> configure.ac <<'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+BUILT_SOURCES = foo.c
+noinst_PROGRAMS = bar baz
+foo.c:
+ rm -f $@ $@-t
+## Use printf, not echo, to avoid spurious interpretation of
+## the "\n" as a newline (seen on NetBSD 5.1).
+ printf '%s\n' '#include <stdio.h>' > $@-t
+ printf '%s\n' 'int main (void)' >> $@-t
+ printf '%s\n' '{ ' >> $@-t
+ printf '%s\n' ' printf ("%s\n", FOOMSG);' >> $@-t
+ printf '%s\n' ' return 0;' >> $@-t
+ printf '%s\n' '}' >> $@-t
+ mv -f $@-t $@
+CLEANFILES = foo.c
+END
+
+cat > bar.c <<'END'
+#define FOOMSG "Howdy, World"
+#include "foo.c"
+END
+
+cat > baz.c <<'END'
+#define FOOMSG "Hello, Earth"
+#include "foo.c"
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+./configure
+$MAKE
+if cross_compiling; then :; else
+ ./bar
+ ./bar | grep 'Howdy, World'
+ ./baz
+ ./baz | grep 'Hello, Earth'
+fi
+$MAKE distcheck
+
+:
t/badprog.sh \
t/block.sh \
t/built-sources-check.sh \
+t/built-sources-cond.sh \
+t/built-sources-fork-bomb.sh \
+t/built-sources-install.sh \
t/built-sources-subdir.sh \
+t/built-sources.sh \
t/candist.sh \
t/canon.sh \
t/canon2.sh \