]> git.ipfire.org Git - thirdparty/make.git/commit
Support conditional modifiers on all assignment operators
authorPaul Smith <psmith@gnu.org>
Thu, 11 Jan 2024 15:05:27 +0000 (10:05 -0500)
committerPaul Smith <psmith@gnu.org>
Sun, 28 Jan 2024 19:20:47 +0000 (14:20 -0500)
commit1eff20f6f64d00f588c218e265f8d3a81a8fb00b
tree24a030c60a9b94f6497f6c290b2dacc39b458f9f
parent82708b3a3a7114c6cd11a11e525a8d33118dbf61
Support conditional modifiers on all assignment operators

Rework the single "?=" operator to instead allow a "?" modifier to be
prepended to ANY assignment operator.  If "?" is given then the
variable is assigned (using whatever operator comes next) if and only
if the variable is not already defined.  If it is defined then no
action is taken (the right-hand side is not expanded, etc.)

* NEWS: Announce this new feature.
* doc/make.texi: Modify the documentation around assignment operators.
* src/variable.h: Remove the f_conditional variable flavor.
(do_variable_definition): Add an argument specifying conditional.
* src/variable.c (parse_variable_definition): Use the existing flag
"conditional" to remember if we saw "?" rather than the flavor.
When we see "?" skip it and continue trying to parse an assignment.
(try_variable_definition): Pass condition to do_variable_definition().
(initialize_file_variables): Ditto.
(do_variable_definition): Check for conditional up-front: quit if set.
Remove handling of obsolete f_conditional flavor.
* src/read.c (eval_makefile): MAKEFILE_LIST is not conditional.
(do_define): Unset conditional for define with no operator.  Pass the
conditional flag to do_variable_definition().
(construct_include_path): .INCLUDE_DIRS is not conditional.
* src/load.c (load_file): .LOADED is not conditional.
* tests/scripts/variables/conditional: Add new tests.
NEWS
doc/make.texi
src/load.c
src/read.c
src/variable.c
src/variable.h
tests/scripts/variables/conditional [new file with mode: 0644]