work as expected:
TESTS = $(wildcard $(srcdir)/t[0-9][0-9]*.sh)
+Pattern rules and suffix rules
+==============================
+
+* Old-fashioned suffix rules are not supported anymore; Automake-NG will
+ error out if you try to use them. Use pattern rules instead, as
+ advised in the GNU make manual itself.
+
+* The .SUFFIXES: special target and the SUFFIXES special variable are
+ not supported anymore either; Automake-NG will error out if you try
+ to define them.
+
+* To retain support for user-defined file extensions in the '_SOURCES'
+ variables (see "Handling new file extensions" in the Automake manual),
+ Automake-NG still tries to parse and understand suffix-based pattern
+ rules. So, an usage like:
+
+ SUFFIXES = .baz .c
+ .baz.c:
+ cp $< $@
+ foo_SOURCES = foo.c bar.baz
+ DISTCLEANFILES = bar.c
+
+ which was valid with mainline Automake, should be translated for
+ Automake-NG as:
+
+ %.c: %.baz
+ cp $< $@
+ bin_PROGRAMS = foo
+ foo_SOURCES = foo.c sub/bar.baz
+ DISTCLEANFILES = bar.c
+
Miscellaneous
=============
################################################################
-# var_SUFFIXES_trigger ($TYPE, $VALUE)
-# ------------------------------------
-# This is called by Automake::Variable::define() when SUFFIXES
-# is defined ($TYPE eq '') or appended ($TYPE eq '+').
-# The work here needs to be performed as a side-effect of the
-# macro_define() call because SUFFIXES definitions impact
-# on $KNOWN_EXTENSIONS_PATTERN which is used used when parsing
-# the input am file.
-sub var_SUFFIXES_trigger ($$)
-{
- my ($type, $value) = @_;
- accept_extensions (split (' ', $value));
-}
-Automake::Variable::hook ('SUFFIXES', \&var_SUFFIXES_trigger);
-
-################################################################
-
## --------------------------------- ##
## Forward subroutine declarations. ##
## --------------------------------- ##
# Handle footer elements.
sub handle_footer
{
- reject_rule ('.SUFFIXES',
- "use variable 'SUFFIXES', not target '.SUFFIXES'");
-
- # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
- # before .SUFFIXES. So we make sure that .SUFFIXES appears before
- # anything else, by sticking it right after the default: target.
- $output_header .= ".SUFFIXES:\n";
- my $suffixes = var 'SUFFIXES';
- my @suffixes = Automake::Rule::suffixes;
- if (@suffixes || $suffixes)
- {
- # Make sure SUFFIXES has unique elements. Sort them to ensure
- # the output remains consistent. However, $(SUFFIXES) is
- # always at the start of the list, unsorted. This is done
- # because make will choose rules depending on the ordering of
- # suffixes, and this lets the user have some control. Push
- # actual suffixes, and not $(SUFFIXES). Some versions of make
- # do not like variable substitutions on the .SUFFIXES line.
- my @user_suffixes = ($suffixes
- ? $suffixes->value_as_list_recursive : ());
-
- my %suffixes = map { $_ => 1 } @suffixes;
- delete @suffixes{@user_suffixes};
-
- $output_header .= (".SUFFIXES: "
- . join (' ', @user_suffixes, sort keys %suffixes)
- . "\n");
- }
-
- $output_trailer .= file_contents ('footer', new Automake::Location);
+ # Automake used to have special support for old-fashioned suffix
+ # rules, but Automake-NG favors the use of GNU make pattern rules.
+ reject_rule '.SUFFIXES',
+ "use pattern rules, not old-fashioned suffix rules";
+ reject_var 'SUFFIXES',
+ "use pattern rules, not old-fashioned suffix rules";
+ $output_trailer .= file_contents ('footer', new Automake::Location);
}
@file{.lo} when using libtool). Normally these object files are named
after the source file, but other factors can change this. If a file in
the @code{_SOURCES} variable has an unrecognized extension, Automake
-will do one of two things with it. If a suffix rule exists for turning
-files with the unrecognized extension into @file{.o} files, then
-@command{automake} will treat this file as it will any other source file
-(@pxref{Support for Other Languages}). Otherwise, the file will be
+will do one of two things with it. If a suffix-based pattern rule exists
+for turning files with the unrecognized extension into @file{.o} files,
+then @command{automake} will treat this file as it will any other source
+file (@pxref{Support for Other Languages}). Otherwise, the file will be
ignored as though it were a header file.
The prefixes @code{dist_} and @code{nodist_} can be used to control
on user demand.
Some limited support for adding your own languages is available via the
-suffix rule handling (@pxref{Suffixes}).
+suffix-based pattern rules handling (@pxref{Suffixes}).
@node Dependencies
@section Automatic dependency tracking
overwrite your rules (it assumes you know better than it).
@samp{foo.$(OBJEXT): bindir.h} supersedes any rule Automake may want to
output to build @samp{foo.$(OBJEXT)}. It happens to work in this case
-because Automake doesn't have to output any @samp{foo.$(OBJEXT):}
-target: it relies on a suffix rule instead (i.e., @samp{.c.$(OBJEXT):}).
+because Automake doesn't have to output any @samp{foo.$(OBJEXT):} target:
+it relies on a pattern rule instead (i.e., @samp{%.$(OBJEXT): %.c}).
Always check the generated @file{Makefile.in} if you do this.
@subsubheading Build @file{bindir.h} from @file{configure}
@vindex SUFFIXES
It is sometimes useful to introduce a new implicit rule to handle a file
-type that Automake does not know about.
+type that Automake-NG does not know about. Automake-NG offers a limited
+support to do so, through the use of suffix-based pattern rules.
For instance, suppose you had a compiler that could compile @file{.foo}
-files to @file{.o} files. You would simply define a suffix rule for
+files to @file{.o} files. You would simply define a pattern rule for
your language:
@example
-.foo.o:
+%.o: %.foo
foocc -c -o $@@ $<
@end example
doit_SOURCES = doit.foo
@end example
-This was the simpler and more common case. In other cases, you will
-have to help Automake to figure out which extensions you are defining your
-suffix rule for. This usually happens when your extension does not
-start with a dot. Then, all you have to do is to put a list of new
-suffixes in the @code{SUFFIXES} variable @strong{before} you define your
-implicit rule.
+Note that the above only works with suffixes that start with a dot.
-For instance, the following definition prevents Automake from misinterpreting
-the @samp{.idlC.cpp:} rule as an attempt to transform @file{.idlC} files into
-@file{.cpp} files.
-
-@c Keep in sync with suffix7.sh
-@example
-SUFFIXES = .idl C.cpp
-.idlC.cpp:
- # whatever
-@end example
-
-As you may have noted, the @code{SUFFIXES} variable behaves like the
-@code{.SUFFIXES} special target of @command{make}. You should not touch
-@code{.SUFFIXES} yourself, but use @code{SUFFIXES} instead and let
-Automake generate the suffix list for @code{.SUFFIXES}. Any given
-@code{SUFFIXES} go at the start of the generated suffixes list, followed
-by Automake generated suffixes not already in the list.
+Also note that Automake-NG does not support old-fashioned suffix rules
+(@pxref{Suffix Rules, ,Old-fashioned Suffix Rules, make, The GNU make
+Manual}), since they are obsoleted by the GNU make pattern rules. In
+fact, Automake-NG will error out an any attempt to use old-fashioned
+suffix rules.
@node Include
@chapter Include
use vars '@ISA', '@EXPORT', '@EXPORT_OK';
@ISA = qw/Automake::Item Exporter/;
@EXPORT = qw (reset register_suffix_rule suffix_rules_count
- suffixes rules $suffix_rules $KNOWN_EXTENSIONS_PATTERN
+ rules $suffix_rules $KNOWN_EXTENSIONS_PATTERN
depend %dependencies %actions register_action
accept_extensions
reject_rule msg_rule msg_cond_rule err_rule err_cond_rule
=cut
-my $_SUFFIX_RULE_PATTERN =
- '^(\.[a-zA-Z0-9_(){}$+@\-]+)(\.[a-zA-Z0-9_(){}$+@\-]+)' . "\$";
-
-# Suffixes found during a run.
-use vars '@_suffixes';
-
# Same as $suffix_rules (declared below), but records only the
# default rules supplied by the languages Automake supports.
use vars '$_suffix_rules_default';
sub reset()
{
%_rule_dict = ();
- @_suffixes = ();
# The first time we initialize the variables,
# we save the value of $suffix_rules.
if (defined $_suffix_rules_default)
=item C<register_suffix_rule ($where, $src, $dest)>
-Register a suffix rule defined on C<$where> that transforms
-files ending in C<$src> into files ending in C<$dest>.
+Register a suffix-based pattern rule defined on C<$where> that
+transforms files ending in C<$src> into files ending in C<$dest>.
This upgrades the C<$suffix_rules> variables.
my ($where, $src, $dest) = @_;
verb "Sources ending in $src become $dest";
- push @_suffixes, $src, $dest;
# When transforming sources to objects, Automake uses the
# %suffix_rules to move from each source extension to
return (scalar keys %$suffix_rules) - (scalar keys %$_suffix_rules_default);
}
-=item C<@list = suffixes>
-
-Return the list of known suffixes.
-
-=cut
-
-sub suffixes ()
-{
- return @_suffixes;
-}
-
=item C<rule ($rulename)>
Return the C<Automake::Rule> object for the rule
$rule->set ($c, $def);
}
- # We honor inference rules with multiple targets because many
- # makes support this and people use it. However this is disallowed
- # by POSIX. We'll print a warning later.
- my $target_count = 0;
- my $inference_rule_count = 0;
+ my $chars_rx = '[a-zA-Z0-9_(){}$+@\-]+';
+ my $suffix_rule_rx = "^(\\.$chars_rx+)(\\.$chars_rx+)(?:\\s|\$)";
+ my $pattern_rx ="^%(\\.$chars_rx+)";
- for my $t (split (' ', $target))
+ # Let's see if the rule is a suffix-based pattern rule we can handle.
+ if ($target =~ /^%(\.$chars_rx)$/o)
{
- ++$target_count;
- # Check if the rule is a suffix rule: either it's a rule for
- # two known extensions...
- if ($t =~ /^($KNOWN_EXTENSIONS_PATTERN)($KNOWN_EXTENSIONS_PATTERN)$/
- # ...or it's a rule with unknown extensions (i.e., the rule
- # looks like '.foo.bar:' but '.foo' or '.bar' are not
- # declared in SUFFIXES and are not known language
- # extensions). Automake will complete SUFFIXES from
- # @suffixes automatically (see handle_footer).
- || ($t =~ /$_SUFFIX_RULE_PATTERN/o && accept_extensions($1)))
- {
- ++$inference_rule_count;
- register_suffix_rule ($where, $1, $2);
- }
+ my $objsuf = $1;
+ if ($deps =~ /^\s*%(\.$chars_rx)(\s|$)/o)
+ {
+ my $srcsuf = $1;
+ accept_extensions ($srcsuf);
+ register_suffix_rule ($where, $srcsuf, $objsuf);
+ }
+ }
+ # We don't support old-fashioned suffix rules anymore, but want to
+ # report them as errors.
+ elsif ($target =~ /$suffix_rule_rx/o)
+ {
+ error $where, "use pattern rules, not old-fashioned suffix rules";
}
-
- # POSIX allows multiple targets before the colon, but disallows
- # definitions of multiple inference rules. It's also
- # disallowed to mix plain targets with inference rules.
- msg ('portability', $where,
- "inference rules can have only one target before the colon (POSIX)")
- if $inference_rule_count > 0 && $target_count > 1;
return @conds;
}
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
+# Neutralize the default suffix rules.
+.SUFFIXES:
+
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
AC_INIT([$me], [1.0])
AM_INIT_AUTOMAKE([-Wall -Werror gnu])
AC_CONFIG_FILES([Makefile])
+AC_PROG_CC
END
cat > Makefile.am <<'END'
-# The following should expand to '-Wnone -Wno-error foreign -Wportability'.
+# The following should expand to:
+# subdir-objects -Wnone -Wno-error foreign -Wportability
AUTOMAKE_OPTIONS = $(foo) foreign
AUTOMAKE_OPTIONS += ${bar}
foo = $(foo1)
foo1 = ${foo2}
-foo2 = -Wnone
+foo2 = subdir-objects -Wnone
foo2 += $(foo3)
foo3 = -Wno-error
bar = -Wportability
+noinst_PROGRAMS = foo
# This will give a warning with '-Wportability'.
-.aaa.bbb .ccc.ddd:
+foo_SOURCES = sub/foo.c
# This would give a warning with '-Woverride'.
install:
END
$ACLOCAL
AUTOMAKE_run
-grep '^Makefile\.am:.*inference rules can have only one target' stderr
+grep '^Makefile\.am:.*sub/foo\.c.*requires.*AM_PROG_CC_C_O' stderr
grep README stderr && Exit 1
$EGREP '(install|override)' stderr && Exit 1
+++ /dev/null
-#! /bin/sh
-# Copyright (C) 2009-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 3 of the License, 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/>.
-
-# Cover corner cases of derive_suffix wrt. file extensions:
-# - extension declared with SUFFIXES but with no suffix rule for it
-# - extension with a suffix rule but none that leads us to $(OBJEXT)
-# In both cases, we don't try to create a rule; but we shouldn't
-# fail either, because magic might be happening behind our back.
-
-. ./defs || Exit 1
-
-cat >> configure.ac << 'END'
-END
-
-cat > Makefile.am << 'END'
-bin_PROGRAMS = foo bar
-foo_SOURCES = foo.goo
-SUFFIXES = .goo
-bar_SOURCES = bar.woo
-.woo.zoo: ; making a zoo $@ from a woo $<
-END
-
-$ACLOCAL
-$AUTOMAKE
-
-Exit 0
cat > Makefile.am << 'END'
TESTS = foo.test
-.in.test:
+%.test: %.in
cp $< $@ && chmod +x $@
check_SCRIPTS = $(TESTS)
EXTRA_DIST = foo.in foo.test
if COND
AM_DEFAULT_SOURCE_EXT = .foo .quux
endif
-SUFFIXES = .foo .c
-.foo.c:
+%.c: %.foo
cat $< >$@
BUILT_SOURCES = bla.c
CLEANFILES = bla.c
END
cat > foo.c << 'END'
-int main () { return 0; }
+int main (void) { return 0; }
END
cp foo.c sub/bar.cpp
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Check that Automake can take advantage of GNU make ability to
-# automatically chain suffix rules.
+# automatically chain suffix-based pattern rules.
# See automake bug#7824 and bug#7670.
required=cc
. ./defs || Exit 1
-plan_ 8
-
cat >> configure.ac <<'END'
AC_PROG_CC
AC_OUTPUT
cat > Makefile.am <<'END'
bin_PROGRAMS = foo
foo_SOURCES = foo.c1
-.c1.c0:
+%.c0: %.c1
(echo 'int main (void)' && echo '{' && cat $<) > $@
-.c0.c:
+%.c: %.c0
(cat $< && echo '}') > $@
CLEANFILES = foo.c0 foo.c
END
echo 'return 0;' > foo.c1
-command_ok_ "aclocal" $ACLOCAL
-command_ok_ "automake" $AUTOMAKE
-command_ok_ "autoconf" $AUTOCONF
-command_ok_ "configure" ./configure
-command_ok_ "make all" $MAKE all
-command_ok_ "make distcheck" $MAKE distcheck
-command_ok_ "clean" $MAKE clean
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+./configure
+$MAKE all
+$MAKE distcheck
-# Sanity check.
+# Try with explicit dependencies as well.
+$MAKE clean
cat >> Makefile <<'END'
foo.c: foo.c0
foo.c0: foo.c1
END
-command_ok_ "make with explicit dependencies" $MAKE
+$MAKE all
:
# 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
AC_OUTPUT
END
-unset OBJEXT || :
-
cat > Makefile.am << 'END'
-SUFFIXES = .zoo .o .obj .@OBJEXT@
-
bin_PROGRAMS = foo
foo_SOURCES = foo.zoo
-.zoo.o:
+%.o: %.zoo
{ echo '=.zoo.o=' && cat $<; } >$@
-.zoo.obj:
+%.obj: %.zoo
{ echo '=.zoo.obj=' && cat $<; } >$@
-.zoo.@OBJEXT@:
+%.@OBJEXT@: %.zoo
{ echo '=.zoo.@OBJEXT@=' && cat $<; } >$@
END
--- /dev/null
+#! /bin/sh
+# Copyright (C) 1999-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/>.
+
+# Automake-NG should reject suffix rules in favor of pattern rules.
+
+. ./defs || Exit 1
+
+$ACLOCAL
+
+cat > Makefile.am << 'END'
+.SUFFIXES: .w
+END
+
+cat > Makefile2.am <<'END'
+## Dummy comments ...
+## ... whose only purpose is ...
+## ... to alter ...
+## ... the line count.
+SUFFIXES = .w
+END
+
+cat > Makefile3.am << 'END'
+.foo.bar: ; cp $< $@
+.mu.um:
+ cp $< $@
+.1.2 .3.4:
+ who cares
+END
+
+msg='use pattern rules, not old-fashioned suffix rules'
+
+AUTOMAKE_fails -Wno-error -Wnone Makefile
+grep "^Makefile\\.am:1:.*$msg" stderr
+AUTOMAKE_fails -Wno-error -Wnone Makefile2
+grep "^Makefile2\\.am:5:.*$msg" stderr
+AUTOMAKE_fails -Wno-error -Wnone Makefile3
+grep "^Makefile3\\.am:1:.*$msg" stderr
+grep "^Makefile3\\.am:2:.*$msg" stderr
+grep "^Makefile3\\.am:4:.*$msg" stderr
+test `grep -c "$msg" stderr` -eq 3
+
+:
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Make sure that derivations work with .lo too.
+# Also check suffixes containing the'-' character.
# (related to PR/37)
required='cc libtoolize yacc'
. ./defs || Exit 1
-plan_ 7
-
cat >>configure.ac <<EOF
AC_PROG_CC
AC_PROG_YACC
cat >Makefile.am << 'END'
lib_LTLIBRARIES = libfoo.la
-libfoo_la_SOURCES = foo.x_
-.x_.y:
+libfoo_la_SOURCES = foo.x-x
+%.y: %.x-x
rm -f $@ $@-t
## The leading ':;' works around a bug in bash <= 3.2.
:; { echo '/* autogenerated */' \
echo $(libfoo_la_OBJECTS) | grep '^foo\.lo$$'
END
-cat > foo.x_ << 'END'
+cat > foo.x-x << 'END'
int foo (void) { return yyparse(); }
END
-command_ok_ "libtoolize" libtoolize --force
-command_ok_ "aclocal" $ACLOCAL
-command_ok_ "autoconf" $AUTOCONF
-command_ok_ "automake" $AUTOMAKE --add-missing
-command_ok_ "configure" ./configure
-command_ok_ "make test" $MAKE test
-command_ok_ "make all" $MAKE all
+libtoolize --force
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure
+
+$MAKE test
+$MAKE all
:
+++ /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/>.
-
-# Tests that Automake understands multiple suffix rules on the same line.
-# PR/371 and PR/372: Reported by Duncan Gibson.
-# We also check for suffixes containing '-'.
-
-required=cc
-. ./defs || Exit 1
-
-plan_ 10
-
-cat >>configure.ac <<EOF
-AC_PROG_CC
-AC_OUTPUT
-EOF
-
-cat >Makefile.am << 'END'
-bin_PROGRAMS = foo bar baz
-foo_SOURCES = foo.x_
-bar_SOURCES = bar.y-z
-baz_SOURCES = baz1.x_ baz2.y-z
-
-.y-z.c .x_.c:
- sed 's/INTEGER/int/g' $< >$@
-
-CLEANFILES = foo.c bar.c baz1.c baz2.c
-
-.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
-
-command_ok_ "aclocal" $ACLOCAL
-command_ok_ "autoconf" $AUTOCONF
-
-# What we do is not portable. Automake should warn.
-AUTOMAKE_fails -a
-command_ok_ "warn about unportable make usage" \
- grep '[iI]nference rules can have only one target before the colon' stderr
-# But this should work anyway.
-command_ok_ "automake" $AUTOMAKE -a -Wno-portability
-
-command_ok_ "configure" ./configure
-command_ok_ "make test-fake" $MAKE test-fake OBJEXT=foo
-command_ok_ "make test-real" $MAKE test-real
-command_ok_ "make" $MAKE
-command_ok_ "make distcheck" $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/>.
-# Tests that Automake understands suffix rules with subdir objects.
-# Reported by John Ratliff.
+# Tests that pattern rules with subdir objects are understood.
+# Originally reported by John Ratliff against suffix rules.
+# This test currently fails, because Automake-NG don't scan nor
+# process pattern rules.
required=cc
. ./defs || Exit 1
cat >Makefile.am << 'END'
AUTOMAKE_OPTIONS = subdir-objects
-SUFFIXES = .baz .o
# We fake here:
-.baz.o:
+%.o: %.baz
cp $< $@
bin_PROGRAMS = foo
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# Tests that Automake understands suffix rules with renamed objects
-# and subdir objects.
-# Reported by Florian Briegel.
+# Tests that Automake understands suffix-based pattern rules with
+# renamed objects and subdir objects. Reported by Florian Briegel.
required=cc
. ./defs || Exit 1
cat >Makefile.am << 'END'
AUTOMAKE_OPTIONS = subdir-objects
-SUFFIXES = .baz .c
-.baz.c:
+%.c: %.baz
case $@ in sub/*) $(MKDIR_P) sub;; *) :;; esac
cp $< $@
bin_PROGRAMS = foo
foo_SOURCES = foo.c sub/bar.baz
-foo_CFLAGS =
+foo_CFLAGS = -DRETVAL=0
END
mkdir sub
int main () { return foo (); }
END
cat > foo.c <<'END'
-int foo () { return 0; }
+int foo () { return RETVAL; }
END
$ACLOCAL
required=c++
. ./defs || Exit 1
-plan_ 10
-
cat >> configure.ac << 'END'
AC_PROG_CXX
AC_OUTPUT
END
cat > Makefile.am << 'END'
-SUFFIXES = .zoo
-.zoo.cc:
+%.cc: %.zoo
sed 's/INTEGER/int/g' $< >$@
bin_PROGRAMS = foo
foo_SOURCES = foo.zoo
CLEANFILES = $(FOO).cc
END
-command_ok_ "aclocal" $ACLOCAL
-command_ok_ "automake" $AUTOMAKE
+$ACLOCAL
+$AUTOMAKE
# The foo.cc intermediate step is implicit, it's a mistake if
# Automake requires this file somewhere. Also, Automake should
# not require the file 'foo.c' anywhere.
-command_ok_ "intermediate files not mentioned" \
- not $FGREP foo.c Makefile.in
+$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).
-command_ok_ "final object file figured out" \
- $FGREP 'foo.$(OBJEXT)' Makefile.in
+$FGREP 'foo.$(OBJEXT)' Makefile.in
-command_ok_ "autoconf" $AUTOCONF
-command_ok_ "configure" ./configure
+$AUTOCONF
+./configure
# This is deliberately valid C++, but invalid C.
cat > foo.zoo <<'END'
}
END
-command_ok_ "make all" $MAKE all
-command_ok_ "make distcheck" $MAKE distcheck
+$MAKE all
+$MAKE distcheck
-# FIXME: should we check that intermediate file 'foo.cc' has
+# TODO: 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.
-command_ok_ "make distdir" $MAKE distdir
-command_ok_ "intermediate file not distributed" test ! -r $me-1.0/foo.cc
+$MAKE distdir
+test ! -r $me-1.0/foo.cc
:
+++ /dev/null
-#! /bin/sh
-# Copyright (C) 2001-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/>.
-
-# Test to make sure Automake doesn't abort on user-defined extensions.
-# Based on a report from Dmitry Mikhin <dmitrym@acres.com.au>.
-
-# Also make sure that .SUFFIXES is automatically adjusted with
-# extensions from implicit rules.
-
-. ./defs || Exit 1
-
-cat > Makefile.am << 'END'
-.k.o:
- echo $< > $@
-
-bin_PROGRAMS = foo
-foo_SOURCES = foo.k
-END
-
-$ACLOCAL
-$AUTOMAKE
-grep '^\.SUFFIXES:' Makefile.in | sed -e 's/$/ /' > suffixes
-cat suffixes
-$FGREP ' .k ' suffixes
-
-:
END
cat > Makefile.am << 'END'
-.k.lo:
+%.lo: %.k
(echo $< && cat $<) > $@
noinst_LTLIBRARIES = libfoo.la
+++ /dev/null
-#! /bin/sh
-# Copyright (C) 2001-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/>.
-
-# Test to make sure Automake supports implicit rules with dot-less
-# 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
-
-cat > Makefile.am << 'END'
-SUFFIXES = a b .$(OBJEXT) c .o .obj
-bin_PROGRAMS = foo
-foo_SOURCES = fooa barc bazc
-ab:
- dummy action 1
-b.$(OBJEXT):
- dummy action 2
-c.o:
- 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)
-$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-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/>.
-
-# Test to make sure Automake supports implicit rules with dot-less
-# extensions. Se also related "grepping" test suffix6.test.
-
-. ./defs || Exit 1
-
-cat >> configure.ac << '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-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/>.
-
-# Test to make sure Automake supports implicit rules "confusing"
-# extensions. Inspired by a mail from Alex Hornby.
-
-. ./defs || Exit 1
-
-cat > Makefile.am << 'END'
-SUFFIXES = .idl S.cpp C.h
-SUFFIXES += C.cpp S.h
-.idlC.cpp:
- cp $< $@
-END
-
-$ACLOCAL
-$AUTOMAKE
-
-# Make sure Automake has NOT recognized .cpp and .idlC as two new
-# extensions.
-grep 'SUFFIXES.* \.cpp' Makefile.in && Exit 1
-grep 'SUFFIXES.* \.idlC' Makefile.in && Exit 1
-
-:
required='cc libtoolize'
. ./defs || Exit 1
-plan_ 10
-
cat >>configure.ac <<'END'
AM_PROG_AR
AM_PROG_LIBTOOL
foo_SOURCES = foo.x_
libfoo_la_SOURCES = bar.x_
-.x_.y_:
+%.y_: %.x_
cp $< $@
-.y_.o:
+%.o: %.y_
cp $< $@
-.y_.obj:
+%.obj: %.y_
cp $< $@
-.y_.z_:
+%.z_: %.y_
cp $< $@
-.z_.lo:
+%.lo: %.z_
cp $< $@
-# 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 'int main (void) { return 0; }' > foo.x_
echo 'int bar (void) { return 0; }' > bar.x_
-command_ok_ "libtoolize" libtoolize
-command_ok_ "aclocal" $ACLOCAL
-command_ok_ "autoconf" $AUTOCONF
-command_ok_ "automake" $AUTOMAKE -a
-command_ok_ "configure" ./configure
-command_ok_ "make test0" $MAKE test0 OBJEXT=foo
+libtoolize
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE test0 OBJEXT=foo
for target in test1 test2 all distcheck; do
- command_ok_ "make $target" $MAKE $target
+ $MAKE $target
done
:
bin_PROGRAMS = foo
foo_SOURCES = foo.x_
-.x_.y:
+%.y: %.x_
cp $< $@
-.x_.c:
+%.c: %.x_
cp $< $@
END
bin_PROGRAMS = foo
foo_SOURCES = foo.x_
-.x_.c:
+%.c: %.x_
cp $< $@
-.x_.y:
+%.y: %.x_
cp $< $@
END
END
cat > Makefile.am <<END
+AUTOMAKE_OPTIONS = subdir-objects
include automake-options.am
-.c.o .c.obj:
- @echo bad
+noinst_PROGRAMS = foo
+foo_SOURCES = sub/foo.c
END
rm -rf autom4te*.cache
echo 'AM_INIT_AUTOMAKE' > am-init-automake.m4
$ACLOCAL
AUTOMAKE_fails -Werror -Wall --foreign
-grep '^Makefile\.am:.*inference rules can have only one target' stderr
+grep '^Makefile\.am:4:.*sub/foo\.c.*requires.*AM_PROG_CC_C_O' stderr
rm -rf autom4te*.cache
: > automake-options.am
$AUTOMAKE
rm -rf autom4te*.cache
-echo 'AUTOMAKE_OPTIONS = -Werror -Wnone gnits' > automake-options.am
+echo 'AUTOMAKE_OPTIONS += -Werror -Wnone gnits' > automake-options.am
echo 'AM_INIT_AUTOMAKE' > am-init-automake.m4
$ACLOCAL
$AUTOMAKE
# We want (almost) complete control over automake options.
AUTOMAKE="$am_original_AUTOMAKE -Werror"
-cat > Makefile.am <<'END'
-.c.o .c.obj:
- @echo bad
-AUTOMAKE_OPTIONS =
-END
-
set_warnings ()
{
set +x
- sed <$2 >$2-t -e "s|^\\(AUTOMAKE_OPTIONS\\) *=.*|\\1 = $1|" \
+ sed <$2 >$2-t -e "s|^\\(AUTOMAKE_OPTIONS\\) *+=.*|\\1 += $1|" \
-e "s|^\\(AM_INIT_AUTOMAKE\\).*|\\1([$1])|"
mv -f $2-t $2
set -x
ko ()
{
AUTOMAKE_fails $*
- grep '^Makefile\.am:1:.*inference rules can have only one target' stderr
+ grep '^Makefile\.am:5:.*sub/foo\.c.*requires.*AM_PROG_CC_C_O' stderr
}
+echo AC_PROG_CC >> configure.ac
+
+cat > Makefile.am <<END
+AUTOMAKE_OPTIONS = subdir-objects
+## For later editing by 'set_am_opts'.
+AUTOMAKE_OPTIONS +=
+noinst_PROGRAMS = foo
+foo_SOURCES = sub/foo.c
+END
+
$ACLOCAL
# Files required in gnu strictness.
# We want (almost) complete control over automake options.
AUTOMAKE="$am_original_AUTOMAKE -Werror"
-cat > Makefile.am <<'END'
-.c.o .c.obj:
- @echo bad
-AUTOMAKE_OPTIONS =
-END
-
set_warnings ()
{
set +x
- sed <$2 >$2-t -e "s|^\\(AUTOMAKE_OPTIONS\\) *=.*|\\1 = $1|" \
+ sed <$2 >$2-t -e "s|^\\(AUTOMAKE_OPTIONS\\) *+=.*|\\1 += $1|" \
-e "s|^\\(AM_INIT_AUTOMAKE\\).*|\\1([$1])|"
mv -f $2-t $2
set -x
ko ()
{
AUTOMAKE_fails $*
- grep '^Makefile\.am:1:.*inference rules can have only one target' stderr
+ grep '^Makefile\.am:5:.*sub/foo\.c.*requires.*AM_PROG_CC_C_O' stderr
}
# Files required in gnu strictness.
touch README INSTALL NEWS AUTHORS ChangeLog COPYING
+echo AC_PROG_CC >> configure.ac
+
+cat > Makefile.am <<END
+AUTOMAKE_OPTIONS = subdir-objects
+## For later editing by 'set_warnings'.
+AUTOMAKE_OPTIONS +=
+noinst_PROGRAMS = foo
+foo_SOURCES = sub/foo.c
+END
+
$ACLOCAL
ok -Wportability -Wno-portability
ko -Wno-portability -Wportability
# We want (almost) complete control over automake options.
AUTOMAKE="$am_original_AUTOMAKE -Werror"
+echo AC_PROG_CC >> configure.ac
+
cat > Makefile.am <<END
-AUTOMAKE_OPTIONS =
-.c.o .c.obj:
- @echo bad
+AUTOMAKE_OPTIONS = subdir-objects
+## For later editing by 'set_am_opts'.
+AUTOMAKE_OPTIONS +=
+noinst_PROGRAMS = foo
+foo_SOURCES = sub/foo.c
END
set_am_opts ()
{
set +x
- sed <$2 >$2-t -e "s|^\\(AUTOMAKE_OPTIONS\\) *=.*|\\1 = $1|" \
+ sed <$2 >$2-t -e "s|^\\(AUTOMAKE_OPTIONS\\) *+=.*|\\1 += $1|" \
-e "s|^\\(AM_INIT_AUTOMAKE\\).*|\\1([$1])|"
mv -f $2-t $2
set -x
set_am_opts 'gnu' Makefile.am
AUTOMAKE_fails
-$ACLOCAL
-grep '^Makefile\.am:2:.*inference rules can have only one target' stderr
+grep '^Makefile\.am:5:.*sub/foo\.c.*requires.*AM_PROG_CC_C_O' stderr
:
ko ()
{
AUTOMAKE_run $*
- grep '^Makefile\.am:.*inference rules can have only one target' stderr
+ grep '^Makefile\.am:.*sub/foo\.c.*requires.*AM_PROG_CC_C_O' stderr
test `wc -l <stderr` -eq 1
}
-set_am_opts()
+set_am_opts ()
{
set +x
- sed <$2 >$2-t -e "s|^\\(AUTOMAKE_OPTIONS\\) *=.*|\\1 = $1|" \
+ sed <$2 >$2-t -e "s|^\\(AUTOMAKE_OPTIONS\\) *+=.*|\\1 += $1|" \
-e "s|^\\(AM_INIT_AUTOMAKE\\).*|\\1([$1])|"
mv -f $2-t $2
set -x
# Files required in gnu strictness.
touch README INSTALL NEWS AUTHORS ChangeLog COPYING
+echo AC_PROG_CC >> configure.ac
+
cat > Makefile.am <<END
-AUTOMAKE_OPTIONS =
-.c.o .c.obj:
- @echo bad
+AUTOMAKE_OPTIONS = subdir-objects
+## For later editing by 'set_am_opts'.
+AUTOMAKE_OPTIONS +=
+noinst_PROGRAMS = foo
+foo_SOURCES = sub/foo.c
END
$ACLOCAL