|Version 1 (modified by simonmar, 7 years ago) (diff)|
Idiom: standard targets (all, clean, etc.)
We want an all target that builds everything, but we also want a way to build individual components (say, everything in rts/). This is achieved by having a separate "all" target for each directory, named all_directory. For example in rts/ghc.mk we might have this:
all : all_rts .PHONY all_rts all_rts : ...dependencies...
When the top level make includes all these ghc.mk files, it will see that target all depends on all_rts, all_ghc, ...etc...; so make all will make all of these. But the individual targets are still available. In particular, you can say
- make all_rts (anywhere) to build everything in the RTS directory
- make all (anywhere) to build everything
- make, with no explicit target, makes the default target in the current directory's stub Makefile, which in turn makes the target all_dir, where dir is the current directory.
Other standard targets such as clean, install, and so on use the same technique. There are pre-canned macros to define your "all" and "clean" targets, take a look in rules/all-target.mk and rules/clean-target.mk.