1 # LOCAL_CONFIG_H .. name of local config.h file generated from values
2 # of options defined in the current directory
3 # config_include_HEADERS .. names of global config files (possibly
5 # xxx_DEFINES .. list of config directives to be included in
6 # config header file of the name <somedir>/xxx.h
8 # Syntax: $(call BUILD_CONFIG_H_template,<header_file_path>,<list_of_options_to_export>,<header_barrier>)
9 define BUILD_CONFIG_H_template
11 $(1) : $(wildcard $(CONFIG_FILE)) $(wildcard $(CONFIG_FILE)-default)
12 @$(QUIET_CMD_ECHO) " CONFGEN $$@ in `pwd`"
13 @if [ ! -d `dirname $(1).tmp` ] ; then \
14 mkdir `dirname $(1).tmp` ; fi
15 @echo "/* Automatically generated from */" > "$(1).tmp"
16 @echo "/* config file: $$< */" >> "$(1).tmp"
17 @echo "#ifndef $(3)" >> "$(1).tmp"
18 @echo "#define $(3)" >> "$(1).tmp"
19 @( $(foreach x, $(shell echo '$($(2))' | sed -e 's/\<\([^ =]*\)\(=[^ ]\+\|\)\>/\1/g' ), \
20 echo '$(x).$($(x))' ; ) echo ; ) | \
21 sed -e '/^[^.]*\.n$$$$/d' -e '/^[^.]*\.$$$$/d' -e 's/^\([^.]*\)\.[ym]$$$$/\1.1/' | \
22 sed -n -e 's/^\([^.]*\)\.\(.*\)$$$$/#define \1 \2/p' \
24 @echo "#endif /*$(3)*/" >> "$(1).tmp"
25 @if cmp --quiet "$(1).tmp" "$(1)" ; then \
26 echo rm "$(1).tmp" ; \
27 else mv "$(1).tmp" "$(1)" ; \
28 echo Updated configuration "$(1)" ; fi
34 $(eval $(call BUILD_CONFIG_H_template,$(LOCAL_CONFIG_H),default_CONFIG,_LOCAL_CONFIG_H) )
38 # Special rules for configuration exported headers
40 #FIXME: The directory for headers should not be specified here.
41 $(foreach confh,$(config_include_HEADERS),$(eval $(call BUILD_CONFIG_H_template,$(addprefix $(USER_INCLUDE_DIR)/,$(confh)),$(basename $(notdir $(confh)))_DEFINES,\
42 _$(basename $(notdir $(confh)))_H \
45 # Add some hooks to standard passes
46 include-pass-local: $(addprefix $(USER_INCLUDE_DIR)/,$(config_include_HEADERS))
48 clean-local: clean-local-config-h
51 @$(foreach confh,$(addprefix $(USER_INCLUDE_DIR)/,$(config_include_HEADERS)),\
52 if [ -e $(confh) ] ; then touch -t 200001010101 $(confh) ; fi ; \