]> rtime.felk.cvut.cz Git - sysless.git/commitdiff
Makefile.rules updated to the newest version.
authorMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 10 Dec 2007 11:23:00 +0000 (11:23 +0000)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 10 Dec 2007 11:23:00 +0000 (11:23 +0000)
darcs-hash:20071210112351-f2ef6-8446bf4b6acbb464cbb575b2ee409077e29c39fe.gz

Makefile.rules

index 7be9fe8dc6148ca9f83ba8957f35450b1a1dd3b0..75227335ff29f8c3490d08d938377e91b536861d 100644 (file)
@@ -5,6 +5,8 @@
 #  (C) Copyright 2003 by Pavel Pisa - OCERA team member
 #  (C) Copyright 2006 by Michal Sojka - Czech Technical University, FEE, DCE
 #
+#  Homepage: http://rtime.felk.cvut.cz/omk/
+#
 # The OMK build system is distributed under the GNU General Public
 # License.  See file COPYING for details.
 #
 # W                .. whole tree - if set to 1, make is always called from the top-level directory
 # SUBDIRS          .. list of subdirectories intended for make from actual directory
 # default_CONFIG   .. list of default config assignments CONFIG_XXX=y/n ...
-# LOCAL_CONFIG_H   .. name of local config.h file generated from values #OMK@config_h
-#                     of options defined in the current directory
-# config_include_HEADERS .. names of global config files (possibly
-#                     with subdirectories)
-# xxx_DEFINES      .. list of config directives to be included in
-#                     config header file of the name <somedir>/xxx.h
 # LN_HEADERS       .. if "y", header files are symbolicaly linked instead of copied. #OMK@include
 #                                                            #OMK@sysless
 # bin_PROGRAMS     .. list of the require binary programs
+# test_PROGRAMS    .. list of the test programs
 # include_HEADERS  .. list of the user-space public header files
 # lib_LIBRARIES    .. list of the user-space libraries
 # lib_LDSCRIPTS    .. list of LD scripts that should be copied to the lib direcotry
 #                     should be used for linking (e.g. ram flash). If this is not
 #                    specified, then the value of DEFAULT_LD_SCRIPT_VARIANT from config.target is used.
 # PREFIX_DIR       .. Prefix to  directories in _compiled and _build. Used in config.omk.
+# LOCAL_CONFIG_H   .. name of local config.h file generated from values #OMK@config_h
+#                     of options defined in the current directory
+# config_include_HEADERS .. names of global config files (possibly
+#                     with subdirectories)
+# xxx_DEFINES      .. list of config directives to be included in
+#                     config header file of the name <somedir>/xxx.h
+# DOXYGEN          .. if non-empty, generated headers includes Doxygen's @file
+#                    command, so it is possible to document config
+#                    variables.
 # local_EVALUATE   .. Makefile hook, which is executed at the end of #OMK@localeval
 #                     the Makefile.rules. Used only for dirty hacks.
                                                              #OMK@sysless-setup
@@ -64,6 +70,7 @@ USER_COMPILED_DIR_NAME=$(MAKERULES_DIR)/$(COMPILED_DIR_NAME)
 USER_INCLUDE_DIR = $(USER_COMPILED_DIR_NAME)/include
 USER_LIB_DIR     = $(USER_COMPILED_DIR_NAME)/lib
 USER_UTILS_DIR   = $(USER_COMPILED_DIR_NAME)/bin-utils
+USER_TESTS_DIR   = $(USER_COMPILED_DIR_NAME)/bin-tests
 USER_BIN_DIR     = $(USER_COMPILED_DIR_NAME)/bin
 USER_OBJS_DIR    = $(LOCAL_BUILD_DIR)
 
@@ -76,7 +83,7 @@ ifndef SOURCES_DIR
 SOURCES_DIR := $(shell ( pwd -L ) )
 endif
 
-.PHONY: all default check-make-ver
+.PHONY: all default check-make-ver omkize
 
 ifdef W
   ifeq ("$(origin W)", "command line")
@@ -125,15 +132,20 @@ export CONFIG_FILE OMK_SERIALIZE_INCLUDED OMK_VERBOSE OMK_SILENT
 ifndef RELATIVE_DIR
 RELATIVE_DIR := $(SOURCES_DIR:$(MAKERULES_DIR)%=%)
 endif
+#$(warning  === RELATIVE_DIR = "$(RELATIVE_DIR)" ===)
 override RELATIVE_DIR := $(RELATIVE_DIR:/%=%)
 override RELATIVE_DIR := $(RELATIVE_DIR:\\%=%)
-#$(warning  RELATIVE_DIR $(RELATIVE_DIR))
+#$(warning  RELATIVE_DIR = "$(RELATIVE_DIR)")
 override BACK2TOP_DIR := $(shell echo $(RELATIVE_DIR)/ | sed -e 's_//_/_g' -e 's_/\./_/_g' -e 's_^\./__g'  -e 's_\([^/][^/]*\)_.._g' -e 's_/$$__')
-#$(warning  BACK2TOP_DIR $(BACK2TOP_DIR))
+#$(warning  BACK2TOP_DIR = "$(BACK2TOP_DIR)")
+
+#$(warning SOURCES_DIR = "$(SOURCES_DIR)")
+#$(warning MAKERULES_DIR = "$(MAKERULES_DIR)")
+#$(warning RELATIVE_DIR = "$(RELATIVE_DIR)")
 
-#$(warning SOURCES_DIR = $(SOURCES_DIR))
-#$(warning MAKERULES_DIR = $(MAKERULES_DIR))
-#$(warning RELATIVE_DIR = $(RELATIVE_DIR))
+# We have to use RELATIVE_PREFIX because of mingw
+override RELATIVE_PREFIX := $(RELATIVE_DIR)/
+override RELATIVE_PREFIX := $(RELATIVE_PREFIX:/%=%)
 
 #vpath %.c $(SOURCES_DIR)
 #vpath %.cc $(SOURCES_DIR)
@@ -151,7 +163,7 @@ endif
 ifndef OMK_VERBOSE
   OMK_VERBOSE = 0
 endif
-ifeq ($(OMK_VERBOSE),1)
+ifneq ($(OMK_VERBOSE),0)
   Q =
 else
   Q = @
@@ -163,15 +175,16 @@ else
   QUIET_CMD_ECHO = echo
 endif
 
+MAKEFILE_OMK=Makefile.omk
 # All subdirectories (even linked ones) containing Makefile.omk
 # Usage in Makefile.omk: SUBDIRS = $(ALL_OMK_SUBDIRS)
-ALL_OMK_SUBDIRS = $(patsubst %/Makefile.omk,%,$(patsubst $(SOURCES_DIR)/%,%,$(wildcard $(SOURCES_DIR)/*/Makefile.omk)))
+ALL_OMK_SUBDIRS = $(patsubst %/$(MAKEFILE_OMK),%,$(patsubst $(SOURCES_DIR)/%,%,$(wildcard $(SOURCES_DIR)/*/$(MAKEFILE_OMK))))
 
 # ===================================================================
 # We have set up all important variables, so we can check and include
 # real OCERA style Makefile.omk now
 ifndef OMK_INCLUDED
-include $(SOURCES_DIR)/Makefile.omk
+include $(SOURCES_DIR)/$(MAKEFILE_OMK)
 OMK_INCLUDED := 1
 endif
 
@@ -204,12 +217,12 @@ define omk_pass_template
 $(1):
        +@$(foreach dir,$(SUBDIRS),$(call mkdir_def,$(2)/$(dir)); \
                $(MAKE) SOURCES_DIR=$(SOURCES_DIR)/$(dir) $(NO_PRINT_DIRECTORY) \
-               RELATIVE_DIR=$(RELATIVE_DIR)/$(dir) -C $(2)/$(dir) \
+               RELATIVE_DIR=$(RELATIVE_PREFIX)$(dir) -C $(2)/$(dir) \
                -f $(SOURCES_DIR)/$(dir)/Makefile $$@ || exit 1 ;) true
 ifneq ($(4),)
        @echo "make[omk]: $$@ in $(RELATIVE_DIR)"; \
        $(call mkdir_def,$(2)); \
-       $(MAKE) $(NO_PRINT_DIRECTORY) -C $(2) \
+       $(MAKE) $(NO_PRINT_DIRECTORY) SOURCES_DIR=$(SOURCES_DIR) RELATIVE_DIR=$(RELATIVE_DIR) -C $(2) \
                -f $(SOURCES_DIR)/Makefile $(3) $$(@:%=%-local)
 endif
 endef
@@ -231,9 +244,21 @@ $(eval $(call omk_pass_template,default-config-pass,$$(LOCAL_BUILD_DIR),,always)
 default-config-pass-local:
 #      @echo Default config for $(RELATIVE_DIR)
        @echo "# Config for $(RELATIVE_DIR)" >> "$(CONFIG_FILE)-default"
-       @$(foreach x, $(default_CONFIG), echo $(x) | \
-               sed -e 's/^.*=x$$/#\0/' >> "$(CONFIG_FILE)-default" ; )
+       @$(foreach x, $(default_CONFIG), echo '$(x)' | \
+               sed -e 's/^[^=]*=x$$/#\0/' >> "$(CONFIG_FILE)-default" ; )
+
 
+omkize:
+       $(Q)if ! grep -q MAKERULES_DIR Makefile; then \
+          echo "Makefile is not OMK leaf makefile!" >&2; exit 1; \
+       fi
+       $(Q)for i in `find -L . -name Makefile.omk` ; do \
+          i=`dirname $${i}`; \
+          if [ x"$$i" != x"." ]; then \
+             rm -f $${i}/Makefile; \
+             cp Makefile $${i}/Makefile; \
+          fi \
+       done
                                                              #OMK@gcc
 # Rules for compilation of C, C++ and assembler sources using GNU
 # toolchain.
@@ -324,7 +349,7 @@ endef # COMPILER_DEFS_template
 
 # Syntax: $(call COMPILE_c_o_template,<source>,<target>,<additional c-flags>)
 define COMPILE_c_o_template
-$(2): $(1) $(LOCAL_CONFIG_H) $$(GEN_HEADERS)
+$(2): $(1) $$(GEN_HEADERS)
        @$(QUIET_CMD_ECHO) "  CC      $$@"
        $(Q) if $$(c_o_COMPILE) $$(CC_DEPFLAGS) $(3) -o $$@ -c $$< ; \
        then mv -f "$$@.d.tmp" "$$@.d" ; \
@@ -336,7 +361,7 @@ endef
 
 # Syntax: $(call COMPILE_cc_o_template,<source>,<target>,<additional c-flags>)
 define COMPILE_cc_o_template
-$(2): $(1) $(LOCAL_CONFIG_H) $$(GEN_HEADERS)
+$(2): $(1) $$(GEN_HEADERS)
        @$(QUIET_CMD_ECHO) "  CXX     $$@"
        $(Q) if $$(cc_o_COMPILE) $$(CC_DEPFLAGS) $(3) -o $$@ -c $$< ; \
        then mv -f "$$@.d.tmp" "$$@.d" ; \
@@ -346,7 +371,7 @@ endef
 
 # Syntax: $(call COMPILE_S_o_template,<source>,<target>,<additional c-flags>)
 define COMPILE_S_o_template
-$(2): $(1) $(LOCAL_CONFIG_H) $$(GEN_HEADERS)
+$(2): $(1) $$(GEN_HEADERS)
        @$(QUIET_CMD_ECHO) "  AS      $$@"
        $(Q) if $$(S_o_COMPILE) -D__ASSEMBLY__ $$(CC_DEPFLAGS) $(3) -o $$@ -c $$< ; \
        then if [ -e "$$@.d.tmp" ] ; then mv -f "$$@.d.tmp" "$$@.d" ; fi ; \
@@ -447,58 +472,6 @@ $(LIB_DIR)/lib$(1).so: $$($(1)_OBJSLO)
        $(Q) $(LD) --shared --soname=lib$(1).so -o $$@ $$^
 endef
 
-# Local Variables:
-# mode:makefile
-# End:
-                                                             #OMK@config_h
-# Syntax: $(call BUILD_CONFIG_H_template,<header_file_path>,<list_of_options_to_export>,<header_barrier>)
-define BUILD_CONFIG_H_template
-
-$(1) : $(wildcard $(CONFIG_FILE)) $(wildcard $(CONFIG_FILE)-default)
-       @$(QUIET_CMD_ECHO) "  CONFGEN $$(@:$(MAKERULES_DIR)/%=%)"
-       @if [ ! -d `dirname $(1).tmp` ] ; then \
-               mkdir `dirname $(1).tmp` ; fi
-       @echo "/* Automatically generated from */" > "$(1).tmp"
-       @echo "/* config file: $$< */" >> "$(1).tmp"
-       @echo "#ifndef $(3)" >> "$(1).tmp"
-       @echo "#define $(3)" >> "$(1).tmp"
-       @( $(foreach x, $(shell echo '$($(2))' | sed -e 's/\<\([^ =]*\)\(=[^ ]\+\|\)\>/\1/g' ), \
-               echo '$(x).$($(x))' ; ) echo ; ) | \
-               sed -e '/^[^.]*\.n$$$$/d' -e '/^[^.]*\.$$$$/d' -e 's/^\([^.]*\)\.[ym]$$$$/\1.1/' | \
-               sed -n -e 's/^\([^.]*\)\.\(.*\)$$$$/#define \1 \2/p' \
-                 >> "$(1).tmp"
-       @echo "#endif /*$(3)*/" >> "$(1).tmp"
-       @if cmp --quiet "$(1).tmp" "$(1)" ; then rm "$(1).tmp" ; \
-       else mv "$(1).tmp" "$(1)" ; \
-       echo Updated configuration "$(1)" ; fi
-
-endef
-
-ifdef LOCAL_CONFIG_H
-
-CFLAGS += -I.
-$(eval $(call BUILD_CONFIG_H_template,$(LOCAL_CONFIG_H),default_CONFIG,_LOCAL_CONFIG_H) )
-
-endif
-
-# Special rules for configuration exported headers
-
-#FIXME: The directory for headers should not be specified here.
-$(foreach confh,$(config_include_HEADERS),$(eval $(call BUILD_CONFIG_H_template,$(addprefix $(USER_INCLUDE_DIR)/,$(confh)),$(basename $(notdir $(confh)))_DEFINES,\
-_$(basename $(notdir $(confh)))_H \
-)))
-
-# Add some hooks to standard passes
-include-pass-local: $(addprefix $(USER_INCLUDE_DIR)/,$(config_include_HEADERS))
-
-clean-local: clean-local-config-h
-
-clean-local-config-h:
-       @$(foreach confh,$(addprefix $(USER_INCLUDE_DIR)/,$(config_include_HEADERS)),\
-           if [ -e $(confh) ] ; then touch -t 200001010101 $(confh) ; fi ; \
-       )
-
-
 # Local Variables:
 # mode:makefile
 # End:
@@ -544,7 +517,7 @@ include-pass: check-dir
 library-pass: include-pass
 binary-pass utils-pass: library-pass
 
-OMK_SERIALIZE_INCLUDED = y
+override OMK_SERIALIZE_INCLUDED = y
 endif
 
 # -------------------------------------
@@ -581,8 +554,10 @@ GEN_HEADERS+=$(cmetric_include_HEADERS:%=$(USER_INCLUDE_DIR)/%)
 # Generate rules for compilation of programs and libraries
 ifneq ($(link_VARIANTS),)
 $(foreach prog,$(bin_PROGRAMS),$(foreach link,$(link_VARIANTS),$(eval $(call PROGRAM_template,$(prog),$(USER_BIN_DIR),$(link)))))
+$(foreach prog,$(test_PROGRAMS),$(foreach link,$(link_VARIANTS),$(eval $(call PROGRAM_template,$(prog),$(USER_TESTS_DIR),$(link)))))
 else
 $(foreach prog,$(bin_PROGRAMS),$(eval $(call PROGRAM_template,$(prog),$(USER_BIN_DIR))))
+$(foreach prog,$(test_PROGRAMS),$(eval $(call PROGRAM_template,$(prog),$(USER_TESTS_DIR))))
 endif
 
 $(foreach lib,$(lib_LIBRARIES),$(eval $(call LIBRARY_template,$(lib))))
@@ -626,11 +601,11 @@ library-pass-local: $(addprefix $(USER_INCLUDE_DIR)/,$(cmetric_include_HEADERS))
                    $(addprefix $(LIB_DIR)/,$(lib_OBJS))
 
 ifneq ($(link_VARIANTS),)
-binary-pass-local:  $(foreach link,$(link_VARIANTS),$(bin_PROGRAMS:%=$(USER_BIN_DIR)/%-$(link)) \
-                   $(foreach of,$(OUTPUT_FORMATS),$(bin_PROGRAMS:%=$(USER_BIN_DIR)/%-$(link).$(of))))
+binary-pass-local:  $(foreach link,$(link_VARIANTS),$(bin_PROGRAMS:%=$(USER_BIN_DIR)/%-$(link)) $(test_PROGRAMS:%=$(USER_TESTS_DIR)/%-$(link)) \
+                   $(foreach of,$(OUTPUT_FORMATS),$(bin_PROGRAMS:%=$(USER_BIN_DIR)/%-$(link).$(of)) $(test_PROGRAMS:%=$(USER_TESTS_DIR)/%-$(link).$(of))))
 else
-binary-pass-local:  $(bin_PROGRAMS:%=$(USER_BIN_DIR)/%) \
-                   $(foreach of,$(OUTPUT_FORMATS),$(bin_PROGRAMS:%=$(USER_BIN_DIR)/%.$(of)))
+binary-pass-local:  $(bin_PROGRAMS:%=$(USER_BIN_DIR)/%) $(test_PROGRAMS:%=$(USER_TESTS_DIR)/%) \
+                   $(foreach of,$(OUTPUT_FORMATS),$(bin_PROGRAMS:%=$(USER_BIN_DIR)/%.$(of)) $(test_PROGRAMS:%=$(USER_TESTS_DIR)/%.$(of)))
 endif
 
 endif # TARGET_RULE_TEMPLATES
@@ -698,7 +673,7 @@ endef
 define LOAD_RUN_VARIANT_template
 .PHONY: load-$(1) run-$(1)
 
-load-$(1): load-$(firstword $(bin_PROGRAMS))-$(1)
+load-$(1): load-$(firstword $(bin_PROGRAMS) $(test_PROGRAMS))-$(1)
 
 run-$(1):
        @$(QUIET_CMD_ECHO) "  RUN     $(1)"
@@ -708,10 +683,11 @@ run-$(1):
 endef
 
 $(foreach link,$(link_VARIANTS),$(foreach prog,$(bin_PROGRAMS),$(eval $(call LOAD_PROGRAM_template,$(prog),$(USER_BIN_DIR),$(link)))))
+$(foreach link,$(link_VARIANTS),$(foreach prog,$(test_PROGRAMS),$(eval $(call LOAD_PROGRAM_template,$(prog),$(USER_TEST_DIR),$(link)))))
 $(foreach link,$(link_VARIANTS),$(eval $(call LOAD_RUN_VARIANT_template,$(link))))
 
 .PHONY: load run
-load: $(addprefix load-,$(firstword $(bin_PROGRAMS))-$(firstword $(link_VARIANTS)))
+load: $(addprefix load-,$(firstword $(bin_PROGRAMS) $(test_PROGRAMS))-$(firstword $(link_VARIANTS)))
 
 run: run-$(firstword $(link_VARIANTS))
 
@@ -721,9 +697,9 @@ run: run-$(firstword $(link_VARIANTS))
 # Generate pass rules from generic templates
 OTHER_PASSES = dep clean install
 
-$(eval $(call omk_pass_template, include-pass, $(LOCAL_BUILD_DIR),,$(include_HEADERS)$(nobase_include_HEADERS)$(renamed_include_HEADERS)$(lib_LDSCRIPTS)$(config_include_HEADERS)))
+$(eval $(call omk_pass_template, include-pass, $(LOCAL_BUILD_DIR),,$(include_HEADERS)$(nobase_include_HEADERS)$(renamed_include_HEADERS)$(lib_LDSCRIPTS)$(config_include_HEADERS)$(LOCAL_CONFIG_H)))
 $(eval $(call omk_pass_template, library-pass, $(LOCAL_BUILD_DIR),TARGET_RULE_TEMPLATES=y,$(lib_LIBRARIES)$(shared_LIBRARIES)$(lib_obj_SOURCES)))
-$(eval $(call omk_pass_template, binary-pass,  $(LOCAL_BUILD_DIR),TARGET_RULE_TEMPLATES=y,$(bin_PROGRAMS)))
+$(eval $(call omk_pass_template, binary-pass,  $(LOCAL_BUILD_DIR),TARGET_RULE_TEMPLATES=y,$(bin_PROGRAMS) $(test_PROGRAMS)))
 $(eval $(call omk_pass_template, utils-pass,   $(LOCAL_BUILD_DIR),HOST_RULE_TEMPLATES=y,$(utils_PROGRAMS)))
 
 
@@ -752,10 +728,86 @@ check-dir:
        @$(call mkdir_def,$(USER_LIB_DIR))
        @$(call mkdir_def,$(USER_BIN_DIR))
        @$(call mkdir_def,$(USER_UTILS_DIR))
+       @$(call mkdir_def,$(USER_TESTS_DIR))
 
 # Which passes to pass
 default: include-pass library-pass binary-pass utils-pass
 
+# Local Variables:
+# mode:makefile
+# End:
+                                                             #OMK@config_h
+# Syntax: $(call BUILD_CONFIG_H_template,<stamp_dir>,<header_file_path>,<list_of_options_to_export>,<header_barrier>)
+define BUILD_CONFIG_H_template
+
+$(addprefix $(1)/,$(notdir $(addsuffix .stamp,$(2)))) : $(wildcard $(CONFIG_FILE)) $(wildcard $(CONFIG_FILE)-default)
+       @$(QUIET_CMD_ECHO) "  CONFGEN $$(@:%.stamp=%)"
+       @if [ ! -d `dirname $(2).tmp` ] ; then \
+               mkdir -p `dirname $(2).tmp` ; fi
+       @echo "/* Automatically generated from */" > "$(2).tmp"
+       @echo "/* config file: $$< */" >> "$(2).tmp"
+       $(if $(DOXYGEN),@echo "/** @file */" >> "$(2).tmp")
+       @echo "#ifndef $(4)" >> "$(2).tmp"
+       @echo "#define $(4)" >> "$(2).tmp"
+       @( $(foreach x, $(shell echo '$($(3))' | tr 'x\t ' 'x\n\n' | sed -e 's/^\([^ =]*\)\(=[^ ]\+\|\)$$/\1/' ), \
+               echo '$(x).$($(x))' ; ) echo ; ) | \
+               sed -e '/^[^.]*\.n$$$$/d' -e '/^[^.]*\.$$$$/d' -e 's/^\([^.]*\)\.[ym]$$$$/\1.1/' | \
+               sed -n -e 's/^\([^.]*\)\.\(.*\)$$$$/#define \1 \2/p' \
+                 >> "$(2).tmp"
+       @echo "#endif /*$(4)*/" >> "$(2).tmp"
+       @touch "$$@"
+       @if cmp --quiet "$(2).tmp" "$(2)" ; then rm "$(2).tmp"; \
+       else mv "$(2).tmp" "$(2)" ; \
+       echo "Updated configuration $(2)" ; fi
+
+endef
+
+ifdef LOCAL_CONFIG_H
+
+# This must be declared after the default cflags are assigned!
+# Override is used to override command line assignemnt.
+override CFLAGS += -I.
+$(eval $(call BUILD_CONFIG_H_template,$(USER_OBJS_DIR),$(USER_OBJS_DIR)/$(LOCAL_CONFIG_H),default_CONFIG,_LOCAL_CONFIG_H) )
+
+endif
+
+# Special rules for configuration exported headers
+
+#FIXME: The directory for headers should not be specified here.
+$(foreach confh,$(config_include_HEADERS),$(eval $(call BUILD_CONFIG_H_template,$(USER_OBJS_DIR),$(addprefix $(USER_INCLUDE_DIR)/,$(confh)),$(basename $(notdir $(confh)))_DEFINES,\
+_$(basename $(notdir $(confh)))_H \
+)))
+
+config_h_stamp_files = $(addprefix $(USER_OBJS_DIR)/,$(notdir $(addsuffix .stamp,$(config_include_HEADERS) $(LOCAL_CONFIG_H))))
+
+# Add some hooks to standard passes
+include-pass-local: $(config_h_stamp_files)
+
+ifneq ($(KERN_CONFIG_HEADERS_REQUIRED),)
+
+ifdef LOCAL_CONFIG_H
+$(eval $(call BUILD_CONFIG_H_template,$(KERN_OBJS_DIR),$(KERN_OBJS_DIR)/$(LOCAL_CONFIG_H),default_CONFIG,_LOCAL_CONFIG_H) )
+endif
+
+$(foreach confh,$(config_include_HEADERS),$(eval $(call BUILD_CONFIG_H_template,$(KERN_OBJS_DIR),$(addprefix $(KERN_INCLUDE_DIR)/,$(confh)),$(basename $(notdir $(confh)))_DEFINES,\
+_$(basename $(notdir $(confh)))_H \
+)))
+
+kern_config_h_stamp_files = $(addprefix $(KERN_OBJS_DIR)/,$(notdir $(addsuffix .stamp,$(config_include_HEADERS) $(LOCAL_CONFIG_H))))
+
+# Add some hooks to standard passes
+include-pass-local: $(kern_config_h_stamp_files)
+
+endif
+
+clean-local: clean-local-config-h
+
+clean-local-config-h:
+       @$(foreach confh,$(config_h_stamp_files) $(kern_config_h_stamp_files),\
+           if [ -e $(confh) ] ; then rm $(confh) ; fi ; \
+       )
+
+
 # Local Variables:
 # mode:makefile
 # End:
@@ -785,7 +837,7 @@ ifeq ($(NEED_SOURCES_LIST),y) # avoid execution of find command bellow if it is
 .PHONY: sources-list
 sources-list: $(SOURCES_LIST)
 
-$(SOURCES_LIST): $(CONFIG_FILE) $(CONFIG_FILE)-default $(shell find -name Makefile.omk)
+$(SOURCES_LIST): $(CONFIG_FILE) $(CONFIG_FILE)-default $(shell find -name $(MAKEFILE_OMK))
        @echo -n "" > "$(SOURCES_LIST).tmp"
        @$(MAKE) --no-print-directory sources-list-pass
        @echo "# Automatically generated list of files in '$(RELATIVE_DIR)' that are used during OMK compilation" > "$(SOURCES_LIST).tmp2"
@@ -802,7 +854,7 @@ sources-list-pass-local:
        @$(foreach ch,$(config_include_HEADERS), \
          echo "$(USER_INCLUDE_DIR:$(MAKERULES_DIR)/$(addsuffix /,$(SOURCES_LIST_DIR))%=%)/$(ch)" >> "$(SOURCES_LIST).tmp";)
        @$(foreach h,$(renamed_include_HEADERS),echo "$(RELATIVE_DIR:$(SOURCES_LIST_DIR)/%=%)/$(h)"|sed -e 's/\(.*\)->.*/\1/' >> "$(SOURCES_LIST).tmp";)
-       @$(foreach bin,$(lib_LIBRARIES) $(shared_LIBRARIES) $(bin_PROGRAMS) $(utils_PROGRAMS) \
+       @$(foreach bin,$(lib_LIBRARIES) $(shared_LIBRARIES) $(bin_PROGRAMS) $(test_PROGRAMS) $(utils_PROGRAMS) \
          $(kernel_LIBRARIES) $(rtlinux_LIBRARIES) $(kernel_MODULES),\
          $(foreach src,$(filter-out %.o,$($(bin)_SOURCES)),echo "$(RELATIVE_DIR:$(SOURCES_LIST_DIR)/%=%)/$(src)" >> "$(SOURCES_LIST).tmp";))
 
@@ -811,16 +863,17 @@ sources-list-pass-local:
 ifeq ($(MAKECMDGOALS),TAGS)
 ETAGS=etags
 TAGS_CMD = $(ETAGS)
+TAGS: $(SOURCES_LIST)
+       @$(MAKE) --no-print-directory do-tags
 endif
 ifeq ($(MAKECMDGOALS),tags) 
 CTAGS=ctags -N
 TAGS_CMD = $(CTAGS)
+tags: $(SOURCES_LIST)
+       @$(MAKE) --no-print-directory do-tags
 endif
 export TAGS_CMD
 
-tags TAGS: $(SOURCES_LIST)
-       @$(MAKE) --no-print-directory do-tags
-
 ifeq ($(MAKECMDGOALS),do-tags)
 .PHONY: do-tags
 do-tags: $(shell sed -e '/^\#/d' $(SOURCES_LIST))