make(1): make test for .INCLUDEDFROMDIR simpler
The .info and .warning directives provide exactly the early expansion that this test needs. No more .for for getting a snapshot of a variable.
This commit is contained in:
parent
ec997a58d5
commit
8981885e47
@ -1,6 +1,6 @@
|
|||||||
main-before-ok
|
make: "include-main.mk" line 12: main-before-ok
|
||||||
sub-before-ok
|
make: "include-sub.mk" line 4: sub-before-ok
|
||||||
subsub-ok
|
make: "include-subsub.mk" line 4: subsub-ok
|
||||||
sub-after-fail(include-sub.mk)
|
make: "include-sub.mk" line 14: warning: sub-after-fail(include-sub.mk)
|
||||||
main-after-fail(include-sub.mk)
|
make: "include-main.mk" line 22: warning: main-after-fail(include-sub.mk)
|
||||||
exit status 0
|
exit status 0
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# $NetBSD: include-main.mk,v 1.2 2020/07/27 20:55:59 rillig Exp $
|
# $NetBSD: include-main.mk,v 1.3 2020/09/05 16:59:19 rillig Exp $
|
||||||
#
|
#
|
||||||
# Demonstrates that the .INCLUDEDFROMFILE magic variable does not behave
|
# Demonstrates that the .INCLUDEDFROMFILE magic variable does not behave
|
||||||
# as described in the manual page.
|
# as described in the manual page.
|
||||||
@ -9,22 +9,17 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
.if !defined(.INCLUDEDFROMFILE)
|
.if !defined(.INCLUDEDFROMFILE)
|
||||||
LOG+= main-before-ok
|
. info main-before-ok
|
||||||
.else
|
.else
|
||||||
. for f in ${.INCLUDEDFROMFILE}
|
. warning main-before-fail(${.INCLUDEDFROMFILE})
|
||||||
LOG+= main-before-fail\(${f:Q}\)
|
|
||||||
. endfor
|
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
.include "include-sub.mk"
|
.include "include-sub.mk"
|
||||||
|
|
||||||
.if !defined(.INCLUDEDFROMFILE)
|
.if !defined(.INCLUDEDFROMFILE)
|
||||||
LOG+= main-after-ok
|
. info main-after-ok
|
||||||
.else
|
.else
|
||||||
. for f in ${.INCLUDEDFROMFILE}
|
. warning main-after-fail(${.INCLUDEDFROMFILE})
|
||||||
LOG+= main-after-fail\(${f:Q}\)
|
|
||||||
. endfor
|
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
all:
|
all: # nothing
|
||||||
@printf '%s\n' ${LOG}
|
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
# $NetBSD: include-sub.mk,v 1.1 2020/05/17 12:36:26 rillig Exp $
|
# $NetBSD: include-sub.mk,v 1.2 2020/09/05 16:59:19 rillig Exp $
|
||||||
|
|
||||||
.if ${.INCLUDEDFROMFILE} == "include-main.mk"
|
.if ${.INCLUDEDFROMFILE} == "include-main.mk"
|
||||||
LOG+= sub-before-ok
|
. info sub-before-ok
|
||||||
.else
|
.else
|
||||||
LOG+= sub-before-fail
|
. warning sub-before-fail
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
.include "include-subsub.mk"
|
.include "include-subsub.mk"
|
||||||
|
|
||||||
.if ${.INCLUDEDFROMFILE} == "include-main.mk"
|
.if ${.INCLUDEDFROMFILE} == "include-main.mk"
|
||||||
LOG+= sub-after-ok
|
. info sub-after-ok
|
||||||
.else
|
.else
|
||||||
. for f in ${.INCLUDEDFROMFILE}
|
. warning sub-after-fail(${.INCLUDEDFROMFILE})
|
||||||
LOG+= sub-after-fail\(${f:Q}\)
|
|
||||||
. endfor
|
|
||||||
.endif
|
.endif
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# $NetBSD: include-subsub.mk,v 1.1 2020/05/17 12:36:26 rillig Exp $
|
# $NetBSD: include-subsub.mk,v 1.2 2020/09/05 16:59:19 rillig Exp $
|
||||||
|
|
||||||
.if ${.INCLUDEDFROMFILE:T} == "include-sub.mk"
|
.if ${.INCLUDEDFROMFILE:T} == "include-sub.mk"
|
||||||
LOG+= subsub-ok
|
. info subsub-ok
|
||||||
.else
|
.else
|
||||||
LOG+= subsub-fail
|
. warning subsub-fail
|
||||||
.endif
|
.endif
|
||||||
|
Loading…
Reference in New Issue
Block a user