1 # $NetBSD: bsd.dep.mk,v 1.82 2014/12/01 01:34:30 erh Exp $
4 #LSC: Be a bit smarter about the default compiler
5 .if exists
(/usr
/pkg
/bin
/clang
) || exists
(/usr
/bin
/clang
)
9 .if exists
(/usr
/pkg
/bin
/gcc
) || exists
(/usr
/bin
/gcc
)
13 MKDEP?
= CC
=${CC
:Q
} mkdep
14 MKDEPCXX?
= CC
=${CXX
:Q
} mkdep
15 .
endif # defined(__MINIX)
18 realdepend
: beforedepend .depend afterdepend
19 .ORDER
: beforedepend .depend afterdepend
21 beforedepend .depend afterdepend
: # ensure existence
26 MKDEP_SUFFIXES?
= .o .d
29 # some of the rules involve .h sources, so remove them from mkdep line
31 .if defined
(SRCS
) && !empty
(SRCS
)
32 __acpp_flags
= ${_ASM_TRADITIONAL_CPP}
35 .for f in
${SRCS} ${DPSRCS}
36 .if
"${NODPSRCS:M${f}}" == ""
37 __DPSRCS.
all+= ${f
:C
/\.
(c|m|s|S|C|
cc|
cpp|
cxx)$/.d
/}
40 beforedepend
: ${DPSRCS}
42 __DPSRCS.
all+= ${SRCS
:C
/\.
(c|m|s|S|C|
cc|
cpp|
cxx)$/.d
/} \
43 ${DPSRCS
:C
/\.
(c|m|s|S|C|
cc|
cpp|
cxx)$/.d
/}
45 __DPSRCS.d
= ${__DPSRCS.
all:O
:u
:M
*.d
}
46 __DPSRCS.notd
= ${__DPSRCS.
all:O
:u
:N
*.d
}
49 __DPSRCS.bcd
= ${"${USE_BITCODE:Uno}" == "yes":?
${SRCS
:M
*.c
:O
:u
:.c
=.bcd
}:}
50 __DPSRCS.d
+= ${__DPSRCS.bcd
}
51 .
endif # defined(__MINIX)
53 .NOPATH
: .depend
${__DPSRCS.d
}
55 .if
!empty
(__DPSRCS.d
) # {
56 ${__DPSRCS.d
}: ${__DPSRCS.notd
} ${DPSRCS}
59 MKDEPSUFFLAGS
=-s
${MKDEP_SUFFIXES
:Q
}
61 .if defined
(MKDEPINCLUDES
) && ${MKDEPINCLUDES} != "no"
63 @echo Rebuilding dependency file
: ${.ALLSRC
}
65 @
(cd
${.CURDIR
} && ${MAKE} depend
)
67 _MKDEP_FILEFLAGS
=${MKDEPSUFFLAGS}
69 _MKDEP_MERGEFLAGS
=${MKDEPSUFFLAGS}
73 .depend
: ${__DPSRCS.d
}
76 ${MKDEP} ${_MKDEP_MERGEFLAGS} -d
-f
${.TARGET
} ${__DPSRCS.d
}
79 .SUFFIXES
: .d .s .S .c .C .
cc .
cpp .
cxx .m
81 .SUFFIXES
: .bcd .d .s .S .c .C .
cc .
cpp .
cxx .m
83 .if
${USE_BITCODE
:Uno
} == "yes"
86 ${MKDEP} -f
${.TARGET
} -s .bc
-- ${MKDEPFLAGS} \
87 ${CFLAGS
:C
/-([IDU
])[ ]*/-\
1/Wg
:M-
[IDU
]*} \
88 ${CPPFLAGS} ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
}
89 .
endif # ${USE_BITCODE:Uno} == "yes"
90 .
endif # !defined(__MINIX)
94 ${MKDEP} -f
${.TARGET
}.tmp
${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \
95 ${CFLAGS
:M-std
=*} ${CFLAGS
:C
/-([IDU
])[ ]*/-\
1/Wg
:M-
[IDU
]*} \
96 ${CPPFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} \
97 ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} && \
98 mv
${.TARGET
}.tmp
${.TARGET
}
102 ${MKDEP} -f
${.TARGET
}.tmp
${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \
103 ${OBJCFLAGS
:C
/-([IDU
])[ ]*/-\
1/Wg
:M-
[IDU
]*} \
104 ${CPPFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} \
105 ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} && \
106 mv
${.TARGET
}.tmp
${.TARGET
}
110 ${MKDEP} -f
${.TARGET
}.tmp
${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \
111 ${AFLAGS
:C
/-([IDU
])[ ]*/-\
1/Wg
:M-
[IDU
]*} \
112 ${CPPFLAGS} ${AFLAGS.
${.IMPSRC
:T
}} ${CPPFLAGS.
${.IMPSRC
:T
}} \
113 ${__acpp_flags} ${.IMPSRC
} && \
114 mv
${.TARGET
}.tmp
${.TARGET
}
116 .C.d .
cc.d .
cpp.d .
cxx.d
:
118 ${MKDEPCXX} -f
${.TARGET
}.tmp
${_MKDEP_FILEFLAGS} -- ${MKDEPFLAGS} \
119 ${CXXFLAGS
:M-std
=*} ${CXXFLAGS
:C
/-([IDU
])[ ]*/-\
1/Wg
:M-
[IDU
]*} \
120 ${CPPFLAGS} ${COPTS.
${.IMPSRC
:T
}} ${CPUFLAGS.
${.IMPSRC
:T
}} \
121 ${CPPFLAGS.
${.IMPSRC
:T
}} ${.IMPSRC
} && \
122 mv
${.TARGET
}.tmp
${.TARGET
}
124 .
endif # defined(SRCS) && !empty(SRCS) # }
127 .if defined
(SRCS
) && !empty
(SRCS
)
128 CLEANDIRFILES
+= .depend
${__DPSRCS.d
} ${__DPSRCS.d
:.d
=.d.tmp
} ${.CURDIR
}/tags ${CLEANDEPEND}
134 .if defined
(SRCS
) && !empty
(SRCS
)
136 -cd
"${.CURDIR}"; ctags
-f
/dev
/stdout
${.ALLSRC
:N
*.h
} | \
137 ${TOOL_SED} "s;\${.CURDIR}/;;" > tags
141 ##### Pull in related .mk logic
142 .
include <bsd.
clean.mk
>