+2010-12-23 Stefano Lattarini <stefano.lattarini@gmail.com>
+
+ Improve and extend tests `suffix*.test'.
+ * tests/suffix.test: Check that suffix rules for C compilation are
+ only included once. Try also with a static library.
+ * tests/suffix2.test: Add a new grep to help potential debugging.
+ Do not run automake with the `--add-missing' options, since we
+ already create all the needed auxiliary files. Try also *without*
+ the `no-dependencies' automake option.
+ * tests/suffix4.test: Make grepping of Makefile.in stricter.
+ * tests/suffix3.test: Rewritten to run also autoconf, ./configure
+ and make.
+ * tests/suffix5.test: Likewise.
+ * tests/suffix6.test: Fix botched recipe indentation (eight spaces
+ were used instead of a tabulation character). Extend to check
+ that `.obj' is handled like `.$(OBJEXT)' (as is done for `.o').
+ Improved parsing & grepping of generated Makefile.in. Other minor
+ fixes and improvements.
+ * tests/suffix10.test: Move some checks in Makefile.am. Also run
+ "make all".
+ * tests/suffix12.test: Likewise, and account for VPATH issues in
+ weaker make implementations.
+ * tests/suffix11.test: Likewise. Also, run "make distcheck", for
+ completeness, and related changes.
+ * tests/suffix8.test: Likewise. Also, do not put `gcc' anymore
+ in $required.
+ * tests/suffix13.test: Do not use the `--force-missing' automake
+ option unnecessarily.
+ * tests/suffix6b.test: New test, semantic sister of `suffix6.test'.
+ * tests/suffix6c.test: Likewise.
+ * tests/Makefile.am (TESTS): Updated.
+
2010-12-23 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
Stefano Lattarini <stefano.lattarini@gmail.com>
suffix4.test \
suffix5.test \
suffix6.test \
+suffix6b.test \
+suffix6c.test \
suffix7.test \
suffix8.test \
suffix9.test \
suffix4.test \
suffix5.test \
suffix6.test \
+suffix6b.test \
+suffix6c.test \
suffix7.test \
suffix8.test \
suffix9.test \
# 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 a suffix rule for C compilation is produced.
+# Make sure proper suffix rules for C compilation are produced, and
+# only once.
+# See also related test `suffix2.test'.
. ./defs || Exit 1
cat >> configure.in << 'END'
AC_PROG_CC
+AC_PROG_RANLIB
END
cat > Makefile.am << 'END'
noinst_PROGRAMS = foo
+noinst_LIBRARIES = libbar.a
END
$ACLOCAL
$AUTOMAKE -i
-grep '^\.c\.o' Makefile.in
+grep '^ *\.c' Makefile.in # for debugging
+test `grep -c '^\.c\.o:' Makefile.in` -eq 1
+test `grep -c '^\.c\.obj:' Makefile.in` -eq 1
$AUTOMAKE
-grep '^\.c\.o' Makefile.in
+grep '^ *\.c' Makefile.in # for debugging
+test `grep -c '^\.c\.o:' Makefile.in` -eq 1
+test `grep -c '^\.c\.obj:' Makefile.in` -eq 1
:
AC_OUTPUT
EOF
-
cat >Makefile.am << 'END'
lib_LTLIBRARIES = libfoo.la
libfoo_la_SOURCES = foo.x_
-
.x_.y:
- cp $< $@
+ rm -f $@ $@-t
+## the leading `:;' works around a bug in bash <= 3.2
+ :; { echo '/* autogenerated */' \
+ && echo '%{' \
+ && echo 'int yylex () {return 0;}' \
+ && echo 'void yyerror (char *s) {}' \
+ && echo '%}' \
+ && echo '%%' \
+ && echo 'WORD: "foo";' \
+ && echo '%%' \
+## account for VPATH issues on weaker make implementations
+ && cat `test -f $< || echo $(srcdir)/`$<; \
+ } > $@-t
+ mv -f $@-t $@
+.PHONY: test
+test:
+ echo $(libfoo_la_OBJECTS) | grep '^foo\.lo$$'
+END
-print:
- echo BEGIN: $(libfoo_la_OBJECTS) :END
+cat > foo.x_ << 'END'
+int foo (void) { return yyparse(); }
END
libtoolize --force
$AUTOMAKE --add-missing
./configure
-
-$MAKE print >stdout || { cat stdout; Exit 1; }
-cat stdout
-grep 'BEGIN: foo.lo :END' stdout
+$MAKE test
+$MAKE all
:
foo_SOURCES = foo.x_
bar_SOURCES = bar.y-z
baz_SOURCES = baz1.x_ baz2.y-z
+
.y-z.c .x_.c:
- cp $< $@
- .z_.c .w_.x_ :
- cp $< $@
+## account for VPATH issues on weaker make implementations (e.g. IRIX 6.5)
+ sed 's/INTEGER/int/g' `test -f $< || echo $(srcdir)/`$< >$@
+
+CLEANFILES = foo.c bar.c baz1.c baz2.c
-.PHONY: print
-print:
- @echo BEGIN: $(foo_OBJECTS) :END
- @echo BEGIN: $(bar_OBJECTS) :END
- @echo BEGIN: $(baz_OBJECTS) :END
+.PHONY: test-real test-fake
+test-fake:
+ echo $(foo_OBJECTS) | grep '^foo\.foo$$'
+ echo $(bar_OBJECTS) | grep '^bar\.foo$$'
+ echo $(baz_OBJECTS) | grep '^baz1\.foo baz2\.foo$$'
+test-real:
+ echo $(foo_OBJECTS) | grep '^foo\.$(OBJEXT)$$'
+ echo $(bar_OBJECTS) | grep '^bar\.$(OBJEXT)$$'
+ echo $(baz_OBJECTS) | grep '^baz1\.$(OBJEXT) baz2\.$(OBJEXT)$$'
+check-local: test-real
END
+echo 'INTEGER main(void) { return 0; }' > foo.x_
+echo 'INTEGER main(void) { return 0; }' > bar.y-z
+echo 'INTEGER main(void) { INTEGER baz(void); return baz(); }' > baz1.x_
+echo 'INTEGER baz(void) { return 0; }' > baz2.y-z
+
$ACLOCAL
$AUTOCONF
./configure
-OBJEXT=foo $MAKE -e print >stdout || { cat stdout; Exit 1; }
-cat stdout
-$FGREP 'BEGIN: foo.foo :END' stdout
-$FGREP 'BEGIN: bar.foo :END' stdout
-$FGREP 'BEGIN: baz1.foo baz2.foo :END' stdout
+OBJEXT=foo $MAKE -e test-fake
+$MAKE test-real
+$MAKE
+$MAKE distcheck
:
SUFFIXES = .baz .o
# we fake here:
.baz.o:
- cp $< $@
+ ## account for VPATH issues on weaker make implementations
+ cp `test -f $< || echo $(srcdir)/`$< $@
bin_PROGRAMS = foo
foo_SOURCES = foo.c sub/bar.baz
-.PHONY: print
-print:
- @echo BEGIN: $(foo_OBJECTS) :END
+.PHONY: test-fake test-real
+test-fake:
+ echo $(foo_OBJECTS) | grep '^foo\.quux sub/bar\.quux$$'
+test-real:
+ echo $(foo_OBJECTS) | grep '^foo\.$(OBJEXT) sub/bar\.$(OBJEXT)$$'
END
mkdir sub
$ACLOCAL
$AUTOCONF
$AUTOMAKE -a
+
./configure
-OBJEXT=OBJ $MAKE -e print >stdout || { cat stdout; Exit 1; }
-cat stdout
-$FGREP 'BEGIN: foo.OBJ sub/bar.OBJ :END' stdout
+
+OBJEXT=quux $MAKE -e test-fake
+$MAKE test-real
:
sed '/subdir-objects/d' < Makefile.am > t
mv -f t Makefile.am
-$AUTOMAKE --force
+$AUTOMAKE
./configure
$MAKE
$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/>.
-# Test to make sure .c.o rule is only included once.
+# Make sure proper suffix rules for C compilation are produced,
+# and only once, even for libtool libraries.
+# See also related test `suffix.test'.
required=libtoolize
. ./defs || Exit 1
END
cat > Makefile.am << 'END'
-AUTOMAKE_OPTIONS = no-dependencies
lib_LTLIBRARIES = libltdl.la
libltdl_la_SOURCES = ltdl.c ltdl.h
END
: > config.sub
$ACLOCAL
-$AUTOMAKE -a
+$AUTOMAKE -i
+grep '^ *\.c' Makefile.in # for debugging
+test `grep -c '^\.c\.o:' Makefile.in` -eq 1
+test `grep -c '^\.c\.obj:' Makefile.in` -eq 1
+
+$AUTOMAKE
+grep '^ *\.c' Makefile.in # for debugging
test `grep -c '^\.c\.o:' Makefile.in` -eq 1
test `grep -c '^\.c\.obj:' Makefile.in` -eq 1
cat >> configure.in << 'END'
AC_PROG_CXX
+AC_OUTPUT
END
cat > Makefile.am << 'END'
SUFFIXES = .zoo
.zoo.cc:
- convert-zoo whatever
+ sed 's/INTEGER/int/g' `test -f $< || echo $(srcdir)/`$< >$@
bin_PROGRAMS = foo
foo_SOURCES = foo.zoo
+# This is required by "make distcheck". The useless indirection is
+# reequired to avoid false positives by the grepping checks below.
+FOO = foo
+CLEANFILES = $(FOO).cc
END
$ACLOCAL
$AUTOMAKE
# The foo.cc intermediate step is implicit, it's a mistake if
-# Automake requires this file somewhere.
-$FGREP foo.cc Makefile.in && Exit 1
+# Automake requires this file somewhere. Also, Automake should
+# not require the file `foo.c' anywhere.
+$FGREP foo.c Makefile.in && Exit 1
# However Automake must figure that foo.zoo is eventually
# transformed into foo.o, and use this latter file (to link foo).
$FGREP 'foo.$(OBJEXT)' Makefile.in
+$AUTOCONF
+./configure
+
+# This is deliberately valid C++, but invalid C.
+cat > foo.zoo <<'END'
+#include <iostream>
+using namespace std;
+INTEGER main(void)
+{
+ return 0;
+}
+END
+
+$MAKE
+# FIXME: should we check that intermediate file `foo.cc' has
+# been removed? Or is this requiring too much from the make
+# implementation?
+
+# Intermediate files should not be distributed.
+$MAKE distdir
+test ! -r $me-1.0/foo.cc
+
+# Check the distribution.
+$MAKE distcheck
+
:
$ACLOCAL
$AUTOMAKE
-grep '.SUFFIXES:.*\.k' Makefile.in
+grep '^\.SUFFIXES:' Makefile.in | sed -e 's/$/ /' > suffixes
+cat suffixes
+$FGREP ' .k ' suffixes
:
set -e
cat >> configure.in << 'END'
+AC_SUBST([LINK], [:])
AC_PROG_LIBTOOL
+AC_OUTPUT
END
cat > Makefile.am << 'END'
.k.lo:
- echo $< > $@
+## account for VPATH issues on weaker make implementations
+ (echo $< && cat `test -f $< || echo $(srcdir)/`$<) > $@
noinst_LTLIBRARIES = libfoo.la
libfoo_la_SOURCES = foo.k
+
+.PHONY: test
+test: all
+ grep '^=GREP=ME=$$' foo.lo
+## weaker regex to account for VPATH issues
+ grep 'foo\.k$$' foo.lo
+check-local: test
END
: > ltmain.sh
-: > config.guess
-: > config.sub
+
+cp "$testsrcdir/../lib/config.guess" "$testsrcdir/../lib/config.sub" .
$ACLOCAL
$AUTOMAKE
grep '_OBJECTS.*foo\.lo' Makefile.in
+$AUTOCONF
+./configure
+
+echo '=GREP=ME=' > foo.k
+
+$MAKE test
+$MAKE distcheck
+
:
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Test to make sure Automake supports implicit rules with dot-less
-# extensions. Also make sure that `.o' is handled like `.$(OBJEXT)'.
+# extensions. Also make sure that `.o' and `.obj' are handled like
+# `.$(OBJEXT)'. See also related "semantic" tests suffix6b.test
+# and suffix6c.test.
. ./defs || Exit 1
set -e
cat > Makefile.am << 'END'
-SUFFIXES = a b .$(OBJEXT) c .o
+SUFFIXES = a b .$(OBJEXT) c .o .obj
bin_PROGRAMS = foo
-foo_SOURCES = fooa fuc
+foo_SOURCES = fooa barc bazc
ab:
- cp $< $@
+ dummy action 1
b.$(OBJEXT):
- cp $< $@
+ dummy action 2
c.o:
- cp $< $@
+ dummy action C
+c.obj:
+ dummy action C
END
$ACLOCAL
$AUTOMAKE
+sed -n -e '/foo_OBJECTS *=.*\\$/ {
+ :loop
+ p
+ n
+ t clear
+ :clear
+ s/\\$/\\/
+ t loop
+ p
+ n
+}' -e 's/$/ /' -e 's/^.*foo_OBJECTS *= */ /p' Makefile.in > foo-objects
+cat foo-objects
+
# Automake must figure that fooa translates to foo.$(OBJEXT) and
# foo.$(OBJEXT) using the following rules:
# fooa --[ab]--> foob --[b.$(OBJEXT)]--> foo.$(OBJEXT)
-grep '_OBJECTS.* foo\.\$(OBJEXT)' Makefile.in
-# fuc --[c.o]--> fu.$(OBJEXT) ## This is really meant !
-grep '_OBJECTS.* fu\.\$(OBJEXT)' Makefile.in
+$FGREP ' foo.$(OBJEXT) ' foo-objects
+# barc --[c.o]--> bar.$(OBJEXT) ## This is really meant !
+$FGREP ' bar.$(OBJEXT) ' foo-objects
+# bazc --[c.obj]--> baz.$(OBJEXT) ## This is really meant !
+$FGREP ' baz.$(OBJEXT) ' foo-objects
:
--- /dev/null
+#! /bin/sh
+# Copyright (C) 2001, 2002, 2010 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/>.
+
+# Test to make sure Automake supports implicit rules with dot-less
+# extensions. Se also related "grepping" test suffix6.test.
+
+required=GNUmake # other makes might not grok dot-less suffix rules
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+# $(LINK) is not defined automatically by Automake, since the *_SOURCES
+# variables don't contain any known extension (.c, .cc, .f ...),
+# So we need this hack -- but since such an hack can also serve as a
+# mild stress test, that's ok.
+AC_SUBST([LINK], ['cat >$@'])
+AC_SUBST([OBJEXT], [oOo])
+AC_SUBST([EXEEXT], [.XxX])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+SUFFIXES = a b c .$(OBJEXT)
+bin_PROGRAMS = foo
+foo_SOURCES = fooa
+ab:
+ { echo '=ab=' && cat $<; } >$@
+bc:
+ { echo '=bc=' && cat $<; } >$@
+c.$(OBJEXT):
+ { echo '=b.obj=' && cat $<; } >$@
+test:
+ : for debugging
+ ls -l
+ : implicit intermediate files should be removed by GNU make
+ test ! -r foob
+ test ! -r fooc
+ : but object files should not
+ cat foo.$(OBJEXT)
+ : for debugging
+ cat foo.XxX
+ : now check that the chain of implicit rules has been executed
+ : completely and in the correct order
+ (echo =b.obj= && echo =bc= && echo =ab= && echo =src=) > exp
+ diff exp foo.XxX
+ rm -f exp
+.PHONY: test
+check-local: test
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+echo =src= > fooa
+
+$MAKE
+$MAKE test
+$MAKE distcheck
+
+:
--- /dev/null
+#! /bin/sh
+# Copyright (C) 2001, 2002, 2010 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/>.
+
+# Test to make sure that `.o' and `.obj' are handled like `.$(OBJEXT)'.
+# See also related "grepping" test suffix6.test.
+
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+# $(LINK) is not defined automatically by Automake, since the *_SOURCES
+# variables don't contain any known extension (.c, .cc, .f ...),
+# So we need this hack -- but since such an hack can also serve as a
+# mild stress test, that's ok.
+OBJEXT=${OBJEXT-oOo}
+AC_SUBST([LINK], ['cat >$@'])
+AC_SUBST([EXEEXT], [.XxX])
+AC_SUBST([OBJEXT])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+SUFFIXES = .zoo .o .obj .@OBJEXT@
+
+bin_PROGRAMS = foo
+foo_SOURCES = foo.zoo
+
+.zoo.o:
+ { echo '=.zoo.o=' && cat $<; } >$@
+.zoo.obj:
+ { echo '=.zoo.obj=' && cat $<; } >$@
+.zoo.@OBJEXT@:
+ { echo '=.zoo.@OBJEXT@=' && cat $<; } >$@
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+cat > foo.exp <<'END'
+=.zoo.oOo=
+%ONE%
+END
+echo %ONE% > foo.zoo
+$MAKE
+cat foo.oOo
+cat foo.XxX
+diff foo.XxX foo.exp
+
+rm -f foo.* exp
+
+cat > foo.exp <<'END'
+=.zoo.o=
+%TWO%
+END
+echo %TWO% > foo.zoo
+OBJEXT=o $MAKE -e
+cat foo.o
+cat foo.XxX
+diff foo.XxX foo.exp
+
+rm -f foo.* exp
+
+cat > foo.exp <<'END'
+=.zoo.obj=
+%THREE%
+END
+echo %THREE% > foo.zoo
+OBJEXT=obj $MAKE -e
+cat foo.obj
+cat foo.XxX
+diff foo.XxX foo.exp
+
+rm -f foo.* exp
+
+:
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# Test to make sure Automake supports multiple derivations for the same suffix.
-# PR/37
+# Test to make sure Automake supports multiple derivations for the
+# same suffix.
+# From PR/37.
-required='gcc libtoolize'
+required=libtoolize
. ./defs || Exit 1
set -e
END
cat >Makefile.am << 'END'
+# $(LINK) is not defined automatically by Automake, since the *_SOURCES
+# variables don't contain any known extension (.c, .cc, .f ...),
+# So we need this hack.
+LINK = :
+
bin_PROGRAMS = foo
lib_LTLIBRARIES = libfoo.la
foo_SOURCES = foo.x_
libfoo_la_SOURCES = bar.x_
+# The elaborate cp commands below account for VPATH issues on
+# weaker make implementations (e.g. IRIX 6.5).
.x_.y_:
- cp $< $@
-
+ cp `test -f $< || echo $(srcdir)/`$< $@
.y_.o:
- cp $< $@
-
+ cp `test -f $< || echo $(srcdir)/`$< $@
.y_.z_:
- cp $< $@
-
+ cp `test -f $< || echo $(srcdir)/`$< $@
.z_.lo:
- cp $< $@
-
-# Add explicit dependencies to help make implementations that
-# don't otherwise chain implicit rules (e.g., Sun make).
-foo.$(OBJEXT): foo.y_
-bar.lo: bar.z_
-bar.z_: bar.y_
-
-print:
- @echo BEGIN: $(foo_OBJECTS) :END
- @echo BEGIN: $(libfoo_la_OBJECTS) :END
-
-test: $(foo_OBJECTS) $(libfoo_la_OBJECTS)
+ cp `test -f $< || echo $(srcdir)/`$< $@
+
+# Some make implementations don't remove intermediate files
+# automatically, thus causing "make distcheck" to fail if
+# this is not added.
+MOSTLYCLEANFILES = *.y_ *.z_
+
+.PHONY: test0 test1 test2
+test0:
+ echo $(foo_OBJECTS) | grep '^foo\.foo$$'
+ echo $(libfoo_la_OBJECTS) | grep '^bar\.lo$$'
+test1:
+ echo $(foo_OBJECTS) | grep '^foo\.$(OBJEXT)$$'
+ echo $(libfoo_la_OBJECTS) | grep '^bar\.lo$$'
+test2: $(foo_OBJECTS) $(libfoo_la_OBJECTS)
test -f foo.$(OBJEXT)
test -f bar.lo
+check-local: test1 test2
END
-echo 'int main() { return 0; }' > foo.x_
-cp foo.x_ bar.x_
+echo 'int main(void) { return 0; }' > foo.x_
+echo 'int bar(void) { return 0; }' > bar.x_
libtoolize
$ACLOCAL
./configure
-OBJEXT=foo $MAKE -e print >stdout || { cat stdout; Exit 1; }
-cat stdout
-$FGREP 'BEGIN: foo.foo :END' stdout
-$FGREP 'BEGIN: bar.lo :END' stdout
-
-$MAKE test
+OBJEXT=foo $MAKE -e test0
+$MAKE test1
+$MAKE test2
+$MAKE all
+$MAKE distcheck
: