# 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 .)



_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to