Hi I have a problem with variable definition Here is a semplified makefile that reproduce the problem (is also attached) -------------8<----------------------- TRG += target
target_COMPILE_SET = debug opt target_debug_CSRC = ad.c target_debug_CSRC += bd.c target_debug_CSRC += cd.c target_opt_CSRC = ao.c target_opt_CSRC += bo.c target_opt_CSRC += co.c target_debug_FLAGS0 = td_flg target_opt_FLAGS0 = to_flg target_debug_FLAGS1 = td_flg target_opt_FLAGS1 = to_flg target_MCU = mcu .PHONY: all all: target_debug target_opt define build_target $(info marker1 $(0) ** $(1) ** $(2)) ifneq ($$(strip $$($(1)_VAR1)),) $(1)_$(2)_FLAGS0 += $$($(1)_VAR1) endif $(1)_$(2)_FLAGS1 += $$($(1)_VAR1) $(1)_$(2)_TRE = $$(foreach file,$$($(1)_$(2)_CSRC:%.c=%.o), $(1)/$$(file)) $(1)_$(2): @echo P0 $(1) $(2) -- $($(1)_$(2)_CSRC) -- $$($(1)_$(2)_TRE) @echo P1 $(1)_VAR1=$$($(1)_VAR1) @echo P2 $(1)_$(2)_FLAGS0=$$($(1)_$(2)_FLAGS0) @echo P3 $(1)_$(2)_FLAGS1=$$($(1)_$(2)_FLAGS1) endef define asdrubale $(info marker0 $(0) ** $(1)) $(1)_VAR1 = -param_$$($(1)_MCU) $(foreach z,$($(1)_COMPILE_SET),$(eval $(call build_target,$(1),$(z)))) endef $(foreach t,$(TRG),$(eval $(call asdrubale,$(t)))) -------------8<----------------------- the output is: marker0 asdrubale ** target marker1 build_target ** target ** debug marker1 build_target ** target ** opt P0 target debug -- ad.c bd.c cd.c -- target/ad.o target/bd.o target/cd.o P1 target_VAR1=-param_mcu P2 target_debug_FLAGS0=td_flg P3 target_debug_FLAGS1=td_flg -param_mcu P0 target opt -- ao.c bo.c co.c -- target/ao.o target/bo.o target/co.o P1 target_VAR1=-param_mcu P2 target_opt_FLAGS0=to_flg P3 target_opt_FLAGS1=to_flg -param_mcu $(target_debug_FLAGS0) and $(target_debug_FLAGS1) shuold be the same (ando also $(target_opt_FLAGS0) and $(target_opt_FLAGS1). it seems that ifneq ($$(strip $$($(1)_VAR1)),) $(1)_$(2)_FLAGS0 += $$($(1)_VAR1) endif doesn't work. It never add $$($(1)_VAR1) to $(1)_$(2)_FLAGS0, as if $$($(1)_VAR1) was empty, but is is not, infact it is assigned to $(1)_ $(2)_FLAGS1 How can I resolve the problem? thanks
TRG += target target_COMPILE_SET = debug opt target_debug_CSRC = ad.c target_debug_CSRC += bd.c target_debug_CSRC += cd.c target_opt_CSRC = ao.c target_opt_CSRC += bo.c target_opt_CSRC += co.c target_debug_FLAGS0 = td_flg target_opt_FLAGS0 = to_flg target_debug_FLAGS1 = td_flg target_opt_FLAGS1 = to_flg target_MCU = mcu .PHONY: all all: target_debug target_opt define build_target $(info marker1 $(0) ** $(1) ** $(2)) ifneq ($$(strip $$($(1)_VAR1)),) $(1)_$(2)_FLAGS0 += $$($(1)_VAR1) endif $(1)_$(2)_FLAGS1 += $$($(1)_VAR1) $(1)_$(2)_TRE = $$(foreach file,$$($(1)_$(2)_CSRC:%.c=%.o),$(1)/$$(file)) $(1)_$(2): @echo P0 $(1) $(2) -- $($(1)_$(2)_CSRC) -- $$($(1)_$(2)_TRE) @echo P1 $(1)_VAR1=$$($(1)_VAR1) @echo P2 $(1)_$(2)_FLAGS0=$$($(1)_$(2)_FLAGS0) @echo P3 $(1)_$(2)_FLAGS1=$$($(1)_$(2)_FLAGS1) endef define asdrubale $(info marker0 $(0) ** $(1)) $(1)_VAR1 = -param_$$($(1)_MCU) $(foreach z,$($(1)_COMPILE_SET),$(eval $(call build_target,$(1),$(z)))) endef $(foreach t,$(TRG),$(eval $(call asdrubale,$(t))))
_______________________________________________ Help-make mailing list Help-make@gnu.org http://lists.gnu.org/mailman/listinfo/help-make