I'm using Make and I have a makefile which sets a variable with a value that I need to override from a parent makefile. I've tried setting the variable in the parent makefile and using export
to pass it to the submake but the variable is not using the passed down value, instead it is using the value explicitly set in the sub-Makefile.
I know that variables specified on the command line override any ordinary assignments in the makefile (unless override
is used) but is there a way to achieve this for submakes without having to specify it on the command line for each invocation of the submake (because there are quite a few and I like to stay DRY)?
UPDATE
I should have mentioned that I can't modify the submake file because it's from an external repository that we track and I don't have the authority to modify it so I need to work at the parent makefile level to influence the submake.
EXAMPLE
Here's a representative target in the parent makefile that's calling the submake:
$.PHONY (external_lib)
$(external_lib):
$(MAKE) -C $(source_dir)/project/component $(PROJECTVARS) make_a
$(MAKE) -C $(source_dir)/project/component $(PROJECTVARS) make_b
$(MAKE) -C $(source_dir)/project/component $(PROJECTVARS) make_c
$(MAKE) -C $(source_dir)/project/component $(PROJECTVARS) make_d
$(MAKE) -C $(source_dir)/project/component $(PROJECTVARS) make_e
$(MAKE) -C $(source_dir)/project/component $(PROJECTVARS) make_f
$(MAKE) -C $(source_dir)/project/component $(PROJECTVARS) make_g
$(MAKE) -C $(source_dir)/project/component $(PROJECTVARS) make_h
$(MAKE) -C $(source_dir)/project/component $(PROJECTVARS) make_i
$(MAKE) -C $(source_dir)/project/component $(PROJECTVARS) library