[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: make VAR+=VAL
From: |
Paul Smith |
Subject: |
Re: make VAR+=VAL |
Date: |
Sat, 19 Mar 2016 10:22:26 -0400 |
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
- make VAR+=VAL, ??????, 2016/03/15
- Re: make VAR+=VAL,
Paul Smith <=