summaryrefslogtreecommitdiff
path: root/mk/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'mk/Makefile')
-rw-r--r--mk/Makefile52
1 files changed, 52 insertions, 0 deletions
diff --git a/mk/Makefile b/mk/Makefile
new file mode 100644
index 0000000..7658b42
--- /dev/null
+++ b/mk/Makefile
@@ -0,0 +1,52 @@
+SHELL := /bin/bash
+RUNDIR := $(CURDIR)
+ifndef TOP
+TOP := $(shell \
+ top=$(RUNDIR); \
+ while [ ! -r "$$top/Rules.top" ] && [ "$$top" != "" ]; do \
+ top=$${top%/*}; \
+ done; \
+ echo $$top)
+endif
+
+MK := $(TOP)/mk
+
+.PHONY: dir tree all clean clean_all clean_tree dist_clean
+
+# Default target when nothing is given on the command line. Reasonable
+# options are:
+# "dir" - updates only targets from current directory and its dependencies
+# "tree" - updates targets (and their dependencies) in whole subtree
+# starting at current directory
+# "all" - updates all targets in the project
+.DEFAULT_GOAL := dir
+
+dir : dir_$(RUNDIR)
+tree : tree_$(RUNDIR)
+
+clean : clean_$(RUNDIR)
+clean_tree : clean_tree_$(RUNDIR)
+
+# $(d) keeps the path of "current" directory during tree traversal and
+# $(dir_stack) is used for backtracking during traversal
+d := $(TOP)
+dir_stack :=
+
+include $(MK)/header.mk
+include $(MK)/footer.mk
+
+# Automatic inclusion of the skel.mk at the top level - that way
+# Rules.top has exactly the same structure as other Rules.mk
+include $(MK)/skel.mk
+
+.SECONDEXPANSION:
+$(eval $(value HEADER))
+include $(TOP)/Rules.top
+$(eval $(value FOOTER))
+
+# Optional final makefile where you can specify additional targets
+-include $(TOP)/final.mk
+
+# This is just a convenience - to let you know when make has stopped
+# interpreting make files and started their execution.
+$(info Rules generated $(if $(BUILD_MODE),for "$(BUILD_MODE)" mode,)...)