Merge commit 'f864f99efe57685e1762590c1a880dd16bca6da9' into merges
[unleashed.git] / usr / src / uts / Makefile.uts
blob36960d078205bf8d21e81bf95a75ff08e87bfe07
2 # CDDL HEADER START
4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
19 # CDDL HEADER END
23 # Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
24 # Copyright (c) 2011 Bayard G. Bell. All rights reserved.
25 # Copyright (c) 2011 by Delphix. All rights reserved.
26 # Copyright (c) 2013 Andrew Stormont.  All rights reserved.
27 # Copyright 2016 Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
31 #       This Makefile contains the common targets and definitions for
32 #       all kernels. It is to be included in the Makefiles for specific
33 #       implementation architectures and processor architecture dependent
34 #       modules: i.e.: all driving kernel Makefiles.
36 #       Include global definitions:
38 include $(SRC)/Makefile.master
41 #       No text domain in the kernel.
43 DTEXTDOM =
46 #       Keep references to $(SRC)/common relative.
47 COMMONBASE=     $(UTSBASE)/../common
50 #       Setup build-specific vars
51 #       To add a build type:
52 #               add name to ALL_BUILDS32 & ALL_BUILDS64
53 #               set CLASS_name and OBJ_DIR_name
54 #               add targets to Makefile.targ
58 #       DEF_BUILDS is for def,  sischeck, and install
59 #       ALL_BUILDS is for everything else (all, clean, ...)
61 # The NOT_RELEASE_BUILD noise is to maintain compatibility with the
62 # gatekeeper's nightly build script.
64 DEF_BUILDS64                            = obj64
65 DEF_BUILDSONLY64                        = obj64
66 $(NOT_RELEASE_BUILD)DEF_BUILDS64        = debug64
67 $(NOT_RELEASE_BUILD)DEF_BUILDSONLY64    = debug64
68 ALL_BUILDS64                            = obj64 debug64
69 ALL_BUILDSONLY64                        = obj64 debug64
72 #       Build class (64b)
74 CLASS_OBJ64     = 64
75 CLASS_DBG64     = 64
76 CLASS           = $(CLASS_$(BUILD_TYPE))
79 #       Build subdirectory
81 OBJS_DIR_OBJ64  = obj64
82 OBJS_DIR_DBG64  = debug64
83 OBJS_DIR        = $(OBJS_DIR_$(BUILD_TYPE))
86 #       Create defaults so empty rules don't
87 #       confuse make
89 CLASS_          = 64
90 OBJS_DIR_       = debug64
93 #       Build tools
95 CC_sparc_32     = $(sparc_CC)
96 CC_sparc_64     = $(sparcv9_CC)
98 CC_i386_32      = $(i386_CC)
99 CC_i386_64      = $(amd64_CC)
100 CC_amd64_64     = $(amd64_CC)
102 CC              = $(CC_$(MACH)_$(CLASS))
104 AS_sparc_32     = $(sparc_AS)
105 AS_sparc_64     = $(sparcv9_AS)
107 AS_i386_32      = $(i386_AS)
108 AS_i386_64      = $(amd64_AS)
109 AS_amd64_64     = $(amd64_AS)
111 AS              = $(AS_$(MACH)_$(CLASS))
113 LD_sparc_32     = $(sparc_LD)
114 LD_sparc_64     = $(sparcv9_LD)
116 LD_i386_32      = $(i386_LD)
117 LD_i386_64      = $(amd64_LD)
118 LD_amd64_64     = $(amd64_LD)
120 LD              = $(LD_$(MACH)_$(CLASS))
122 MODEL_32        = ilp32
123 MODEL_64        = lp64
124 MODEL           = $(MODEL_$(CLASS))
127 #       Build the compile/assemble lines:
129 EXTRA_OPTIONS           = 
130 AS_DEFS                 = -D_ASM
132 ALWAYS_DEFS_32          = -D_KERNEL -D_SYSCALL32 -D_DDI_STRICT -D__UNLEASHED_VISIBLE
133 ALWAYS_DEFS_64          = -D_KERNEL -D_SYSCALL32 -D_SYSCALL32_IMPL -D_ELF64 \
134                         -D_DDI_STRICT -D__UNLEASHED_VISIBLE
136 # XX64  This should be defined by the compiler!
138 ALWAYS_DEFS_64          += -Dsun -D__sun -D__SVR4
139 ALWAYS_DEFS             = $(ALWAYS_DEFS_$(CLASS))
142 #       CPPFLAGS is deliberatly set with a "=" and not a "+=".  For the kernel
143 #       the header include path should not look for header files outside of
144 #       the kernel code.  This "=" removes the search path built in
145 #       Makefile.master inside CPPFLAGS.  Ditto for AS_CPPFLAGS.
147 CPPFLAGS        = $(ALWAYS_DEFS) $(ALL_DEFS) $(CONFIG_DEFS) \
148                    $(INCLUDE_PATH) $(EXTRA_OPTIONS)
149 AS_CPPFLAGS     = $(ALWAYS_DEFS) $(ALL_DEFS) $(CONFIG_DEFS) $(AS_DEFS) \
150                    $(AS_INC_PATH) $(EXTRA_OPTIONS)
153 #       Make it (relatively) easy to share compilation options between
154 #       all kernel implementations.
157 # Override the default, the kernel is squeaky clean
158 CERRWARN = -Wall -Wextra -Werror
160 CERRWARN += -Wno-missing-braces
161 CERRWARN += -Wno-sign-compare
162 CERRWARN += -Wno-unknown-pragmas
163 CERRWARN += -Wno-unused-parameter
164 CERRWARN += -Wno-missing-field-initializers
166 # DEBUG v. -nd make for frequent unused variables, empty conditions, etc. in
167 # -nd builds
168 $(RELEASE_BUILD)CERRWARN += -Wno-unused
169 $(RELEASE_BUILD)CERRWARN += -Wno-empty-body
171 C99MODE = $(C99_ENABLE)
173 CFLAGS_uts              =
174 CFLAGS_uts              += $(STAND_FLAGS_$(CLASS))
175 CFLAGS_uts              += $(XAOPT)
176 CFLAGS_uts              += $(CTF_FLAGS_$(CLASS))
177 CFLAGS_uts              += $(CERRWARN)
178 CFLAGS_uts              += $(CCNOAUTOINLINE)
179 CFLAGS_uts              += $(EXTRA_CFLAGS)
180 CFLAGS_uts              += $(CSOURCEDEBUGFLAGS)
181 CFLAGS_uts              += $(CUSERFLAGS)
184 #       Declare that $(OBJECTS) can be compiled in parallel.
185 #       The DUMMY target is for those instances where OBJECTS
186 #       are empty (to avoid an unconditional .PARALLEL).
187 .PARALLEL:      $(OBJECTS) DUMMY
190 #       Expanded dependencies
192 DEF_DEPS        = $(DEF_BUILDS:%=def.%)
193 ALL_DEPS        = $(ALL_BUILDS:%=all.%)
194 CLEAN_DEPS      = $(ALL_BUILDS:%=clean.%)
195 CLOBBER_DEPS    = $(ALL_BUILDS:%=clobber.%)
196 MODLIST_DEPS    = $(DEF_BUILDS:%=modlist.%)
197 INSTALL_DEPS    = $(DEF_BUILDS:%=install.%)
198 SYM_DEPS        = $(SYM_BUILDS:%=symcheck.%)
199 SISCHECK_DEPS   = $(DEF_BUILDS:%=sischeck.%)
200 SISCLEAN_DEPS   = $(ALL_BUILDS:%=sisclean.%)
203 #       Default module name
205 BINARY          = $(OBJS_DIR)/$(MODULE)
208 #       Default cleanup definitions
210 CLEANFILES      = $(OBJECTS)
211 CLOBBERFILES    = $(BINARY) $(CLEANFILES)
214 #       Installation constants:
216 #               FILEMODE is the mode given to the kernel modules
217 #               CFILEMODE is the mode given to the '.conf' files
219 FILEMODE         = 755
220 DIRMODE          = 755
221 CFILEMODE        = 644
224 #       Special Installation Macros for the installation of '.conf' files.
226 #       These are unique because they are not installed from the current
227 #       working directory.
229 CONFFILE                = $(MODULE).conf
230 SRC_CONFFILE            = $(CONF_SRCDIR)/$(CONFFILE)
231 ROOT_CONFFILE_32        = $(ROOTMODULE).conf
232 ROOT_CONFFILE_64        = $(ROOTMODULE:%/$(SUBDIR64)/$(MODULE)=%/$(MODULE)).conf
233 ROOT_CONFFILE           = $(ROOT_CONFFILE_$(CLASS))
236 INS.conffile= \
237         $(INS) -m $(CFILEMODE) $(SRC_CONFFILE) $(@D)/
239 CTFMERGE_MODULE=        $(CTFMERGE) $(CTFMRGFLAGS) -L VERSION -o $@ $(OBJECTS) \
240     $(CTFEXTRAOBJS)
243 # Rule for building fake shared libraries used for symbol resolution
244 # when building other modules.  -znoreloc is needed here to avoid
245 # tripping over code that isn't really suitable for shared libraries.
247 BUILD.SO                = \
248         $(LD) -o $@ -G $(ZNORELOC) -h $(SONAME)
251 # SONAME defaults for common fake shared libraries.
253 $(LIBGEN)               := SONAME = $(MODULE)
254 $(PLATLIB)              := SONAME = misc/platmod
255 $(CPULIB)               := SONAME = 'cpu/$$CPU'
256 $(DTRACESTUBS)          := SONAME = dtracestubs
259 #       Installation directories
263 #       For now, 64b modules install into a subdirectory
264 #       of their 32b brethren.
266 SUBDIR64_sparc          = sparcv9
267 SUBDIR64_i386           = amd64
268 SUBDIR64                = $(SUBDIR64_$(MACH))
270 ROOT_MOD_DIR            = $(ROOT)/kernel
272 ROOT_KERN_DIR           = $(ROOT_MOD_DIR)
273 ROOT_BRAND_DIR          = $(ROOT_MOD_DIR)/brand
274 ROOT_DRV_DIR            = $(ROOT_MOD_DIR)/drv
275 ROOT_DTRACE_DIR         = $(ROOT_MOD_DIR)/dtrace
276 ROOT_EXEC_DIR           = $(ROOT_MOD_DIR)/exec
277 ROOT_FS_DIR             = $(ROOT_MOD_DIR)/fs
278 ROOT_SCHED_DIR          = $(ROOT_MOD_DIR)/sched
279 ROOT_SOCK_DIR           = $(ROOT_MOD_DIR)/socketmod
280 ROOT_STRMOD_DIR         = $(ROOT_MOD_DIR)/strmod
281 ROOT_IPP_DIR            = $(ROOT_MOD_DIR)/ipp
282 ROOT_SYS_DIR            = $(ROOT_MOD_DIR)/sys
283 ROOT_MISC_DIR           = $(ROOT_MOD_DIR)/misc
284 ROOT_KGSS_DIR           = $(ROOT_MOD_DIR)/misc/kgss
285 ROOT_SCSI_VHCI_DIR      = $(ROOT_MOD_DIR)/misc/scsi_vhci
286 ROOT_PMCS_FW_DIR        = $(ROOT_MOD_DIR)/misc/pmcs
287 ROOT_QLC_FW_DIR         = $(ROOT_MOD_DIR)/misc/qlc
288 ROOT_EMLXS_FW_DIR       = $(ROOT_MOD_DIR)/misc/emlxs
289 ROOT_NLMISC_DIR         = $(ROOT_MOD_DIR)/misc
290 ROOT_MACH_DIR           = $(ROOT_MOD_DIR)/mach
291 ROOT_CPU_DIR            = $(ROOT_MOD_DIR)/cpu
292 ROOT_TOD_DIR            = $(ROOT_MOD_DIR)/tod
293 ROOT_FONT_DIR           = $(ROOT_MOD_DIR)/fonts
294 ROOT_DACF_DIR           = $(ROOT_MOD_DIR)/dacf
295 ROOT_CRYPTO_DIR         = $(ROOT_MOD_DIR)/crypto
296 ROOT_MAC_DIR            = $(ROOT_MOD_DIR)/mac
297 ROOT_KICONV_DIR         = $(ROOT_MOD_DIR)/kiconv
298 ROOT_FIRMWARE_DIR       = $(ROOT_MOD_DIR)/firmware
300 ROOT_MOD_DIRS           = $(ROOT_BRAND_DIR) $(ROOT_DRV_DIR)
301 ROOT_MOD_DIRS           += $(ROOT_EXEC_DIR) $(ROOT_DTRACE_DIR)
302 ROOT_MOD_DIRS           += $(ROOT_FS_DIR) $(ROOT_SCHED_DIR)
303 ROOT_MOD_DIRS           += $(ROOT_STRMOD_DIR) $(ROOT_SYS_DIR)
304 ROOT_MOD_DIRS           += $(ROOT_IPP_DIR) $(ROOT_SOCK_DIR)
305 ROOT_MOD_DIRS           += $(ROOT_MISC_DIR) $(ROOT_MACH_DIR)
306 ROOT_MOD_DIRS           += $(ROOT_KGSS_DIR)
307 ROOT_MOD_DIRS           += $(ROOT_SCSI_VHCI_DIR)
308 ROOT_MOD_DIRS           += $(ROOT_PMCS_FW_DIR)
309 ROOT_MOD_DIRS           += $(ROOT_QLC_FW_DIR)
310 ROOT_MOD_DIRS           += $(ROOT_EMLXS_FW_DIR)
311 ROOT_MOD_DIRS           += $(ROOT_CPU_DIR) $(ROOT_FONT_DIR)
312 ROOT_MOD_DIRS           += $(ROOT_TOD_DIR) $(ROOT_DACF_DIR)
313 ROOT_MOD_DIRS           += $(ROOT_CRYPTO_DIR) $(ROOT_MAC_DIR)
314 ROOT_MOD_DIRS           += $(ROOT_KICONV_DIR)
315 ROOT_MOD_DIRS           += $(ROOT_FIRMWARE_DIR)
317 USR_MOD_DIR             = $(ROOT)/usr/kernel
319 USR_DRV_DIR             = $(USR_MOD_DIR)/drv
320 USR_EXEC_DIR            = $(USR_MOD_DIR)/exec
321 USR_FS_DIR              = $(USR_MOD_DIR)/fs
322 USR_SCHED_DIR           = $(USR_MOD_DIR)/sched
323 USR_SOCK_DIR            = $(USR_MOD_DIR)/socketmod
324 USR_STRMOD_DIR          = $(USR_MOD_DIR)/strmod
325 USR_SYS_DIR             = $(USR_MOD_DIR)/sys
326 USR_MISC_DIR            = $(USR_MOD_DIR)/misc
327 USR_DACF_DIR            = $(USR_MOD_DIR)/dacf
328 USR_PCBE_DIR            = $(USR_MOD_DIR)/pcbe
329 USR_DTRACE_DIR          = $(USR_MOD_DIR)/dtrace
330 USR_BRAND_DIR           = $(USR_MOD_DIR)/brand
332 USR_MOD_DIRS            = $(USR_DRV_DIR) $(USR_EXEC_DIR)
333 USR_MOD_DIRS            += $(USR_FS_DIR) $(USR_SCHED_DIR)
334 USR_MOD_DIRS            += $(USR_STRMOD_DIR) $(USR_SYS_DIR)
335 USR_MOD_DIRS            += $(USR_MISC_DIR) $(USR_DACF_DIR)
336 USR_MOD_DIRS            += $(USR_PCBE_DIR)
337 USR_MOD_DIRS            += $(USR_DTRACE_DIR) $(USR_BRAND_DIR)
338 USR_MOD_DIRS            += $(USR_SOCK_DIR)
343 include $(SRC)/Makefile.psm
346 #       The "-r" on the remove may be considered temporary, but is required
347 #       while the replacement of the SUNW,SPARCstation-10,SX directory by
348 #       a symbolic link is being propagated.
350 INS.slink1= $(RM) -r $@; $(SYMLINK) $(PLATFORM) $@
351 INS.slink2= $(RM) -r $@; $(SYMLINK) ../$(PLATFORM)/$(@F) $@
352 INS.slink3= $(RM) -r $@; $(SYMLINK) $(IMPLEMENTED_PLATFORM) $@
353 INS.slink4= $(RM) -r $@; $(SYMLINK) ../$(PLATFORM)/include $@
354 INS.slink5= $(RM) -r $@; $(SYMLINK) ../$(PLATFORM)/sbin $@
355 INS.slink6= $(RM) -r $@; $(SYMLINK) ../../$(PLATFORM)/lib/$(MODULE) $@
356 INS.slink7= $(RM) -r $@; $(SYMLINK) ../../$(PLATFORM)/sbin/$(@F) $@
358 ROOT_PLAT_LINKS          = $(PLAT_LINKS:%=$(ROOT_PLAT_DIR)/%)
359 ROOT_PLAT_LINKS_2        = $(PLAT_LINKS_2:%=$(ROOT_PLAT_DIR)/%)
360 USR_PLAT_LINKS           = $(PLAT_LINKS:%=$(USR_PLAT_DIR)/%)
361 USR_PLAT_LINKS_2         = $(PLAT_LINKS_2:%=$(USR_PLAT_DIR)/%)
364 # Collection of all relevant, delivered kernel modules.
366 # Note that we insist on building genunix first.  When doing a 'make' from
367 # usr/src/uts/, we'll enter the platform directories first.  These will cd
368 # into the corresponding genunix directory and build it.  So genunix
369 # /shouldn't/ get rebuilt when we get to building all the kernel modules.
370 # However, due to an as-yet-unexplained problem with dependencies, sometimes
371 # it does get rebuilt.  So we always force the issue here rather than try to
372 # build genunix in parallel with everything else.
374 PARALLEL_KMODS = $(DRV_KMODS) $(EXEC_KMODS) $(FS_KMODS) \
375                  $(TOD_KMODS) $(STRMOD_KMODS) $(SYS_KMODS) $(MISC_KMODS) \
376                  $(NLMISC_KMODS) $(MACH_KMODS) $(CPU_KMODS) $(GSS_KMODS) \
377                  $(MMU_KMODS) $(DACF_KMODS) $(EXPORT_KMODS) $(IPP_KMODS) \
378                  $(CRYPTO_KMODS) $(PCBE_KMODS) \
379                  $(DRV_KMODS_$(CLASS)) $(MISC_KMODS_$(CLASS)) $(MAC_KMODS) \
380                  $(BRAND_KMODS) $(KICONV_KMODS)
382 KMODS = $(GENUNIX_KMODS) $(PARALLEL_KMODS)
384 $(PARALLEL_KMODS): $(GENUNIX_KMODS)
387 #       Files to be compiled with -xa, to generate basic block execution
388 #       count data.
390 #       There are several ways to compile parts of the kernel for kcov:
391 #               1)  Add targets to BB_FILES here or in other Makefiles
392 #                       (they must in the form of $(OBJS_DIR)/target.o)
393 #               2)  setenv BB_FILES '$(XXX_OBJS:%=$(OBJS_DIR)/%)'
394 #               3)  setenv BB_FILES '$(OBJECTS)'
396 #       Do NOT setenv CFLAGS -xa, as that will cause infinite recursion
397 #       in unix_bb.o
399 BB_FILES =
400 $(BB_FILES)     := XAOPT = -xa
403 #       The idea here is for unix_bb.o to be in all kernels except the
404 #       kernel which actually gets shipped to customers.  In practice,
405 #       $(RELEASE_BUILD) is on for a number of the late beta and fcs builds.
407 $(NOT_RELEASE_BUILD)$(OBJS_DIR)/unix_bb.o   := CPPFLAGS     += -DKCOV
408 $(NOT_RELEASE_BUILD)$(OBJS_DIR)/unix_bb.ln  := CPPFLAGS     += -DKCOV
411 #       Do not let unix_bb.o get compiled with -xa!
413 $(OBJS_DIR)/unix_bb.o   := XAOPT =
416 # Privilege files
418 PRIVS_AWK = $(SRCTOP)/tools/privs.awk
419 PRIVS_DEF = $(SRCTOP)/kernel/os/priv_defs
422 # USB device data
424 USBDEVS_AWK =   $(SRCTOP)/tools/usbdevs2h.awk
425 USBDEVS_DATA =  $(SRCTOP)/kernel/drivers/usb/usbdevs
429 # We need to make sure that we are building with the private -X option to
430 # ctfconvert which allows us to fixup the struct cpu to account for machcpu.
432 CTFCVTFLAGS += -X
434 INC_PATH += -I${SRCTOP}/include