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
5 cleandir: cleandepend
6 realdepend: beforedepend .depend afterdepend
7 .ORDER: beforedepend .depend afterdepend
8
9 beforedepend .depend afterdepend: # ensure existence
10
11 ##### Default values
12 MKDEP?= mkdep
13 MKDEP_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
65 cleandepend:
66 .if defined(SRCS)
67 rm -f .depend ${__DPSRCS.d} ${.CURDIR}/tags ${CLEANDEPEND}
68 .endif
69
70 ##### Custom rules
71 .if !target(tags)
72 tags: ${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