On Wed, 2016-04-06 at 13:54 -0400, drwho wrote:
Make version 4.1 in Ubuntu 16.04 has different behaviour using the @
(silent) .
It's very helpful if you specify what the older version of make is that
you were using that had different behavior.
%o : %c
@echo "CC $<"
@$(CC) -c $(CFLAGS) $(INCDIR) $< -o $@
now I get this.....
gcc -DI_SHOULD_NOT_SEE_THIS -c -o main.o main.c
gcc -DI_SHOULD_NOT_SEE_THIS -c -o bob.o bob.c
gcc -DI_SHOULD_NOT_SEE_THIS -c -o sally.o sally.c
The @ before the $(CC) doesn't silent anymore?
Well, since you don't see the "CC ..." output, and since the order of
options in the compile line doesn't match the order in your pattern
rule...
It's quite clear that make is not using your pattern rule at all and is
instead using the built-in pattern rule.
My suspicion is that you were using a version of make prior to 3.82.
In newer versions of GNU make, if there are multiple pattern rules
that could be used to build a target make will use the "shortest stem"
rule.
Your pattern rule is odd because you've omitted the "." in the
extension:
%o : %c
where the built-in rule is written (effectively) like this:
%.o : %.c
Because of this, given a target of "foo.o" the built-in rule yields a
stem of "foo" and your pattern rule yields a stem of "foo." (the stem
is the part that matches the "%" of course).
So, the built-in rule has a shorter stem (3 characters where your rule
has 4 characters) and so the built-in rule will take precedence and
your rule will be ignored, except for targets which don't have a ".o"
at the end, so something like "bar.oo" or whatever).
You should change your pattern rule to include the "." and then your
makefile will work:
%.o : %.c
@echo "CC $<"
@$(CC) -c $(CFLAGS) $(INCDIR) $< -o $@