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
This commit is contained in:
Ruslan Ermilov 2002-10-17 13:48:13 +00:00
parent 25388b6cc4
commit ccc4bab104
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=105327
3 changed files with 37 additions and 35 deletions

View File

@ -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

View File

@ -163,20 +163,6 @@ lint: ${SRCS:M*.c}
.endif
.endif
.if defined(NOTAGS)
tags:
.endif
.if !target(tags)
tags: ${SRCS}
.if defined(PROG)
@cd ${.CURDIR} && gtags ${GTAGSFLAGS} ${.OBJDIR}
.if defined(HTML)
@cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR}
.endif
.endif
.endif
.if !defined(NOMAN)
.include <bsd.man.mk>
.endif

View File

@ -108,10 +108,6 @@ YFLAGS ?= -d
# as an i386 architecture.
MACHINE_ARCH ?= i386
# For tags rule.
GTAGSFLAGS= -o
HTAGSFLAGS=
.if defined(%POSIX)
# Posix 1003.2 mandated rules
#