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
7 # DOXYGEN .. if non-empty, generated headers includes Doxygen's @file
8 # command, so it is possible to document config
11 # Syntax: $(call BUILD_CONFIG_H_template,<header_file_path>,<list_of_options_to_export>,<header_barrier>)
12 define BUILD_CONFIG_H_template
14 $(1) : $(wildcard $(CONFIG_FILE)) $(wildcard $(CONFIG_FILE)-default)
15 @$(QUIET_CMD_ECHO) " CONFGEN $$(@:$(MAKERULES_DIR)/%=%)"
16 @if [ ! -d `dirname $(1).tmp` ] ; then \
17 mkdir `dirname $(1).tmp` ; fi
18 @echo "/* Automatically generated from */" > "$(1).tmp"
19 @echo "/* config file: $$< */" >> "$(1).tmp"
20 $(if $(DOXYGEN),@echo "/** @file */" >> "$(1).tmp")
21 @echo "#ifndef $(3)" >> "$(1).tmp"
22 @echo "#define $(3)" >> "$(1).tmp"
23 @( $(foreach x, $(shell echo '$($(2))' | sed -e 's/[ \t]/\n/g' | sed -e 's/^\([^ =]*\)\(=[^ ]\+\|\)$$/\1/' ), \
24 echo '$(x).$($(x))' ; ) echo ; ) | \
25 sed -e '/^[^.]*\.n$$$$/d' -e '/^[^.]*\.$$$$/d' -e 's/^\([^.]*\)\.[ym]$$$$/\1.1/' | \
26 sed -n -e 's/^\([^.]*\)\.\(.*\)$$$$/#define \1 \2/p' \
28 @echo "#endif /*$(3)*/" >> "$(1).tmp"
29 @if cmp --quiet "$(1).tmp" "$(1)" ; then rm "$(1).tmp"; touch "$(1)" ; \
30 else mv "$(1).tmp" "$(1)" ; \
31 echo Updated configuration "$(1)" ; fi
37 # This must be declared after the default cflags are assigned!
38 # Override is used to override command line assignemnt.
39 override CFLAGS += -I.
40 $(eval $(call BUILD_CONFIG_H_template,$(LOCAL_CONFIG_H),default_CONFIG,_LOCAL_CONFIG_H) )
44 # Special rules for configuration exported headers
46 #FIXME: The directory for headers should not be specified here.
47 $(foreach confh,$(config_include_HEADERS),$(eval $(call BUILD_CONFIG_H_template,$(addprefix $(USER_INCLUDE_DIR)/,$(confh)),$(basename $(notdir $(confh)))_DEFINES,\
48 _$(basename $(notdir $(confh)))_H \
51 # Add some hooks to standard passes
52 include-pass-local: $(addprefix $(USER_INCLUDE_DIR)/,$(config_include_HEADERS))
54 clean-local: clean-local-config-h
57 @$(foreach confh,$(addprefix $(USER_INCLUDE_DIR)/,$(config_include_HEADERS)),\
58 if [ -e $(confh) ] ; then touch -t 200001010101 $(confh) ; fi ; \