summaryrefslogtreecommitdiff
path: root/cesar/common
diff options
context:
space:
mode:
authorschodet2009-08-20 15:55:53 +0000
committerschodet2009-08-20 15:55:53 +0000
commitc5f5f0efdf2a9947e99f5a7087db1335e7857952 (patch)
tree42ccd18f4dbe0558be128ef232744e986bb4bc16 /cesar/common
parent71e0374c83fad091e564a3d249d84c7d260860a0 (diff)
* common (closes #447):
- add common/module.h to test if a module is included in build. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@5272 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/common')
-rw-r--r--cesar/common/make/config.mk17
-rw-r--r--cesar/common/make/test/clean-output4
-rw-r--r--cesar/common/make/test/first-output1
-rw-r--r--cesar/common/module.h28
-rwxr-xr-xcesar/common/tools/config-module12
5 files changed, 57 insertions, 5 deletions
diff --git a/cesar/common/make/config.mk b/cesar/common/make/config.mk
index b33923f84b..73d36d13a7 100644
--- a/cesar/common/make/config.mk
+++ b/cesar/common/make/config.mk
@@ -5,6 +5,7 @@ DEFAULT_PROJECT_CONFIG := $(OBJ_DIR)/Config.empty
PROJECT_CONFIG := $(if $(USER_PROJECT_CONFIG),$(USER_PROJECT_CONFIG),$(DEFAULT_PROJECT_CONFIG))
HEADERS_CONFIG := $(OBJ_INC_DIR)/config
CONFIG_LIST_FILE := $(OBJ_DIR)/Config.list
+MODULE_LIST_FILE := $(OBJ_DIR)/Module.list
# Configuration is automatically updated if the list of config file has
# changed since last update.
@@ -12,9 +13,14 @@ CONFIG_LIST_FILE := $(OBJ_DIR)/Config.list
.PHONY: CONFIG_FORCE
CONFIG_FORCE := $(if $(call list-neq,$(CONFIG_LIST),$(PROJECT_CONFIG) $(MODULES_CONFIG)),CONFIG_FORCE)
+# Module configuration should be updated if the list has changed.
+-include $(MODULE_LIST_FILE)
+.PHONY: MODULE_CONFIG_FORCE
+MODULE_CONFIG_FORCE := $(if $(call list-neq,$(MODULE_LIST),$(ALL_MODULES)),MODULE_CONFIG_FORCE)
+
HEADERS_CONFIG_STAMP := $(HEADERS_CONFIG)/headers.stamp
-COMPILE_DEPS += $(HEADERS_CONFIG_STAMP)
+COMPILE_DEPS += $(HEADERS_CONFIG_STAMP) $(OBJ_INC_DIR)/module_config.h
$(DEFAULT_PROJECT_CONFIG): $(OBJ_DIR_STAMP)
touch $@
@@ -31,6 +37,11 @@ $(HEADERS_CONFIG_STAMP): $(MERGED_CONFIG)
$Q$(TOOLS_DIR)/config-headers $(OBJ_INC_DIR) $<
$Qtouch $@
+$(OBJ_INC_DIR)/module_config.h: $(OBJ_INC_DIR_STAMP) $(MODULE_CONFIG_FORCE)
+ @echo CONF module
+ $Q$(TOOLS_DIR)/config-module $(ALL_MODULES) > $@
+ $Qecho MODULE_LIST = $(ALL_MODULES) > $(MODULE_LIST_FILE)
+
config.clean:
- rm -f $(DEFAULT_PROJECT_CONFIG) $(MERGED_CONFIG) $(CONFIG_LIST_FILE)
- rm -rf $(OBJ_INC_DIR)/config.h $(HEADERS_CONFIG)
+ rm -f $(DEFAULT_PROJECT_CONFIG) $(MERGED_CONFIG) $(CONFIG_LIST_FILE) $(MODULE_LIST_FILE)
+ rm -rf $(OBJ_INC_DIR)/config.h $(HEADERS_CONFIG) $(OBJ_INC_DIR)/module_config.h
diff --git a/cesar/common/make/test/clean-output b/cesar/common/make/test/clean-output
index 9bb63b77ce..454ff7a3e4 100644
--- a/cesar/common/make/test/clean-output
+++ b/cesar/common/make/test/clean-output
@@ -1,6 +1,6 @@
CONF merge
-rm -f obj/Config.empty obj/Config.merged obj/Config.list
-rm -rf obj/inc/config.h obj/inc/config
+rm -f obj/Config.empty obj/Config.merged obj/Config.list obj/Module.list
+rm -rf obj/inc/config.h obj/inc/config obj/inc/module_config.h
rm -f obj/test_make obj/test_cpp obj/test_make_ecos.elf obj/test_make_ecos.bin obj/test_make_ecos.rom \
rm -rf obj/ecos/tree.stamp obj/ecos/build
rm -rf obj/ecos/headers.stamp obj/ecos/install
diff --git a/cesar/common/make/test/first-output b/cesar/common/make/test/first-output
index a932d84b05..55d88fa47d 100644
--- a/cesar/common/make/test/first-output
+++ b/cesar/common/make/test/first-output
@@ -3,6 +3,7 @@ ECOS tree
MAKE ecos.defs
CONF merge
CONF headers
+CONF module
CC [host] src/test_make.c
CC [host] ../../../../common/make/test/modules/a/src/a.c
CC [host] ../../../../common/make/test/modules/b/src/b_print.c
diff --git a/cesar/common/module.h b/cesar/common/module.h
new file mode 100644
index 0000000000..33570d7260
--- /dev/null
+++ b/cesar/common/module.h
@@ -0,0 +1,28 @@
+#ifndef common_module_h
+#define common_module_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2009 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file common/module.h
+ * \brief Module header.
+ * \ingroup common
+ *
+ * Gives information about built modules.
+ */
+
+#include "module_config.h"
+
+/**
+ * Return true if the given module was included in build.
+ * \param module module to test, with underscores
+ * \return true if included (to be used as preprocessor conditional)
+ */
+#define MODULE_INCLUDED(module) \
+ defined (_MODULE_INCLUDED_ ## module)
+
+#endif /* common_module_h */
diff --git a/cesar/common/tools/config-module b/cesar/common/tools/config-module
new file mode 100755
index 0000000000..2e4066cb86
--- /dev/null
+++ b/cesar/common/tools/config-module
@@ -0,0 +1,12 @@
+#!/usr/bin/perl
+#
+# Generate a module configuration header from list of modules on command line.
+#
+use strict;
+use warnings;
+
+for (@ARGV)
+{
+ s:/:_:g;
+ print "#define _MODULE_INCLUDED_$_ 1\n";
+}