summaryrefslogtreecommitdiffstats
path: root/share/mk/bsd.dep.mk
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2002-10-17 13:48:13 +0000
committerru <ru@FreeBSD.org>2002-10-17 13:48:13 +0000
commit64dd2ee656bb0005524d781c28e4c227d6bc5a22 (patch)
tree9d155f4e09a9ac61c84d0128e618472317b061de /share/mk/bsd.dep.mk
parentd91054229567b7e8d98914d2335b054dac2635fe (diff)
downloadFreeBSD-src-64dd2ee656bb0005524d781c28e4c227d6bc5a22.zip
FreeBSD-src-64dd2ee656bb0005524d781c28e4c227d6bc5a22.tar.gz
Added the new variable CTAGS which, if set to "ctags", reverts
to creating the tags file using ctags(1). Defaults to "gtags". Made GTAGSFLAGS and HTAGSFLAGS overrideable, added CTAGSFLAGS. Folded bsd.prog.mk version of `tags' into bsd.dep.mk. PR: bin/42852
Diffstat (limited to 'share/mk/bsd.dep.mk')
-rw-r--r--share/mk/bsd.dep.mk54
1 files changed, 37 insertions, 17 deletions
diff --git a/share/mk/bsd.dep.mk b/share/mk/bsd.dep.mk
index fc6ed71..70e54f6 100644
--- a/share/mk/bsd.dep.mk
+++ b/share/mk/bsd.dep.mk
@@ -5,8 +5,16 @@
#
# +++ variables +++
#
+# CTAGS A tags file generation program [gtags]
+#
+# CTAGSFLAGS Options for ctags(1) [not set]
+#
# DEPENDFILE dependencies file [.depend]
#
+# GTAGSFLAGS Options for gtags(1) [-o]
+#
+# HTAGSFLAGS Options for htags(1) [not set]
+#
# MKDEP Options for ${MKDEPCMD} [not set]
#
# MKDEPCMD Makefile dependency list program [mkdep]
@@ -24,13 +32,20 @@
# them in the file ${DEPENDFILE}.
#
# tags:
-# Create a (GLOBAL) gtags file for the source files.
-# If HTML is defined, htags is also run after gtags.
+# In "ctags" mode, create a tags file for the source files.
+# In "gtags" mode, create a (GLOBAL) gtags file for the
+# source files. If HTML is defined, htags(1) is also run
+# after gtags(1).
.if !target(__<bsd.init.mk>__)
.error bsd.dep.mk cannot be included directly.
.endif
+CTAGS?= gtags
+CTAGSFLAGS?=
+GTAGSFLAGS?= -o
+HTAGSFLAGS?=
+
.if ${CC} != "cc"
MKDEPCMD?= CC='${CC}' mkdep
.else
@@ -38,6 +53,20 @@ MKDEPCMD?= mkdep
.endif
DEPENDFILE?= .depend
+# Keep `tags' here, before SRCS are mangled below for `depend'.
+.if !target(tags) && defined(SRCS) && !defined(NOTAGS)
+tags: ${SRCS}
+.if ${CTAGS:T} == "ctags"
+ @${CTAGS} ${CTAGSFLAGS} -f /dev/stdout \
+ ${.ALLSRC:N*.h} | sed "s;${.CURDIR}/;;" > ${.TARGET}
+.elif ${CTAGS:T} == "gtags"
+ @cd ${.CURDIR} && ${CTAGS} ${GTAGSFLAGS} ${.OBJDIR}
+.if defined(HTML)
+ @cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR}
+.endif
+.endif
+.endif
+
.if defined(SRCS)
CLEANFILES?=
@@ -128,25 +157,16 @@ afterdepend:
.endif
.endif
-.if defined(NOTAGS)
-tags:
-.endif
-
-.if !target(tags)
-tags: ${SRCS}
- @cd ${.CURDIR} && gtags ${GTAGSFLAGS} ${.OBJDIR}
-.if defined(HTML)
- @cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR}
-.endif
-.endif
-
.if !target(cleandepend)
cleandepend:
.if defined(SRCS)
- rm -f ${DEPENDFILE} ${.OBJDIR}/GPATH ${.OBJDIR}/GRTAGS \
- ${.OBJDIR}/GSYMS ${.OBJDIR}/GTAGS
+.if ${CTAGS:T} == "ctags"
+ rm -f ${DEPENDFILE} tags
+.elif ${CTAGS:T} == "gtags"
+ rm -f ${DEPENDFILE} GPATH GRTAGS GSYMS GTAGS
.if defined(HTML)
- rm -rf ${.OBJDIR}/HTML
+ rm -rf HTML
+.endif
.endif
.endif
.endif
OpenPOWER on IntegriCloud