Add network submodule.
[ghc.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 # Eliminate use of the built-in implicit rules, and clear out the default list
13 # of suffixes for suffix rules. Speeds up make quite a bit. Both are needed
14 # for the shortest `make -d` output.
15 # Don't set --no-builtin-variables; some rules might stop working if you do
16 # (e.g. 'make clean' in testsuite/ currently relies on an implicit $RM).
17 MAKEFLAGS += --no-builtin-rules
18 .SUFFIXES:
19
20 TOPMAKE = $(MAKE) -C $(TOP)
21
22 default: all
23
24 fast: all
25
26 FAST_MAKE_OPTS =\
27 $(dir)_dist_NO_BUILD_DEPS=YES \
28 $(dir)_dist-boot_NO_BUILD_DEPS=YES \
29 $(dir)_dist-install_NO_BUILD_DEPS=YES \
30 NO_GENERATED_MAKEFILE_RULES=YES \
31 OMIT_PHASE_0=YES OMIT_PHASE_1=YES
32
33 ifneq "$(filter fast,$(MAKECMDGOALS))" ""
34 EXTRA_MAKE_OPTS += $(FAST_MAKE_OPTS)
35 else
36 ifeq "$(FAST)" "YES"
37 EXTRA_MAKE_OPTS += $(FAST_MAKE_OPTS)
38 endif
39 endif
40
41 # We must not execute multiple recursive invocations of make in parallel.
42 .NOTPARALLEL:
43
44 STD_TARGETS = all clean distclean maintainer_clean install html ps pdf
45 DIRECTORY_INDEPENDENT_TARGETS = show show!
46
47 # The + tells make that we're recursively invoking make, otherwise 'make -j2'
48 # goes wrong.
49 $(STD_TARGETS):
50 +$(TOPMAKE) $@_$(dir) $(EXTRA_MAKE_OPTS)
51
52 $(DIRECTORY_INDEPENDENT_TARGETS):
53 +$(TOPMAKE) $@ $(EXTRA_MAKE_OPTS)
54
55 OTHERTARGETS=$(filter-out fast help $(DIRECTORY_INDEPENDENT_TARGETS) $(STD_TARGETS) $(SPEC_TARGETS),$(MAKECMDGOALS))
56 .PHONY: $(OTHERTARGETS)
57 $(OTHERTARGETS):
58 +$(TOPMAKE) $(dir)/$@ $(EXTRA_MAKE_OPTS)
59
60 .PHONY: help
61 help : sub-help
62
63 .PHONY: sub-help
64 sub-help :
65 @echo "You are in subdirectory \"$(dir)\"."
66 @echo "Useful targets in this directory:"
67 @sed '1,/Using `make` in subdirectories/d' $(TOP)/MAKEHELP.md