1 # $FreeBSD: src/share/mk/bsd.dep.mk,v 1.27.2.3 2002/12/23 16:33:37 ru Exp $
3 # The include file <bsd.dep.mk> handles Makefile dependencies.
8 # CTAGS A tags file generation program [gtags]
10 # CTAGSFLAGS Options for ctags(1) [not set]
12 # DEPENDFILE dependencies file [.depend]
14 # GTAGSFLAGS Options for gtags(1) [-o]
16 # HTAGSFLAGS Options for htags(1) [not set]
18 # MKDEP Options for ${MKDEPCMD} [not set]
20 # MKDEPCMD Makefile dependency list program [mkdep]
22 # SRCS List of source files (c, c++, assembler)
28 # Remove depend and tags file
31 # Make the dependencies for the source files, and store
32 # them in the file ${DEPENDFILE}.
35 # In "ctags" mode, create a tags file for the source files.
36 # In "gtags" mode, create a (GLOBAL) gtags file for the
37 # source files. If HTML is defined, htags(1) is also run
40 .if !target(__<bsd.init.mk>__)
41 .error bsd.dep.mk cannot be included directly.
52 # Keep `tags' here, before SRCS are mangled below for `depend'.
53 .if !target(tags) && defined(SRCS) && !defined(NOTAGS)
55 .if ${CTAGS:T} == "ctags"
56 @${CTAGS} ${CTAGSFLAGS} -f /dev/stdout \
57 ${.ALLSRC:N*.h} | sed "s;${.CURDIR}/;;" > ${.TARGET}
58 .elif ${CTAGS:T} == "gtags"
59 @cd ${.CURDIR} && ${CTAGS} ${GTAGSFLAGS} ${.OBJDIR}
61 @cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR}
69 .for _LSRC in ${SRCS:M*.l:N*/*}
70 .for _LC in ${_LSRC:S/.l/.c/}
72 ${LEX} -t ${LFLAGS} ${.ALLSRC} > ${.TARGET}
73 SRCS:= ${SRCS:S/${_LSRC}/${_LC}/}
74 CLEANFILES:= ${CLEANFILES} ${_LC}
78 .for _YSRC in ${SRCS:M*.y:N*/*}
79 .for _YC in ${_YSRC:S/.y/.c/}
80 SRCS:= ${SRCS:S/${_YSRC}/${_YC}/}
81 CLEANFILES:= ${CLEANFILES} ${_YC}
82 .if ${YFLAGS:M-d} != "" && ${SRCS:My.tab.h}
83 .ORDER: ${_YC} y.tab.h
84 ${_YC} y.tab.h: ${_YSRC}
85 ${YACC} ${YFLAGS} ${.ALLSRC}
87 SRCS:= ${SRCS} y.tab.h
88 CLEANFILES:= ${CLEANFILES} y.tab.c y.tab.h
89 .elif ${YFLAGS:M-d} != ""
90 .for _YH in ${_YC:S/.c/.h/}
92 ${_YC} ${_YH}: ${_YSRC}
93 ${YACC} ${YFLAGS} -o ${_YC} ${.ALLSRC}
95 CLEANFILES:= ${CLEANFILES} ${_YH}
99 ${YACC} ${YFLAGS} -o ${_YC} ${.ALLSRC}
107 depend: beforedepend ${DEPENDFILE} afterdepend
109 # Different types of sources are compiled with slightly different flags.
110 # Split up the sources, and filter out headers and non-applicable flags.
111 ${DEPENDFILE}: ${SRCS}
113 .if ${SRCS:M*.[sS]} != ""
114 ${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \
115 ${CFLAGS:M-nostdinc*} ${CFLAGS:M-[BID]*} \
119 .if ${SRCS:M*.c} != ""
120 ${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \
121 ${CFLAGS:M-nostdinc*} ${CFLAGS:M-[BID]*} \
124 .if ${SRCS:M*.cc} != "" || ${SRCS:M*.C} != "" || ${SRCS:M*.cpp} != "" || \
126 ${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \
127 ${CXXFLAGS:M-nostdinc*} ${CXXFLAGS:M-[BID]*} \
128 ${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cpp} ${.ALLSRC:M*.cxx}
130 .if ${SRCS:M*.m} != ""
131 ${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \
132 ${OBJCFLAGS:M-nostdinc*} ${OBJCFLAGS:M-[BID]*} \
133 ${OBJCFLAGS:M-Wno-import*} \
136 .if target(_EXTRADEPEND)
138 ${DEPENDFILE}: _EXTRADEPEND
141 .ORDER: ${DEPENDFILE} afterdepend
143 depend: beforedepend afterdepend
145 .if !target(beforedepend)
148 .ORDER: beforedepend ${DEPENDFILE}
149 .ORDER: beforedepend afterdepend
151 .if !target(afterdepend)
156 .if !target(cleandepend)
159 .if ${CTAGS:T} == "ctags"
160 rm -f ${DEPENDFILE} tags
161 .elif ${CTAGS:T} == "gtags"
162 rm -f ${DEPENDFILE} GPATH GRTAGS GSYMS GTAGS
170 .if !target(checkdpadd) && (defined(DPADD) || defined(LDADD))
172 .if ${OBJFORMAT} != aout
173 @ldadd=`echo \`for lib in ${DPADD} ; do \
174 echo $$lib | sed 's;^/usr/lib/lib\(.*\)\.a;-l\1;' ; \
176 ldadd1=`echo ${LDADD}` ; \
177 if [ "$$ldadd" != "$$ldadd1" ] ; then \
179 echo "DPADD -> $$ldadd" ; \
180 echo "LDADD -> $$ldadd1" ; \
183 @dpadd=`echo \`ld -Bstatic -f ${LDADD}\`` ; \
184 if [ "$$dpadd" != "${DPADD}" ] ; then \
186 echo "LDADD -> $$dpadd" ; \
187 echo "DPADD = ${DPADD}" ; \