summaryrefslogtreecommitdiff
path: root/usr.bin/make/unit-tests/include-main.mk
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2020-05-17 12:36:26 +0000
committerrillig <rillig@NetBSD.org>2020-05-17 12:36:26 +0000
commita3d593e7fe371f2baedcd4ebecf6b9babdca4014 (patch)
treecf0cd740f55d9e85159f540c8c86b868b57be402 /usr.bin/make/unit-tests/include-main.mk
parentc200136eba99e472fe191687a18a407b1756ca80 (diff)
usr.bin/make: demonstrate actual behavior of .INCLUDEDFROMFILE
Diffstat (limited to 'usr.bin/make/unit-tests/include-main.mk')
-rw-r--r--usr.bin/make/unit-tests/include-main.mk30
1 files changed, 30 insertions, 0 deletions
diff --git a/usr.bin/make/unit-tests/include-main.mk b/usr.bin/make/unit-tests/include-main.mk
new file mode 100644
index 00000000000..452b6102a5c
--- /dev/null
+++ b/usr.bin/make/unit-tests/include-main.mk
@@ -0,0 +1,30 @@
+# $NetBSD: include-main.mk,v 1.1 2020/05/17 12:36:26 rillig Exp $
+#
+# Demonstrates that the .INCLUDEDFROMFILE magic variable does not behave
+# as described in the manual page.
+#
+# The manual page says that it is the "filename of the file this Makefile
+# was included from", while in reality it is the "filename in which the
+# latest .include happened".
+#
+
+.if !defined(.INCLUDEDFROMFILE)
+LOG+= main-before-ok
+.else
+. for f in ${.INCLUDEDFROMFILE}
+LOG+= main-before-fail\(${f:Q}\)
+. endfor
+.endif
+
+.include "include-sub.mk"
+
+.if !defined(.INCLUDEDFROMFILE)
+LOG+= main-after-ok
+.else
+. for f in ${.INCLUDEDFROMFILE}
+LOG+= main-after-fail\(${f:Q}\)
+. endfor
+.endif
+
+all:
+ @printf '%s\n' ${LOG}