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