bsd.dep.mk revision 1.52
1#	$NetBSD: bsd.dep.mk,v 1.52 2003/07/29 07:56:23 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
20DEPENDSRCS.src=	${SRCS:M*.c}	${DPSRCS:M*.c}		\
21		${SRCS:M*.m}	${DPSRCS:M*.m}		\
22		${SRCS:M*.[sS]}	${DPSRCS:M*.[sS]}	\
23		${SRCS:M*.C}	${DPSRCS:M*.C}		\
24		${SRCS:M*.cc}	${DPSRCS:M*.cc}		\
25		${SRCS:M*.cpp}	${DPSRCS:M*.cpp}	\
26		${SRCS:M*.cxx}	${DPSRCS:M*.cxx}
27DEPENDSRCS.dep=	${DEPENDSRCS.src:R:S/$/.d/g}
28DEPENDSRCS=	.depend ${DEPENDSRCS.dep}
29
30.depend: ${SRCS} ${DPSRCS} ${DEPENDSRCS.dep}
31	@rm -f .depend
32	cat ${DEPENDSRCS.dep} > .depend
33
34.NOPATH: ${DEPENDSRCS}
35
36.SUFFIXES: .d .c .m .s .S .C .cc .cpp .cxx
37
38.c.d:
39	${MKDEP} -f ${.TARGET} ${MKDEPFLAGS} ${CFLAGS:M-[ID]*} ${CPPFLAGS} \
40	    ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
41
42.m.d:
43	${MKDEP} -f ${.TARGET} ${MKDEPFLAGS} ${OBJCFLAGS:M-[ID]*} \
44	    ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
45
46.s.d .S.d:
47	${MKDEP} -f ${.TARGET} ${MKDEPFLAGS} ${AFLAGS:M-[ID]*} ${CPPFLAGS} \
48	    ${CPPFLAGS.${.IMPSRC:T}} ${__acpp_flags} ${AINC} ${.IMPSRC}
49
50.C.d .cc.d .cpp.d .cxx.d:
51	${MKDEP} -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