On Sat, Dec 26, 2020 at 05:19:55PM +0100, Klemens Nanni wrote:
> After that I'd like to expand it and explain behaviour for other types;
> I've scratched my head on make's behaviour for too long and the manual
> failed to cover this completely.

Here is a minimal diff against our make.1, i.e. not on top of the NetBSD
sync diff.

It ought to complete the mentions of relevant line types which decide
when variables are subsituted.

Here's a trivial Makefile and its output to demonstrate the essence of a
bug I've chased in bsd.port.mk(5):  commands use the "last" value of the
variable (as intended) while conditional directives use whatever value
the variable held at parse time:

        $ cat Makefile
        BOOL =  true

        bool:
                @echo BOOL contains \"${BOOL}\"
                @echo -n '`.  if $${BOOL} == "true"` is '
        .if ${BOOL} == "true"
                @echo true
        .else
                @echo false
        .endif

        BOOL =  false

        $ make bool
        BOOL contains "false"
        `.  if ${BOOL} == "true"` is true

I'd still to get an OK for the previous sync diff and then merge this
diff into the list but have refrained from a combined diff for now to
ease review.

Feedback? Objections? OK?


Index: make.1
===================================================================
RCS file: /cvs/src/usr.bin/make/make.1,v
retrieving revision 1.131
diff -u -p -r1.131 make.1
--- make.1      26 Jan 2020 12:40:50 -0000      1.131
+++ make.1      30 Dec 2020 17:36:54 -0000
@@ -600,9 +600,9 @@ If the variable name contains only a sin
 braces or parentheses are not required.
 This shorter form is not recommended.
 .Pp
-Variable substitution occurs at two distinct times, depending on where
-the variable is being used.
-Variables in dependency lines are expanded as the line is read.
+Variable substitution occurs at distinct times, depending on the type of line.
+Variables in dependency lines, conditinal directives and include statements are
+expanded as the line is read.
 Variables in shell commands are expanded when the shell command is
 executed.
 .Pp

Reply via email to