Hey,
I don't think that it is possible to pass multiple TARGETS to a sub makefile, because the TARGETS aren't stored in a variable - as far as I know. Only the specific target which make is currently executing is available in a variable, named $@. But as an alternative, you could work with common variables as shown below. Take a look at the two make files below, make_toplev and make_sub. make_toplev is the top-level makefile while make_sub is a sub-level makefile in any of your sub-directories. Generally, it's easier to not use makefile names like make_toplev; instead just use makefile/Makefile.
make_toplev:
Code:
all:
@echo "Top-Lev: TARGET: all"
@echo "Top-Lev: PLATFORM: $(PLATFORM)"
make -C sub -f make_sub PLATFORM=$(PLATFORM) all
irun:
@echo "Top-Lev: TARGET: irun"
@echo "Top-Lev: PLATFORM: $(PLATFORM)"
make -C sub -f make_sub PLATFORM=$(PLATFORM) irun
The -C argument to make causes make to change the directory before reading/executing the makefile. The platform is passed to the makefile via the PLATFORM variable and finally passed through to the sub makefile.
make_sub:
Code:
all:
@echo "Sub: TARGET ALL"
@echo "Sub: PLATFORM: $(PLATFORM)"
irun:
@echo "Sub: TARGET irun"
@echo "CP fparam.$(PLATFORM) fparam.f90"
@echo "Sub: PLATFORM: $(PLATFORM)"
Finally, you would then call your top-level makefile by for example
Code:
# make PLATFORM=fcc [-f make_toplev] all
Note: these two makefiles aren't really complete. It would be generally useful to check if the platform variable has really be defined among others.
Hope that helps,
- Andi -