I have a Makefile that is building items, in this case the final output is RPM files. There can be multiple platforms and for each platform, multiple architectures. The RPM contents and name may vary based on the platform and architecture. If make is invoked as "make ARCH=foo PLATFORM=bar", then no problem. BUT! What happens when it is invoked as "make PLATFORM=bar"? What I want is for it to iterate over all possible architectures and re-call itself with ARCH set.
At the top of the Makefile, I can do something like this:
- Code: Select all
$(MAKE) ARCH=$@ $(MAKECMDGOALS)
$(MAKE) PLATFORM=$@ $(MAKECMDGOALS)
That will make it recurse over the appropriate lists, however it doesn't short circuit the original target. So the target gets called appropriately for every combination of ARCH and PLATFORM, but the falls through the PLATFORM level recursion and gets called once for ever value of ARCH with PLATFORM undefined. In order to keep that from happening, I have to wrap all the targets in a big "ifneq ($(and $(ARCH), $(PLATFORM)), )" block which is a bit less that desirable though it does appear to be the only way to do it in a single Makefile.