1# $Id: dep.mk,v 1.17 2014/08/04 05:12:27 sjg Exp $ 2 3.if !target(__${.PARSEFILE}__) 4__${.PARSEFILE}__: 5 6# handle Proc*C as well... 7.if defined(SRCS) 8.if !empty(SRCS:M*.pc) 9.include <proc.mk> 10.endif 11 12# it would be nice to be able to query .SUFFIXES 13OBJ_EXTENSIONS+= .o .po .lo .So 14 15# explicit dependencies help short-circuit .SUFFIX searches 16SRCS_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) 20${s:T:R}$e: $s 21.endif 22.endfor 23.endfor 24.endif 25 26.if exists(/usr/bin/mkdep) 27MKDEP_CMD?= mkdep 28.elif exists(/usr/local/share/bin/mkdeps.sh) 29MKDEP_CMD?= /usr/local/share/bin/mkdeps.sh -N 30.endif 31MKDEP_CMD?= mkdep 32 33MKDEP ?= ${MKDEP_CMD} 34 35.NOPATH: .depend 36 37.if ${MKDEP_MK:Uno} == "auto.dep.mk" && make(depend) 38# auto.dep.mk does not "do" depend 39MK_AUTODEP= no 40.endif 41 42.if ${MK_AUTODEP} == yes 43MKDEP_MK ?= autodep.mk 44.include <${MKDEP_MK}> 45.else 46MKDEP_ENV_VARS += CC CXX 47.for v in ${MKDEP_ENV_VARS:O:u} 48.if !empty($v) 49MKDEP_ENV += $v='${$v}' 50.endif 51.endfor 52 53_MKDEP = ${MKDEP_ENV} ${MKDEP} 54 55# some of the rules involve .h sources, so remove them from mkdep line 56.if !target(depend) 57depend: beforedepend .depend _SUBDIRUSE afterdepend 58 59.if defined(SRCS) 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} 63 @rm -f .depend 64.ifdef LIB 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 74.else 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;; \ 81 esac 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;; \ 88 esac 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;; \ 95 esac 96.endif 97.else 98.depend: 99.endif 100.if !target(beforedepend) 101beforedepend: 102.endif 103.if !target(afterdepend) 104afterdepend: 105.endif 106.endif 107.endif 108 109.if !target(tags) 110.if defined(SRCS) 111tags: ${SRCS} _SUBDIRUSE 112 -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:N*.h} | \ 113 sed "s;\${.CURDIR}/;;" > tags 114.else 115tags: 116.endif 117.endif 118 119.if defined(SRCS) 120cleandir: cleandepend 121.if !target(cleandepend) 122cleandepend: 123 rm -f .depend ${.CURDIR}/tags 124.endif 125.endif 126 127.endif 128