xref: /freebsd/contrib/bmake/unit-tests/deptgt-main.mk (revision 9f45a3c8c82ffead7044ae836d9257113c630d3b)
1*9f45a3c8SSimon J. Gerraty# $NetBSD: deptgt-main.mk,v 1.4 2022/01/23 21:48:59 rillig Exp $
22c3632d1SSimon J. Gerraty#
3e2eeea75SSimon J. Gerraty# Tests for the special target .MAIN in dependency declarations, which defines
4e2eeea75SSimon J. Gerraty# the main target.  This main target is built if no target has been specified
5e2eeea75SSimon J. Gerraty# on the command line or via MAKEFLAGS.
62c3632d1SSimon J. Gerraty
7*9f45a3c8SSimon J. Gerraty# The first target becomes the main target by default.  It can be overridden
8*9f45a3c8SSimon J. Gerraty# though.
9*9f45a3c8SSimon J. Gerratyall: .PHONY
10*9f45a3c8SSimon J. Gerraty	@echo 'This target is not made.'
112c3632d1SSimon J. Gerraty
12*9f45a3c8SSimon J. Gerraty# This target is not the first to be defined, but it lists '.MAIN' as one of
13*9f45a3c8SSimon J. Gerraty# its sources.  The word '.MAIN' only has a special meaning when it appears as
14*9f45a3c8SSimon J. Gerraty# a _target_ in a dependency declaration, not as a _source_.  It is thus
15*9f45a3c8SSimon J. Gerraty# ignored.
16*9f45a3c8SSimon J. Gerratydepsrc-main: .PHONY .MAIN
17*9f45a3c8SSimon J. Gerraty	@echo 'This target is not made either.'
18*9f45a3c8SSimon J. Gerraty
19*9f45a3c8SSimon J. Gerraty# This target is the first to be marked with '.MAIN', so it replaces the
20*9f45a3c8SSimon J. Gerraty# previous main target, which was 'all'.
21*9f45a3c8SSimon J. Gerraty.MAIN: real-main
22*9f45a3c8SSimon J. Gerratyreal-main: .PHONY
23*9f45a3c8SSimon J. Gerraty	@echo 'This target ${.TARGET} is the one that is made.'
24*9f45a3c8SSimon J. Gerraty
25*9f45a3c8SSimon J. Gerraty# This target is marked with '.MAIN' but there already is a main target.  The
26*9f45a3c8SSimon J. Gerraty# attribute '.MAIN' is thus ignored.
27*9f45a3c8SSimon J. Gerraty.MAIN: too-late
28*9f45a3c8SSimon J. Gerratytoo-late: .PHONY
29*9f45a3c8SSimon J. Gerraty	@echo 'This target comes too late, there is already a .MAIN target.'
30