xref: /freebsd/contrib/bmake/unit-tests/depsrc-use.mk (revision 2f2a5ecdf8a04af94c0c5995fd321cafaf630e45)
1*2f2a5ecdSSimon J. Gerraty# $NetBSD: depsrc-use.mk,v 1.6 2022/04/18 14:38:24 rillig Exp $
22c3632d1SSimon J. Gerraty#
32c3632d1SSimon J. Gerraty# Tests for the special source .USE in dependency declarations,
42c3632d1SSimon J. Gerraty# which allows to append common commands to other targets.
5*2f2a5ecdSSimon J. Gerraty#
6*2f2a5ecdSSimon J. Gerraty# See also:
7*2f2a5ecdSSimon J. Gerraty#	.USEBEFORE
8*2f2a5ecdSSimon J. Gerraty#	depsrc-usebefore.mk
92c3632d1SSimon J. Gerraty
109f45a3c8SSimon J. Gerraty# Before make.h 1.280 from 2021-12-28, a .USEBEFORE target was accidentally
119f45a3c8SSimon J. Gerraty# regarded as a candidate for the main target.  On the other hand, a .USE
129f45a3c8SSimon J. Gerraty# target was not.
139f45a3c8SSimon J. Gerratynot-a-main-candidate: .USE
149f45a3c8SSimon J. Gerraty
152c3632d1SSimon J. Gerratyall: action directly
162c3632d1SSimon J. Gerraty
17*2f2a5ecdSSimon J. Gerratyfirst: .USE first-first first-second
182c3632d1SSimon J. Gerraty	@echo first 1		# Using ${.TARGET} here would expand to "action"
192c3632d1SSimon J. Gerraty	@echo first 2
20*2f2a5ecdSSimon J. Gerratyfirst-first: .USE
21*2f2a5ecdSSimon J. Gerraty	@echo first-first 1
22*2f2a5ecdSSimon J. Gerraty	@echo first-first 2
23*2f2a5ecdSSimon J. Gerratyfirst-second: .USE
24*2f2a5ecdSSimon J. Gerraty	@echo first-second 1
25*2f2a5ecdSSimon J. Gerraty	@echo first-second 2
262c3632d1SSimon J. Gerraty
272c3632d1SSimon J. Gerratysecond: .USE
282c3632d1SSimon J. Gerraty	@echo second 1
292c3632d1SSimon J. Gerraty	@echo second 2
302c3632d1SSimon J. Gerraty
312c3632d1SSimon J. Gerraty# It's possible but uncommon to have a .USE target with no commands.
322c3632d1SSimon J. Gerraty# This may happen as the result of expanding a .for loop.
332c3632d1SSimon J. Gerratyempty: .USE
342c3632d1SSimon J. Gerraty
35*2f2a5ecdSSimon J. Gerraty# It's possible but uncommon to directly make a .USE target.
362c3632d1SSimon J. Gerratydirectly: .USE
372c3632d1SSimon J. Gerraty	@echo directly
382c3632d1SSimon J. Gerraty
392c3632d1SSimon J. Gerratyaction: first second empty
40