include-main.mk revision 1.4 1 # $NetBSD: include-main.mk,v 1.4 2020/09/05 18:13:47 rillig Exp $
2 #
3 # Demonstrates that the .INCLUDEDFROMFILE magic variable does not behave
4 # as described in the manual page.
5 #
6 # The manual page says that it is the "filename of the file this Makefile
7 # was included from", while in reality it is the "filename in which the
8 # latest .include happened". See parse.c, function ParseSetIncludeFile.
9 #
10
11 .if !defined(.INCLUDEDFROMFILE)
12 . info main-before-ok
13 .else
14 . warning main-before-fail(${.INCLUDEDFROMFILE})
15 .endif
16
17 .for i in once
18 . if !defined(${.INCLUDEDFROMFILE})
19 . info main-before-for-ok
20 . else
21 . warning main-before-for-fail(${.INCLUDEDFROMFILE})
22 . endif
23 .endfor
24
25 .include "include-sub.mk"
26
27 .if !defined(.INCLUDEDFROMFILE)
28 . info main-after-ok
29 .else
30 . warning main-after-fail(${.INCLUDEDFROMFILE})
31 .endif
32
33 .for i in once
34 . if !defined(${.INCLUDEDFROMFILE})
35 . info main-after-for-ok
36 . else
37 . warning main-after-for-fail(${.INCLUDEDFROMFILE})
38 . endif
39 .endfor
40
41 all: # nothing
42