1999-08-28 00:22:10 +00:00
|
|
|
# $FreeBSD$
|
1996-05-25 23:09:49 +00:00
|
|
|
#
|
|
|
|
# The include file <bsd.dep.mk> handles Makefile dependencies.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# +++ variables +++
|
|
|
|
#
|
2002-10-17 13:48:13 +00:00
|
|
|
# CTAGS A tags file generation program [gtags]
|
|
|
|
#
|
|
|
|
# CTAGSFLAGS Options for ctags(1) [not set]
|
|
|
|
#
|
1996-05-25 23:09:49 +00:00
|
|
|
# DEPENDFILE dependencies file [.depend]
|
|
|
|
#
|
2002-10-17 13:48:13 +00:00
|
|
|
# GTAGSFLAGS Options for gtags(1) [-o]
|
|
|
|
#
|
|
|
|
# HTAGSFLAGS Options for htags(1) [not set]
|
|
|
|
#
|
1996-05-25 23:09:49 +00:00
|
|
|
# MKDEP Options for ${MKDEPCMD} [not set]
|
|
|
|
#
|
|
|
|
# MKDEPCMD Makefile dependency list program [mkdep]
|
|
|
|
#
|
|
|
|
# SRCS List of source files (c, c++, assembler)
|
|
|
|
#
|
2004-01-13 17:37:45 +00:00
|
|
|
# DPSRCS List of source files which are needed for generating
|
|
|
|
# dependencies, ${SRCS} are always part of it.
|
1996-05-25 23:09:49 +00:00
|
|
|
#
|
|
|
|
# +++ targets +++
|
|
|
|
#
|
|
|
|
# cleandepend:
|
|
|
|
# Remove depend and tags file
|
|
|
|
#
|
|
|
|
# depend:
|
|
|
|
# Make the dependencies for the source files, and store
|
|
|
|
# them in the file ${DEPENDFILE}.
|
|
|
|
#
|
|
|
|
# tags:
|
2002-10-17 13:48:13 +00:00
|
|
|
# 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).
|
1996-05-25 23:09:49 +00:00
|
|
|
|
2002-04-22 10:04:41 +00:00
|
|
|
.if !target(__<bsd.init.mk>__)
|
|
|
|
.error bsd.dep.mk cannot be included directly.
|
|
|
|
.endif
|
1996-04-01 18:58:28 +00:00
|
|
|
|
2002-10-17 13:48:13 +00:00
|
|
|
CTAGS?= gtags
|
|
|
|
CTAGSFLAGS?=
|
|
|
|
GTAGSFLAGS?= -o
|
|
|
|
HTAGSFLAGS?=
|
|
|
|
|
2002-04-15 15:23:45 +00:00
|
|
|
.if ${CC} != "cc"
|
2002-05-07 00:15:53 +00:00
|
|
|
MKDEPCMD?= CC='${CC}' mkdep
|
2002-04-15 15:23:45 +00:00
|
|
|
.else
|
|
|
|
MKDEPCMD?= mkdep
|
|
|
|
.endif
|
1996-04-01 18:58:28 +00:00
|
|
|
DEPENDFILE?= .depend
|
1994-08-04 21:10:08 +00:00
|
|
|
|
2002-10-17 13:48:13 +00:00
|
|
|
# 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
|
|
|
|
|
1998-05-11 15:37:13 +00:00
|
|
|
.if defined(SRCS)
|
|
|
|
CLEANFILES?=
|
|
|
|
|
2004-01-17 18:51:55 +00:00
|
|
|
.if !exists(${.OBJDIR}/${DEPENDFILE})
|
|
|
|
.for _S in ${SRCS:N*.[hly]}
|
|
|
|
${_S:R}.o: ${_S}
|
|
|
|
.endfor
|
|
|
|
.endif
|
|
|
|
|
1998-05-11 15:37:13 +00:00
|
|
|
.for _LSRC in ${SRCS:M*.l:N*/*}
|
2004-01-12 15:29:47 +00:00
|
|
|
.for _LC in ${_LSRC:R}.c
|
1998-05-11 15:37:13 +00:00
|
|
|
${_LC}: ${_LSRC}
|
|
|
|
${LEX} -t ${LFLAGS} ${.ALLSRC} > ${.TARGET}
|
2004-01-17 18:51:55 +00:00
|
|
|
.if !exists(${.OBJDIR}/${DEPENDFILE})
|
|
|
|
${_LC:R}.o: ${_LC}
|
|
|
|
.endif
|
1998-05-11 15:37:13 +00:00
|
|
|
SRCS:= ${SRCS:S/${_LSRC}/${_LC}/}
|
2004-01-12 15:29:47 +00:00
|
|
|
CLEANFILES+= ${_LC}
|
1998-05-11 15:37:13 +00:00
|
|
|
.endfor
|
|
|
|
.endfor
|
|
|
|
|
|
|
|
.for _YSRC in ${SRCS:M*.y:N*/*}
|
2004-01-12 15:29:47 +00:00
|
|
|
.for _YC in ${_YSRC:R}.c
|
1998-05-11 15:37:13 +00:00
|
|
|
SRCS:= ${SRCS:S/${_YSRC}/${_YC}/}
|
2004-01-12 15:29:47 +00:00
|
|
|
CLEANFILES+= ${_YC}
|
1998-05-11 15:37:13 +00:00
|
|
|
.if ${YFLAGS:M-d} != "" && ${SRCS:My.tab.h}
|
|
|
|
.ORDER: ${_YC} y.tab.h
|
|
|
|
${_YC} y.tab.h: ${_YSRC}
|
|
|
|
${YACC} ${YFLAGS} ${.ALLSRC}
|
|
|
|
cp y.tab.c ${_YC}
|
2004-01-12 15:29:47 +00:00
|
|
|
CLEANFILES+= y.tab.c y.tab.h
|
1998-05-11 15:37:13 +00:00
|
|
|
.elif ${YFLAGS:M-d} != ""
|
2004-01-12 15:29:47 +00:00
|
|
|
.for _YH in ${_YC:R}.h
|
1998-05-11 15:37:13 +00:00
|
|
|
.ORDER: ${_YC} ${_YH}
|
|
|
|
${_YC} ${_YH}: ${_YSRC}
|
|
|
|
${YACC} ${YFLAGS} -o ${_YC} ${.ALLSRC}
|
2004-01-12 15:29:47 +00:00
|
|
|
SRCS+= ${_YH}
|
|
|
|
CLEANFILES+= ${_YH}
|
1998-05-11 15:37:13 +00:00
|
|
|
.endfor
|
|
|
|
.else
|
|
|
|
${_YC}: ${_YSRC}
|
|
|
|
${YACC} ${YFLAGS} -o ${_YC} ${.ALLSRC}
|
|
|
|
.endif
|
2004-01-17 18:51:55 +00:00
|
|
|
.if !exists(${.OBJDIR}/${DEPENDFILE})
|
|
|
|
${_YC:R}.o: ${_YC}
|
|
|
|
.endif
|
1998-05-11 15:37:13 +00:00
|
|
|
.endfor
|
|
|
|
.endfor
|
|
|
|
.endif
|
|
|
|
|
1994-08-04 21:10:08 +00:00
|
|
|
.if !target(depend)
|
|
|
|
.if defined(SRCS)
|
2002-04-23 09:03:56 +00:00
|
|
|
depend: beforedepend ${DEPENDFILE} afterdepend
|
1996-04-01 18:58:28 +00:00
|
|
|
|
1998-03-07 13:57:37 +00:00
|
|
|
# Different types of sources are compiled with slightly different flags.
|
|
|
|
# Split up the sources, and filter out headers and non-applicable flags.
|
2004-01-13 17:37:45 +00:00
|
|
|
DPSRCS+= ${SRCS}
|
|
|
|
${DEPENDFILE}: ${DPSRCS}
|
1996-04-01 18:58:28 +00:00
|
|
|
rm -f ${DEPENDFILE}
|
2004-01-13 17:37:45 +00:00
|
|
|
.if ${DPSRCS:M*.[cS]} != ""
|
1998-03-07 13:57:37 +00:00
|
|
|
${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \
|
|
|
|
${CFLAGS:M-nostdinc*} ${CFLAGS:M-[BID]*} \
|
2003-07-02 16:43:07 +00:00
|
|
|
${.ALLSRC:M*.[cS]}
|
1996-04-01 18:58:28 +00:00
|
|
|
.endif
|
2004-01-13 17:37:45 +00:00
|
|
|
.if ${DPSRCS:M*.cc} != "" || ${DPSRCS:M*.C} != "" || ${DPSRCS:M*.cpp} != "" || \
|
|
|
|
${DPSRCS:M*.cxx} != ""
|
1996-04-01 18:58:28 +00:00
|
|
|
${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \
|
1998-03-07 13:57:37 +00:00
|
|
|
${CXXFLAGS:M-nostdinc*} ${CXXFLAGS:M-[BID]*} \
|
1998-06-05 18:38:55 +00:00
|
|
|
${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cpp} ${.ALLSRC:M*.cxx}
|
1996-04-01 18:58:28 +00:00
|
|
|
.endif
|
2004-01-13 17:37:45 +00:00
|
|
|
.if ${DPSRCS:M*.m} != ""
|
1998-05-15 09:30:13 +00:00
|
|
|
${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \
|
|
|
|
${OBJCFLAGS:M-nostdinc*} ${OBJCFLAGS:M-[BID]*} \
|
|
|
|
${OBJCFLAGS:M-Wno-import*} \
|
|
|
|
${.ALLSRC:M*.m}
|
|
|
|
.endif
|
1997-04-09 16:10:27 +00:00
|
|
|
.if target(_EXTRADEPEND)
|
2002-04-17 05:42:18 +00:00
|
|
|
_EXTRADEPEND: .USE
|
2002-04-16 12:27:07 +00:00
|
|
|
${DEPENDFILE}: _EXTRADEPEND
|
1997-04-09 16:10:27 +00:00
|
|
|
.endif
|
1996-04-01 18:58:28 +00:00
|
|
|
|
1997-10-05 09:40:24 +00:00
|
|
|
.ORDER: ${DEPENDFILE} afterdepend
|
1994-08-04 21:10:08 +00:00
|
|
|
.else
|
2002-04-23 09:03:56 +00:00
|
|
|
depend: beforedepend afterdepend
|
1994-08-04 21:10:08 +00:00
|
|
|
.endif
|
|
|
|
.if !target(beforedepend)
|
|
|
|
beforedepend:
|
1997-10-05 09:40:24 +00:00
|
|
|
.else
|
|
|
|
.ORDER: beforedepend ${DEPENDFILE}
|
|
|
|
.ORDER: beforedepend afterdepend
|
1994-08-04 21:10:08 +00:00
|
|
|
.endif
|
|
|
|
.if !target(afterdepend)
|
|
|
|
afterdepend:
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
1996-06-24 04:26:21 +00:00
|
|
|
.if !target(cleandepend)
|
2002-04-23 09:03:56 +00:00
|
|
|
cleandepend:
|
1997-08-26 16:54:33 +00:00
|
|
|
.if defined(SRCS)
|
2002-10-17 13:48:13 +00:00
|
|
|
.if ${CTAGS:T} == "ctags"
|
|
|
|
rm -f ${DEPENDFILE} tags
|
|
|
|
.elif ${CTAGS:T} == "gtags"
|
|
|
|
rm -f ${DEPENDFILE} GPATH GRTAGS GSYMS GTAGS
|
1997-04-13 06:44:25 +00:00
|
|
|
.if defined(HTML)
|
2002-10-17 13:48:13 +00:00
|
|
|
rm -rf HTML
|
|
|
|
.endif
|
1997-04-13 06:44:25 +00:00
|
|
|
.endif
|
1996-06-24 04:26:21 +00:00
|
|
|
.endif
|
|
|
|
.endif
|
2002-07-03 12:44:06 +00:00
|
|
|
|
|
|
|
.if !target(checkdpadd) && (defined(DPADD) || defined(LDADD))
|
2003-07-03 11:43:57 +00:00
|
|
|
_LDADD_FROM_DPADD= ${DPADD:C;^/usr/lib/lib(.*)\.a$;-l\1;}
|
|
|
|
_LDADD_CANONICALIZED= ${LDADD:S/$//}
|
2002-07-03 12:44:06 +00:00
|
|
|
checkdpadd:
|
2003-07-03 11:43:57 +00:00
|
|
|
.if ${_LDADD_FROM_DPADD} != ${_LDADD_CANONICALIZED}
|
|
|
|
@echo ${.CURDIR}
|
|
|
|
@echo "DPADD -> ${_LDADD_FROM_DPADD}"
|
|
|
|
@echo "LDADD -> ${_LDADD_CANONICALIZED}"
|
|
|
|
.endif
|
2002-07-03 12:44:06 +00:00
|
|
|
.endif
|