1 # $NetBSD: cond-func-make-main.mk,v 1.2 2021/04/04 10:13:09 rillig Exp $
3 # Test how accurately the make() function in .if conditions reflects
4 # what is actually made.
6 # There are several ways to specify what is being made:
8 # 1. The default main target is the first target in the given makefiles that
9 # is not one of the special targets. For example, .PHONY is special when
10 # it appears on the left-hand side of the ':'. It is not special on the
11 # right-hand side though.
13 # 2. Command line arguments that are neither options (-ds or -k) nor variable
14 # assignments (VAR=value) are interpreted as targets to be made. These
15 # override the default main target from above.
17 # 3. All sources of the first '.MAIN: sources' line. Any further .MAIN line
18 # is treated as if .MAIN were a regular name.
20 # This test only covers items 1 and 3. For item 2, see cond-func-make.mk.
25 # Even though the main-target would actually be made at this point, it is
26 # ignored by the make() function.
27 .if make(first-main-target)
31 # Declaring a target via the .MAIN dependency adds it to the targets to be
32 # created (opts.create), but only that list was empty at the beginning of
33 # the line. This implies that several main targets can be set at the name
34 # time, but they have to be in the same dependency group.
36 # See ParseDependencyTargetSpecial, branch SP_MAIN.
37 .MAIN: dot-main-target-1a dot-main-target-1b
39 .if !make(dot-main-target-1a)
42 .if !make(dot-main-target-1b)
46 dot-main-target-{1,2}{a,b}:
49 # At this point, the list of targets to be made (opts.create) is not empty
50 # anymore. ParseDependencyTargetSpecial therefore treats the .MAIN as if
51 # it were an ordinary target. Since .MAIN is not listed as a dependency
52 # anywhere, it is not made.
56 .MAIN: dot-main-target-2a dot-main-target-2b
60 .if make(dot-main-target-2a)