1246149Ssjg# $Id: dep.mk,v 1.16 2012/11/11 22:37:02 sjg Exp $ 2246149Ssjg 3246149Ssjg.if !target(__${.PARSEFILE}__) 4246149Ssjg__${.PARSEFILE}__: 5246149Ssjg 6246149Ssjg# handle Proc*C as well... 7246149Ssjg.if defined(SRCS) 8246149Ssjg.if !empty(SRCS:M*.pc) 9246149Ssjg.include <proc.mk> 10246149Ssjg.endif 11246149Ssjg 12246149Ssjg# it would be nice to be able to query .SUFFIXES 13246149SsjgOBJ_EXTENSIONS+= .o .po .lo .So 14246149Ssjg 15246149Ssjg# explicit dependencies help short-circuit .SUFFIX searches 16246149SsjgSRCS_DEP_FILTER+= N*.[hly] 17246149Ssjg.for s in ${SRCS:${SRCS_DEP_FILTER:O:u:ts:}} 18246149Ssjg.for e in ${OBJ_EXTENSIONS:O:u} 19246149Ssjg.if !target(${s:T:R}$e) 20246149Ssjg${s:T:R}$e: $s 21246149Ssjg.endif 22246149Ssjg.endfor 23246149Ssjg.endfor 24246149Ssjg.endif 25246149Ssjg 26246149Ssjg.if exists(/usr/bin/mkdep) 27246149SsjgMKDEP_CMD?= mkdep 28246149Ssjg.elif exists(/usr/local/share/bin/mkdeps.sh) 29246149SsjgMKDEP_CMD?= /usr/local/share/bin/mkdeps.sh -N 30246149Ssjg.endif 31246149SsjgMKDEP_CMD?= mkdep 32246149Ssjg 33246149SsjgMKDEP ?= ${MKDEP_CMD} 34246149Ssjg 35246149Ssjg.NOPATH: .depend 36246149Ssjg 37246149Ssjg.if ${MKDEP} == "auto.dep" && make(depend) 38246149Ssjg# auto.dep.mk does not "do" depend 39246149SsjgMK_AUTODEP= no 40246149Ssjg.endif 41246149Ssjg 42246149Ssjg.if ${MK_AUTODEP} == yes 43246149Ssjg.if ${MKDEP:T:S,auto,,} != ${MKDEP:T} 44246149Ssjg.include <${MKDEP}.mk> 45246149Ssjg.else 46246149Ssjg.include <autodep.mk> 47246149Ssjg.endif 48246149Ssjg.else 49246149Ssjg.if ${MKDEP:T:S,auto,,} != ${MKDEP:T} 50246149SsjgMKDEP = ${MKDEP_CMD} 51246149Ssjg.endif 52246149SsjgMKDEP_ENV_VARS += CC CXX 53246149Ssjg.for v in ${MKDEP_ENV_VARS:O:u} 54246149Ssjg.if !empty($v) 55246149SsjgMKDEP_ENV += $v='${$v}' 56246149Ssjg.endif 57246149Ssjg.endfor 58246149Ssjg 59246149Ssjg_MKDEP = ${MKDEP_ENV} ${MKDEP} 60246149Ssjg 61246149Ssjg# some of the rules involve .h sources, so remove them from mkdep line 62246149Ssjg.if !target(depend) 63246149Ssjgdepend: beforedepend .depend _SUBDIRUSE afterdepend 64246149Ssjg 65246149Ssjg.if defined(SRCS) 66246149Ssjg# libs can have too many SRCS for a single command line 67246149Ssjg# so do them one at a time. 68246149Ssjg.depend: ${SRCS} ${.PARSEDIR}/${.PASEFILE} 69246149Ssjg @rm -f .depend 70246149Ssjg.ifdef LIB 71246149Ssjg @files="${.ALLSRC:M*.[sS]}"; \ 72246149Ssjg set -x; for f in $$files; do ${_MKDEP} -a ${MKDEPFLAGS} \ 73246149Ssjg ${CFLAGS:M-[ID]*} ${CPPFLAGS} ${AINC} $$f; done 74246149Ssjg @files="${.ALLSRC:M*.c} ${.ALLSRC:M*.pc:T:.pc=.c}"; \ 75246149Ssjg set -x; for f in $$files; do ${_MKDEP} -a ${MKDEPFLAGS} \ 76246149Ssjg ${CFLAGS:M-[ID]*} ${CPPFLAGS} $$f; done 77246149Ssjg @files="${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cxx}"; \ 78246149Ssjg set -x; for f in $$files; do ${_MKDEP} -a ${MKDEPFLAGS} \ 79246149Ssjg ${CXXFLAGS:M-[ID]*} ${CPPFLAGS} $$f; done 80246149Ssjg.else 81246149Ssjg @files="${.ALLSRC:M*.[Ss]}"; \ 82246149Ssjg case "$$files" in *.[Ss]*) \ 83246149Ssjg echo ${_MKDEP} -a ${MKDEPFLAGS} \ 84246149Ssjg ${CFLAGS:M-[ID]*} ${CPPFLAGS} ${AINC} $$files; \ 85246149Ssjg ${_MKDEP} -a ${MKDEPFLAGS} \ 86246149Ssjg ${CFLAGS:M-[ID]*} ${CPPFLAGS} ${AINC} $$files;; \ 87246149Ssjg esac 88246149Ssjg @files="${.ALLSRC:M*.c} ${.ALLSRC:M*.pc:T:.pc=.c}"; \ 89246149Ssjg case "$$files" in *.c*) \ 90246149Ssjg echo ${_MKDEP} -a ${MKDEPFLAGS} \ 91246149Ssjg ${CFLAGS:M-[ID]*} ${CPPFLAGS} $$files; \ 92246149Ssjg ${_MKDEP} -a ${MKDEPFLAGS} \ 93246149Ssjg ${CFLAGS:M-[ID]*} ${CPPFLAGS} $$files;; \ 94246149Ssjg esac 95246149Ssjg @files="${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cxx}"; \ 96246149Ssjg case "$$files" in *.[Cc]*) \ 97246149Ssjg echo ${_MKDEP} -a ${MKDEPFLAGS} \ 98246149Ssjg ${CXXFLAGS:M-[ID]*} ${CPPFLAGS} $$files; \ 99246149Ssjg ${_MKDEP} -a ${MKDEPFLAGS} \ 100246149Ssjg ${CXXFLAGS:M-[ID]*} ${CPPFLAGS} $$files;; \ 101246149Ssjg esac 102246149Ssjg.endif 103246149Ssjg.else 104246149Ssjg.depend: 105246149Ssjg.endif 106246149Ssjg.if !target(beforedepend) 107246149Ssjgbeforedepend: 108246149Ssjg.endif 109246149Ssjg.if !target(afterdepend) 110246149Ssjgafterdepend: 111246149Ssjg.endif 112246149Ssjg.endif 113246149Ssjg.endif 114246149Ssjg 115246149Ssjg.if !target(tags) 116246149Ssjg.if defined(SRCS) 117246149Ssjgtags: ${SRCS} _SUBDIRUSE 118246149Ssjg -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:N*.h} | \ 119246149Ssjg sed "s;\${.CURDIR}/;;" > tags 120246149Ssjg.else 121246149Ssjgtags: 122246149Ssjg.endif 123246149Ssjg.endif 124246149Ssjg 125246149Ssjg.if defined(SRCS) 126246149Ssjgcleandir: cleandepend 127246149Ssjg.if !target(cleandepend) 128246149Ssjgcleandepend: 129246149Ssjg rm -f .depend ${.CURDIR}/tags 130246149Ssjg.endif 131246149Ssjg.endif 132246149Ssjg 133246149Ssjg.endif 134