1 # $NetBSD: deptgt-begin.mk,v 1.7 2023/06/01 20:56:35 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.
7 # expect+2: warning: using previous script for ".BEGIN" defined here
11 # To register a custom action to be run at the beginning, the simplest way is
12 # to directly place some commands on the '.BEGIN' target. This doesn't scale
13 # though, since the ':' dependency operator prevents that any other place may
14 # add its commands after this.
16 # There are several ways to resolve this situation, which are detailed below.
17 # expect+2: warning: duplicate script for target ".BEGIN" ignored
21 # One way to run commands at the beginning is to define a custom target and
22 # make the .BEGIN depend on that target. This way, the commands from the
23 # custom target are run even before the .BEGIN target.
25 before-begin: .PHONY .NOTMAIN
26 : Making $@ before .BEGIN.
28 # Another way is to define a custom target and make that a .USE dependency.
29 # For the .BEGIN target, .USE dependencies do not work though, since in
30 # Compat_MakeAll, the .USE and .USEBEFORE nodes are expanded right after the
31 # .BEGIN target has been made, which is too late.
34 : Making $@ from a .USE dependency.
36 # Same as with .USE, but run the commands before the main commands from the
39 # For the .BEGIN target, .USEBEFORE dependencies do not work though, since in
40 # Compat_MakeAll, the .USE and .USEBEFORE nodes are expanded right after the
41 # .BEGIN target has been made, which is too late.
43 use-before: .USEBEFORE .NOTMAIN
44 : Making $@ from a .USEBEFORE dependency.
49 _!= echo : parse time 1>&2