summaryrefslogtreecommitdiff
path: root/mk/sub-makefile.mk
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2009-04-26 11:42:15 +0000
committerIan Lynagh <igloo@earth.li>2009-04-26 11:42:15 +0000
commit34cc75e1a62638f2833815746ebce0a9114dc26b (patch)
treeef21e8fd7af1356beea9cce7d6efb8a65374e24c /mk/sub-makefile.mk
parent74e1368d4688ee16f6decdf2cd3ebe27506b26ba (diff)
downloadhaskell-34cc75e1a62638f2833815746ebce0a9114dc26b.tar.gz
GHC new build system megapatch
Diffstat (limited to 'mk/sub-makefile.mk')
-rw-r--r--mk/sub-makefile.mk34
1 files changed, 34 insertions, 0 deletions
diff --git a/mk/sub-makefile.mk b/mk/sub-makefile.mk
new file mode 100644
index 0000000000..1e9cf2265d
--- /dev/null
+++ b/mk/sub-makefile.mk
@@ -0,0 +1,34 @@
+# This file is included by all the "stub makefiles" in every directory
+# in the tree except the root. Its job is to invoke $(MAKE) on the
+# top-level Makefile, but modifying the target so that it applies to
+# the current directory only.
+#
+# eg.
+# make foo.o ==> make -C $(TOP) dir/foo.o
+# make all ==> make -C $(TOP) all_dir
+# make clean ==> make -C $(TOP) clean_dir
+#
+
+# Important, otherwise we get silly built-in rules:
+.SUFFIXES:
+
+TOPMAKE = $(MAKE) -C $(TOP)
+
+default :
+ +$(TOPMAKE) all_$(dir)
+
+# We must not execute multiple recursive invocations of make in parallel.
+.NOTPARALLEL:
+
+# all comes first, we want it to be the default target
+STD_TARGETS = all clean distclean maintainer_clean install
+
+# The + tells make that we're recursively invoking make, otherwise 'make -j2'
+# goes wrong.
+$(STD_TARGETS):
+ +$(TOPMAKE) $@_$(dir)
+
+OTHERTARGETS=$(filter-out $(STD_TARGETS) $(SPEC_TARGETS),$(MAKECMDGOALS))
+.PHONY: $(OTHERTARGETS)
+$(OTHERTARGETS):
+ +$(TOPMAKE) $(dir)/$@