1 # $NetBSD: directive-export-impl.mk,v 1.1 2020/12/29 01:45:06 rillig Exp $
3 # Test for the implementation of exporting variables to child processes.
4 # This involves marking variables for export, actually exporting them,
5 # or marking them for being re-exported.
10 # VarExportedMode (global)
11 # VAR_EXPORTED (per variable)
12 # VAR_REEXPORT (per variable)
13 # VarExportMode (per call of Var_Export and ExportVar)
15 : ${:U:sh} # side effect: initialize .SHELL
19 # This is a variable that references another variable. At this point, the
20 # other variable is still undefined.
23 # At this point, ExportVar("UT_VAR", VEM_PLAIN) is called. Since the
24 # variable value refers to another variable, ExportVar does not actually
25 # export the variable but only marks it as VAR_EXPORTED and VAR_REEXPORT.
26 # After that, ExportVars registers the variable name in .MAKE.EXPORTED.
30 # Evaluating this expression shows the variable flags in the debug log,
31 # which are VAR_EXPORTED|VAR_REEXPORT.
34 # At the last moment before actually forking off the child process for the
35 # :!...! modifier, Cmd_Exec calls Var_ReexportVars to have all relevant
36 # variables exported. Since this variable has both of the above-mentioned
37 # flags set, it is actually exported to the environment. The variable flags
38 # are not modified though, since the next time the :!...! modifier is
39 # evaluated, the referenced variables could have changed, therefore the
40 # variable will be exported anew for each ':sh' modifier, ':!...!' modifier,
41 # '!=' variable assignment.
42 .if ${:!echo "\$UT_VAR"!} != "<>"
46 # Evaluating this expression shows the variable flags in the debug log,
47 # which are still VAR_EXPORTED|VAR_REEXPORT, which means that the variable
48 # is still marked as being re-exported for each child process.
51 # Now the referenced variable gets defined. This does not influence anything
52 # in the process of exporting the variable value, though.
55 # Nothing surprising here. The variable UT_VAR gets exported, and this time,
56 # REF is defined and gets expanded into the exported environment variable.
57 .if ${:!echo "\$UT_VAR"!} != "<defined>"