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
|
||||
sub-before-ok
|
||||
subsub-ok
|
||||
sub-after-fail(include-sub.mk)
|
||||
main-after-fail(include-sub.mk)
|
||||
make: "include-main.mk" line 12: main-before-ok
|
||||
make: "include-sub.mk" line 4: sub-before-ok
|
||||
make: "include-subsub.mk" line 4: subsub-ok
|
||||
make: "include-sub.mk" line 14: warning: sub-after-fail(include-sub.mk)
|
||||
make: "include-main.mk" line 22: warning: main-after-fail(include-sub.mk)
|
||||
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
|
||||
# as described in the manual page.
|
||||
|
@ -9,22 +9,17 @@
|
|||
#
|
||||
|
||||
.if !defined(.INCLUDEDFROMFILE)
|
||||
LOG+= main-before-ok
|
||||
. info main-before-ok
|
||||
.else
|
||||
. for f in ${.INCLUDEDFROMFILE}
|
||||
LOG+= main-before-fail\(${f:Q}\)
|
||||
. endfor
|
||||
. warning main-before-fail(${.INCLUDEDFROMFILE})
|
||||
.endif
|
||||
|
||||
.include "include-sub.mk"
|
||||
|
||||
.if !defined(.INCLUDEDFROMFILE)
|
||||
LOG+= main-after-ok
|
||||
. info main-after-ok
|
||||
.else
|
||||
. for f in ${.INCLUDEDFROMFILE}
|
||||
LOG+= main-after-fail\(${f:Q}\)
|
||||
. endfor
|
||||
. warning main-after-fail(${.INCLUDEDFROMFILE})
|
||||
.endif
|
||||
|
||||
all:
|
||||
@printf '%s\n' ${LOG}
|
||||
all: # nothing
|
||||
|
|
|
@ -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"
|
||||
LOG+= sub-before-ok
|
||||
. info sub-before-ok
|
||||
.else
|
||||
LOG+= sub-before-fail
|
||||
. warning sub-before-fail
|
||||
.endif
|
||||
|
||||
.include "include-subsub.mk"
|
||||
|
||||
.if ${.INCLUDEDFROMFILE} == "include-main.mk"
|
||||
LOG+= sub-after-ok
|
||||
. info sub-after-ok
|
||||
.else
|
||||
. for f in ${.INCLUDEDFROMFILE}
|
||||
LOG+= sub-after-fail\(${f:Q}\)
|
||||
. endfor
|
||||
. warning sub-after-fail(${.INCLUDEDFROMFILE})
|
||||
.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"
|
||||
LOG+= subsub-ok
|
||||
. info subsub-ok
|
||||
.else
|
||||
LOG+= subsub-fail
|
||||
. warning subsub-fail
|
||||
.endif
|
||||
|
|
Loading…
Reference in New Issue