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 $(notdir $(addsuffix .stamp,$(1))) : $(wildcard $(CONFIG_FILE)) $(wildcard $(CONFIG_FILE)-default)
15 @$(QUIET_CMD_ECHO) " CONFGEN $$(@:%.stamp=%)"
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"
30 @if cmp --quiet "$(1).tmp" "$(1)" ; then rm "$(1).tmp"; \
31 else mv "$(1).tmp" "$(1)" ; \
32 echo "Updated configuration $(1)" ; fi
38 # This must be declared after the default cflags are assigned!
39 # Override is used to override command line assignemnt.
40 override CFLAGS += -I.
41 $(eval $(call BUILD_CONFIG_H_template,$(LOCAL_CONFIG_H),default_CONFIG,_LOCAL_CONFIG_H) )
45 # Special rules for configuration exported headers
47 #FIXME: The directory for headers should not be specified here.
48 $(foreach confh,$(config_include_HEADERS),$(eval $(call BUILD_CONFIG_H_template,$(addprefix $(USER_INCLUDE_DIR)/,$(confh)),$(basename $(notdir $(confh)))_DEFINES,\
49 _$(basename $(notdir $(confh)))_H \
52 config_h_stamp_files = $(notdir $(addsuffix .stamp,$(config_include_HEADERS) $(LOCAL_CONFIG_H)))
54 # Add some hooks to standard passes
55 include-pass-local: $(config_h_stamp_files)
57 clean-local: clean-local-config-h
60 @$(foreach confh,$(config_h_stamp_files),\
61 if [ -e $(confh) ] ; then rm $(confh) ; fi ; \