]> rtime.felk.cvut.cz Git - omk.git/blob - snippets/config_h
Dirty workaround for map file processing under MinGW make.
[omk.git] / snippets / config_h
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
4 #                     with subdirectories)
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
9 #                     variables.
10
11 # Syntax: $(call BUILD_CONFIG_H_template,<header_file_path>,<list_of_options_to_export>,<header_barrier>)
12 define BUILD_CONFIG_H_template
13
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' \
27                   >> "$(1).tmp"
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
32
33 endef
34
35 ifdef LOCAL_CONFIG_H
36
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) )
41
42 endif
43
44 # Special rules for configuration exported headers
45
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 \
49 )))
50
51 # Add some hooks to standard passes
52 include-pass-local: $(addprefix $(USER_INCLUDE_DIR)/,$(config_include_HEADERS))
53
54 clean-local: clean-local-config-h
55
56 clean-local-config-h:
57         @$(foreach confh,$(addprefix $(USER_INCLUDE_DIR)/,$(config_include_HEADERS)),\
58             if [ -e $(confh) ] ; then touch -t 200001010101 $(confh) ; fi ; \
59         )
60
61
62 # Local Variables:
63 # mode:makefile
64 # End: