bsd.dep.mk revision 1.48
1# $NetBSD: bsd.dep.mk,v 1.48 2003/07/28 08:59:52 lukem Exp $ 2 3##### Basic targets 4.PHONY: cleandepend 5cleandir: cleandepend 6realdepend: beforedepend .depend afterdepend 7.ORDER: beforedepend .depend afterdepend 8 9beforedepend .depend afterdepend: # ensure existence 10 11##### Default values 12MKDEP?= 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 20SRCS_C= ${SRCS:M*.c} ${DPSRCS:M*.c} 21DEPS_C= ${SRCS_C:C/(.*)/\1.dep/g:S/^.dep$//} 22SRCS_M= ${SRCS:M*.m} ${DPSRCS:M*.m} 23DEPS_M= ${SRCS_M:C/(.*)/\1.dep/g:S/^.dep$//} 24SRCS_S= ${SRCS:M*.[sS]} ${DPSRCS:M*.[sS]} 25DEPS_S= ${SRCS_S:C/(.*)/\1.dep/g:S/^.dep$//} 26SRCS_X= ${SRCS:M*.C} ${DPSRCS:M*.C} \ 27 ${SRCS:M*.cc} ${DPSRCS:M*.cc} \ 28 ${SRCS:M*.cpp} ${DPSRCS:M*.cpp} \ 29 ${SRCS:M*.cxx} ${DPSRCS:M*.cxx} 30DEPS_X= ${SRCS_X:C/(.*)/\1.dep/g:S/^.dep$//} 31 32CLEANDEPEND+=${DEPS_C} ${DEPS_M} ${DEPS_S} ${DEPS_X} 33 34.depend: ${SRCS} ${DPSRCS} ${DEPS_C} ${DEPS_M} ${DEPS_S} ${DEPS_X} 35 @rm -f .depend 36 cat ${.ALLSRC:M*.dep} > .depend 37 38.for F in ${DEPS_C:O:u} 39.NOPATH: ${F} 40${F}: ${F:R} 41 ${MKDEP} -a -f ${.TARGET} ${MKDEPFLAGS} ${CFLAGS:M-[ID]*} ${CPPFLAGS} \ 42 ${CPPFLAGS.${.ALLSRC:T}} ${.ALLSRC} 43.endfor 44 45.for F in ${DEPS_M:O:u} 46.NOPATH: ${F} 47${F}: ${F:R} 48 ${MKDEP} -a -f ${.TARGET} ${MKDEPFLAGS} ${OBJCFLAGS:M-[ID]*} \ 49 ${CPPFLAGS} ${CPPFLAGS.${.ALLSRC:T}} ${.ALLSRC} 50.endfor 51 52.for F in ${DEPS_S:O:u} 53.NOPATH: ${F} 54${F}: ${F:R} 55 ${MKDEP} -a -f ${.TARGET} ${MKDEPFLAGS} ${AFLAGS:M-[ID]*} ${CPPFLAGS} \ 56 ${CPPFLAGS.${.ALLSRC:T}} ${__acpp_flags} ${AINC} ${.ALLSRC} 57.endfor 58 59.for F in ${DEPS_X:O:u} 60.NOPATH: ${F} 61${F}: ${F:R} 62 ${MKDEP} -a -f ${.TARGET} ${MKDEPFLAGS} ${CXXFLAGS:M-[ID]*} \ 63 ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEMXX} \ 64 ${DESTDIR}/usr/include/g++} \ 65 ${CPPFLAGS} ${CPPFLAGS.${.ALLSRC:T}} ${.ALLSRC} 66.endfor 67 68.endif # defined(SRCS) 69 70##### Clean rules 71cleandepend: 72.if defined(SRCS) 73 rm -f .depend ${.CURDIR}/tags ${CLEANDEPEND} 74.endif 75 76##### Custom rules 77.if !target(tags) 78tags: ${SRCS} 79.if defined(SRCS) 80 -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:N*.h} | \ 81 sed "s;\${.CURDIR}/;;" > tags 82.endif 83.endif 84