Skip to content

Commit 3353397

Browse files
committed
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 <[email protected]>
1 parent 703f05a commit 3353397

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2115,17 +2115,21 @@ po/git.pot: $(LOCALIZED_C)
21152115

21162116
pot: po/git.pot
21172117

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+
21182122
$(ETAGS_TARGET): FORCE
21192123
$(RM) $(ETAGS_TARGET)
2120-
$(FIND) . -name '*.[hcS]' -print | xargs etags -a -o $(ETAGS_TARGET)
2124+
$(FIND_SOURCE_FILES) | xargs etags -a -o $(ETAGS_TARGET)
21212125

21222126
tags: FORCE
21232127
$(RM) tags
2124-
$(FIND) . -name '*.[hcS]' -print | xargs ctags -a
2128+
$(FIND_SOURCE_FILES) | xargs ctags -a
21252129

21262130
cscope:
21272131
$(RM) cscope*
2128-
$(FIND) . -name '*.[hcS]' -print | xargs cscope -b
2132+
$(FIND_SOURCE_FILES) | xargs cscope -b
21292133

21302134
### Detect prefix changes
21312135
TRACK_CFLAGS = $(CC):$(subst ','\'',$(ALL_CFLAGS)):\

0 commit comments

Comments
 (0)