>Synopsis: make ignores single-suffix inference rules with dependencies
>Category: user
>Environment:
System : OpenBSD 7.7
Details : OpenBSD 7.7 (GENERIC.MP) #2: Sun Jun 29 09:04:02 MDT 2025
[email protected]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
Architecture: OpenBSD.amd64
Machine : amd64
>Description:
A make(1) rule which uses suffix inference is being ignored if the
target has explicit prerequisites declared (but no explicit rule
command itself).
This only happens for single-suffix rules (e.g ".c:").
>How-To-Repeat:
Consider this makefile:
.c.o:
echo RULE .c.o: $< $@
foo.c: foo.h
.c:
echo RULE .c: $< $@
bar: bar.h
Create the files and build foo.o and bar:
% touch foo.c foo.h bar.c bar.h
% make foo.o
echo RULE .c.o: foo.c foo.o
RULE .c.o: foo.c foo.o
% make bar
%
Here, "make bar" should have triggered the ".c" rule.
When we remove the line "bar: bar.h", it does.
This works in GNU Make 4.4.1, portable NetBSD bmake-20250804,
pdpmake 2.0.3, Smake 1.7.
POSIX-1.2024 says:
> Prerequisites added by target rules without commands shall not
> affect the selection of the applicable inference rule.
Since it already works for the ".c.o" rule, I think this is a bug.
--
Leah Neukirchen <[email protected]> https://leahneukirchen.org/