]> rtime.felk.cvut.cz Git - omk.git/blob - snippets/sources-list
Aded rules for TAGS generation according to generated sources-list.
[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:=$(MAKERULES_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_FILE) $(CONFIG_FILE)-default $(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)))
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 h,$(renamed_include_HEADERS),echo "$(RELATIVE_DIR:$(SOURCES_LIST_DIR)/%=%)/$(h)"|sed -e 's/\(.*\)->.*/\1/' >> "$(SOURCES_LIST).tmp";)
42         @$(foreach bin,$(lib_LIBRARIES) $(shared_LIBRARIES) $(bin_PROGRAMS) $(utils_PROGRAMS) \
43           $(kernel_LIBRARIES) $(rtlinux_LIBRARIES) $(kernel_MODULES),\
44           $(foreach src,$(filter-out %.o,$($(bin)_SOURCES)),echo "$(RELATIVE_DIR:$(SOURCES_LIST_DIR)/%=%)/$(src)" >> "$(SOURCES_LIST).tmp";))
45
46 ############ TAGS ###########
47
48 ifeq ($(MAKECMDGOALS),TAGS)
49 TAGS_CMD = etags
50 endif
51 ifeq ($(MAKECMDGOALS),tags) 
52 TAGS_CMD = ctags
53 endif
54 export TAGS_CMD
55
56 tags TAGS: $(SOURCES_LIST)
57         @$(MAKE) --no-print-directory do-tags
58
59 ifeq ($(MAKECMDGOALS),do-tags)
60 .PHONY: do-tags
61 do-tags: $(shell sed -e '/^\#/d' $(SOURCES_LIST))
62         @$(QUIET_CMD_ECHO) "  TAGS    $(SOURCES_LIST_FN)"
63         $(Q)$(TAGS_CMD) $^
64 endif
65
66 # Local Variables:
67 # mode:makefile
68 # End: