summaryrefslogtreecommitdiff
path: root/usr/src/uts/Makefile.targ
blob: 0807ad70dc1010273d65586830fe469adff09e22 (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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright 2014 Garrett D'Amore <garrett@damore.org>
# Copyright 2016 Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
# Copyright (c) 2017 by Delphix. All rights reserved.
# Copyright 2019 Joyent, Inc.
#
#	This Makefiles contains the common targets and definitions for
#	all kernels. It is to be included in the Makefiles for specific
#	implementation architectures and processor architecture dependent
#	modules: i.e.: all driving kernel Makefiles.
#

#
#	Partially link .o files to generate the kmod. The fake dependency
#	on modstubs simplifies things...
#
$(BINARY):		$(OBJECTS) $(DTRACE_MAPFILE) $(MAPFILE)
	$(LD) -ztype=kmod $(LDFLAGS) -o $@ $(OBJECTS)
	$(CTFMERGE_UNIQUIFY_AGAINST_GENUNIX)
	$(POST_PROCESS)

#
#	This target checks each kmod for undefined entry points. It does not
#	modify the kmod in any way.
#
$(MODULE).check:	FRC
	@BUILD_TYPE=DBG32 $(MAKE) $(MODULE).check.targ

$(MODULE).check.targ:	$(BINARY) $(OBJECTS) $(EXTRA_CHECK_OBJS) $(UNIX_O) $(MODSTUBS_O) $(GENLIB)
	$(LD) -o /dev/null $(OBJECTS) $(EXTRA_CHECK_OBJS) $(UNIX_O) $(MODSTUBS_O) $(GENLIB)

#
# Since assym.h is a derived file, the dependency must be explicit for all
# files including this file.  The actual lists are defined in
# */Makefile.files.
#
$(ASSYM_DEPS:%=$(OBJS_DIR)/%):	$(DSF_DIR)/$(OBJS_DIR)/assym.h

#
#	Everybody need to know how to create a modstubs.o built with the
#	appropriate flags and located in the appropriate location.
#
$(MODSTUBS_O):	$(MODSTUBS)
	$(COMPILE.s) -o $@ $(MODSTUBS)

#
# Build the source file which contains the kernel's utsname,
# with release, version and machine set as follows:
#
#	release: contents of $(RELEASE) (Spaces replaced by '_')
#	version: contents of $(PATCHID) (Spaces replaced by '_')
#	machine: contents of $(UNAME_M)
#
# Build environment information is only contained in the comment section.
#

$(OBJS_DIR)/vers.o: $(OBJECTS)
	$(COMPILE.c) -DUTS_RELEASE=\"`$(ECHO) $(RELEASE) | sed -e 's/ /_/g'`\" \
	    -DUTS_VERSION=\"`$(ECHO) $(PATCHID) | sed -e 's/ /_/g'`\" \
	    -DUTS_PLATFORM=\"$(UNAME_M)\" -o $@ $(SRC)/uts/common/os/vers.c
	$(CTFCONVERT_O)
	$(POST_PROCESS_O)

#
#	Installation targets and rules:
#
$(ROOT_MOD_DIR) $(USR_MOD_DIR):
	-$(INS.dir)

$(ROOT_MOD_DIRS_32):	$(ROOT_MOD_DIR)
	-$(INS.dir)

$(USR_MOD_DIRS_32):	$(USR_MOD_DIR)
	-$(INS.dir)

$(ROOT_MOD_DIR)/%:	$(OBJS_DIR)/% $(ROOT_MOD_DIR) FRC
	$(INS.file)

$(ROOT_CPU_DIR)/%:	$(OBJS_DIR)/% $(ROOT_CPU_DIR) FRC
	$(INS.file)

$(ROOT_DRV_DIR)/%:	$(OBJS_DIR)/% $(ROOT_DRV_DIR) FRC
	$(INS.file)

$(ROOT_DTRACE_DIR)/%:	$(OBJS_DIR)/% $(ROOT_DTRACE_DIR) FRC
	$(INS.file)

$(ROOT_EXEC_DIR)/%:	$(OBJS_DIR)/% $(ROOT_EXEC_DIR) FRC
	$(INS.file)

$(ROOT_FS_DIR)/%:	$(OBJS_DIR)/% $(ROOT_FS_DIR) FRC
	$(INS.file)

$(ROOT_SCHED_DIR)/%:	$(OBJS_DIR)/% $(ROOT_SCHED_DIR) FRC
	$(INS.file)

$(ROOT_SOCK_DIR)/%:	$(OBJS_DIR)/% $(ROOT_SOCK_DIR) FRC
	$(INS.file)

$(ROOT_STRMOD_DIR)/%:	$(OBJS_DIR)/% $(ROOT_STRMOD_DIR) FRC
	$(INS.file)

$(ROOT_IPP_DIR)/%:	$(OBJS_DIR)/% $(ROOT_IPP_DIR) FRC
	$(INS.file)

$(ROOT_SYS_DIR)/%:	$(OBJS_DIR)/% $(ROOT_SYS_DIR) FRC
	$(INS.file)

$(ROOT_MISC_DIR)/%:	$(OBJS_DIR)/% $(ROOT_MISC_DIR) FRC
	$(INS.file)

$(ROOT_DACF_DIR)/%:	$(OBJS_DIR)/% $(ROOT_DACF_DIR) FRC
	$(INS.file)

$(ROOT_BRAND_DIR)/%:	$(OBJS_DIR)/% $(ROOT_BRAND_DIR) FRC
	$(INS.file)

$(ROOT_CC_DIR)/%:	$(OBJS_DIR)/% $(ROOT_MOD_DIR) $(ROOT_CC_DIR) FRC
	$(INS.file)

$(ROOT_CRYPTO_DIR)/%:	$(OBJS_DIR)/% $(ROOT_CRYPTO_DIR) FRC
	$(INS.file)

$(ROOT_KGSS_DIR)/%:	$(OBJS_DIR)/% $(ROOT_KGSS_DIR) FRC
	$(INS.file)

$(ROOT_SCSI_VHCI_DIR)/%: $(OBJS_DIR)/% $(ROOT_SCSI_VHCI_DIR) FRC
	$(INS.file)

$(ROOT_PMCS_FW_DIR)/%:	$(OBJS_DIR)/% $(ROOT_PMCS_FW_DIR) FRC
	$(INS.file)

$(ROOT_QLC_FW_DIR)/%:	$(OBJS_DIR)/% $(ROOT_QLC_FW_DIR) FRC
	$(INS.file)

$(ROOT_EMLXS_FW_DIR)/%:	$(OBJS_DIR)/% $(ROOT_EMLXS_FW_DIR) FRC
	$(INS.file)

$(ROOT_MACH_DIR)/%:	$(OBJS_DIR)/% $(ROOT_MACH_DIR) FRC
	$(INS.file)

$(ROOT_FONT_DIR)/%:	$(OBJS_DIR)/% $(ROOT_MOD_DIR) $(ROOT_FONT_DIR) FRC
	$(INS.file)

$(ROOT_MAC_DIR)/%:	$(OBJS_DIR)/% $(ROOT_MOD_DIR) $(ROOT_MAC_DIR) FRC
	$(INS.file)

$(ROOT_OVERLAY_DIR)/%:	$(OBJS_DIR)/% $(ROOT_MOD_DIR) $(ROOT_OVERLAY_DIR) FRC
	$(INS.file)

$(USR_DRV_DIR)/%:	$(OBJS_DIR)/% $(USR_DRV_DIR) FRC
	$(INS.file)

$(USR_EXEC_DIR)/%:	$(OBJS_DIR)/% $(USR_EXEC_DIR) FRC
	$(INS.file)

$(USR_FS_DIR)/%:	$(OBJS_DIR)/% $(USR_FS_DIR) FRC
	$(INS.file)

$(USR_SCHED_DIR)/%:	$(OBJS_DIR)/% $(USR_SCHED_DIR) FRC
	$(INS.file)

$(USR_SOCK_DIR)/%:	$(OBJS_DIR)/% $(USR_SOCK_DIR) FRC
	$(INS.file)

$(USR_STRMOD_DIR)/%:	$(OBJS_DIR)/% $(USR_STRMOD_DIR) FRC
	$(INS.file)

$(USR_SYS_DIR)/%:	$(OBJS_DIR)/% $(USR_SYS_DIR) FRC
	$(INS.file)

$(USR_MISC_DIR)/%:	$(OBJS_DIR)/% $(USR_MISC_DIR) FRC
	$(INS.file)

$(USR_DACF_DIR)/%:	$(OBJS_DIR)/% $(USR_DACF_DIR) FRC
	$(INS.file)

$(USR_PCBE_DIR)/%:	$(OBJS_DIR)/% $(USR_PCBE_DIR) FRC
	$(INS.file)

$(USR_DTRACE_DIR)/%:	$(OBJS_DIR)/% $(USR_DTRACE_DIR) FRC
	$(INS.file)

$(USR_BRAND_DIR)/%:	$(OBJS_DIR)/% $(USR_BRAND_DIR) FRC
	$(INS.file)

$(ROOT_KICONV_DIR)/%:	$(OBJS_DIR)/% $(ROOT_KICONV_DIR) FRC
	$(INS.file)

$(ROOT_FIRMWARE_DIR)/$(MODULE):
	$(INS.dir)

$(ROOT_FIRMWARE_DIR)/$(MODULE)/%:= FILEMODE = $(CFILEMODE)

$(ROOT_FIRMWARE_DIR)/$(MODULE)/%: $(ROOT_FIRMWARE_DIR)/$(MODULE) $(FWDIR)/%
	$(INS.file)

include $(SRC)/Makefile.psm.targ

#
#	Target for 64b modules
#
$(ROOT_KERN_DIR_64):
	-$(INS.dir)

$(ROOT_KERN_DIR_64)/%:	$(OBJS_DIR)/% $(ROOT_KERN_DIR_64) FRC
	$(INS.file)

%/$(SUBDIR64):		%
	-$(INS.dir)

#
#	Targets for '.conf' file installation.
#
$(ROOT_CONFFILE):	$(SRC_CONFFILE)	$(ROOT_CONFFILE:%/$(CONFFILE)=%)
	$(INS.conffile)

#
#	Targets for creating links between common platforms. ROOT_PLAT_LINKS
#	are are the /platform level while ROOT_PLAT_LINKS_2 are one level
#	down (/platform/`uname -i`/{lib|sbin|kernel}.
#
$(ROOT_PLAT_LINKS):
	$(INS.slink1)

$(ROOT_PLAT_LINKS_2):
	$(INS.slink2)

$(USR_PLAT_LINKS):
	$(INS.slink1)

$(USR_PLAT_LINKS_2):
	$(INS.slink2)

#
# multiple builds support
#
def $(DEF_DEPS)			:= TARGET = def
all $(ALL_DEPS)			:= TARGET = all
clean $(CLEAN_DEPS)		:= TARGET = clean
clobber $(CLOBBER_DEPS)		:= TARGET = clobber
modlist	$(MODLIST_DEPS)		:= TARGET = modlist
modlist	$(MODLIST_DEPS)		:= NO_STATE= -K $$MODSTATE$$$$
install $(INSTALL_DEPS)		:= TARGET = install
symcheck $(SYM_DEPS)		:= TARGET = symcheck

ALL_TARGS	= def all clean clobber install symcheck

ALL_OBJ32	= $(ALL_TARGS:%=%.obj32)

$(ALL_OBJ32):	FRC
	@BUILD_TYPE=OBJ32 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ

ALL_DEBUG32	= $(ALL_TARGS:%=%.debug32)

$(ALL_DEBUG32):	FRC
	@BUILD_TYPE=DBG32 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ

ALL_OBJ64	= $(ALL_TARGS:%=%.obj64)

$(ALL_OBJ64):	FRC
	@BUILD_TYPE=OBJ64 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ

ALL_DEBUG64	= $(ALL_TARGS:%=%.debug64)

$(ALL_DEBUG64):	FRC
	@BUILD_TYPE=DBG64 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ

#
#	Currently only the IP module needs symbol checking on obj64.
#	Other modules have the same global-objs nm output for debug64 and obj64.
#
$(SISCHECK_DEPS):	$(DEF_DEPS)
	@TARG=`$(ECHO) $@ | $(CUT) -d'.' -f2`; \
	MODSYMS=$(MODULE).symbols.$$TARG; \
	if [ -f "$(MODULE).global-objs.$$TARG" ]; then \
		$(GREP) -v '#' $(MODULE).global-objs.$$TARG |$(GREP) . | \
		    $(SORT) -u > $$MODSYMS.tmp; \
		$(NM) $$TARG/$(MODULE) |$(GREP) OBJT |$(GREP) -v UNDEF | \
		    $(CUT) -d'|' -f8 |$(GREP) -v '^___const_' | \
		    $(GREP) -v '\.[0-9]*$$' |$(SORT) -u \
		    > $$MODSYMS.tmp.new; \
		$(DIFF) $$MODSYMS.tmp $$MODSYMS.tmp.new > $$MODSYMS.diff || \
		    ($(ECHO) "warning: $(MODULE) symbol checking:" \
		    "global variable(s) introduced and/or removed."; \
		    $(CAT) $$MODSYMS.diff; exit 1) \
	fi

$(SISCLEAN_DEPS):
	-TARG=`$(ECHO) $@ | $(CUT) -d'.' -f2`; \
	MODSYMS=$(MODULE).symbols.$$TARG; \
	$(RM) $$MODSYMS.tmp $$MODSYMS.tmp.new $$MODSYMS.diff Nothing_to_remove


$(OBJS_DIR):
	-@mkdir -p $@ 2> /dev/null

def.targ:		$(OBJS_DIR) $(ALL_TARGET)

all.targ:		$(OBJS_DIR) $(ALL_TARGET)

install.targ:		$(OBJS_DIR) $(INSTALL_TARGET)

#
# Support for Install.sh.
#

modlist:	$(MODLIST_DEPS)

# paths relative to $(ROOT).
RELMODULE = $(ROOTMODULE:$(ROOT)/%=%)
RELCONF = $(ROOT_CONFFILE:$(ROOT)/%=%)
RELLINK = $(ROOTLINK:$(ROOT)/%=%)
RELUNIX = $(UNIX32_LINK:$(ROOT)/%=%)
RELSOFTLINKS = $(ROOTSOFTLINKS:$(ROOT)/%=%)

MODSRC:sh=		pwd

#
# Generate module information for Install.sh, i.e., specify what files
# Install.sh should include.  Each line looks like
#   <tag> <srcdir> <arg1> <arg2> ...
# where <tag> specifies the type of file, <srcdir> gives the source
# path (useful if there is an error), and <argN> is one or more
# additional bits of information that Install.sh needs (e.g., source
# directory, install directory, filtering tags).  See Install.sh for
# details on the arguments for each tag type, especially the functions
# copymod, filtmod, and filtimpl.
#
# Changes to this target may require corresponding changes to
# Install.sh.
#
# Don't issue a MOD entry if it's not in the install list.
#

$(MODLIST_DEPS): FRC
	@case $@ in \
	*32) \
		class=32; \
		[ -n "$(RELMODULE)" ] && relmodule=`dirname $(RELMODULE)`;; \
	*64) \
		class=64; \
		[ -n "$(RELMODULE)" ] && \
		    relmodule=`dirname $(RELMODULE)`/$(SUBDIR64);; \
	esac; \
	if [ -z "$(THISIMPL)" ]; then \
		impl=all; \
	else \
		impl=$(THISIMPL); \
	fi; \
	if [ -n "$(ROOTMODULE)" -a -n "$(INSTALL_TARGET)" ]; then \
		if [ -z "$(MODULE)" ]; then \
			module=`basename $(ROOTMODULE)`; \
		else \
			module=$(MODULE); \
		fi; \
		tinstall="$(INSTALL_TARGET)"; \
		for t in $$tinstall; do \
			if [ "$(ROOTMODULE)" = $$t ]; then \
				echo MOD $(MODSRC) $$module $$relmodule \
				    $$class $$impl; \
				break; \
			fi \
		done \
	fi; \
	if [ -n "$(CONF_SRCDIR)" ]; then \
		tinstall="$(INSTALL_TARGET)"; \
		for t in $$tinstall; do \
			if [ $(ROOT_CONFFILE) = $$t ]; then \
				echo CONF $(MODSRC) $(RELCONF) \
				    $(MODSRC)/$(CONF_SRCDIR) $$impl $$module; \
				break; \
			fi \
		done \
	fi; \
	if [ -n "$(ROOTLINK)" ]; then \
		rellinks="$(RELLINK)"; \
		for r in $$rellinks; do \
			if [ $$class = 32 ]; then \
				linkdir=`dirname $$r`; \
			else \
				linkdir=`dirname $$r`/$(SUBDIR64); \
			fi; \
			echo LINK $(MODSRC) $$relmodule $$module \
				$$linkdir `basename $$r` $$impl; \
		done \
	fi; \
	if [ -n "$(UNIX32_LINK)" ]; then \
		echo SYMLINK $(MODSRC) $(SUBDIR64)/$(UNIX) \
		    `dirname $(RELUNIX)` unix $$impl $$module; \
	fi; \
	trelsoftlinks="$(RELSOFTLINKS)"; \
	for t in $$trelsoftlinks; do \
		if [ $$class = 32 ]; then \
			linkdir=`dirname $$t`; \
		else \
			linkdir=`dirname $$t`/$(SUBDIR64); \
		fi; \
		linkname=`basename $$t`; \
		echo SYMLINK $(MODSRC) $(MODULE) $$linkdir $$linkname \
		    $$impl $$module; \
	done

#
#	Cleanliness is next to ...
#
clean.targ:
	-$(RM) $(CLEANFILES) Nothing_to_remove

clobber.targ:
	-$(RM) $(CLOBBERFILES) Nothing_to_remove

FRC: