[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problem with makefile
From: |
Paul Smith |
Subject: |
Re: Problem with makefile |
Date: |
Wed, 06 Mar 2013 15:31:31 -0500 |
On Wed, 2013-03-06 at 20:05 +0000, Hiebert, Darren (IS) wrote:
> Attached (and below) is a slight variation of my original makefile
> that incorporates your recommendation, but no longer works for any of
> the SAMPLE_BINn_OBJECT_FILES (where n is 1, 2, or 3). It replaces the
> three different expansions with one foreach.
If you take the approach I mentioned previously and add the info BEFORE
the eval, you'll see the problem:
SAMPLE_TARGET_DIR ?= $(SAMPLE_DIR)
SAMPLE_TARGET_NUMBERS ?= 1 2 3
ifneq "$(strip $(SAMPLE_BIN$(SAMPLE_TARGET_NUMBERS)_TARGET))" ""
SAMPLE_BIN$(SAMPLE_TARGET_NUMBERS)_OBJECT_FILES := $(addprefix
$(SAMPLE_DIR),$(SAMPLE_BIN$(SAMPLE_TARGET_NUMBERS)_OBJECTS))
endif
which is clearly not what you want.
> $(foreach index,$$($(1)_TARGET_NUMBERS),$(call
> indexed_bin_target,$(1),$(index)))
The problem is you need another level of eval here. Remember that the
single "$" means that the value is expanded by the call function, before
eval gets it. That means that the for loop is expanded, and index is
equivalent to the value $(SAMPLE_TARGET_NUMBERS) (not the evaluation of
that). Basically, the above loop is functionally identical to:
$(call indexed_bin_target,$(1),$$(SAMPLE_TARGET_NUMBERS))
which expands as you see above.
You're trying to evaluate the for loop inside the eval, not the call,
which means that you need to (a) add another level of escaping, and (b)
add another eval, that the first eval will expand:
$$(foreach index,$$($(1)_TARGET_NUMBERS),$$(eval $$(call
indexed_bin_target,$(1),$$(index))))