summaryrefslogtreecommitdiff
path: root/digital/ucoolib/build/config.mk
diff options
context:
space:
mode:
authorNicolas Schodet2012-10-20 09:56:17 +0200
committerNicolas Schodet2012-10-21 18:56:29 +0200
commitbeaa75f184d07855ea40da2b1e336cf1fe86a7b8 (patch)
tree129d2e8cbc3d8442308bdcb650abcc275cec5d55 /digital/ucoolib/build/config.mk
parent143379df9873622ffe938592cd27e89a95361ddf (diff)
digital/ucoolib: add build time configuration system
Diffstat (limited to 'digital/ucoolib/build/config.mk')
-rw-r--r--digital/ucoolib/build/config.mk32
1 files changed, 32 insertions, 0 deletions
diff --git a/digital/ucoolib/build/config.mk b/digital/ucoolib/build/config.mk
new file mode 100644
index 00000000..6f3f527b
--- /dev/null
+++ b/digital/ucoolib/build/config.mk
@@ -0,0 +1,32 @@
+# ucoolib - Microcontroller object oriented library.
+#
+# Build time configuration system.
+
+PROJECT_CONFIG ?= Config
+MODULES_CONFIG := $(wildcard $(ALL_MODULES:%=$(BASE)/ucoolib/%/Config))
+
+CONFIG_LIST := $(wildcard $(PROJECT_CONFIG)) $(MODULES_CONFIG)
+
+# Ensure that configuration is up to date, using two mechanisms:
+# - make will make sure config.list is up to date as it is included.
+# - comparison with CONFIG_LIST ensures that the list of included
+# configuration (including the project configuration) is the same.
+ifneq ($(MAKECMDGOALS),clean)
+-include $(OBJDIR)/config.list
+ifneq ($(CONFIG_LIST),$(CONFIG_LIST_OLD))
+CONFIG_FORCE := CONFIG_FORCE
+endif
+endif
+
+clean: config-clean
+
+.PHONY: config-clean CONFIG_FORCE
+
+$(OBJDIR)/config.list: $(CONFIG_LIST) $(CONFIG_FORCE)
+ @echo "CONF $(PROJECT_CONFIG)"
+ $Q$(BASE)/build/tools/config-gen -H $(OBJDIR)/config/%.hh \
+ -p $(PROJECT_CONFIG) $(MODULES_CONFIG)
+ $Qecho "CONFIG_LIST_OLD = $(CONFIG_LIST)" > $@
+
+config-clean:
+ rm -rf $(OBJDIR)/config $(OBJDIR)/config.list