1 # $Id: dep.mk,v 1.17 2014/08/04 05:12:27 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_MK:Uno} == "auto.dep.mk" && make(depend)
38 # auto.dep.mk does not "do" depend
42 .if ${MK_AUTODEP} == yes
43 MKDEP_MK ?= autodep.mk
44 .include <${MKDEP_MK}>
46 MKDEP_ENV_VARS += CC CXX
47 .for v in ${MKDEP_ENV_VARS:O:u}
49 MKDEP_ENV += $v='${$v}'
53 _MKDEP = ${MKDEP_ENV} ${MKDEP}
55 # some of the rules involve .h sources, so remove them from mkdep line
57 depend: beforedepend .depend _SUBDIRUSE afterdepend
60 # libs can have too many SRCS for a single command line
61 # so do them one at a time.
62 .depend: ${SRCS} ${.PARSEDIR}/${.PASEFILE}
65 @files="${.ALLSRC:M*.[sS]}"; \
66 set -x; for f in $$files; do ${_MKDEP} -a ${MKDEPFLAGS} \
67 ${CFLAGS:M-[ID]*} ${CPPFLAGS} ${AINC} $$f; done
68 @files="${.ALLSRC:M*.c} ${.ALLSRC:M*.pc:T:.pc=.c}"; \
69 set -x; for f in $$files; do ${_MKDEP} -a ${MKDEPFLAGS} \
70 ${CFLAGS:M-[ID]*} ${CPPFLAGS} $$f; done
71 @files="${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cxx}"; \
72 set -x; for f in $$files; do ${_MKDEP} -a ${MKDEPFLAGS} \
73 ${CXXFLAGS:M-[ID]*} ${CPPFLAGS} $$f; done
75 @files="${.ALLSRC:M*.[Ss]}"; \
76 case "$$files" in *.[Ss]*) \
77 echo ${_MKDEP} -a ${MKDEPFLAGS} \
78 ${CFLAGS:M-[ID]*} ${CPPFLAGS} ${AINC} $$files; \
79 ${_MKDEP} -a ${MKDEPFLAGS} \
80 ${CFLAGS:M-[ID]*} ${CPPFLAGS} ${AINC} $$files;; \
82 @files="${.ALLSRC:M*.c} ${.ALLSRC:M*.pc:T:.pc=.c}"; \
83 case "$$files" in *.c*) \
84 echo ${_MKDEP} -a ${MKDEPFLAGS} \
85 ${CFLAGS:M-[ID]*} ${CPPFLAGS} $$files; \
86 ${_MKDEP} -a ${MKDEPFLAGS} \
87 ${CFLAGS:M-[ID]*} ${CPPFLAGS} $$files;; \
89 @files="${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cxx}"; \
90 case "$$files" in *.[Cc]*) \
91 echo ${_MKDEP} -a ${MKDEPFLAGS} \
92 ${CXXFLAGS:M-[ID]*} ${CPPFLAGS} $$files; \
93 ${_MKDEP} -a ${MKDEPFLAGS} \
94 ${CXXFLAGS:M-[ID]*} ${CPPFLAGS} $$files;; \
100 .if !target(beforedepend)
103 .if !target(afterdepend)
111 tags: ${SRCS} _SUBDIRUSE
112 -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:N*.h} | \
113 sed "s;\${.CURDIR}/;;" > tags
120 cleandir: cleandepend
121 .if !target(cleandepend)
123 rm -f .depend ${.CURDIR}/tags