1 # $NetBSD: deptgt-begin.mk,v 1.5 2020/11/15 22:28:08 rillig Exp $
3 # Tests for the special target .BEGIN in dependency declarations,
4 # which is a container for commands that are run before any other
5 # commands from the shell lines.
10 # To register a custom action to be run at the beginning, the simplest way is
11 # to directly place some commands on the '.BEGIN' target. This doesn't scale
12 # though, since the ':' dependency operator prevents that any other place may
13 # add its commands after this.
15 # There are several ways to resolve this situation, which are detailed below.
19 # One way to run commands at the beginning is to define a custom target and
20 # make the .BEGIN depend on that target. This way, the commands from the
21 # custom target are run even before the .BEGIN target.
23 before-begin: .PHONY .NOTMAIN
24 : Making $@ before .BEGIN.
26 # Another way is to define a custom target and make that a .USE dependency.
27 # For the .BEGIN target, .USE dependencies do not work though, since in
28 # Compat_Run, the .USE and .USEBEFORE nodes are expanded right after the
29 # .BEGIN target has been run, which is too late.
32 : Making $@ from a .USE dependency.
34 # Same as with .USE, but run the commands before the main commands from the
37 # For the .BEGIN target, .USEBEFORE dependencies do not work though, since in
38 # Compat_Run, the .USE and .USEBEFORE nodes are expanded right after the
39 # .BEGIN target has been run, which is too late.
41 use-before: .USEBEFORE .NOTMAIN
42 : Making $@ from a .USEBEFORE dependency.
47 _!= echo : parse time 1>&2