]> rtime.felk.cvut.cz Git - omk.git/blob - snippets/config_h.omk
Removed emacs modelines
[omk.git] / snippets / config_h.omk
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,<stamp_dir>,<header_file_path>,<list_of_options_to_export>,<header_barrier>)
12 define BUILD_CONFIG_H_template
13
14 $(addprefix $(1)/,$(notdir $(addsuffix .stamp,$(2)))) : $(CONFIG_FILES)
15         @$(QUIET_CMD_ECHO) "  CONFGEN $$(@:%.stamp=%)"
16         @if [ ! -d `dirname $(2).tmp` ] ; then \
17                 mkdir -p `dirname $(2).tmp` ; fi
18         @echo "/* Automatically generated from */" > "$(2).tmp"
19         @echo "/* config files: $$(^:$(OUTPUT_DIR)/%=%) */" >> "$(2).tmp"
20         $(if $(DOXYGEN),@echo "/** @file */" >> "$(2).tmp")
21         @echo "#ifndef $(4)" >> "$(2).tmp"
22         @echo "#define $(4)" >> "$(2).tmp"
23         @( $(foreach x, $(shell echo '$($(3))' | tr 'x\t ' 'x\n\n' | 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                   >> "$(2).tmp"
28         @echo "#endif /*$(4)*/" >> "$(2).tmp"
29         @touch "$$@"
30         @if cmp --quiet "$(2).tmp" "$(2)" ; then rm "$(2).tmp"; \
31         else mv "$(2).tmp" "$(2)" ; \
32         echo "Updated configuration $(2)" ; fi
33
34 endef
35
36 ifdef LOCAL_CONFIG_H
37
38 # This must be declared after the default cflags are assigned!
39 # Override is used to override command line assignemnt.
40 override CFLAGS += -I $(USER_OBJS_DIR)
41 override kernel_INCLUDES += -I $(KERN_OBJS_DIR)
42 $(eval $(call BUILD_CONFIG_H_template,$(USER_OBJS_DIR),$(USER_OBJS_DIR)/$(LOCAL_CONFIG_H),default_CONFIG,_LOCAL_CONFIG_H) )
43
44 endif
45
46 # Special rules for configuration exported headers
47
48 #FIXME: The directory for headers should not be specified here.
49 $(foreach confh,$(config_include_HEADERS),$(eval $(call BUILD_CONFIG_H_template,$(USER_OBJS_DIR),$(addprefix $(USER_INCLUDE_DIR)/,$(confh)),$(basename $(notdir $(confh)))_DEFINES,\
50 _$(basename $(notdir $(confh)))_H \
51 )))
52
53 config_h_stamp_files = $(addprefix $(USER_OBJS_DIR)/,$(notdir $(addsuffix .stamp,$(config_include_HEADERS) $(LOCAL_CONFIG_H))))
54
55 # Add some hooks to standard passes
56 include-pass-local: $(config_h_stamp_files)
57
58 ifneq ($(KERN_CONFIG_HEADERS_REQUIRED),)
59
60 ifdef LOCAL_CONFIG_H
61 $(eval $(call BUILD_CONFIG_H_template,$(KERN_OBJS_DIR),$(KERN_OBJS_DIR)/$(LOCAL_CONFIG_H),default_CONFIG,_LOCAL_CONFIG_H) )
62 endif
63
64 $(foreach confh,$(config_include_HEADERS),$(eval $(call BUILD_CONFIG_H_template,$(KERN_OBJS_DIR),$(addprefix $(KERN_INCLUDE_DIR)/,$(confh)),$(basename $(notdir $(confh)))_DEFINES,\
65 _$(basename $(notdir $(confh)))_H \
66 )))
67
68 kern_config_h_stamp_files = $(addprefix $(KERN_OBJS_DIR)/,$(notdir $(addsuffix .stamp,$(config_include_HEADERS) $(LOCAL_CONFIG_H))))
69
70 # Add some hooks to standard passes
71 include-pass-local: $(kern_config_h_stamp_files)
72
73 endif
74
75 clean-local: clean-local-config-h
76
77 clean-local-config-h:
78         @$(foreach confh,$(config_h_stamp_files) $(kern_config_h_stamp_files),\
79             if [ -e $(confh) ] ; then rm $(confh) ; fi ; \
80         )