summaryrefslogtreecommitdiff
path: root/usr/src/uts/Makefile.uts
blob: 1256d73d5d7d1a18efe3a54c319ed87a6fca48c3 (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
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
#
# 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 (c) 2011 Bayard G. Bell. All rights reserved.
# Copyright (c) 2011,2017 by Delphix. All rights reserved.
# Copyright (c) 2013 Andrew Stormont.  All rights reserved.
# Copyright 2018 Joyent, Inc.
# Copyright 2016 Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
# Copyright 2019 Joyent, Inc.
#

#
#	This Makefile 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.
#
#	Include global definitions:
#
include $(SRC)/Makefile.master

#
#	No text domain in the kernel.
#
DTEXTDOM =

#
#	Keep references to $(SRC)/common relative.
COMMONBASE=	$(UTSBASE)/../common

#
#	Setup build-specific vars
#	To add a build type:
#		add name to ALL_BUILDS32 & ALL_BUILDS64
#		set CLASS_name and OBJ_DIR_name
#		add targets to Makefile.targ
#

#
#	DEF_BUILDS is for def, lint, sischeck, and install
#	ALL_BUILDS is for everything else (all, clean, ...)
#
# The NOT_RELEASE_BUILD noise is to maintain compatibility with the
# gatekeeper's nightly build script.
#
DEF_BUILDS32				= obj32
DEF_BUILDS64				= obj64
DEF_BUILDSONLY64			= obj64
$(NOT_RELEASE_BUILD)DEF_BUILDS32	= debug32
$(NOT_RELEASE_BUILD)DEF_BUILDS64	= debug64
$(NOT_RELEASE_BUILD)DEF_BUILDSONLY64	= debug64
ALL_BUILDS32				= obj32 debug32
ALL_BUILDS64				= obj64 debug64
ALL_BUILDSONLY64			= obj64 debug64

#
#	For modules in 64b dirs that aren't built 64b
#	or modules in 64b dirs that aren't built 32b we
#	need to create empty modlintlib files so global lint works
#
LINT32_BUILDS	= debug32
LINT64_BUILDS	= debug64

#
#	Build class (32b or 64b)
#
CLASS_OBJ32	= 32
CLASS_DBG32	= 32
CLASS_OBJ64	= 64
CLASS_DBG64	= 64
CLASS		= $(CLASS_$(BUILD_TYPE))

#
#	Build subdirectory
#
OBJS_DIR_OBJ32	= obj32
OBJS_DIR_DBG32	= debug32
OBJS_DIR_OBJ64	= obj64
OBJS_DIR_DBG64	= debug64
OBJS_DIR	= $(OBJS_DIR_$(BUILD_TYPE))

#
#	Create defaults so empty rules don't
#	confuse make
#
CLASS_		= 64
OBJS_DIR_	= debug64

#
#	Build tools
#
CC_sparc_32	= $(sparc_CC)
CC_sparc_64	= $(sparcv9_CC)

CC_i386_32	= $(i386_CC)
CC_i386_64	= $(amd64_CC)
CC_amd64_64	= $(amd64_CC)

CC		= $(CC_$(MACH)_$(CLASS))

AS_sparc_32	= $(sparc_AS)
AS_sparc_64	= $(sparcv9_AS)

AS_i386_32	= $(i386_AS)
AS_i386_64	= $(amd64_AS)
AS_amd64_64	= $(amd64_AS)

AS		= $(AS_$(MACH)_$(CLASS))

LD_sparc_32	= $(sparc_LD)
LD_sparc_64	= $(sparcv9_LD)

LD_i386_32	= $(i386_LD)
LD_i386_64	= $(amd64_LD)
LD_amd64_64	= $(amd64_LD)

LD		= $(LD_$(MACH)_$(CLASS))

LINT_sparc_32	= $(sparc_LINT)
LINT_sparc_64	= $(sparcv9_LINT)

LINT_i386_32	= $(i386_LINT)
LINT_i386_64	= $(amd64_LINT)
LINT_amd64_64	= $(amd64_LINT)

LINT		= $(LINT_$(MACH)_$(CLASS))

MODEL_32	= ilp32
MODEL_64	= lp64
MODEL		= $(MODEL_$(CLASS))

#
#	Build rules for linting the kernel.
#
LHEAD =	$(ECHO) "\n$@";

# Note: egrep returns "failure" if there are no matches, which is
# exactly the opposite of what we need.
LGREP.2 =	if egrep -v ' (_init|_fini|_info) '; then false; else true; fi

LTAIL =

LINT.c =	$(LINT) -c -dirout=$(LINTS_DIR) $(LINTFLAGS) $(LINT_DEFS) $(CPPFLAGS)

# Please do not add new erroff directives here.  If you need to disable
# lint warnings in your module for things that cannot be fixed in any
# reasonable manner, please augment LINTTAGS in your module Makefile
# instead.
LINTTAGS	= -erroff=E_INCONS_ARG_DECL2
LINTTAGS	+= -erroff=E_INCONS_VAL_TYPE_DECL2

LINTFLAGS_sparc_32	= $(LINTCCMODE) -nsxmuF -errtags=yes
LINTFLAGS_sparc_64	= $(LINTFLAGS_sparc_32) -m64
LINTFLAGS_i386_32	= $(LINTCCMODE) -nsxmuF -errtags=yes
LINTFLAGS_i386_64	= $(LINTFLAGS_i386_32) -m64

LINTFLAGS	= $(LINTFLAGS_$(MACH)_$(CLASS)) $(LINTTAGS)
LINTFLAGS	+= $(C99LMODE)

#
#	Override this variable to modify the name of the lint target.
#
LINT_MODULE=	$(MODULE)

#
#	Build the compile/assemble lines:
#
EXTRA_OPTIONS		=
AS_DEFS			= -D_ASM -D__STDC__=0

ALWAYS_DEFS_32		= -D_KERNEL -D_SYSCALL32 -D_DDI_STRICT
ALWAYS_DEFS_64		= -D_KERNEL -D_SYSCALL32 -D_SYSCALL32_IMPL -D_ELF64 \
			-D_DDI_STRICT
#
# XX64	This should be defined by the compiler!
#
ALWAYS_DEFS_64		+= -Dsun -D__sun -D__SVR4
ALWAYS_DEFS		= $(ALWAYS_DEFS_$(CLASS))

#
#	CPPFLAGS is deliberatly set with a "=" and not a "+=".  For the kernel
#	the header include path should not look for header files outside of
#	the kernel code.  This "=" removes the search path built in
#	Makefile.master inside CPPFLAGS.  Ditto for AS_CPPFLAGS.
#
CPPFLAGS	= $(ALWAYS_DEFS) $(ALL_DEFS) $(CONFIG_DEFS) \
		   $(INCLUDE_PATH) $(EXTRA_OPTIONS)
ASFLAGS		+= -P
AS_CPPFLAGS	= $(ALWAYS_DEFS) $(ALL_DEFS) $(CONFIG_DEFS) $(AS_DEFS) \
		   $(AS_INC_PATH) $(EXTRA_OPTIONS)

#
#	Make it (relatively) easy to share compilation options between
#	all kernel implementations.
#

# Override the default, the kernel is squeaky clean
CERRWARN = -errtags=yes -errwarn=%all

CERRWARN += -_gcc=-Wno-missing-braces
CERRWARN += -_gcc=-Wno-sign-compare
CERRWARN += -_gcc=-Wno-unknown-pragmas
CERRWARN += -_gcc=-Wno-unused-parameter
CERRWARN += -_gcc=-Wno-missing-field-initializers

# gcc4 lacks -Wno-maybe-uninitialized
CNOWARN_UNINIT = -_gcc4=-Wno-uninitialized \
    -_gcc7=-Wno-maybe-uninitialized \
    -_gcc8=-Wno-maybe-uninitialized

# DEBUG v. -nd make for frequent unused variables, empty conditions, etc. in
# -nd builds
$(RELEASE_BUILD)CERRWARN += -_gcc=-Wno-unused
$(RELEASE_BUILD)CERRWARN += -_gcc=-Wno-empty-body

CERRWARN += -_smatch=-p=illumos_kernel
include $(SRC)/Makefile.smatch

#
# Unfortunately, _IOWR() is regularly used with a third argument of 0,
# so we have to disable all these smatch checks.
#
SMOFF += sizeof

#
# Add specific compiler options that are required based on the
# architecture in question.
#
CFLAGS_uts_i386 += -_gcc7=-mindirect-branch=thunk-extern
CFLAGS_uts_i386 += -_gcc7=-mindirect-branch-register
CFLAGS_uts_i386 += -_gcc8=-mindirect-branch=thunk-extern
CFLAGS_uts_i386 += -_gcc8=-mindirect-branch-register

CSTD = $(CSTD_GNU99)

CFLAGS_uts		=
CFLAGS_uts		+= $(STAND_FLAGS_$(CLASS))
CFLAGS_uts		+= $(CCVERBOSE)
CFLAGS_uts		+= $(ILDOFF)
CFLAGS_uts		+= $(XAOPT)
CFLAGS_uts		+= $(CTF_FLAGS_$(CLASS))
CFLAGS_uts		+= $(CERRWARN)
CFLAGS_uts		+= $(CCNOAUTOINLINE)
CFLAGS_uts		+= $(CCNOREORDER)
CFLAGS_uts		+= $(CCNOAGGRESSIVELOOPS)
CFLAGS_uts		+= $(CGLOBALSTATIC)
CFLAGS_uts		+= $(EXTRA_CFLAGS)
CFLAGS_uts		+= $(CSOURCEDEBUGFLAGS)
CFLAGS_uts		+= $(CUSERFLAGS)
CFLAGS_uts		+= $(CFLAGS_uts_$(MACH))

#
#	Declare that $(OBJECTS) and $(LINTS) can be compiled in parallel.
#	The DUMMY target is for those instances where OBJECTS and LINTS
#	are empty (to avoid an unconditional .PARALLEL).
.PARALLEL:	$(OBJECTS) $(LINTS) DUMMY

#
#	Expanded dependencies
#
DEF_DEPS	= $(DEF_BUILDS:%=def.%)
ALL_DEPS	= $(ALL_BUILDS:%=all.%)
CLEAN_DEPS	= $(ALL_BUILDS:%=clean.%)
CLOBBER_DEPS	= $(ALL_BUILDS:%=clobber.%)
LINT_DEPS	= $(DEF_BUILDS:%=lint.%)
MODLINTLIB_DEPS	= $(DEF_BUILDS:%=modlintlib.%)
MODLIST_DEPS	= $(DEF_BUILDS:%=modlist.%)
CLEAN_LINT_DEPS	= $(ALL_BUILDS:%=clean.lint.%)
INSTALL_DEPS	= $(DEF_BUILDS:%=install.%)
SYM_DEPS	= $(SYM_BUILDS:%=symcheck.%)
SISCHECK_DEPS	= $(DEF_BUILDS:%=sischeck.%)
SISCLEAN_DEPS	= $(ALL_BUILDS:%=sisclean.%)

#
#	Default module name
#
BINARY		= $(OBJS_DIR)/$(MODULE)

#
#	Default cleanup definitions
#
CLEANLINTFILES	= $(LINTS) $(MOD_LINT_LIB)
CLEANFILES	= $(OBJECTS) $(CLEANLINTFILES)
CLOBBERFILES	= $(BINARY) $(CLEANFILES)

#
#	Installation constants:
#
#		FILEMODE is the mode given to the kernel modules
#		CFILEMODE is the mode given to the '.conf' files
#
FILEMODE	 = 755
DIRMODE		 = 755
CFILEMODE	 = 644

#
#	Special Installation Macros for the installation of '.conf' files.
#
#	These are unique because they are not installed from the current
#	working directory.
#
# Sigh.  Apparently at some time in the past there was a confusion on
# whether the name is SRC_CONFFILE or SRC_CONFILE.  Consistency with the
# other names would indicate SRC_CONFFILE, but the voting is >180 Makefiles
# with SRC_CONFILE and about 11 with SRC_CONFFILE.  Software development
# isn't a popularity contest, though, and so my inclination is to define
# both names for now and incrementally convert to SRC_CONFFILE to be consistent
# with the other names.
#
CONFFILE		= $(MODULE).conf
SRC_CONFFILE		= $(CONF_SRCDIR)/$(CONFFILE)
SRC_CONFILE		= $(SRC_CONFFILE)
ROOT_CONFFILE_32	= $(ROOTMODULE).conf
ROOT_CONFFILE_64	= $(ROOTMODULE:%/$(SUBDIR64)/$(MODULE)=%/$(MODULE)).conf
ROOT_CONFFILE		= $(ROOT_CONFFILE_$(CLASS))


INS.conffile= \
	$(RM) $@; $(INS) -s -m $(CFILEMODE) -f $(@D) $(SRC_CONFFILE)

#
# The CTF merge of child kernel modules is performed against one of the genunix
# modules.  For Intel builds, all modules will be used with a single genunix:
# the one built in intel/genunix.  For SPARC builds, a given
# module may be
# used with one of a number of genunix files, depending on what platform the
# module is deployed on.  We merge against the sun4u genunix to optimize for
# the common case.  We also merge against the ip driver since networking is
# typically loaded and types defined therein are shared between many modules.
#
CTFMERGE_GUDIR_sparc	= sun4u
CTFMERGE_GUDIR_i386	= intel
CTFMERGE_GUDIR		= $(CTFMERGE_GUDIR_$(MACH))

CTFMERGE_GENUNIX	= \
	$(UTSBASE)/$(CTFMERGE_GUDIR)/genunix/$(OBJS_DIR)/genunix

#
# Used to uniquify a non-genunix module against genunix. $VERSION is used
# for the label.
#
# For the ease of developers dropping modules onto possibly unrelated systems,
# you can set NO_GENUNIX_UNIQUIFY= in the environment to skip uniquifying
# against genunix.
#
NO_GENUNIX_UNIQUIFY=$(POUND_SIGN)
CTFMERGE_GENUNIX_DFLAG=-d $(CTFMERGE_GENUNIX)
$(NO_GENUNIX_UNIQUIFY)CTFMERGE_GENUNIX_DFLAG=

CTFMERGE_UNIQUIFY_AGAINST_GENUNIX	= \
	$(CTFMERGE) $(CTFMRGFLAGS) -L VERSION \
	$(CTFMERGE_GENUNIX_DFLAG) -o $@ $(OBJECTS) $(CTFEXTRAOBJS)

#
# Used to merge the genunix module.
#
CTFMERGE_GENUNIX_MERGE		= \
	$(CTFMERGE) $(CTFMRGFLAGS) -L VERSION -o $@ \
	$(OBJECTS) $(CTFEXTRAOBJS) $(IPCTF_TARGET)

#
# We ctfmerge the ip objects into genunix to maximize the number of common types
# found there, thus maximizing the effectiveness of uniquification.  We don't
# want the genunix build to have to know about the individual ip objects, so we
# put them in an archive.  The genunix ctfmerge then includes this archive.
#
IPCTF		= $(IPDRV_DIR)/$(OBJS_DIR)/ipctf.a

#
# Rule for building fake shared libraries used for symbol resolution
# when building other modules.  -znoreloc is needed here to avoid
# tripping over code that isn't really suitable for shared libraries.
#
BUILD.SO		= \
	$(LD) -o $@ $(GSHARED) $(ZNORELOC) -h $(SONAME)

#
# SONAME defaults for common fake shared libraries.
#
$(LIBGEN)		:= SONAME = $(MODULE)
$(PLATLIB)		:= SONAME = misc/platmod
$(CPULIB)		:= SONAME = 'cpu/$$CPU'
$(DTRACESTUBS)		:= SONAME = dtracestubs

#
#	Installation directories
#

#
#	For now, 64b modules install into a subdirectory
#	of their 32b brethren.
#
SUBDIR64_sparc		= sparcv9
SUBDIR64_i386		= amd64
SUBDIR64		= $(SUBDIR64_$(MACH))

ROOT_MOD_DIR		= $(ROOT)/kernel

ROOT_KERN_DIR_32	= $(ROOT_MOD_DIR)
ROOT_BRAND_DIR_32	= $(ROOT_MOD_DIR)/brand
ROOT_DRV_DIR_32		= $(ROOT_MOD_DIR)/drv
ROOT_DTRACE_DIR_32	= $(ROOT_MOD_DIR)/dtrace
ROOT_EXEC_DIR_32	= $(ROOT_MOD_DIR)/exec
ROOT_FS_DIR_32		= $(ROOT_MOD_DIR)/fs
ROOT_SCHED_DIR_32	= $(ROOT_MOD_DIR)/sched
ROOT_SOCK_DIR_32	= $(ROOT_MOD_DIR)/socketmod
ROOT_STRMOD_DIR_32	= $(ROOT_MOD_DIR)/strmod
ROOT_IPP_DIR_32		= $(ROOT_MOD_DIR)/ipp
ROOT_SYS_DIR_32		= $(ROOT_MOD_DIR)/sys
ROOT_MISC_DIR_32	= $(ROOT_MOD_DIR)/misc
ROOT_KGSS_DIR_32	= $(ROOT_MOD_DIR)/misc/kgss
ROOT_SCSI_VHCI_DIR_32	= $(ROOT_MOD_DIR)/misc/scsi_vhci
ROOT_PMCS_FW_DIR_32	= $(ROOT_MOD_DIR)/misc/pmcs
ROOT_QLC_FW_DIR_32	= $(ROOT_MOD_DIR)/misc/qlc
ROOT_EMLXS_FW_DIR_32	= $(ROOT_MOD_DIR)/misc/emlxs
ROOT_NLMISC_DIR_32	= $(ROOT_MOD_DIR)/misc
ROOT_MACH_DIR_32	= $(ROOT_MOD_DIR)/mach
ROOT_CPU_DIR_32		= $(ROOT_MOD_DIR)/cpu
ROOT_TOD_DIR_32		= $(ROOT_MOD_DIR)/tod
ROOT_FONT_DIR_32	= $(ROOT_MOD_DIR)/fonts
ROOT_DACF_DIR_32	= $(ROOT_MOD_DIR)/dacf
ROOT_CRYPTO_DIR_32	= $(ROOT_MOD_DIR)/crypto
ROOT_MAC_DIR_32		= $(ROOT_MOD_DIR)/mac
ROOT_CC_DIR_32		= $(ROOT_MOD_DIR)/cc
ROOT_OVERLAY_DIR_32	= $(ROOT_MOD_DIR)/overlay
ROOT_KICONV_DIR_32	= $(ROOT_MOD_DIR)/kiconv

ROOT_KERN_DIR_64	= $(ROOT_MOD_DIR)/$(SUBDIR64)
ROOT_BRAND_DIR_64	= $(ROOT_MOD_DIR)/brand/$(SUBDIR64)
ROOT_DRV_DIR_64		= $(ROOT_MOD_DIR)/drv/$(SUBDIR64)
ROOT_DTRACE_DIR_64	= $(ROOT_MOD_DIR)/dtrace/$(SUBDIR64)
ROOT_EXEC_DIR_64	= $(ROOT_MOD_DIR)/exec/$(SUBDIR64)
ROOT_FS_DIR_64		= $(ROOT_MOD_DIR)/fs/$(SUBDIR64)
ROOT_SCHED_DIR_64	= $(ROOT_MOD_DIR)/sched/$(SUBDIR64)
ROOT_SOCK_DIR_64	= $(ROOT_MOD_DIR)/socketmod/$(SUBDIR64)
ROOT_STRMOD_DIR_64	= $(ROOT_MOD_DIR)/strmod/$(SUBDIR64)
ROOT_IPP_DIR_64		= $(ROOT_MOD_DIR)/ipp/$(SUBDIR64)
ROOT_SYS_DIR_64		= $(ROOT_MOD_DIR)/sys/$(SUBDIR64)
ROOT_MISC_DIR_64	= $(ROOT_MOD_DIR)/misc/$(SUBDIR64)
ROOT_KGSS_DIR_64	= $(ROOT_MOD_DIR)/misc/kgss/$(SUBDIR64)
ROOT_SCSI_VHCI_DIR_64	= $(ROOT_MOD_DIR)/misc/scsi_vhci/$(SUBDIR64)
ROOT_PMCS_FW_DIR_64	= $(ROOT_MOD_DIR)/misc/pmcs/$(SUBDIR64)
ROOT_QLC_FW_DIR_64	= $(ROOT_MOD_DIR)/misc/qlc/$(SUBDIR64)
ROOT_EMLXS_FW_DIR_64	= $(ROOT_MOD_DIR)/misc/emlxs/$(SUBDIR64)
ROOT_NLMISC_DIR_64	= $(ROOT_MOD_DIR)/misc/$(SUBDIR64)
ROOT_MACH_DIR_64	= $(ROOT_MOD_DIR)/mach/$(SUBDIR64)
ROOT_CPU_DIR_64		= $(ROOT_MOD_DIR)/cpu/$(SUBDIR64)
ROOT_TOD_DIR_64		= $(ROOT_MOD_DIR)/tod/$(SUBDIR64)
ROOT_FONT_DIR_64	= $(ROOT_MOD_DIR)/fonts/$(SUBDIR64)
ROOT_DACF_DIR_64	= $(ROOT_MOD_DIR)/dacf/$(SUBDIR64)
ROOT_CRYPTO_DIR_64	= $(ROOT_MOD_DIR)/crypto/$(SUBDIR64)
ROOT_MAC_DIR_64		= $(ROOT_MOD_DIR)/mac/$(SUBDIR64)
ROOT_CC_DIR_64		= $(ROOT_MOD_DIR)/cc/$(SUBDIR64)
ROOT_OVERLAY_DIR_64	= $(ROOT_MOD_DIR)/overlay/$(SUBDIR64)
ROOT_KICONV_DIR_64	= $(ROOT_MOD_DIR)/kiconv/$(SUBDIR64)

ROOT_KERN_DIR		= $(ROOT_KERN_DIR_$(CLASS))
ROOT_BRAND_DIR		= $(ROOT_BRAND_DIR_$(CLASS))
ROOT_DRV_DIR		= $(ROOT_DRV_DIR_$(CLASS))
ROOT_DTRACE_DIR		= $(ROOT_DTRACE_DIR_$(CLASS))
ROOT_EXEC_DIR		= $(ROOT_EXEC_DIR_$(CLASS))
ROOT_FS_DIR		= $(ROOT_FS_DIR_$(CLASS))
ROOT_SCHED_DIR		= $(ROOT_SCHED_DIR_$(CLASS))
ROOT_SOCK_DIR		= $(ROOT_SOCK_DIR_$(CLASS))
ROOT_STRMOD_DIR		= $(ROOT_STRMOD_DIR_$(CLASS))
ROOT_IPP_DIR		= $(ROOT_IPP_DIR_$(CLASS))
ROOT_SYS_DIR		= $(ROOT_SYS_DIR_$(CLASS))
ROOT_MISC_DIR		= $(ROOT_MISC_DIR_$(CLASS))
ROOT_KGSS_DIR		= $(ROOT_KGSS_DIR_$(CLASS))
ROOT_SCSI_VHCI_DIR	= $(ROOT_SCSI_VHCI_DIR_$(CLASS))
ROOT_PMCS_FW_DIR	= $(ROOT_PMCS_FW_DIR_$(CLASS))
ROOT_QLC_FW_DIR		= $(ROOT_QLC_FW_DIR_$(CLASS))
ROOT_EMLXS_FW_DIR	= $(ROOT_EMLXS_FW_DIR_$(CLASS))
ROOT_NLMISC_DIR		= $(ROOT_NLMISC_DIR_$(CLASS))
ROOT_MACH_DIR		= $(ROOT_MACH_DIR_$(CLASS))
ROOT_CPU_DIR		= $(ROOT_CPU_DIR_$(CLASS))
ROOT_TOD_DIR		= $(ROOT_TOD_DIR_$(CLASS))
ROOT_FONT_DIR		= $(ROOT_FONT_DIR_$(CLASS))
ROOT_DACF_DIR		= $(ROOT_DACF_DIR_$(CLASS))
ROOT_CRYPTO_DIR		= $(ROOT_CRYPTO_DIR_$(CLASS))
ROOT_MAC_DIR		= $(ROOT_MAC_DIR_$(CLASS))
ROOT_CC_DIR		= $(ROOT_CC_DIR_$(CLASS))
ROOT_OVERLAY_DIR	= $(ROOT_OVERLAY_DIR_$(CLASS))
ROOT_KICONV_DIR		= $(ROOT_KICONV_DIR_$(CLASS))
ROOT_FIRMWARE_DIR	= $(ROOT_MOD_DIR)/firmware

ROOT_MOD_DIRS_32	= $(ROOT_BRAND_DIR_32) $(ROOT_DRV_DIR_32)
ROOT_MOD_DIRS_32	= $(ROOT_BRAND_DIR_32) $(ROOT_DRV_DIR_32)
ROOT_MOD_DIRS_32	+= $(ROOT_EXEC_DIR_32) $(ROOT_DTRACE_DIR_32)
ROOT_MOD_DIRS_32	+= $(ROOT_FS_DIR_32) $(ROOT_SCHED_DIR_32)
ROOT_MOD_DIRS_32	+= $(ROOT_STRMOD_DIR_32) $(ROOT_SYS_DIR_32)
ROOT_MOD_DIRS_32	+= $(ROOT_IPP_DIR_32) $(ROOT_SOCK_DIR_32)
ROOT_MOD_DIRS_32	+= $(ROOT_MISC_DIR_32) $(ROOT_MACH_DIR_32)
ROOT_MOD_DIRS_32	+= $(ROOT_KGSS_DIR_32)
ROOT_MOD_DIRS_32	+= $(ROOT_SCSI_VHCI_DIR_32)
ROOT_MOD_DIRS_32	+= $(ROOT_PMCS_FW_DIR_32)
ROOT_MOD_DIRS_32        += $(ROOT_QLC_FW_DIR_32)
ROOT_MOD_DIRS_32        += $(ROOT_EMLXS_FW_DIR_32)
ROOT_MOD_DIRS_32	+= $(ROOT_CPU_DIR_32) $(ROOT_FONT_DIR_32)
ROOT_MOD_DIRS_32	+= $(ROOT_TOD_DIR_32) $(ROOT_DACF_DIR_32)
ROOT_MOD_DIRS_32	+= $(ROOT_CRYPTO_DIR_32) $(ROOT_MAC_DIR_32)
ROOT_MOD_DIRS_32	+= $(ROOT_CC_DIR_32)
ROOT_MOD_DIRS_32	+= $(ROOT_OVERLAY_DIR_32)
ROOT_MOD_DIRS_32	+= $(ROOT_KICONV_DIR_32)
ROOT_MOD_DIRS_32	+= $(ROOT_FIRMWARE_DIR)

USR_MOD_DIR		= $(ROOT)/usr/kernel

USR_DRV_DIR_32		= $(USR_MOD_DIR)/drv
USR_EXEC_DIR_32		= $(USR_MOD_DIR)/exec
USR_FS_DIR_32		= $(USR_MOD_DIR)/fs
USR_SCHED_DIR_32	= $(USR_MOD_DIR)/sched
USR_SOCK_DIR_32		= $(USR_MOD_DIR)/socketmod
USR_STRMOD_DIR_32	= $(USR_MOD_DIR)/strmod
USR_SYS_DIR_32		= $(USR_MOD_DIR)/sys
USR_MISC_DIR_32		= $(USR_MOD_DIR)/misc
USR_DACF_DIR_32		= $(USR_MOD_DIR)/dacf
USR_PCBE_DIR_32		= $(USR_MOD_DIR)/pcbe
USR_DTRACE_DIR_32	= $(USR_MOD_DIR)/dtrace
USR_BRAND_DIR_32	= $(USR_MOD_DIR)/brand

USR_DRV_DIR_64		= $(USR_MOD_DIR)/drv/$(SUBDIR64)
USR_EXEC_DIR_64		= $(USR_MOD_DIR)/exec/$(SUBDIR64)
USR_FS_DIR_64		= $(USR_MOD_DIR)/fs/$(SUBDIR64)
USR_SCHED_DIR_64	= $(USR_MOD_DIR)/sched/$(SUBDIR64)
USR_SOCK_DIR_64		= $(USR_MOD_DIR)/socketmod/$(SUBDIR64)
USR_STRMOD_DIR_64	= $(USR_MOD_DIR)/strmod/$(SUBDIR64)
USR_SYS_DIR_64		= $(USR_MOD_DIR)/sys/$(SUBDIR64)
USR_MISC_DIR_64		= $(USR_MOD_DIR)/misc/$(SUBDIR64)
USR_DACF_DIR_64		= $(USR_MOD_DIR)/dacf/$(SUBDIR64)
USR_PCBE_DIR_64		= $(USR_MOD_DIR)/pcbe/$(SUBDIR64)
USR_DTRACE_DIR_64	= $(USR_MOD_DIR)/dtrace/$(SUBDIR64)
USR_BRAND_DIR_64	= $(USR_MOD_DIR)/brand/$(SUBDIR64)

USR_DRV_DIR		= $(USR_DRV_DIR_$(CLASS))
USR_EXEC_DIR		= $(USR_EXEC_DIR_$(CLASS))
USR_FS_DIR		= $(USR_FS_DIR_$(CLASS))
USR_SCHED_DIR		= $(USR_SCHED_DIR_$(CLASS))
USR_SOCK_DIR		= $(USR_SOCK_DIR_$(CLASS))
USR_STRMOD_DIR		= $(USR_STRMOD_DIR_$(CLASS))
USR_SYS_DIR		= $(USR_SYS_DIR_$(CLASS))
USR_MISC_DIR		= $(USR_MISC_DIR_$(CLASS))
USR_DACF_DIR		= $(USR_DACF_DIR_$(CLASS))
USR_PCBE_DIR		= $(USR_PCBE_DIR_$(CLASS))
USR_DTRACE_DIR		= $(USR_DTRACE_DIR_$(CLASS))
USR_BRAND_DIR		= $(USR_BRAND_DIR_$(CLASS))

USR_MOD_DIRS_32		= $(USR_DRV_DIR_32) $(USR_EXEC_DIR_32)
USR_MOD_DIRS_32		+= $(USR_FS_DIR_32) $(USR_SCHED_DIR_32)
USR_MOD_DIRS_32		+= $(USR_STRMOD_DIR_32) $(USR_SYS_DIR_32)
USR_MOD_DIRS_32		+= $(USR_MISC_DIR_32) $(USR_DACF_DIR_32)
USR_MOD_DIRS_32		+= $(USR_PCBE_DIR_32)
USR_MOD_DIRS_32		+= $(USR_DTRACE_DIR_32) $(USR_BRAND_DIR_32)
USR_MOD_DIRS_32		+= $(USR_SOCK_DIR_32)

#
#
#
include $(SRC)/Makefile.psm

#
#	The "-r" on the remove may be considered temporary, but is required
#	while the replacement of the SUNW,SPARCstation-10,SX directory by
#	a symbolic link is being propagated.
#
INS.slink1= $(RM) -r $@; $(SYMLINK) $(PLATFORM) $@
INS.slink2= $(RM) -r $@; $(SYMLINK) ../$(PLATFORM)/$(@F) $@
INS.slink3= $(RM) -r $@; $(SYMLINK) $(IMPLEMENTED_PLATFORM) $@
INS.slink4= $(RM) -r $@; $(SYMLINK) ../$(PLATFORM)/include $@
INS.slink5= $(RM) -r $@; $(SYMLINK) ../$(PLATFORM)/sbin $@
INS.slink6= $(RM) -r $@; $(SYMLINK) ../../$(PLATFORM)/lib/$(MODULE) $@
INS.slink7= $(RM) -r $@; $(SYMLINK) ../../$(PLATFORM)/sbin/$(@F) $@

ROOT_PLAT_LINKS		 = $(PLAT_LINKS:%=$(ROOT_PLAT_DIR)/%)
ROOT_PLAT_LINKS_2	 = $(PLAT_LINKS_2:%=$(ROOT_PLAT_DIR)/%)
USR_PLAT_LINKS		 = $(PLAT_LINKS:%=$(USR_PLAT_DIR)/%)
USR_PLAT_LINKS_2	 = $(PLAT_LINKS_2:%=$(USR_PLAT_DIR)/%)

#
# Collection of all relevant, delivered kernel modules.
#
# Note that we insist on building genunix first, because everything else
# uniquifies against it.  When doing a 'make' from usr/src/uts/, we'll enter
# the platform directories first.  These will cd into the corresponding genunix
# directory and build it.  So genunix /shouldn't/ get rebuilt when we get to
# building all the kernel modules.  However, due to an as-yet-unexplained
# problem with dependencies, sometimes it does get rebuilt, which then messes
# up the other modules.  So we always force the issue here rather than try to
# build genunix in parallel with everything else.
#
PARALLEL_KMODS = $(DRV_KMODS) $(EXEC_KMODS) $(FS_KMODS) $(SCHED_KMODS) \
		 $(TOD_KMODS) $(STRMOD_KMODS) $(SYS_KMODS) $(MISC_KMODS) \
		 $(NLMISC_KMODS) $(MACH_KMODS) $(CPU_KMODS) $(GSS_KMODS) \
		 $(MMU_KMODS) $(DACF_KMODS) $(EXPORT_KMODS) $(IPP_KMODS) \
		 $(CRYPTO_KMODS) $(PCBE_KMODS) \
		 $(DRV_KMODS_$(CLASS)) $(MISC_KMODS_$(CLASS)) $(MAC_KMODS) \
		 $(BRAND_KMODS) $(KICONV_KMODS) $(OVERLAY_KMODS) $(CC_KMODS) \
		 $(SOCKET_KMODS)

KMODS = $(GENUNIX_KMODS) $(PARALLEL_KMODS)

$(PARALLEL_KMODS): $(GENUNIX_KMODS)

LINT_KMODS = $(DRV_KMODS) $(EXEC_KMODS) $(FS_KMODS) $(SCHED_KMODS) \
	  $(TOD_KMODS) $(STRMOD_KMODS) $(SYS_KMODS) $(MISC_KMODS) \
	  $(MACH_KMODS) $(GSS_KMODS) $(DACF_KMODS) $(IPP_KMODS) \
	  $(CRYPTO_KMODS) $(PCBE_KMODS) \
	  $(DRV_KMODS_$(CLASS)) $(MISC_KMODS_$(CLASS)) $(MAC_KMODS) \
	  $(BRAND_KMODS) $(KICONV_KMODS) $(CC_KMODS) $(SOCKET_KMODS)

#
#	Files to be compiled with -xa, to generate basic block execution
#	count data.
#
#	There are several ways to compile parts of the kernel for kcov:
#               1)  Add targets to BB_FILES here or in other Makefiles
#                       (they must in the form of $(OBJS_DIR)/target.o)
#               2)  setenv BB_FILES '$(XXX_OBJS:%=$(OBJS_DIR)/%)'
#               3)  setenv BB_FILES '$(OBJECTS)'
#
#       Do NOT setenv CFLAGS -xa, as that will cause infinite recursion
#       in unix_bb.o
#
BB_FILES =
$(BB_FILES)	:= XAOPT = -xa

#
#	The idea here is for unix_bb.o to be in all kernels except the
#	kernel which actually gets shipped to customers.  In practice,
#	$(RELEASE_BUILD) is on for a number of the late beta and fcs builds.
#
$(NOT_RELEASE_BUILD)$(OBJS_DIR)/unix_bb.o   := CPPFLAGS     += -DKCOV
$(NOT_RELEASE_BUILD)$(OBJS_DIR)/unix_bb.ln  := CPPFLAGS     += -DKCOV

#
#	Do not let unix_bb.o get compiled with -xa!
#
$(OBJS_DIR)/unix_bb.o	:= XAOPT =

#
# Privilege files
#
PRIVS_AWK = $(SRC)/uts/common/os/privs.awk
PRIVS_DEF = $(SRC)/uts/common/os/priv_defs

#
# USB device data
#
USBDEVS_AWK =	$(SRC)/uts/common/io/usb/usbdevs2h.awk
USBDEVS_DATA =	$(SRC)/uts/common/io/usb/usbdevs


#
# If we're using the newer CTF tools, then we need to make sure that we
# are building with the private -X option to ctfconvert which allows us
# to fixup the struct cpu to account for machcpu.
#
$(BUILD_NEW_CTF_TOOLS)CTFCVTFLAGS += -X