[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Appending to a variable with '+=' forces immediate expansion?
From: |
Greg Chicares |
Subject: |
Appending to a variable with '+=' forces immediate expansion? |
Date: |
Mon, 05 Dec 2005 03:09:36 +0000 |
User-agent: |
Mozilla Thunderbird 1.0.2 (Windows/20050317) |
# Here are two testcases. The first works as expected:
$cat GNUmakefile
some_target: prerequisite
flags := INAPPROPRIATE for prerequisite
prerequisite: flags := appropriate for prerequisite
all_flags = $(flags)
prerequisite:
@echo " flags are" $(flags)
@echo " all_flags are" $(all_flags)
$make
flags are appropriate for prerequisite
all_flags are appropriate for prerequisite
# Here is the second testcase. It's identical to the first testcase,
# except for the additional '+=' line at the top:
$cat GNUmakefile
some_target: all_flags += ...some other flags...
some_target: prerequisite
flags := INAPPROPRIATE for prerequisite
prerequisite: flags := appropriate for prerequisite
all_flags = $(flags)
prerequisite:
@echo " flags are" $(flags)
@echo " all_flags are" $(all_flags)
$make
flags are appropriate for prerequisite
all_flags are INAPPROPRIATE for prerequisite ...some other flags...
# I was surprised by this second testcase. I had expected
# all_flags are appropriate for prerequisite ...some other flags...
# because $(all_flags) is a recursively-expanded variable. Is the
# observed behavior correct? (I'm using GNU Make version 3.79.1 .)
- Appending to a variable with '+=' forces immediate expansion?,
Greg Chicares <=