On Tue, 2016-03-15 at 10:29 +0800, 一瓶水 wrote: > I saw GNU make (I am using 3.8.1) allows the usage of 'make VAR+=VAL' > command line, but it does not append VAL to VAR and instead it > overrides VAR to VAL. > > > Is this expected behavior? I did not find any doc explaining the usage > of VAR+=VAL on command line.
It is expected behavior. Variables on the command line have a higher priority than variables set inside makefiles, and command line variables are set first when the command line is parsed. So, by the time the makefile is read in and another variable assignment is seen, that will have a lower priority and it will be ignored. If you want the value in the makefile to be preserved you need to use "override": override FOO += bar all: ; @echo '$(FOO)' Then: $ make bar $ make FOO=foo foo bar _______________________________________________ Help-make mailing list Help-make@gnu.org https://lists.gnu.org/mailman/listinfo/help-make