Home | History | Annotate | Line # | Download | only in mk
bsd.dep.mk revision 1.57
      1 #	$NetBSD: bsd.dep.mk,v 1.57 2003/08/11 09:59:43 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 .if !empty(__DPSRCS.d)							# {
     28 ${__DPSRCS.d}: ${__DPSRCS.notd} ${DPSRCS}
     29 .endif									# }
     30 
     31 .depend: ${__DPSRCS.d}
     32 	@rm -f .depend
     33 	cat ${__DPSRCS.d} /dev/null > .depend
     34 
     35 .SUFFIXES: .d .s .S .c .C .cc .cpp .cxx .m
     36 
     37 .c.d:
     38 	${MKDEP} -f ${.TARGET} ${MKDEPFLAGS} ${CFLAGS:M-[ID]*} ${CPPFLAGS} \
     39 	    ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
     40 
     41 .m.d:
     42 	${MKDEP} -f ${.TARGET} ${MKDEPFLAGS} ${OBJCFLAGS:M-[ID]*} \
     43 	    ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
     44 
     45 .s.d .S.d:
     46 	${MKDEP} -f ${.TARGET} ${MKDEPFLAGS} ${AFLAGS:M-[ID]*} ${CPPFLAGS} \
     47 	    ${CPPFLAGS.${.IMPSRC:T}} ${__acpp_flags} ${AINC} ${.IMPSRC}
     48 
     49 .C.d .cc.d .cpp.d .cxx.d:
     50 	${MKDEP} -f ${.TARGET} ${MKDEPFLAGS} ${CXXFLAGS:M-[ID]*} \
     51 	    ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEMXX} \
     52 	    ${DESTDIR}/usr/include/g++} \
     53 	    ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
     54 
     55 .endif # defined(SRCS)							# }
     56 
     57 ##### Clean rules
     58 cleandepend:
     59 .if defined(SRCS)
     60 	rm -f .depend ${__DPSRCS.d} ${.CURDIR}/tags ${CLEANDEPEND}
     61 .endif
     62 
     63 ##### Custom rules
     64 .if !target(tags)
     65 tags: ${SRCS}
     66 .if defined(SRCS)
     67 	-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:N*.h} | \
     68 	    sed "s;\${.CURDIR}/;;" > tags
     69 .endif
     70 .endif
     71