Home | History | Annotate | Line # | Download | only in mk
bsd.dep.mk revision 1.65
      1 #	$NetBSD: bsd.dep.mk,v 1.65 2004/01/27 03:31:48 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 MKDEP_SUFFIXES?=	.o
     14 
     15 ##### Build rules
     16 # some of the rules involve .h sources, so remove them from mkdep line
     17 
     18 .if defined(SRCS)							# {
     19 _TRADITIONAL_CPP?=-traditional-cpp
     20 __acpp_flags=	${_TRADITIONAL_CPP}
     21 
     22 __DPSRCS.all=	${SRCS:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/} \
     23 		${DPSRCS:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/}
     24 __DPSRCS.d=	${__DPSRCS.all:O:u:M*.d}
     25 __DPSRCS.notd=	${__DPSRCS.all:O:u:N*.d}
     26 
     27 .NOPATH: .depend ${__DPSRCS.d}
     28 
     29 .if !empty(__DPSRCS.d)							# {
     30 ${__DPSRCS.d}: ${__DPSRCS.notd} ${DPSRCS}
     31 .endif									# }
     32 
     33 .depend: ${__DPSRCS.d}
     34 	${_MKTARGET_CREATE}
     35 	rm -f .depend
     36 	${MKDEP} -d -f ${.TARGET} -s ${MKDEP_SUFFIXES:Q} ${__DPSRCS.d}
     37 
     38 .SUFFIXES: .d .s .S .c .C .cc .cpp .cxx .m
     39 
     40 .c.d:
     41 	${_MKTARGET_CREATE}
     42 	${MKDEP} -f ${.TARGET} -- ${MKDEPFLAGS} \
     43 	    ${CFLAGS:C/-([IDU])[  ]*/-\1/Wg:M-[IDU]*} \
     44 	    ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
     45 
     46 .m.d:
     47 	${_MKTARGET_CREATE}
     48 	${MKDEP} -f ${.TARGET} -- ${MKDEPFLAGS} \
     49 	    ${OBJCFLAGS:C/-([IDU])[  ]*/-\1/Wg:M-[IDU]*} \
     50 	    ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
     51 
     52 .s.d .S.d:
     53 	${_MKTARGET_CREATE}
     54 	${MKDEP} -f ${.TARGET} -- ${MKDEPFLAGS} \
     55 	    ${AFLAGS:C/-([IDU])[  ]*/-\1/Wg:M-[IDU]*} \
     56 	    ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${__acpp_flags} ${AINC} \
     57 	    ${.IMPSRC}
     58 
     59 .C.d .cc.d .cpp.d .cxx.d:
     60 	${_MKTARGET_CREATE}
     61 	${MKDEP} -f ${.TARGET} -- ${MKDEPFLAGS} \
     62 	    ${CXXFLAGS:C/-([IDU])[  ]*/-\1/Wg:M-[IDU]*} \
     63 	    ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEMXX} \
     64 			${DESTDIR}/usr/include/g++} \
     65 	    ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
     66 
     67 .endif # defined(SRCS)							# }
     68 
     69 ##### Clean rules
     70 cleandepend:
     71 .if defined(SRCS)
     72 	rm -f .depend ${__DPSRCS.d} ${.CURDIR}/tags ${CLEANDEPEND}
     73 .endif
     74 
     75 ##### Custom rules
     76 .if !target(tags)
     77 tags: ${SRCS}
     78 .if defined(SRCS)
     79 	-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:N*.h} | \
     80 	    sed "s;\${.CURDIR}/;;" > tags
     81 .endif
     82 .endif
     83