Home | History | Annotate | Line # | Download | only in mk
bsd.dep.mk revision 1.51
      1 #	$NetBSD: bsd.dep.mk,v 1.51 2003/07/28 23:57:24 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 .NOPATH:	.depend
     20 
     21 DEPENDSRCS.src=	${SRCS:M*.c}	${DPSRCS:M*.c}		\
     22 		${SRCS:M*.m}	${DPSRCS:M*.m}		\
     23 		${SRCS:M*.[sS]}	${DPSRCS:M*.[sS]}	\
     24 		${SRCS:M*.C}	${DPSRCS:M*.C}		\
     25 		${SRCS:M*.cc}	${DPSRCS:M*.cc}		\
     26 		${SRCS:M*.cpp}	${DPSRCS:M*.cpp}	\
     27 		${SRCS:M*.cxx}	${DPSRCS:M*.cxx}
     28 DEPENDSRCS.dep=	${DEPENDSRCS.src:R:S/$/.d/g}
     29 DEPENDSRCS=	.depend ${DEPENDSRCS.dep}
     30 
     31 .depend: ${SRCS} ${DPSRCS} ${DEPENDSRCS.dep}
     32 	@rm -f .depend
     33 	cat ${DEPENDSRCS.dep} > .depend
     34 
     35 .SUFFIXES: .d .c .m .s .S .C .cc .cpp .cxx
     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 ${DEPENDSRCS} ${.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