1# $NetBSD: include-main.mk,v 1.8 2023/01/19 23:26:14 rillig Exp $
2#
3# Until 2020-09-05, the .INCLUDEDFROMFILE magic variable did 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 before 2020-09-05 it was the "filename in which
8# the latest .include happened". See parse.c, function SetParseFile.
9#
10# Since 2020-09-05, the .INCLUDEDFROMDIR and .INCLUDEDFROMFILE variables
11# properly handle nested includes and even .for loops.
12
13.if !defined(.INCLUDEDFROMFILE)
14.  info main-before-ok
15.else
16.  warning main-before-fail(${.INCLUDEDFROMFILE})
17.endif
18
19.for i in once
20.  if !defined(.INCLUDEDFROMFILE)
21.    info main-before-for-ok
22.  else
23.    warning main-before-for-fail(${.INCLUDEDFROMFILE})
24.  endif
25.endfor
26
27.include "include-sub.inc"
28
29.if !defined(.INCLUDEDFROMFILE)
30.  info main-after-ok
31.else
32.  warning main-after-fail(${.INCLUDEDFROMFILE})
33.endif
34
35.for i in once
36.  if !defined(.INCLUDEDFROMFILE)
37.    info main-after-for-ok
38.  else
39.    warning main-after-for-fail(${.INCLUDEDFROMFILE})
40.  endif
41.endfor
42
43all:	# nothing
44