1 # $NetBSD: opt-m-include-dir.mk,v 1.4 2020/09/01 20:14:34 rillig Exp $
3 # Tests for the -m command line option, which adds a directory to the
4 # search path for the .include <...> directive.
6 # The .../canary.mk special argument starts searching in the current
7 # directory and walks towards the file system root, until it finds a
8 # directory that contains a file called canary.mk.
10 # To set up this scenario, the file step2.mk is created deep in a hierarchy
11 # of subdirectories. Another file called opt-m-step3.mk is created a few
12 # steps up in the directory hierarchy, serving as the canary file.
14 # Next to the canary file, there is opt-m-step3.mk. This file is found
15 # by mentioning its simple name in an .include directive. It defines the
16 # target "step2" that is needed by "step2.mk".
18 .if ${.PARSEFILE:T} == "opt-m-include-dir.mk"
20 # Set up the other files needed for this test.
22 TEST_DIR:= ${.PARSEFILE:R}.tmp/sub/sub/sub/workdir
23 CANARY_FILE:= ${.PARSEFILE:R}.tmp/sub/opt-m-canary.mk
24 ACTUAL_FILE:= ${.PARSEFILE:R}.tmp/sub/opt-m-step3.mk
26 _!= mkdir -p ${TEST_DIR}
28 _!= cp ${MAKEFILE} ${TEST_DIR}/step2.mk
29 _!= cp ${MAKEFILE} ${ACTUAL_FILE}
32 @${.MAKE} -C ${TEST_DIR} -f step2.mk step2
35 @rm -rf ${MAKEFILE:R}.tmp
37 .elif ${.PARSEFILE:T} == "step2.mk"
39 # This is the file deep in the directory hierarchy. It sets up the
40 # search path for the .include <...> directive and then includes a
41 # single file from that search path.
43 # This option adds .tmp/sub to the search path for .include <...>.
44 .MAKEFLAGS: -m .../opt-m-canary.mk
46 # This option does not add any directory to the search path since the
47 # canary file does not exist.
48 .MAKEFLAGS: -m .../does-not-exist
50 .include <opt-m-step3.mk>
52 .elif ${.PARSEFILE:T} == "opt-m-step3.mk"
54 # This file is included by step2.mk.