X-Git-Url: http://rtime.felk.cvut.cz/gitweb/omk.git/blobdiff_plain/ad84afc206e2bd1516fd2f07a2595f7dea310405..98facfbc0494a9d7a152b58ae8efb832600c11b3:/snippets/config_h diff --git a/snippets/config_h b/snippets/config_h index b753be4..0e25ad9 100644 --- a/snippets/config_h +++ b/snippets/config_h @@ -4,27 +4,32 @@ # with subdirectories) # xxx_DEFINES .. list of config directives to be included in # config header file of the name /xxx.h +# DOXYGEN .. if non-empty, generated headers includes Doxygen's @file +# command, so it is possible to document config +# variables. -# Syntax: $(call BUILD_CONFIG_H_template,,,) +# Syntax: $(call BUILD_CONFIG_H_template,,,,) 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' ), \ +$(addprefix $(1)/,$(notdir $(addsuffix .stamp,$(2)))) : $(CONFIG_FILES) + @$(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 files: $$(^:$(OUTPUT_DIR)/%=%) */" >> "$(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' \ - >> "$(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 + >> "$(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 @@ -33,25 +38,44 @@ 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,$(LOCAL_CONFIG_H),default_CONFIG,_LOCAL_CONFIG_H) ) +$(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,$(addprefix $(USER_INCLUDE_DIR)/,$(confh)),$(basename $(notdir $(confh)))_DEFINES,\ +$(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: $(addprefix $(USER_INCLUDE_DIR)/,$(config_include_HEADERS)) +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,$(addprefix $(USER_INCLUDE_DIR)/,$(config_include_HEADERS)),\ - if [ -e $(confh) ] ; then touch -t 200001010101 $(confh) ; fi ; \ + @$(foreach confh,$(config_h_stamp_files) $(kern_config_h_stamp_files),\ + if [ -e $(confh) ] ; then rm $(confh) ; fi ; \ )