bsd.dep.mk revision 1.63
1#	$NetBSD: bsd.dep.mk,v 1.63 2003/11/10 18:21:55 dsl 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
13MKDEP_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} ${CFLAGS:M-[ID]*} ${CPPFLAGS} \
43	    ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
44
45.m.d:
46	${_MKTARGET_CREATE}
47	${MKDEP} -f ${.TARGET} ${MKDEPFLAGS} ${OBJCFLAGS:M-[ID]*} \
48	    ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
49
50.s.d .S.d:
51	${_MKTARGET_CREATE}
52	${MKDEP} -f ${.TARGET} ${MKDEPFLAGS} ${AFLAGS:M-[ID]*} ${CPPFLAGS} \
53	    ${CPPFLAGS.${.IMPSRC:T}} ${__acpp_flags} ${AINC} ${.IMPSRC}
54
55.C.d .cc.d .cpp.d .cxx.d:
56	${_MKTARGET_CREATE}
57	${MKDEP} -f ${.TARGET} ${MKDEPFLAGS} ${CXXFLAGS:M-[ID]*} \
58	    ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEMXX} \
59	    ${DESTDIR}/usr/include/g++} \
60	    ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC}
61
62.endif # defined(SRCS)							# }
63
64##### Clean rules
65cleandepend:
66.if defined(SRCS)
67	rm -f .depend ${__DPSRCS.d} ${.CURDIR}/tags ${CLEANDEPEND}
68.endif
69
70##### Custom rules
71.if !target(tags)
72tags: ${SRCS}
73.if defined(SRCS)
74	-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:N*.h} | \
75	    sed "s;\${.CURDIR}/;;" > tags
76.endif
77.endif
78