blob: 2a37767ad5377ce15e095743fb90c0d5a816e5f8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# Copyright (c) 2010-1013 by Aleksey Cheusov
# Copyright (c) 1994-2009 The NetBSD Foundation, Inc.
######################################################################
.if !defined(_MKC_IMP_DEP_MK) && !empty(_SRCS_ALL)
_MKC_IMP_DEP_MK := 1
DISTCLEANFILES += .depend ${__DPSRCS.d} ${CLEANDEPEND}
##### Basic targets
do_depend1 do_depend2: .PHONY # ensure existence
realdo_depend: do_depend1 .WAIT do_depend2
##### Default values
MKDEP ?= mkdep
MKDEP_SUFFIXES ?= .o .os .op
MKDEP_CC ?= ${CC}
##### Build rules
# some of the rules involve .h sources, so remove them from mkdep line
.if defined(_SRCS_ALL)
__DPSRCS.all = ${_SRCS_ALL:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/} \
${DPSRCS:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/}
__DPSRCS.d = ${__DPSRCS.all:O:u:M*.d}
__DPSRCS.notd = ${__DPSRCS.all:O:u:N*.d}
do_depend1: ${DPSRCS}
do_depend2: .depend
MESSAGE.dep ?= @${_MESSAGE} "DEP: ${.TARGET}"
.NOPATH: .depend ${__DPSRCS.d}
.if !empty(__DPSRCS.d)
${__DPSRCS.d}: ${__DPSRCS.notd} ${DPSRCS}
.endif # __DPSRCS.d
.if ${MKDEP_TYPE:U} == "nbmkdep"
ddash=--
.else
ddash=
.endif
.if ${MKDEP_TYPE:U} == "makedepend"
MKDEP.c = ${MAKEDEPEND} -f- ${ddash} ${MKDEPFLAGS} \
${CFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} ${_CPPFLAGS} > ${.TARGET}
MKDEP.m = ${MKDEP} -f- ${ddash} ${MKDEPFLAGS} \
${OBJCFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} ${_CPPFLAGS} > ${.TARGET}
MKDEP.cc = ${MKDEP} -f- ${ddash} ${MKDEPFLAGS} \
${CXXFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} ${_CPPFLAGS} > ${.TARGET}
MKDEP.s = ${MKDEP} -f- ${ddash} ${MKDEPFLAGS} \
${AFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} ${_CPPFLAGS} > ${.TARGET}
.else
MKDEP.c = ${MKDEP} -f ${.TARGET} ${ddash} ${MKDEPFLAGS} \
${CFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} ${_CPPFLAGS}
MKDEP.m = ${MKDEP} -f ${.TARGET} ${ddash} ${MKDEPFLAGS} \
${OBJCFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} ${_CPPFLAGS}
MKDEP.cc = ${MKDEP} -f ${.TARGET} ${ddash} ${MKDEPFLAGS} \
${CXXFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} ${_CPPFLAGS}
MKDEP.s = ${MKDEP} -f ${.TARGET} ${ddash} ${MKDEPFLAGS} \
${AFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} ${_CPPFLAGS}
.endif
.depend: ${__DPSRCS.d}
${MESSAGE.dep}
@${RM} -f ${.TARGET}
.if ${MKDEP_TYPE:U} == "nbmkdep"
@${MKDEP} -d -f ${.TARGET} -s ${MKDEP_SUFFIXES:Q} ${__DPSRCS.d}
.else
@sed 's/^\([^ ]*\)[.]o\(.*\)$$/${MKDEP_SUFFIXES:C,^,\\\\1,}\2/' ${__DPSRCS.d} > ${.TARGET}
.endif
.SUFFIXES: .d .s .S .c .C .cc .cpp .cxx .m
.c.d:
${MESSAGE.dep}
@env CC=${MKDEP_CC:Q} ${MKDEP.c} ${.IMPSRC}
.m.d:
${MESSAGE.dep}
@${MKDEP.m} ${.IMPSRC}
.s.d .S.d:
${MESSAGE.dep}
@env CC=${MKDEP_CC:Q} ${MKDEP.s} ${.IMPSRC}
.C.d .cc.d .cpp.d .cxx.d:
${MESSAGE.dep}
@env CC=${MKDEP_CC:Q} ${MKDEP.cc} ${.IMPSRC}
.endif # defined(SRCS)
######################################################################
.endif # _MKC_IMP_DEP_MK
|