bsd.dep.mk revision 1.38 1 # $NetBSD: bsd.dep.mk,v 1.38 2002/11/26 18:42:30 thorpej 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
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 .depend: ${SRCS} ${DPSRCS}
21 @rm -f .depend
22 @files="${.ALLSRC:M*.s} ${.ALLSRC:M*.S}"; \
23 if [ "$$files" != " " ]; then \
24 echo ${MKDEP} -a ${MKDEPFLAGS} \
25 ${AFLAGS:M-[ID]*:Q} ${CPPFLAGS:Q} ${__acpp_flags} ${AINC:Q} \
26 $$files; \
27 ${MKDEP} -a ${MKDEPFLAGS} \
28 ${AFLAGS:M-[ID]*} ${CPPFLAGS} ${__acpp_flags} ${AINC} $$files; \
29 fi
30 @files="${.ALLSRC:M*.c}"; \
31 if [ "$$files" != "" ]; then \
32 echo ${MKDEP} -a ${MKDEPFLAGS} \
33 ${CFLAGS:M-[ID]*:Q} ${CPPFLAGS:Q} $$files; \
34 ${MKDEP} -a ${MKDEPFLAGS} \
35 ${CFLAGS:M-[ID]*} ${CPPFLAGS} $$files; \
36 fi
37 @files="${.ALLSRC:M*.m}"; \
38 if [ "$$files" != "" ]; then \
39 echo ${MKDEP} -a ${MKDEPFLAGS} \
40 ${OBJCFLAGS:M-[ID]*:Q} ${CPPFLAGS:Q} $$files; \
41 ${MKDEP} -a ${MKDEPFLAGS} \
42 ${OBJCFLAGS:M-[ID]*} ${CPPFLAGS} $$files; \
43 fi
44 @files="${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cxx}"; \
45 if [ "$$files" != " " ]; then \
46 echo ${MKDEP} -a ${MKDEPFLAGS} \
47 ${CXXFLAGS:M-[ID]*:Q} ${CPPFLAGS:Q} $$files; \
48 ${MKDEP} -a ${MKDEPFLAGS} \
49 ${CXXFLAGS:M-[ID]*} ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include/g++} ${CPPFLAGS} $$files; \
50 fi
51 .endif # defined(SRCS)
52
53 ##### Clean rules
54 cleandepend:
55 .if defined(SRCS)
56 rm -f .depend ${.CURDIR}/tags ${CLEANDEPEND}
57 .endif
58
59 ##### Custom rules
60 .if !target(tags)
61 tags: ${SRCS}
62 .if defined(SRCS)
63 -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:N*.h} | \
64 sed "s;\${.CURDIR}/;;" > tags
65 .endif
66 .endif
67