Print this page
10080 smatch Makefile changes for usr/src/cmd
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/mdb/Makefile.module
+++ new/usr/src/cmd/mdb/Makefile.module
1 1 #
2 2 # CDDL HEADER START
3 3 #
4 4 # The contents of this file are subject to the terms of the
5 5 # Common Development and Distribution License (the "License").
6 6 # You may not use this file except in compliance with the License.
7 7 #
8 8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 # or http://www.opensolaris.org/os/licensing.
10 10 # See the License for the specific language governing permissions
11 11 # and limitations under the License.
12 12 #
13 13 # When distributing Covered Code, include this CDDL HEADER in each
14 14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 # If applicable, add the following below this CDDL HEADER, with the
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
16 16 # fields enclosed by brackets "[]" replaced with your own identifying
17 17 # information: Portions Copyright [yyyy] [name of copyright owner]
18 18 #
19 19 # CDDL HEADER END
20 20 #
21 21 #
22 22 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 23 # Use is subject to license terms.
24 24 #
25 25 # Copyright (c) 2013 by Delphix. All rights reserved.
26 -# Copyright 2015, Joyent, Inc.
26 +# Copyright (c) 2018, Joyent, Inc.
27 27 #
28 28
29 29 .KEEP_STATE:
30 30 .SUFFIXES:
31 31
32 32 include $(SRC)/cmd/mdb/Makefile.tools
33 33
34 34 #
35 35 # Make sure we're getting a consistent execution environment for the
36 36 # embedded scripts.
37 37 #
38 38 SHELL= /usr/bin/ksh93
39 39
40 40 $(KMOD_SOURCES_DIFFERENT)KMODSRCS = $(MODSRCS)
41 41 $(KMOD_SOURCES_DIFFERENT)KMODASMSRCS = $(MODASMSRCS)
42 42
43 43 MODOBJS = $(MODSRCS:%.c=dmod/%.o) $(MODASMSRCS:%.s=dmod/%.o)
44 44 KMODOBJS = $(KMODSRCS:%.c=kmod/%.o) $(KMODASMSRCS:%.s=kmod/%.o)
45 45
46 46 MODNAME_cmd = if [ -n "$(MODULE_NAME)" ]; then print $(MODULE_NAME); else print $(MODULE)| sed -e 's:\.so$$::'; fi
47 47 MODNAME = $(MODNAME_cmd:sh)
48 48 KMODULE = $(MODNAME)
49 49
50 50 MODFILE = dmod/$(MODULE)
51 51 KMODFILE = kmod/$(KMODULE)
52 52
53 53 #
54 54 # The mess below is designed to pick the right set of objects to build and/or
55 55 # lint. We have three flavors:
56 56 #
57 57 # 1. proc and raw modules. Only $(MODOBJS) are built.
58 58 # 2. kvm modules for systems without kmdb. Only $(MODOBJS) are built.
59 59 # 3. kvm modules for systems with kmdb. $(MODOBJS) and $(KMODOBJS) are built.
60 60 #
61 61 # Complicating matters, we'd like to make the distinction between 2 and 3 before
62 62 # this Makefile is loaded. By default, we'll assume that all kvm modules should
63 63 # be built for kmdb. If, however, the user sets $(MODULE_BUILD_TYPE) to `mdb',
64 64 # the kmdb variant of the module won't be built.
65 65 #
66 66
67 67 # Which flavors are to be built?
68 68 TARGETS_kvm_type_ = both # Build both if $(MODULE_BUILD_TYPE) is unset
69 69 TARGETS_kvm_type_kmdb = both
70 70 TARGETS_kvm_type_mdb = mdb
71 71 TARGETS_kvm_type = $(TARGETS_kvm_type_$(MODULE_BUILD_TYPE))
72 72
73 73 # What should we build?
74 74 TARGETS_kvm_kmdb = $(KMODFILE)
75 75 TARGETS_kvm_mdb = $(MODFILE)
76 76 TARGETS_kvm_both = $(TARGETS_kvm_mdb) $(TARGETS_kvm_kmdb)
77 77 TARGETS_kvm = $(TARGETS_kvm_$(TARGETS_kvm_type))
78 78 TARGETS_proc = $(MODFILE)
79 79 TARGETS_raw = $(MODFILE)
80 80 TARGETS = $(TARGETS_$(MDBTGT))
81 81
82 82 # Where should we install that which we've built?
83 83 ROOTTGTS_kvm_type = $(TARGETS_kvm_type) # overridden by mdb_ks
84 84 ROOTTGTS_kvm_kmdb = $(ROOTKMOD)/$(KMODULE)
85 85 ROOTTGTS_kvm_mdb = $(ROOTMOD)/$(MODULE)
86 86 ROOTTGTS_kvm_both = $(ROOTTGTS_kvm_mdb) $(ROOTTGTS_kvm_kmdb)
87 87 ROOTTGTS_kvm = $(ROOTTGTS_kvm_$(ROOTTGTS_kvm_type))
88 88 ROOTTGTS_proc = $(ROOTMOD)/$(MODULE)
89 89 ROOTTGTS_raw = $(ROOTMOD)/$(MODULE)
90 90 ROOTTGTS = $(ROOTTGTS_$(MDBTGT))
91 91
92 92 # What should we lint?
93 93 KLINTOBJS = $(KMODOBJS:%.o=%.ln)
94 94 LINTOBJS = $(MODOBJS:%.o=%.ln)
95 95
96 96 LINTFILES_kvm_type = $(TARGETS_kvm_type)
97 97 LINTFILES_kvm_both = $(KLINTOBJS) $(LINTOBJS)
98 98 LINTFILES_kvm_mdb = $(LINTOBJS)
99 99 LINTFILES_kvm = $(LINTFILES_kvm_$(LINTFILES_kvm_type))
100 100 LINTFILES_proc = $(LINTOBJS)
101 101 LINTFILES_raw = $(LINTOBJS)
102 102 LINTFILES = $(LINTFILES_$(MDBTGT))
103 103
104 104 #
105 105 # Python specific flags. To try and make life easier for folks how are
106 106 # building with an LFS python, we attempt to use -isystem when it's
107 107 # available.
108 108 #
109 109 PYCPPFLAGS = -_gcc=-isystem -_gcc=$(ADJUNCT_PROTO)/usr/include/python$(PYTHON_VERSION)
110 110 PYCPPFLAGS += -_cc=-I$(ADJUNCT_PROTO)/usr/include/python$(PYTHON_VERSION)
111 111 PYLNFLAGS = -I$(ADJUNCT_PROTO)/usr/include/python$(PYTHON_VERSION)
112 112
113 113 kvm_TGTFLAGS = -D_KERNEL
114 114 proc_TGTFLAGS = -D_USER
115 115
↓ open down ↓ |
79 lines elided |
↑ open up ↑ |
116 116 CSTD = $(CSTD_GNU99)
117 117
118 118 CFLAGS += $(CCVERBOSE)
119 119 CFLAGS64 += $(CCVERBOSE)
120 120 CPPFLAGS += $($(MDBTGT)_TGTFLAGS) -I../../../common
121 121 LDFLAGS += $(ZTEXT)
122 122 LDFLAGS64 += $(ZTEXT)
123 123 ASFLAGS += -P
124 124 AS_CPPFLAGS += -D_ASM
125 125
126 +SMOFF += all_func_returns,index_overflow
127 +
126 128 # Module type-specific compiler flags
127 129 $(MODOBJS) := CFLAGS += $(C_BIGPICFLAGS) $(XREGSFLAG)
128 130 $(MODOBJS) := CFLAGS64 += $(C_BIGPICFLAGS) $(XREGSFLAG)
129 131 $(KMODOBJS) $(KLINTOBJS) := CPPFLAGS += -D_KMDB
130 132 $(KMODOBJS) := V9CODESIZE = $(CCABS32)
131 133 $(KMODOBJS) := DTS_ERRNO =
132 134
133 135 # Modules aren't allowed to export symbols
134 136 MAPFILE = $(SRC)/cmd/mdb/common/modules/conf/mapfile
135 137
136 138 # Modules typically make external references. To provide for -zdefs use
137 139 # and clean ldd(1) processing, explicitly define all external references.
138 140 MAPFILE-EXT = $(SRC)/cmd/mdb/common/modules/conf/mapfile-extern
139 141
140 142 #
141 143 # kmdb is a kernel module, so we'll use the kernel's build flags.
142 144 $(KMODOBJS) := CFLAGS64 += $(STAND_FLAGS_64)
143 145
144 146 #
145 147 # Override this to pull source files from another directory
146 148 #
147 149 MODSRCS_DIR = ../../../common/modules/genunix
148 150
149 151 all: $$(TARGETS)
150 152
151 153 install: all $$(ROOTTGTS)
152 154
153 155 dmods: install
154 156
155 157 clean.lint:
156 158 $(RM) $(LINTFILES) $(MODSRCS:.c=.ln)
157 159
158 160 clean:
159 161 $(RM) $(MODOBJS) $(KMODOBJS) $(CLEANFILES)
160 162
161 163 clobber: clean clean.lint
162 164 $(RM) $(MODFILE) $(KMODFILE) $(CLOBBERFILES)
163 165
164 166 lint: $$(LINTFILES)
165 167
166 168 .NO_PARALLEL:
167 169 .PARALLEL: $(MODOBJS) $(KMODOBJS) mdb_tgt kmdb_tgt dmod kmod \
168 170 $(TARGETS) $(LINTFILES)
169 171
170 172 $(MODFILE): dmod .WAIT $(MODOBJS) $$(MAPFILE-EXT)
171 173 $(LINK.c) $(ZDEFS) $(ZIGNORE) $(MAPFILE-EXT:%=-M%) $(GSHARED) \
172 174 $(MODOBJS) -o $@ $(LDLIBS) -lc
173 175 $(CTFMERGE) -L VERSION -o $@ $(MODOBJS)
174 176 $(POST_PROCESS_SO)
175 177
176 178 #
177 179 # kmdb dmods must *not* stray from the module API. To ensure that they don't,
178 180 # we try to link them, at build time, against an object that exports the symbols
179 181 # that they can legally use. The link test object is, however, only built when
180 182 # kmdb itself is built. Requiring module developers to build kmdb first would
181 183 # be painful, so by default, module-level builds don't do the link test (the
182 184 # $(POUND_SIGN) assignment below takes care of that). Builds of the entire
183 185 # tree can, however, guarantee the construction of kmdb first, and as such can
184 186 # override the setting of $(KMDB_LINKTEST_ENABLE). This override causes the
185 187 # link test to be run.
186 188 #
187 189 # Developers wanting to force a link test for a single module can use the
188 190 # `linktest' target from within a module directory.
189 191 #
190 192 LINKTESTOBJ = $(KMDBDIR)/kmdb_modlinktest.o
191 193
192 194 KMDB_LINKTEST = \
193 195 $(LD) $(ZDEFS) -dy -r -o $@.linktest $(KMODOBJS) \
194 196 $(STANDOBJS) $(LINKTESTOBJ) && \
195 197 $(RM) $@.linktest
196 198
197 199 KMDB_LINKTEST_ENABLE=$(POUND_SIGN)
198 200 $(KMDB_LINKTEST_ENABLE)KMDB_LINKTEST_CMD = $(KMDB_LINKTEST)
199 201
200 202 #
201 203 # Ensure that dmods don't use floating point
202 204 #
203 205 KMDB_FPTEST_CMD = $(KMDB_FPTEST)
204 206
205 207 $(KMODFILE): kmod .WAIT $(KMODOBJS) $(MAPFILE)
206 208 $(LD) -dy -r $(MAPFILE:%=-M%) -Nmisc/kmdbmod -o $@ $(KMODOBJS) \
207 209 $(STANDOBJS)
208 210 $(KMDB_LINKTEST_CMD)
209 211 $(KMDB_FPTEST_CMD)
210 212 $(CTFMERGE) -f -L VERSION -o $@ $(KMODOBJS)
211 213 $(POST_PROCESS)
212 214 $(SETDYNFLAG) -f DF_1_NOKSYMS $@
213 215
214 216 linktest: linktest_check .WAIT kmod .WAIT $(KMODOBJS)
215 217 $(KMDB_LINKTEST)
216 218
217 219 linktest_check:
218 220 @if [ "$(MDBTGT)" != "kvm" ] ; then \
219 221 echo "ERROR: linktest is not supported non-kvm/disasm dmods" \
220 222 >&2 ; \
221 223 exit 1 ; \
222 224 fi
223 225
224 226 #
225 227 # Dynamic rules for object construction
226 228 #
227 229 dmod/%.o kmod/%.o: %.c
228 230 $(COMPILE.c) -o $@ $<
229 231 $(CTFCONVERT_O)
230 232
231 233 dmod/%.o kmod%.o: %.s
232 234 $(COMPILE.s) -o $@ $<
233 235 $(CTFCONVERT_O)
234 236
235 237 dmod/%.o kmod/%.o: ../%.c
236 238 $(COMPILE.c) -o $@ $<
237 239 $(CTFCONVERT_O)
238 240
239 241 dmod/%.o kmod%.o: ../%.s
240 242 $(COMPILE.s) -o $@ $<
241 243 $(CTFCONVERT_O)
242 244
243 245 dmod/%.o kmod/%.o: ../../../common/modules/$(MODNAME)/%.c
244 246 $(COMPILE.c) -o $@ $<
245 247 $(CTFCONVERT_O)
246 248
247 249 dmod/%.o kmod%.o: ../../../common/modules/$(MODNAME)/%.s
248 250 $(COMPILE.s) -o $@ $<
249 251 $(CTFCONVERT_O)
250 252
251 253 dmod/%.o kmod/%.o: $$(MODSRCS_DIR)/%.c
252 254 $(COMPILE.c) -o $@ $<
253 255 $(CTFCONVERT_O)
254 256
255 257 dmod/%.o kmod%.o: $$(MODSRCS_DIR)/%.s
256 258 $(COMPILE.s) -o $@ $<
257 259 $(CTFCONVERT_O)
258 260
259 261 #
260 262 # Lint
261 263 #
262 264 dmod/%.ln kmod/%.ln: %.c
263 265 $(LINT.c) -dirout=$(@D) -c $<
264 266
265 267 dmod/%.ln kmod/%.ln: %.s
266 268 $(LINT.s) -dirout=$(@D) -c $<
267 269
268 270 dmod/%.ln kmod/%.ln: ../%.c
269 271 $(LINT.c) -dirout=$(@D) -c $<
270 272
271 273 dmod/%.ln kmod/%.ln: ../%.s
272 274 $(LINT.s) -dirout=$(@D) -c $<
273 275
274 276 dmod/%.ln kmod/%.ln: ../../../common/modules/$(MODNAME)/%.c
275 277 $(LINT.c) -dirout=$(@D) -c $<
276 278
277 279 dmod/%.ln kmod/%.ln: ../../../common/modules/$(MODNAME)/%.s
278 280 $(LINT.s) -dirout=$(@D) -c $<
279 281
280 282 dmod/%.ln kmod/%.ln: $$(MODSRCS_DIR)/%.c
281 283 $(LINT.c) -dirout=$(@D) -c $<
282 284
283 285 dmod/%.ln kmod/%.ln: $$(MODSRCS_DIR)/%.s
284 286 $(LINT.s) -dirout=$(@D) -c $<
285 287
286 288 #
287 289 # Installation targets
288 290 #
289 291
290 292 $(ROOT)/usr/lib/mdb/$(MDBTGT): $(ROOT)/usr/lib/mdb
291 293 $(INS.dir)
292 294
293 295 $(ROOT)/usr/lib/mdb:
294 296 $(INS.dir)
295 297
296 298 $(ROOT)/kernel/kmdb:
297 299 $(INS.dir)
298 300
299 301 $(ROOTMOD)/$(MODULE): $(ROOTMOD)
300 302
301 303 $(ROOTKMOD)/$(KMODULE): $(ROOTKMOD)
302 304
303 305 kmod dmod:
304 306 -@mkdir -p $@
↓ open down ↓ |
169 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX