getconf: don't include xpg4 bits, gcc7 includes xpg6 bits for us
[unleashed.git] / share / mk / dep.mk
blob9d316d9fd5c7dbc1a07c4d165921e6ee6c41f98a
1 # $Id: dep.mk,v 1.17 2014/08/04 05:12:27 sjg Exp $
3 .if !target(__${.PARSEFILE}__)
4 __${.PARSEFILE}__:
6 # handle Proc*C as well...
7 .if defined(SRCS)
8 .if !empty(SRCS:M*.pc)
9 .include <proc.mk>
10 .endif
12 # it would be nice to be able to query .SUFFIXES
13 OBJ_EXTENSIONS+= .o .po .lo .So
15 # explicit dependencies help short-circuit .SUFFIX searches
16 SRCS_DEP_FILTER+= N*.[hly]
17 .for s in ${SRCS:${SRCS_DEP_FILTER:O:u:ts:}}
18 .for e in ${OBJ_EXTENSIONS:O:u}
19 .if !target(${s:T:R}$e)
20 ${s:T:R}$e: $s
21 .endif
22 .endfor
23 .endfor
24 .endif
26 .if exists(/usr/bin/mkdep)
27 MKDEP_CMD?= mkdep
28 .elif exists(/usr/local/share/bin/mkdeps.sh)
29 MKDEP_CMD?= /usr/local/share/bin/mkdeps.sh -N
30 .endif
31 MKDEP_CMD?= mkdep
33 MKDEP ?= ${MKDEP_CMD}
35 .NOPATH: .depend
37 .if ${MKDEP_MK:Uno} == "auto.dep.mk" && make(depend)
38 # auto.dep.mk does not "do" depend
39 MK_AUTODEP= no
40 .endif
42 .if ${MK_AUTODEP} == yes
43 MKDEP_MK ?= autodep.mk
44 .include <${MKDEP_MK}>
45 .else
46 MKDEP_ENV_VARS += CC CXX
47 .for v in ${MKDEP_ENV_VARS:O:u}
48 .if !empty($v)
49 MKDEP_ENV += $v='${$v}'
50 .endif
51 .endfor
53 _MKDEP = ${MKDEP_ENV} ${MKDEP}
55 # some of the rules involve .h sources, so remove them from mkdep line
56 .if !target(depend)
57 depend: beforedepend .depend _SUBDIRUSE afterdepend
59 .if defined(SRCS)
60 # libs can have too many SRCS for a single command line
61 # so do them one at a time.
62 .depend: ${SRCS} ${.PARSEDIR}/${.PASEFILE}
63 @rm -f .depend
64 .ifdef LIB
65 @files="${.ALLSRC:M*.[sS]}"; \
66 set -x; for f in $$files; do ${_MKDEP} -a ${MKDEPFLAGS} \
67 ${CFLAGS:M-[ID]*} ${CPPFLAGS} ${AINC} $$f; done
68 @files="${.ALLSRC:M*.c} ${.ALLSRC:M*.pc:T:.pc=.c}"; \
69 set -x; for f in $$files; do ${_MKDEP} -a ${MKDEPFLAGS} \
70 ${CFLAGS:M-[ID]*} ${CPPFLAGS} $$f; done
71 @files="${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cxx}"; \
72 set -x; for f in $$files; do ${_MKDEP} -a ${MKDEPFLAGS} \
73 ${CXXFLAGS:M-[ID]*} ${CPPFLAGS} $$f; done
74 .else
75 @files="${.ALLSRC:M*.[Ss]}"; \
76 case "$$files" in *.[Ss]*) \
77 echo ${_MKDEP} -a ${MKDEPFLAGS} \
78 ${CFLAGS:M-[ID]*} ${CPPFLAGS} ${AINC} $$files; \
79 ${_MKDEP} -a ${MKDEPFLAGS} \
80 ${CFLAGS:M-[ID]*} ${CPPFLAGS} ${AINC} $$files;; \
81 esac
82 @files="${.ALLSRC:M*.c} ${.ALLSRC:M*.pc:T:.pc=.c}"; \
83 case "$$files" in *.c*) \
84 echo ${_MKDEP} -a ${MKDEPFLAGS} \
85 ${CFLAGS:M-[ID]*} ${CPPFLAGS} $$files; \
86 ${_MKDEP} -a ${MKDEPFLAGS} \
87 ${CFLAGS:M-[ID]*} ${CPPFLAGS} $$files;; \
88 esac
89 @files="${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cxx}"; \
90 case "$$files" in *.[Cc]*) \
91 echo ${_MKDEP} -a ${MKDEPFLAGS} \
92 ${CXXFLAGS:M-[ID]*} ${CPPFLAGS} $$files; \
93 ${_MKDEP} -a ${MKDEPFLAGS} \
94 ${CXXFLAGS:M-[ID]*} ${CPPFLAGS} $$files;; \
95 esac
96 .endif
97 .else
98 .depend:
99 .endif
100 .if !target(beforedepend)
101 beforedepend:
102 .endif
103 .if !target(afterdepend)
104 afterdepend:
105 .endif
106 .endif
107 .endif
109 .if !target(tags)
110 .if defined(SRCS)
111 tags: ${SRCS} _SUBDIRUSE
112 -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:N*.h} | \
113 sed "s;\${.CURDIR}/;;" > tags
114 .else
115 tags:
116 .endif
117 .endif
119 .if defined(SRCS)
120 cleandir: cleandepend
121 .if !target(cleandepend)
122 cleandepend:
123 rm -f .depend ${.CURDIR}/tags
124 .endif
125 .endif
127 BUILDFIRST ?=
128 BUILDAFTER ?=
129 .if !empty(BUILDAFTER)
130 . for i in ${BUILDFIRST}
131 . if !exists($i)
132 ${BUILDAFTER}: $i
133 . endif
134 . endfor
135 .endif
137 .endif