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]
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.
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.
66 DEF_BUILDSONLY64 = obj64
67 $(NOT_RELEASE_BUILD)DEF_BUILDS32 = debug32
68 $(NOT_RELEASE_BUILD)DEF_BUILDS64 = debug64
69 $(NOT_RELEASE_BUILD)DEF_BUILDSONLY64 = debug64
70 ALL_BUILDS32 = obj32 debug32
71 ALL_BUILDS64 = obj64 debug64
72 ALL_BUILDSONLY64 = obj64 debug64
75 # Build class (32b or 64b)
81 CLASS = $(CLASS_$(BUILD_TYPE))
86 OBJS_DIR_OBJ32 = obj32
87 OBJS_DIR_DBG32 = debug32
88 OBJS_DIR_OBJ64 = obj64
89 OBJS_DIR_DBG64 = debug64
90 OBJS_DIR = $(OBJS_DIR_$(BUILD_TYPE))
93 # Create defaults so empty rules don't
102 CC_sparc_32 = $(sparc_CC)
103 CC_sparc_64 = $(sparcv9_CC)
105 CC_i386_32 = $(i386_CC)
106 CC_i386_64 = $(amd64_CC)
107 CC_amd64_64 = $(amd64_CC)
109 CC = $(CC_$(MACH)_$(CLASS))
111 AS_sparc_32 = $(sparc_AS)
112 AS_sparc_64 = $(sparcv9_AS)
114 AS_i386_32 = $(i386_AS)
115 AS_i386_64 = $(amd64_AS)
116 AS_amd64_64 = $(amd64_AS)
118 AS = $(AS_$(MACH)_$(CLASS))
120 LD_sparc_32 = $(sparc_LD)
121 LD_sparc_64 = $(sparcv9_LD)
123 LD_i386_32 = $(i386_LD)
124 LD_i386_64 = $(amd64_LD)
125 LD_amd64_64 = $(amd64_LD)
127 LD = $(LD_$(MACH)_$(CLASS))
131 MODEL = $(MODEL_$(CLASS))
134 # Build the compile/assemble lines:
139 ALWAYS_DEFS_32 = -D_KERNEL -D_SYSCALL32 -D_DDI_STRICT -D__UNLEASHED_VISIBLE
140 ALWAYS_DEFS_64 = -D_KERNEL -D_SYSCALL32 -D_SYSCALL32_IMPL -D_ELF64 \
141 -D_DDI_STRICT -D__UNLEASHED_VISIBLE
143 # XX64 This should be defined by the compiler!
145 ALWAYS_DEFS_64 += -Dsun -D__sun -D__SVR4
146 ALWAYS_DEFS = $(ALWAYS_DEFS_$(CLASS))
149 # CPPFLAGS is deliberatly set with a "=" and not a "+=". For the kernel
150 # the header include path should not look for header files outside of
151 # the kernel code. This "=" removes the search path built in
152 # Makefile.master inside CPPFLAGS. Ditto for AS_CPPFLAGS.
154 CPPFLAGS = $(ALWAYS_DEFS) $(ALL_DEFS) $(CONFIG_DEFS) \
155 $(INCLUDE_PATH) $(EXTRA_OPTIONS)
156 AS_CPPFLAGS = $(ALWAYS_DEFS) $(ALL_DEFS) $(CONFIG_DEFS) $(AS_DEFS) \
157 $(AS_INC_PATH) $(EXTRA_OPTIONS)
160 # Make it (relatively) easy to share compilation options between
161 # all kernel implementations.
164 # Override the default, the kernel is squeaky clean
165 CERRWARN = -Wall -Wextra -Werror
167 CERRWARN += -Wno-missing-braces
168 CERRWARN += -Wno-sign-compare
169 CERRWARN += -Wno-unknown-pragmas
170 CERRWARN += -Wno-unused-parameter
171 CERRWARN += -Wno-missing-field-initializers
173 # DEBUG v. -nd make for frequent unused variables, empty conditions, etc. in
175 $(RELEASE_BUILD)CERRWARN += -Wno-unused
176 $(RELEASE_BUILD)CERRWARN += -Wno-empty-body
178 C99MODE = $(C99_ENABLE)
181 CFLAGS_uts += $(STAND_FLAGS_$(CLASS))
182 CFLAGS_uts += $(XAOPT)
183 CFLAGS_uts += $(CTF_FLAGS_$(CLASS))
184 CFLAGS_uts += $(CERRWARN)
185 CFLAGS_uts += $(CCNOAUTOINLINE)
186 CFLAGS_uts += $(EXTRA_CFLAGS)
187 CFLAGS_uts += $(CSOURCEDEBUGFLAGS)
188 CFLAGS_uts += $(CUSERFLAGS)
191 # Declare that $(OBJECTS) can be compiled in parallel.
192 # The DUMMY target is for those instances where OBJECTS
193 # are empty (to avoid an unconditional .PARALLEL).
194 .PARALLEL: $(OBJECTS) DUMMY
197 # Expanded dependencies
199 DEF_DEPS = $(DEF_BUILDS:%=def.%)
200 ALL_DEPS = $(ALL_BUILDS:%=all.%)
201 CLEAN_DEPS = $(ALL_BUILDS:%=clean.%)
202 CLOBBER_DEPS = $(ALL_BUILDS:%=clobber.%)
203 MODLIST_DEPS = $(DEF_BUILDS:%=modlist.%)
204 INSTALL_DEPS = $(DEF_BUILDS:%=install.%)
205 SYM_DEPS = $(SYM_BUILDS:%=symcheck.%)
206 SISCHECK_DEPS = $(DEF_BUILDS:%=sischeck.%)
207 SISCLEAN_DEPS = $(ALL_BUILDS:%=sisclean.%)
210 # Default module name
212 BINARY = $(OBJS_DIR)/$(MODULE)
215 # Default cleanup definitions
217 CLEANFILES = $(OBJECTS)
218 CLOBBERFILES = $(BINARY) $(CLEANFILES)
221 # Installation constants:
223 # FILEMODE is the mode given to the kernel modules
224 # CFILEMODE is the mode given to the '.conf' files
231 # Special Installation Macros for the installation of '.conf' files.
233 # These are unique because they are not installed from the current
236 CONFFILE = $(MODULE).conf
237 SRC_CONFFILE = $(CONF_SRCDIR)/$(CONFFILE)
238 ROOT_CONFFILE_32 = $(ROOTMODULE).conf
239 ROOT_CONFFILE_64 = $(ROOTMODULE:%/$(SUBDIR64)/$(MODULE)=%/$(MODULE)).conf
240 ROOT_CONFFILE = $(ROOT_CONFFILE_$(CLASS))
244 $(INS) -m $(CFILEMODE) $(SRC_CONFFILE) $(@D)/
246 CTFMERGE_MODULE= $(CTFMERGE) $(CTFMRGFLAGS) -L VERSION -o $@ $(OBJECTS) \
250 # Rule for building fake shared libraries used for symbol resolution
251 # when building other modules. -znoreloc is needed here to avoid
252 # tripping over code that isn't really suitable for shared libraries.
255 $(LD) -o $@ -G $(ZNORELOC) -h $(SONAME)
258 # SONAME defaults for common fake shared libraries.
260 $(LIBGEN) := SONAME = $(MODULE)
261 $(PLATLIB) := SONAME = misc/platmod
262 $(CPULIB) := SONAME = 'cpu/$$CPU'
263 $(DTRACESTUBS) := SONAME = dtracestubs
266 # Installation directories
270 # For now, 64b modules install into a subdirectory
271 # of their 32b brethren.
273 SUBDIR64_sparc = sparcv9
274 SUBDIR64_i386 = amd64
275 SUBDIR64 = $(SUBDIR64_$(MACH))
277 ROOT_MOD_DIR = $(ROOT)/kernel
279 ROOT_KERN_DIR = $(ROOT_MOD_DIR)
280 ROOT_BRAND_DIR = $(ROOT_MOD_DIR)/brand
281 ROOT_DRV_DIR = $(ROOT_MOD_DIR)/drv
282 ROOT_DTRACE_DIR = $(ROOT_MOD_DIR)/dtrace
283 ROOT_EXEC_DIR = $(ROOT_MOD_DIR)/exec
284 ROOT_FS_DIR = $(ROOT_MOD_DIR)/fs
285 ROOT_SCHED_DIR = $(ROOT_MOD_DIR)/sched
286 ROOT_SOCK_DIR = $(ROOT_MOD_DIR)/socketmod
287 ROOT_STRMOD_DIR = $(ROOT_MOD_DIR)/strmod
288 ROOT_IPP_DIR = $(ROOT_MOD_DIR)/ipp
289 ROOT_SYS_DIR = $(ROOT_MOD_DIR)/sys
290 ROOT_MISC_DIR = $(ROOT_MOD_DIR)/misc
291 ROOT_KGSS_DIR = $(ROOT_MOD_DIR)/misc/kgss
292 ROOT_SCSI_VHCI_DIR = $(ROOT_MOD_DIR)/misc/scsi_vhci
293 ROOT_PMCS_FW_DIR = $(ROOT_MOD_DIR)/misc/pmcs
294 ROOT_QLC_FW_DIR = $(ROOT_MOD_DIR)/misc/qlc
295 ROOT_EMLXS_FW_DIR = $(ROOT_MOD_DIR)/misc/emlxs
296 ROOT_NLMISC_DIR = $(ROOT_MOD_DIR)/misc
297 ROOT_MACH_DIR = $(ROOT_MOD_DIR)/mach
298 ROOT_CPU_DIR = $(ROOT_MOD_DIR)/cpu
299 ROOT_TOD_DIR = $(ROOT_MOD_DIR)/tod
300 ROOT_FONT_DIR = $(ROOT_MOD_DIR)/fonts
301 ROOT_DACF_DIR = $(ROOT_MOD_DIR)/dacf
302 ROOT_CRYPTO_DIR = $(ROOT_MOD_DIR)/crypto
303 ROOT_MAC_DIR = $(ROOT_MOD_DIR)/mac
304 ROOT_KICONV_DIR = $(ROOT_MOD_DIR)/kiconv
305 ROOT_FIRMWARE_DIR = $(ROOT_MOD_DIR)/firmware
307 ROOT_MOD_DIRS = $(ROOT_BRAND_DIR) $(ROOT_DRV_DIR)
308 ROOT_MOD_DIRS += $(ROOT_EXEC_DIR) $(ROOT_DTRACE_DIR)
309 ROOT_MOD_DIRS += $(ROOT_FS_DIR) $(ROOT_SCHED_DIR)
310 ROOT_MOD_DIRS += $(ROOT_STRMOD_DIR) $(ROOT_SYS_DIR)
311 ROOT_MOD_DIRS += $(ROOT_IPP_DIR) $(ROOT_SOCK_DIR)
312 ROOT_MOD_DIRS += $(ROOT_MISC_DIR) $(ROOT_MACH_DIR)
313 ROOT_MOD_DIRS += $(ROOT_KGSS_DIR)
314 ROOT_MOD_DIRS += $(ROOT_SCSI_VHCI_DIR)
315 ROOT_MOD_DIRS += $(ROOT_PMCS_FW_DIR)
316 ROOT_MOD_DIRS += $(ROOT_QLC_FW_DIR)
317 ROOT_MOD_DIRS += $(ROOT_EMLXS_FW_DIR)
318 ROOT_MOD_DIRS += $(ROOT_CPU_DIR) $(ROOT_FONT_DIR)
319 ROOT_MOD_DIRS += $(ROOT_TOD_DIR) $(ROOT_DACF_DIR)
320 ROOT_MOD_DIRS += $(ROOT_CRYPTO_DIR) $(ROOT_MAC_DIR)
321 ROOT_MOD_DIRS += $(ROOT_KICONV_DIR)
322 ROOT_MOD_DIRS += $(ROOT_FIRMWARE_DIR)
324 USR_MOD_DIR = $(ROOT)/usr/kernel
326 USR_DRV_DIR = $(USR_MOD_DIR)/drv
327 USR_EXEC_DIR = $(USR_MOD_DIR)/exec
328 USR_FS_DIR = $(USR_MOD_DIR)/fs
329 USR_SCHED_DIR = $(USR_MOD_DIR)/sched
330 USR_SOCK_DIR = $(USR_MOD_DIR)/socketmod
331 USR_STRMOD_DIR = $(USR_MOD_DIR)/strmod
332 USR_SYS_DIR = $(USR_MOD_DIR)/sys
333 USR_MISC_DIR = $(USR_MOD_DIR)/misc
334 USR_DACF_DIR = $(USR_MOD_DIR)/dacf
335 USR_PCBE_DIR = $(USR_MOD_DIR)/pcbe
336 USR_DTRACE_DIR = $(USR_MOD_DIR)/dtrace
337 USR_BRAND_DIR = $(USR_MOD_DIR)/brand
339 USR_MOD_DIRS = $(USR_DRV_DIR) $(USR_EXEC_DIR)
340 USR_MOD_DIRS += $(USR_FS_DIR) $(USR_SCHED_DIR)
341 USR_MOD_DIRS += $(USR_STRMOD_DIR) $(USR_SYS_DIR)
342 USR_MOD_DIRS += $(USR_MISC_DIR) $(USR_DACF_DIR)
343 USR_MOD_DIRS += $(USR_PCBE_DIR)
344 USR_MOD_DIRS += $(USR_DTRACE_DIR) $(USR_BRAND_DIR)
345 USR_MOD_DIRS += $(USR_SOCK_DIR)
350 include $(SRC)/Makefile.psm
353 # The "-r" on the remove may be considered temporary, but is required
354 # while the replacement of the SUNW,SPARCstation-10,SX directory by
355 # a symbolic link is being propagated.
357 INS.slink1= $(RM) -r $@; $(SYMLINK) $(PLATFORM) $@
358 INS.slink2= $(RM) -r $@; $(SYMLINK) ../$(PLATFORM)/$(@F) $@
359 INS.slink3= $(RM) -r $@; $(SYMLINK) $(IMPLEMENTED_PLATFORM) $@
360 INS.slink4= $(RM) -r $@; $(SYMLINK) ../$(PLATFORM)/include $@
361 INS.slink5= $(RM) -r $@; $(SYMLINK) ../$(PLATFORM)/sbin $@
362 INS.slink6= $(RM) -r $@; $(SYMLINK) ../../$(PLATFORM)/lib/$(MODULE) $@
363 INS.slink7= $(RM) -r $@; $(SYMLINK) ../../$(PLATFORM)/sbin/$(@F) $@
365 ROOT_PLAT_LINKS = $(PLAT_LINKS:%=$(ROOT_PLAT_DIR)/%)
366 ROOT_PLAT_LINKS_2 = $(PLAT_LINKS_2:%=$(ROOT_PLAT_DIR)/%)
367 USR_PLAT_LINKS = $(PLAT_LINKS:%=$(USR_PLAT_DIR)/%)
368 USR_PLAT_LINKS_2 = $(PLAT_LINKS_2:%=$(USR_PLAT_DIR)/%)
371 # Collection of all relevant, delivered kernel modules.
373 # Note that we insist on building genunix first. When doing a 'make' from
374 # usr/src/uts/, we'll enter the platform directories first. These will cd
375 # into the corresponding genunix directory and build it. So genunix
376 # /shouldn't/ get rebuilt when we get to building all the kernel modules.
377 # However, due to an as-yet-unexplained problem with dependencies, sometimes
378 # it does get rebuilt. So we always force the issue here rather than try to
379 # build genunix in parallel with everything else.
381 PARALLEL_KMODS = $(DRV_KMODS) $(EXEC_KMODS) $(FS_KMODS) \
382 $(TOD_KMODS) $(STRMOD_KMODS) $(SYS_KMODS) $(MISC_KMODS) \
383 $(NLMISC_KMODS) $(MACH_KMODS) $(CPU_KMODS) $(GSS_KMODS) \
384 $(MMU_KMODS) $(DACF_KMODS) $(EXPORT_KMODS) $(IPP_KMODS) \
385 $(CRYPTO_KMODS) $(PCBE_KMODS) \
386 $(DRV_KMODS_$(CLASS)) $(MISC_KMODS_$(CLASS)) $(MAC_KMODS) \
387 $(BRAND_KMODS) $(KICONV_KMODS)
389 KMODS = $(GENUNIX_KMODS) $(PARALLEL_KMODS)
391 $(PARALLEL_KMODS): $(GENUNIX_KMODS)
394 # Files to be compiled with -xa, to generate basic block execution
397 # There are several ways to compile parts of the kernel for kcov:
398 # 1) Add targets to BB_FILES here or in other Makefiles
399 # (they must in the form of $(OBJS_DIR)/target.o)
400 # 2) setenv BB_FILES '$(XXX_OBJS:%=$(OBJS_DIR)/%)'
401 # 3) setenv BB_FILES '$(OBJECTS)'
403 # Do NOT setenv CFLAGS -xa, as that will cause infinite recursion
407 $(BB_FILES) := XAOPT = -xa
410 # The idea here is for unix_bb.o to be in all kernels except the
411 # kernel which actually gets shipped to customers. In practice,
412 # $(RELEASE_BUILD) is on for a number of the late beta and fcs builds.
414 $(NOT_RELEASE_BUILD)$(OBJS_DIR)/unix_bb.o := CPPFLAGS += -DKCOV
415 $(NOT_RELEASE_BUILD)$(OBJS_DIR)/unix_bb.ln := CPPFLAGS += -DKCOV
418 # Do not let unix_bb.o get compiled with -xa!
420 $(OBJS_DIR)/unix_bb.o := XAOPT =
425 PRIVS_AWK = $(SRCTOP)/tools/privs.awk
426 PRIVS_DEF = $(SRCTOP)/kernel/os/priv_defs
431 USBDEVS_AWK = $(SRCTOP)/tools/usbdevs2h.awk
432 USBDEVS_DATA = $(SRCTOP)/kernel/drivers/usb/usbdevs
436 # We need to make sure that we are building with the private -X option to
437 # ctfconvert which allows us to fixup the struct cpu to account for machcpu.
441 INC_PATH += -I${SRCTOP}/include