Makefile: ask "ls-files" to list source files if available
The [ce]tags and cscope targets used to run "find" looking for any paths that match '*.[chS]' to feed the list of source files to downstream xargs. Use "git ls-files" if it is already available to us, and otherwise use a tighter "find" expression that does not list directories and does not go into our .git directory. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Oct 18, 2011 at 00:26 UTC
335339758c48ed17c8eb34437269e821824f577b
1 file changed
+7
-3
Makefile
+7
-3
@@ -2115,17 +2115,21 @@ po/git.pot: $(LOCALIZED_C)
2115
2116
pot: po/git.pot
2117
2118
+FIND_SOURCE_FILES = ( git ls-files '*.[hcS]' 2>/dev/null || \
2119
+ $(FIND) . \( -name .git -type d -prune \) \
2120
+ -o \( -name '*.[hcS]' -type f -print \) )
2121
+
2122
$(ETAGS_TARGET): FORCE
2123
$(RM) $(ETAGS_TARGET)
2120
- $(FIND) . -name '*.[hcS]' -print | xargs etags -a -o $(ETAGS_TARGET)
2124
+ $(FIND_SOURCE_FILES) | xargs etags -a -o $(ETAGS_TARGET)
2125
2126
tags: FORCE
2127
$(RM) tags
2124
- $(FIND) . -name '*.[hcS]' -print | xargs ctags -a
2128
+ $(FIND_SOURCE_FILES) | xargs ctags -a
2129
2130
cscope:
2131
$(RM) cscope*
2128
- $(FIND) . -name '*.[hcS]' -print | xargs cscope -b
2132
+ $(FIND_SOURCE_FILES) | xargs cscope -b
2133
2134
### Detect prefix changes
2135
TRACK_CFLAGS = $(CC):$(subst ','\'',$(ALL_CFLAGS)):\