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