]> rtime.felk.cvut.cz Git - omk.git/blob - snippets/sources-list
Added EXTRA_RULES_SUBDIRS feature
[omk.git] / snippets / sources-list
1
2 # Rules that creates the list of files which are used during
3 # compilation. The list reflects conditional compilation depending on
4 # config.omk and other variables.
5
6 SOURCES_LIST_FN=sources.txt
7 ifndef SOURCES_LIST
8 SOURCES_LIST_DIR:=$(RELATIVE_DIR)
9 SOURCES_LIST:=$(OUTPUT_DIR)/$(SOURCES_LIST_DIR)/$(SOURCES_LIST_FN)
10 export SOURCES_LIST SOURCES_LIST_DIR
11 endif
12
13 ifeq ($(MAKECMDGOALS),sources-list)
14 NEED_SOURCES_LIST=y
15 endif
16 ifeq ($(MAKECMDGOALS),TAGS)
17 NEED_SOURCES_LIST=y
18 endif
19 ifeq ($(MAKECMDGOALS),tags)
20 NEED_SOURCES_LIST=y
21 endif
22
23 ifeq ($(NEED_SOURCES_LIST),y) # avoid execution of find command bellow if it is not useful
24 .PHONY: sources-list
25 sources-list: $(SOURCES_LIST)
26
27 $(SOURCES_LIST): $(CONFIG_FILES) $(shell find -name $(MAKEFILE_OMK))
28         @echo -n "" > "$(SOURCES_LIST).tmp"
29         @$(MAKE) --no-print-directory sources-list-pass
30         @echo "# Automatically generated list of files in '$(RELATIVE_DIR)' that are used during OMK compilation" > "$(SOURCES_LIST).tmp2"
31         @cat "$(SOURCES_LIST).tmp"|sort|uniq >> "$(SOURCES_LIST).tmp2"
32         @rm "$(SOURCES_LIST).tmp"
33         @mv "$(SOURCES_LIST).tmp2" "$(SOURCES_LIST)"
34 endif
35
36 $(eval $(call omk_pass_template,sources-list-pass,$$(LOCAL_BUILD_DIR),,always))
37
38 sources-list-pass-local:
39         @$(foreach h,$(include_HEADERS) $(nobase_include_HEADERS) $(kernel_HEADERS),\
40           echo "$(RELATIVE_DIR:$(SOURCES_LIST_DIR)/%=%)/$(h)" >> "$(SOURCES_LIST).tmp";)
41         @$(foreach ch,$(config_include_HEADERS), \
42           echo "$(USER_INCLUDE_DIR:$(OUTPUT_DIR)/$(addsuffix /,$(SOURCES_LIST_DIR))%=%)/$(ch)" >> "$(SOURCES_LIST).tmp";)
43         @$(foreach h,$(renamed_include_HEADERS),echo "$(RELATIVE_DIR:$(SOURCES_LIST_DIR)/%=%)/$(h)"|sed -e 's/\(.*\)->.*/\1/' >> "$(SOURCES_LIST).tmp";)
44         @$(foreach bin,$(lib_LIBRARIES) $(shared_LIBRARIES) $(bin_PROGRAMS) $(test_PROGRAMS) $(utils_PROGRAMS) \
45           $(kernel_LIBRARIES) $(rtlinux_LIBRARIES) $(kernel_MODULES),\
46           $(foreach src,$(filter-out %.o,$($(bin)_SOURCES)),echo "$(RELATIVE_DIR:$(SOURCES_LIST_DIR)/%=%)/$(src)" >> "$(SOURCES_LIST).tmp";))
47
48 ############ TAGS ###########
49
50 ifeq ($(MAKECMDGOALS),TAGS)
51 ETAGS=etags
52 TAGS_CMD = $(ETAGS)
53 TAGS: $(SOURCES_LIST)
54         @$(MAKE) --no-print-directory do-tags
55 endif
56 ifeq ($(MAKECMDGOALS),tags) 
57 CTAGS=ctags -N
58 TAGS_CMD = $(CTAGS)
59 tags: $(SOURCES_LIST)
60         @$(MAKE) --no-print-directory do-tags
61 endif
62 export TAGS_CMD
63
64 ifeq ($(MAKECMDGOALS),do-tags)
65 .PHONY: do-tags
66 do-tags: $(shell sed -e '/^\#/d' $(SOURCES_LIST))
67         @$(QUIET_CMD_ECHO) "  TAGS    $(SOURCES_LIST_FN)"
68         $(Q)$(TAGS_CMD) $^
69 endif
70
71 ############ CSCOPE ###########
72
73 cscope: $(SOURCES_LIST)
74         @$(QUIET_CMD_ECHO) "  CSCOPE  < $(SOURCES_LIST_FN)"
75         $(Q)sed -e '/^#/d' $(SOURCES_LIST)|cscope -b -i-
76 #FIXME: see doc to -i in cscope(1)
77
78 # Local Variables:
79 # mode:makefile
80 # End: