# LOCAL_CONFIG_H .. name of local config.h file generated from values # 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 /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,,,,) define BUILD_CONFIG_H_template $(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' \ >> "$(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: