Print this page
3946 ::gcore
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
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.
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
15 15 # If applicable, add the following below this CDDL HEADER, with the
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 +# Copyright (c) 2013 by Delphix. All rights reserved.
26 +#
25 27
26 28 .KEEP_STATE:
27 29 .SUFFIXES:
28 30
29 31 include $(SRC)/cmd/mdb/Makefile.tools
30 32
31 33 $(KMOD_SOURCES_DIFFERENT)KMODSRCS = $(MODSRCS)
32 34
33 35 MODOBJS = $(MODSRCS:%.c=dmod/%.o)
34 36 KMODOBJS = $(KMODSRCS:%.c=kmod/%.o)
35 37
36 38 MODNAME = $(MODULE:%.so=%)
37 39 KMODULE = $(MODNAME)
38 40
39 41 MODFILE = dmod/$(MODULE)
40 42 KMODFILE = kmod/$(KMODULE)
41 43
42 44 #
43 45 # The mess below is designed to pick the right set of objects to build and/or
44 46 # lint. We have three flavors:
45 47 #
46 48 # 1. proc and raw modules. Only $(MODOBJS) are built.
47 49 # 2. kvm modules for systems without kmdb. Only $(MODOBJS) are built.
48 50 # 3. kvm modules for systems with kmdb. $(MODOBJS) and $(KMODOBJS) are built.
49 51 #
50 52 # Complicating matters, we'd like to make the distinction between 2 and 3 before
51 53 # this Makefile is loaded. By default, we'll assume that all kvm modules should
52 54 # be built for kmdb. If, however, the user sets $(MODULE_BUILD_TYPE) to `mdb',
53 55 # the kmdb variant of the module won't be built.
54 56 #
55 57
56 58 # Which flavors are to be built?
57 59 TARGETS_kvm_type_ = both # Build both if $(MODULE_BUILD_TYPE) is unset
58 60 TARGETS_kvm_type_kmdb = both
59 61 TARGETS_kvm_type_mdb = mdb
60 62 TARGETS_kvm_type = $(TARGETS_kvm_type_$(MODULE_BUILD_TYPE))
61 63
62 64 # What should we build?
63 65 TARGETS_kvm_kmdb = $(KMODFILE)
64 66 TARGETS_kvm_mdb = $(MODFILE)
65 67 TARGETS_kvm_both = $(TARGETS_kvm_mdb) $(TARGETS_kvm_kmdb)
66 68 TARGETS_kvm = $(TARGETS_kvm_$(TARGETS_kvm_type))
67 69 TARGETS_proc = $(MODFILE)
68 70 TARGETS_raw = $(MODFILE)
69 71 TARGETS = $(TARGETS_$(MDBTGT))
70 72
71 73 # Where should we install that which we've built?
72 74 ROOTTGTS_kvm_type = $(TARGETS_kvm_type) # overridden by mdb_ks
73 75 ROOTTGTS_kvm_kmdb = $(ROOTKMOD)/$(KMODULE)
74 76 ROOTTGTS_kvm_mdb = $(ROOTMOD)/$(MODULE)
75 77 ROOTTGTS_kvm_both = $(ROOTTGTS_kvm_mdb) $(ROOTTGTS_kvm_kmdb)
76 78 ROOTTGTS_kvm = $(ROOTTGTS_kvm_$(ROOTTGTS_kvm_type))
77 79 ROOTTGTS_proc = $(ROOTMOD)/$(MODULE)
78 80 ROOTTGTS_raw = $(ROOTMOD)/$(MODULE)
79 81 ROOTTGTS = $(ROOTTGTS_$(MDBTGT))
80 82
81 83 # What should we lint?
82 84 KLINTOBJS = $(KMODOBJS:%.o=%.ln)
83 85 LINTOBJS = $(MODOBJS:%.o=%.ln)
84 86
85 87 LINTFILES_kvm_type = $(TARGETS_kvm_type)
↓ open down ↓ |
51 lines elided |
↑ open up ↑ |
86 88 LINTFILES_kvm_both = $(KLINTOBJS) $(LINTOBJS)
87 89 LINTFILES_kvm_mdb = $(LINTOBJS)
88 90 LINTFILES_kvm = $(LINTFILES_kvm_$(LINTFILES_kvm_type))
89 91 LINTFILES_proc = $(LINTOBJS)
90 92 LINTFILES_raw = $(LINTOBJS)
91 93 LINTFILES = $(LINTFILES_$(MDBTGT))
92 94
93 95 kvm_TGTFLAGS = -D_KERNEL
94 96 proc_TGTFLAGS = -D_USER
95 97
98 +C99MODE = $(C99_ENABLE)
99 +
96 100 CFLAGS += $(CCVERBOSE)
97 101 CFLAGS64 += $(CCVERBOSE)
98 102 CPPFLAGS += $($(MDBTGT)_TGTFLAGS) -I../../../common
99 103 LDFLAGS += $(ZTEXT)
100 104 LDFLAGS64 += $(ZTEXT)
101 105
102 106 # Module type-specific compiler flags
103 107 $(MODOBJS) := CFLAGS += $(C_BIGPICFLAGS) $(XREGSFLAG)
104 108 $(MODOBJS) := CFLAGS64 += $(C_BIGPICFLAGS) $(XREGSFLAG)
105 109 $(KMODOBJS) $(KLINTOBJS) := CPPFLAGS += -D_KMDB
106 110 $(KMODOBJS) := V9CODESIZE = $(CCABS32)
107 111 $(KMODOBJS) := DTS_ERRNO =
108 112
109 113 # Modules aren't allowed to export symbols
110 114 MAPFILE = $(SRC)/cmd/mdb/common/modules/conf/mapfile
111 115
112 116 # Modules typically make external references. To provide for -zdefs use
113 117 # and clean ldd(1) processing, explicitly define all external references.
114 118 MAPFILE-EXT = $(SRC)/cmd/mdb/common/modules/conf/mapfile-extern
115 119
116 120 #
117 121 # kmdb is a kernel module, so we'll use the kernel's build flags.
118 122 $(KMODOBJS) := CFLAGS += $(STAND_FLAGS_32)
119 123 $(KMODOBJS) := CFLAGS64 += $(STAND_FLAGS_64)
120 124
121 125 #
122 126 # Override this to pull source files from another directory
123 127 #
124 128 MODSRCS_DIR = ../../../common/modules/genunix
125 129
126 130 all: $$(TARGETS)
127 131
128 132 install: all $$(ROOTTGTS)
129 133
130 134 dmods: install
131 135
132 136 clean.lint:
133 137 $(RM) $(LINTFILES)
134 138
135 139 clean:
136 140 $(RM) $(MODOBJS) $(KMODOBJS) $(CLEANFILES)
137 141
138 142 clobber: clean clean.lint
139 143 $(RM) $(MODFILE) $(KMODFILE) $(CLOBBERFILES)
140 144
141 145 lint: $$(LINTFILES)
142 146
143 147 .NO_PARALLEL:
144 148 .PARALLEL: $(MODOBJS) $(KMODOBJS) mdb_tgt kmdb_tgt dmod kmod \
145 149 $(TARGETS) $(LINTFILES)
146 150
147 151 $(MODFILE): dmod .WAIT $(MODOBJS) $$(MAPFILE-EXT)
148 152 $(LINK.c) $(ZDEFS) $(ZIGNORE) $(MAPFILE-EXT:%=-M%) $(GSHARED) \
149 153 $(MODOBJS) -o $@ $(LDLIBS) -lc
150 154 $(CTFMERGE) -L VERSION -o $@ $(MODOBJS)
151 155 $(POST_PROCESS_SO)
152 156
153 157 #
154 158 # kmdb dmods must *not* stray from the module API. To ensure that they don't,
155 159 # we try to link them, at build time, against an object that exports the symbols
156 160 # that they can legally use. The link test object is, however, only built when
157 161 # kmdb itself is built. Requiring module developers to build kmdb first would
158 162 # be painful, so by default, module-level builds don't do the link test (the
159 163 # $(POUND_SIGN) assignment below takes care of that). Builds of the entire
160 164 # tree can, however, guarantee the construction of kmdb first, and as such can
161 165 # override the setting of $(KMDB_LINKTEST_ENABLE). This override causes the
162 166 # link test to be run.
163 167 #
164 168 # Developers wanting to force a link test for a single module can use the
165 169 # `linktest' target from within a module directory.
166 170 #
167 171 LINKTESTOBJ = $(KMDBDIR)/kmdb_modlinktest.o
168 172
169 173 KMDB_LINKTEST = \
170 174 $(LD) $(ZDEFS) -dy -r -o $@.linktest $(KMODOBJS) \
171 175 $(STANDOBJS) $(LINKTESTOBJ) && \
172 176 $(RM) $@.linktest
173 177
174 178 KMDB_LINKTEST_ENABLE=$(POUND_SIGN)
175 179 $(KMDB_LINKTEST_ENABLE)KMDB_LINKTEST_CMD = $(KMDB_LINKTEST)
176 180
177 181 #
178 182 # Ensure that dmods don't use floating point
179 183 #
180 184 KMDB_FPTEST_CMD = $(KMDB_FPTEST)
181 185
182 186 $(KMODFILE): kmod .WAIT $(KMODOBJS) $(MAPFILE)
183 187 $(LD) -dy -r $(MAPFILE:%=-M%) -Nmisc/kmdbmod -o $@ $(KMODOBJS) \
184 188 $(STANDOBJS)
185 189 $(KMDB_LINKTEST_CMD)
186 190 $(KMDB_FPTEST_CMD)
187 191 $(CTFMERGE) -f -L VERSION -o $@ $(KMODOBJS)
188 192 $(SETDYNFLAG) -f DF_1_NOKSYMS $@
189 193
190 194 linktest: linktest_check .WAIT kmod .WAIT $(KMODOBJS)
191 195 $(KMDB_LINKTEST)
192 196
193 197 linktest_check:
194 198 @if [ "$(MDBTGT)" != "kvm" ] ; then \
195 199 echo "ERROR: linktest is not supported non-kvm/disasm dmods" \
196 200 >&2 ; \
197 201 exit 1 ; \
198 202 fi
199 203
200 204 #
201 205 # Dynamic rules for object construction
202 206 #
203 207 dmod/%.o kmod/%.o: %.c
204 208 $(COMPILE.c) -o $@ $<
205 209 $(CTFCONVERT_O)
206 210
207 211 dmod/%.o kmod/%.o: ../%.c
208 212 $(COMPILE.c) -o $@ $<
209 213 $(CTFCONVERT_O)
210 214
211 215 dmod/%.o kmod/%.o: ../../../common/modules/$(MODNAME)/%.c
212 216 $(COMPILE.c) -o $@ $<
213 217 $(CTFCONVERT_O)
214 218
215 219 dmod/%.o kmod/%.o: $$(MODSRCS_DIR)/%.c
216 220 $(COMPILE.c) -o $@ $<
217 221 $(CTFCONVERT_O)
218 222
219 223 #
220 224 # Lint
221 225 #
222 226 dmod/%.ln kmod/%.ln: %.c
223 227 $(LINT.c) -dirout=$(@D) -c $<
224 228
225 229 dmod/%.ln kmod/%.ln: ../%.c
226 230 $(LINT.c) -dirout=$(@D) -c $<
227 231
228 232 dmod/%.ln kmod/%.ln: ../../../common/modules/$(MODNAME)/%.c
229 233 $(LINT.c) -dirout=$(@D) -c $<
230 234
231 235 dmod/%.ln kmod/%.ln: $$(MODSRCS_DIR)/%.c
232 236 $(LINT.c) -dirout=$(@D) -c $<
233 237
234 238 #
235 239 # Installation targets
236 240 #
237 241
238 242 $(ROOT)/usr/lib/mdb/$(MDBTGT): $(ROOT)/usr/lib/mdb
239 243 $(INS.dir)
240 244
241 245 $(ROOT)/usr/lib/mdb:
242 246 $(INS.dir)
243 247
244 248 $(ROOT)/kernel/kmdb:
245 249 $(INS.dir)
246 250
247 251 $(ROOTMOD)/$(MODULE): $(ROOTMOD)
248 252
249 253 $(ROOTKMOD)/$(KMODULE): $(ROOTKMOD)
250 254
251 255 kmod dmod:
252 256 -@mkdir -p $@
↓ open down ↓ |
147 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX