diff mbox series

[9/9] libtracefs: Have make tags and TAGS honor O= build directory

Message ID 20211217004214.16074-10-rostedt@goodmis.org (mailing list archive)
State Superseded
Headers show
Series libtracefs: Updates to the Makefile | expand

Commit Message

Steven Rostedt Dec. 17, 2021, 12:42 a.m. UTC
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

Currently if one does a "make O=/tmp/build tags" the tags are still built
in the source directory. Although this is uncommon to do, the tags (and
TAGS) target should still honor the build directory.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 Makefile | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index 58b4219e7b62..bf085bfdb800 100644
--- a/Makefile
+++ b/Makefile
@@ -198,7 +198,7 @@  endif
 		$(src)/$(UTEST_DIR)/$(UTEST_BINARY)
 
 define find_tag_files
-	find . -name '\.pc' -prune -o -name '*\.[ch]' -print -o -name '*\.[ch]pp' \
+	find $(src) -name '\.pc' -prune -o -name '*\.[ch]' -print -o -name '*\.[ch]pp' \
 		! -name '\.#' -print
 endef
 
@@ -221,18 +221,26 @@  $(BUILD_PREFIX): force
 $(PKG_CONFIG_FILE) : ${PKG_CONFIG_SOURCE_FILE}.template $(BUILD_PREFIX) $(VERSION_FILE)
 	$(Q) $(call do_make_pkgconfig_file,$(prefix))
 
-tags:	force
-	$(RM) tags
-	$(call find_tag_files) | xargs ctags --extra=+f --c-kinds=+px
+VIM_TAGS = $(obj)/tags
+EMACS_TAGS = $(obj)/TAGS
+CSCOPE_TAGS = $(obj)/cscope
 
-TAGS:	force
-	$(RM) TAGS
-	$(call find_tag_files) | xargs etags
+$(VIM_TAGS): force
+	$(RM) $@
+	$(call find_tag_files) | (cd $(obj) && xargs ctags --extra=+f --c-kinds=+px)
 
-cscope: force
-	$(RM) cscope*
+$(EMACS_TAGS): force
+	$(RM) $@
+	$(call find_tag_files) | (cd $(obj) && xargs etags)
+
+$(CSCOPE_TAGS): force
+	$(RM) $(obj)/cscope*
 	$(call find_tag_files) | cscope -b -q
 
+tags: $(VIM_TAGS)
+TAGS: $(EMACS_TAGS)
+cscope: $(CSCOPE_TAGS)
+
 ifeq ("$(DESTDIR)", "")
 # If DESTDIR is not defined, then test if after installing the library
 # and running ldconfig, if the library is visible by ld.so.