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