xref: /freebsd/contrib/bmake/unit-tests/use-inference.mk (revision 994297b01b98816bea1abf45ae4bac1bc69ee7a0)
1# $NetBSD: use-inference.mk,v 1.3 2020/12/07 00:53:30 rillig Exp $
2#
3# Demonstrate that .USE rules do not have an effect on inference rules.
4# At least not in the special case where the inference rule does not
5# have any associated commands.
6
7.SUFFIXES:
8.SUFFIXES: .from .to
9
10all: use-inference.to
11
12verbose: .USE
13	@echo 'Verbosely making $@ out of $>'
14
15.from.to: verbose
16# Since this inference rule does not have any associated commands, it
17# is ignored.
18#
19#	@echo 'Building $@ from $<'
20
21use-inference.from:		# assume it exists
22	@echo 'Building $@ from nothing'
23
24# Possible but unproven explanation:
25#
26# The main target is "all", which depends on "use-inference.to".
27# The inference connects the .from to the .to file, otherwise make
28# would not know that the .from file would need to be built.
29#
30# The .from file is then built.
31#
32# After this, make stops since it doesn't know how to make the .to file.
33# This is strange since make definitely knows about the .from.to suffix
34# inference rule.  But it seems to ignore it, maybe because it doesn't
35# have any associated commands.
36
37# Until 2020-12-07, despite the error message "don't know how to make",
38# the exit status was 0.  This was inconsistent.
39