Home | History | Annotate | Line # | Download | only in mk
bsd.dep.mk revision 1.55
      1 #	$NetBSD: bsd.dep.mk,v 1.55 2003/08/01 17:04:01 lukem Exp $
      2 
      3 ##### Basic targets
      4 .PHONY:		cleandepend
      5 cleandir:	cleandepend
      6 realdepend:	beforedepend .depend afterdepend
      7 .ORDER:		beforedepend .depend afterdepend
      8 
      9 beforedepend .depend afterdepend: # ensure existence
     10 
     11 ##### Default values
     12 MKDEP?=		mkdep
     13 
     14 ##### Build rules
     15 # some of the rules involve .h sources, so remove them from mkdep line
     16 
     17 .if defined(SRCS)							# {
     18 __acpp_flags=	-traditional-cpp
     19 
     20 __DPSRCS.all=	${SRCS:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/} \
     21 		${DPSRCS:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/}
     22 __DPSRCS.d=	${__DPSRCS.all:O:u:M*.d}
     23 __DPSRCS.notd=	${__DPSRCS.all:O:u:N*.d}
     24 
     25 .NOPATH: .depend ${__DPSRCS.d}
     26 
     27 ${__DPSRCS.d}: ${__DPSRCS.notd} ${DPSRCS}
     28 
     29 .depend: ${__DPSRCS.d}
     30 	@rm -f .depend
     31 	cat ${__DPSRCS.d} > .depend
     32 
     33 .SUFFIXES: .d .c .m .s .S .C .cc .cpp .cxx
     34 
     35 .c.d:
     36 	${MKDEP} -f ${.TARGET} ${MKDEPFLAGS} ${CFLAGS:M-[ID]*} ${CPPFLAGS} \
     37 	    ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
     38 
     39 .m.d:
     40 	${MKDEP} -f ${.TARGET} ${MKDEPFLAGS} ${OBJCFLAGS:M-[ID]*} \
     41 	    ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
     42 
     43 .s.d .S.d:
     44 	${MKDEP} -f ${.TARGET} ${MKDEPFLAGS} ${AFLAGS:M-[ID]*} ${CPPFLAGS} \
     45 	    ${CPPFLAGS.${.IMPSRC:T}} ${__acpp_flags} ${AINC} ${.IMPSRC}
     46 
     47 .C.d .cc.d .cpp.d .cxx.d:
     48 	${MKDEP} -f ${.TARGET} ${MKDEPFLAGS} ${CXXFLAGS:M-[ID]*} \
     49 	    ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEMXX} \
     50 	    ${DESTDIR}/usr/include/g++} \
     51 	    ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
     52 
     53 .endif # defined(SRCS)							# }
     54 
     55 ##### Clean rules
     56 cleandepend:
     57 .if defined(SRCS)
     58 	rm -f .depend ${__DPSRCS.d} ${.CURDIR}/tags ${CLEANDEPEND}
     59 .endif
     60 
     61 ##### Custom rules
     62 .if !target(tags)
     63 tags: ${SRCS}
     64 .if defined(SRCS)
     65 	-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:N*.h} | \
     66 	    sed "s;\${.CURDIR}/;;" > tags
     67 .endif
     68 .endif
     69