Home | History | Annotate | Line # | Download | only in mk
bsd.dep.mk revision 1.74
      1 #	$NetBSD: bsd.dep.mk,v 1.74 2012/02/19 23:19:37 matt Exp $
      2 
      3 ##### Basic targets
      4 realdepend:	beforedepend .depend afterdepend
      5 .ORDER:		beforedepend .depend afterdepend
      6 
      7 beforedepend .depend afterdepend: # ensure existence
      8 
      9 ##### Default values
     10 MKDEP?=			mkdep
     11 MKDEP_SUFFIXES?=	.o
     12 
     13 ##### Build rules
     14 # some of the rules involve .h sources, so remove them from mkdep line
     15 
     16 .if defined(SRCS)							# {
     17 __acpp_flags=	${_ASM_TRADITIONAL_CPP}
     18 
     19 .if defined(NODPSRCS)
     20 .for f in ${SRCS} ${DPSRCS}
     21 .if "${NODPSRCS:M${f}}" == ""
     22 __DPSRCS.all+=	${f:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/}
     23 .endif
     24 .endfor
     25 beforedepend: ${DPSRCS}
     26 .else
     27 __DPSRCS.all+=	${SRCS:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/} \
     28 		${DPSRCS:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/}
     29 .endif
     30 __DPSRCS.d=	${__DPSRCS.all:O:u:M*.d}
     31 __DPSRCS.notd=	${__DPSRCS.all:O:u:N*.d}
     32 
     33 .NOPATH: .depend ${__DPSRCS.d}
     34 
     35 .if !empty(__DPSRCS.d)							# {
     36 ${__DPSRCS.d}: ${__DPSRCS.notd} ${DPSRCS}
     37 .endif									# }
     38 
     39 .depend: ${__DPSRCS.d}
     40 	${_MKTARGET_CREATE}
     41 	rm -f .depend
     42 	${MKDEP} -d -f ${.TARGET} -s ${MKDEP_SUFFIXES:Q} ${__DPSRCS.d}
     43 
     44 .SUFFIXES: .d .s .S .c .C .cc .cpp .cxx .m
     45 
     46 .c.d:
     47 	${_MKTARGET_CREATE}
     48 	${MKDEP} -f ${.TARGET} -- ${MKDEPFLAGS} \
     49 	    ${CFLAGS:C/-([IDU])[  ]*/-\1/Wg:M-[IDU]*} \
     50 	    ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
     51 
     52 .m.d:
     53 	${_MKTARGET_CREATE}
     54 	${MKDEP} -f ${.TARGET} -- ${MKDEPFLAGS} \
     55 	    ${OBJCFLAGS:C/-([IDU])[  ]*/-\1/Wg:M-[IDU]*} \
     56 	    ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
     57 
     58 .s.d .S.d:
     59 	${_MKTARGET_CREATE}
     60 	${MKDEP} -f ${.TARGET} -- ${MKDEPFLAGS} \
     61 	    ${AFLAGS:C/-([IDU])[  ]*/-\1/Wg:M-[IDU]*} \
     62 	    ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${__acpp_flags} ${.IMPSRC}
     63 
     64 .C.d .cc.d .cpp.d .cxx.d:
     65 	${_MKTARGET_CREATE}
     66 	${MKDEP} -f ${.TARGET} -- ${MKDEPFLAGS} \
     67 	    ${CXXFLAGS:C/-([IDU])[  ]*/-\1/Wg:M-[IDU]*} \
     68 	    ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
     69 
     70 .endif # defined(SRCS)							# }
     71 
     72 ##### Clean rules
     73 .if defined(SRCS)
     74 CLEANDIRFILES+= .depend ${__DPSRCS.d} ${.CURDIR}/tags ${CLEANDEPEND}
     75 .endif
     76 
     77 ##### Custom rules
     78 .if !target(tags)
     79 tags: ${SRCS}
     80 .if defined(SRCS)
     81 	-cd "${.CURDIR}"; ctags -f /dev/stdout ${.ALLSRC:N*.h} | \
     82 	    ${TOOL_SED} "s;\${.CURDIR}/;;" > tags
     83 .endif
     84 .endif
     85 
     86 ##### Pull in related .mk logic
     87 .include <bsd.clean.mk>
     88