# 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 # 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' ), \ 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: