3 # The include file <bsd.dep.mk> handles Makefile dependencies.
8 # DEPENDFILE dependencies file [.depend]
10 # MKDEP Options for ${MKDEPCMD} [not set]
12 # MKDEPCMD Makefile dependency list program [mkdep]
14 # SRCS List of source files (c, c++, assembler)
20 # Remove depend and tags file
23 # Make the dependencies for the source files, and store
24 # them in the file ${DEPENDFILE}.
27 # Create a (GLOBAL) gtags file for the source files.
28 # If HTML is defined, htags is also run after gtags.
30 .if !target(__<bsd.init.mk>__)
31 .error bsd.dep.mk cannot be included directly.
35 MKDEPCMD?= CC='${CC}' mkdep
44 .for _LSRC in ${SRCS:M*.l:N*/*}
45 .for _LC in ${_LSRC:S/.l/.c/}
47 ${LEX} -t ${LFLAGS} ${.ALLSRC} > ${.TARGET}
48 SRCS:= ${SRCS:S/${_LSRC}/${_LC}/}
49 CLEANFILES:= ${CLEANFILES} ${_LC}
53 .for _YSRC in ${SRCS:M*.y:N*/*}
54 .for _YC in ${_YSRC:S/.y/.c/}
55 SRCS:= ${SRCS:S/${_YSRC}/${_YC}/}
56 CLEANFILES:= ${CLEANFILES} ${_YC}
57 .if ${YFLAGS:M-d} != "" && ${SRCS:My.tab.h}
58 .ORDER: ${_YC} y.tab.h
59 ${_YC} y.tab.h: ${_YSRC}
60 ${YACC} ${YFLAGS} ${.ALLSRC}
62 SRCS:= ${SRCS} y.tab.h
63 CLEANFILES:= ${CLEANFILES} y.tab.c y.tab.h
64 .elif ${YFLAGS:M-d} != ""
65 .for _YH in ${_YC:S/.c/.h/}
67 ${_YC} ${_YH}: ${_YSRC}
68 ${YACC} ${YFLAGS} -o ${_YC} ${.ALLSRC}
70 CLEANFILES:= ${CLEANFILES} ${_YH}
74 ${YACC} ${YFLAGS} -o ${_YC} ${.ALLSRC}
82 depend: beforedepend ${DEPENDFILE} afterdepend
84 # Different types of sources are compiled with slightly different flags.
85 # Split up the sources, and filter out headers and non-applicable flags.
86 ${DEPENDFILE}: ${SRCS}
88 .if ${SRCS:M*.[sS]} != ""
89 ${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \
90 ${CFLAGS:M-nostdinc*} ${CFLAGS:M-[BID]*} \
94 .if ${SRCS:M*.c} != ""
95 ${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \
96 ${CFLAGS:M-nostdinc*} ${CFLAGS:M-[BID]*} \
99 .if ${SRCS:M*.cc} != "" || ${SRCS:M*.C} != "" || ${SRCS:M*.cpp} != "" || \
101 ${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \
102 ${CXXFLAGS:M-nostdinc*} ${CXXFLAGS:M-[BID]*} \
103 ${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cpp} ${.ALLSRC:M*.cxx}
105 .if ${SRCS:M*.m} != ""
106 ${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \
107 ${OBJCFLAGS:M-nostdinc*} ${OBJCFLAGS:M-[BID]*} \
108 ${OBJCFLAGS:M-Wno-import*} \
111 .if target(_EXTRADEPEND)
113 ${DEPENDFILE}: _EXTRADEPEND
116 .ORDER: ${DEPENDFILE} afterdepend
118 depend: beforedepend afterdepend
120 .if !target(beforedepend)
123 .ORDER: beforedepend ${DEPENDFILE}
124 .ORDER: beforedepend afterdepend
126 .if !target(afterdepend)
137 @cd ${.CURDIR} && gtags ${GTAGSFLAGS} ${.OBJDIR}
139 @cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR}
143 .if !target(cleandepend)
146 rm -f ${DEPENDFILE} ${.OBJDIR}/GPATH ${.OBJDIR}/GRTAGS \
147 ${.OBJDIR}/GSYMS ${.OBJDIR}/GTAGS
149 rm -rf ${.OBJDIR}/HTML