Add support for 'make help' in subdirectories
[ghc-hetmet.git] / mk / sub-makefile.mk
1 # This file is included by all the "stub makefiles" in every directory
2 # in the tree except the root.  Its job is to invoke $(MAKE) on the
3 # top-level Makefile, but modifying the target so that it applies to
4 # the current directory only.
5 #
6 # eg.
7 #  make foo.o  ==>  make -C $(TOP) dir/foo.o
8 #  make all    ==>  make -C $(TOP) all_dir
9 #  make clean  ==>  make -C $(TOP) clean_dir
10 #
11
12 # Important, otherwise we get silly built-in rules:
13 .SUFFIXES:
14
15 TOPMAKE = $(MAKE) -C $(TOP)
16
17 default: all
18
19 fast :
20         +$(TOPMAKE) all_$(dir) $(dir)_dist-install_NO_BUILD_DEPS=YES \
21            OMIT_PHASE_1=YES OMIT_PHASE_2=YES OMIT_PHASE_3=YES
22
23 # We must not execute multiple recursive invocations of make in parallel.
24 .NOTPARALLEL:
25
26 STD_TARGETS = all clean distclean maintainer_clean install html ps pdf
27
28 # The + tells make that we're recursively invoking make, otherwise 'make -j2'
29 # goes wrong.
30 $(STD_TARGETS): 
31         +$(TOPMAKE) $@_$(dir)
32
33 OTHERTARGETS=$(filter-out fast help $(STD_TARGETS) $(SPEC_TARGETS),$(MAKECMDGOALS))
34 .PHONY: $(OTHERTARGETS)
35 $(OTHERTARGETS):
36         +$(TOPMAKE) $(dir)/$@
37
38 .PHONY: help
39 help : sub-help
40
41 .PHONY: sub-help
42 sub-help :
43         @echo "You are in subdirectory \"$(dir)\"."
44         @echo "Useful targets in this directory:"
45         @cat $(TOP)/SUBMAKEHELP