1 # $Id: dep.mk,v 1.16 2012/11/11 22:37:02 sjg Exp $
3 .if !target(__${.PARSEFILE}__)
6 # handle Proc*C as well...
12 # it would be nice to be able to query .SUFFIXES
13 OBJ_EXTENSIONS+= .o .po .lo .So
15 # explicit dependencies help short-circuit .SUFFIX searches
16 SRCS_DEP_FILTER+= N*.[hly]
17 .for s in ${SRCS:${SRCS_DEP_FILTER:O:u:ts:}}
18 .for e in ${OBJ_EXTENSIONS:O:u}
19 .if !target(${s:T:R}$e)
26 .if exists(/usr/bin/mkdep)
28 .elif exists(/usr/local/share/bin/mkdeps.sh)
29 MKDEP_CMD?= /usr/local/share/bin/mkdeps.sh -N
37 .if ${MKDEP} == "auto.dep" && make(depend)
38 # auto.dep.mk does not "do" depend
42 .if ${MK_AUTODEP} == yes
43 .if ${MKDEP:T:S,auto,,} != ${MKDEP:T}
44 .include <${MKDEP}.mk>
49 .if ${MKDEP:T:S,auto,,} != ${MKDEP:T}
52 MKDEP_ENV_VARS += CC CXX
53 .for v in ${MKDEP_ENV_VARS:O:u}
55 MKDEP_ENV += $v='${$v}'
59 _MKDEP = ${MKDEP_ENV} ${MKDEP}
61 # some of the rules involve .h sources, so remove them from mkdep line
63 depend: beforedepend .depend _SUBDIRUSE afterdepend
66 # libs can have too many SRCS for a single command line
67 # so do them one at a time.
68 .depend: ${SRCS} ${.PARSEDIR}/${.PASEFILE}
71 @files="${.ALLSRC:M*.[sS]}"; \
72 set -x; for f in $$files; do ${_MKDEP} -a ${MKDEPFLAGS} \
73 ${CFLAGS:M-[ID]*} ${CPPFLAGS} ${AINC} $$f; done
74 @files="${.ALLSRC:M*.c} ${.ALLSRC:M*.pc:T:.pc=.c}"; \
75 set -x; for f in $$files; do ${_MKDEP} -a ${MKDEPFLAGS} \
76 ${CFLAGS:M-[ID]*} ${CPPFLAGS} $$f; done
77 @files="${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cxx}"; \
78 set -x; for f in $$files; do ${_MKDEP} -a ${MKDEPFLAGS} \
79 ${CXXFLAGS:M-[ID]*} ${CPPFLAGS} $$f; done
81 @files="${.ALLSRC:M*.[Ss]}"; \
82 case "$$files" in *.[Ss]*) \
83 echo ${_MKDEP} -a ${MKDEPFLAGS} \
84 ${CFLAGS:M-[ID]*} ${CPPFLAGS} ${AINC} $$files; \
85 ${_MKDEP} -a ${MKDEPFLAGS} \
86 ${CFLAGS:M-[ID]*} ${CPPFLAGS} ${AINC} $$files;; \
88 @files="${.ALLSRC:M*.c} ${.ALLSRC:M*.pc:T:.pc=.c}"; \
89 case "$$files" in *.c*) \
90 echo ${_MKDEP} -a ${MKDEPFLAGS} \
91 ${CFLAGS:M-[ID]*} ${CPPFLAGS} $$files; \
92 ${_MKDEP} -a ${MKDEPFLAGS} \
93 ${CFLAGS:M-[ID]*} ${CPPFLAGS} $$files;; \
95 @files="${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cxx}"; \
96 case "$$files" in *.[Cc]*) \
97 echo ${_MKDEP} -a ${MKDEPFLAGS} \
98 ${CXXFLAGS:M-[ID]*} ${CPPFLAGS} $$files; \
99 ${_MKDEP} -a ${MKDEPFLAGS} \
100 ${CXXFLAGS:M-[ID]*} ${CPPFLAGS} $$files;; \
106 .if !target(beforedepend)
109 .if !target(afterdepend)
117 tags: ${SRCS} _SUBDIRUSE
118 -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:N*.h} | \
119 sed "s;\${.CURDIR}/;;" > tags
126 cleandir: cleandepend
127 .if !target(cleandepend)
129 rm -f .depend ${.CURDIR}/tags