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]
22 # Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
23 # Copyright 2014 Garrett D'Amore <garrett@damore.org>
24 # Copyright 2016 Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
26 # This Makefiles contains the common targets and definitions for
27 # all kernels. It is to be included in the Makefiles for specific
28 # implementation architectures and processor architecture dependent
29 # modules: i.e.: all driving kernel Makefiles.
33 # Default rule for building the lint library directory:
36 -@mkdir -p $@ 2> /dev/null
39 # All C objects depend on inline files. However, cc(1) doesn't generate
40 # the correct dependency info. Also, these Makefiles don't contain a
41 # separate list of C-derived object files (but it is light weight to
42 # let the assembler files think they depend upon this when they don't).
43 # Fortunately, the inline files won't change very often. So, for now,
44 # all objects depend on the inline files. Remove this when the inliner
45 # is fixed to drop correct dependency information.
47 $(OBJECTS): $(INLINES)
50 # Partially link .o files to generate the kmod. The fake dependency
51 # on modstubs simplifies things...
54 $(LD) -r $(LDFLAGS) -o $@ $(OBJECTS)
55 $(CTFMERGE_UNIQUIFY_AGAINST_GENUNIX)
59 # This target checks each kmod for undefined entry points. It does not
60 # modify the kmod in any way.
63 @BUILD_TYPE=DBG32 $(MAKE) $(MODULE).check.targ
65 $(MODULE).check.targ: $(BINARY) $(OBJECTS) $(EXTRA_CHECK_OBJS) $(UNIX_O) $(MODSTUBS_O) $(GENLIB)
66 $(LD) -o /dev/null $(OBJECTS) $(EXTRA_CHECK_OBJS) $(UNIX_O) $(MODSTUBS_O) $(GENLIB)
69 # Module lint library construction targets.
71 MOD_LINT_LIB = $(LINT_LIB_DIR)/llib-l$(LINT_MODULE).ln
73 $(MOD_LINT_LIB): $(LINT_LIB_DIR) $(LINTS)
74 @-$(ECHO) "\n$(OBJS_DIR)/$(MODULE): (library construction):"
75 @($(LINT) -o $(LINT_MODULE)-$(OBJS_DIR) \
76 $(LINTFLAGS) $(LINTS) $(LTAIL))
77 @$(MV) llib-l$(LINT_MODULE)-$(OBJS_DIR).ln $@
79 $(LINT_MODULE).lint: $(MOD_LINT_LIB) $(LINT_LIB) $(GEN_LINT_LIB)
80 @-$(ECHO) "\n$(OBJS_DIR)/$(LINT_MODULE): global crosschecks:"
81 @($(LINT) $(LINTFLAGS) $(MOD_LINT_LIB) \
82 $(LINT_LIB) $(GEN_LINT_LIB) $(LTAIL))
85 # Since assym.h is a derived file, the dependency must be explicit for
86 # all files including this file. (This is only actually required in the
87 # instance when the .nse_depinfo file does not exist.) It may seem that
88 # the lint targets should also have a similar dependency, but they don't
89 # since only C headers are included when #defined(lint) is true. The
90 # actual lists are defined in */Makefile.files.
92 $(ASSYM_DEPS:%=$(OBJS_DIR)/%): $(DSF_DIR)/$(OBJS_DIR)/assym.h
95 # Everybody need to know how to create a modstubs.o built with the
96 # appropriate flags and located in the appropriate location.
98 $(MODSTUBS_O): $(MODSTUBS)
99 $(COMPILE.s) -o $@ $(MODSTUBS)
101 $(LINTS_DIR)/modstubs.ln: $(MODSTUBS)
102 @($(LHEAD) $(LINT.s) $(MODSTUBS) $(LTAIL))
105 # Build the source file which contains the kernel's utsname,
106 # with release, version and machine set as follows:
108 # release: contents of $(RELEASE) (Spaces replaced by '_')
109 # version: contents of $(PATCHID) (Spaces replaced by '_')
110 # machine: contents of $(UNAME_M)
112 # Build environment information is only contained in the comment section.
115 $(OBJS_DIR)/vers.o: $(OBJECTS)
116 $(COMPILE.c) -DUTS_RELEASE=\"`$(ECHO) $(RELEASE) | sed -e 's/ /_/g'`\" \
117 -DUTS_VERSION=\"`$(ECHO) $(PATCHID) | sed -e 's/ /_/g'`\" \
118 -DUTS_PLATFORM=\"$(UNAME_M)\" -o $@ $(SRC)/uts/common/os/vers.c
122 $(LINTS_DIR)/vers.ln: $(SRC)/uts/common/os/vers.c
123 @($(LHEAD) $(LINT.c) -DUTS_RELEASE=\"\" -DUTS_VERSION=\"\" \
124 -DUTS_PLATFORM=\"\" $(SRC)/uts/common/os/vers.c $(LTAIL))
127 # Installation targets and rules:
129 $(ROOT_MOD_DIR) $(USR_MOD_DIR):
132 $(ROOT_MOD_DIRS_32): $(ROOT_MOD_DIR)
135 $(USR_MOD_DIRS_32): $(USR_MOD_DIR)
138 $(ROOT_MOD_DIR)/%: $(OBJS_DIR)/% $(ROOT_MOD_DIR) FRC
141 $(ROOT_CPU_DIR)/%: $(OBJS_DIR)/% $(ROOT_CPU_DIR) FRC
144 $(ROOT_DRV_DIR)/%: $(OBJS_DIR)/% $(ROOT_DRV_DIR) FRC
147 $(ROOT_DTRACE_DIR)/%: $(OBJS_DIR)/% $(ROOT_DTRACE_DIR) FRC
150 $(ROOT_EXEC_DIR)/%: $(OBJS_DIR)/% $(ROOT_EXEC_DIR) FRC
153 $(ROOT_FS_DIR)/%: $(OBJS_DIR)/% $(ROOT_FS_DIR) FRC
156 $(ROOT_SCHED_DIR)/%: $(OBJS_DIR)/% $(ROOT_SCHED_DIR) FRC
159 $(ROOT_SOCK_DIR)/%: $(OBJS_DIR)/% $(ROOT_SOCK_DIR) FRC
162 $(ROOT_STRMOD_DIR)/%: $(OBJS_DIR)/% $(ROOT_STRMOD_DIR) FRC
165 $(ROOT_IPP_DIR)/%: $(OBJS_DIR)/% $(ROOT_IPP_DIR) FRC
168 $(ROOT_SYS_DIR)/%: $(OBJS_DIR)/% $(ROOT_SYS_DIR) FRC
171 $(ROOT_MISC_DIR)/%: $(OBJS_DIR)/% $(ROOT_MISC_DIR) FRC
174 $(ROOT_DACF_DIR)/%: $(OBJS_DIR)/% $(ROOT_DACF_DIR) FRC
177 $(ROOT_BRAND_DIR)/%: $(OBJS_DIR)/% $(ROOT_BRAND_DIR) FRC
180 $(ROOT_CRYPTO_DIR)/%: $(OBJS_DIR)/% $(ROOT_CRYPTO_DIR) FRC
183 $(ROOT_KGSS_DIR)/%: $(OBJS_DIR)/% $(ROOT_KGSS_DIR) FRC
186 $(ROOT_SCSI_VHCI_DIR)/%: $(OBJS_DIR)/% $(ROOT_SCSI_VHCI_DIR) FRC
189 $(ROOT_PMCS_FW_DIR)/%: $(OBJS_DIR)/% $(ROOT_PMCS_FW_DIR) FRC
192 $(ROOT_QLC_FW_DIR)/%: $(OBJS_DIR)/% $(ROOT_QLC_FW_DIR) FRC
195 $(ROOT_EMLXS_FW_DIR)/%: $(OBJS_DIR)/% $(ROOT_EMLXS_FW_DIR) FRC
198 $(ROOT_MACH_DIR)/%: $(OBJS_DIR)/% $(ROOT_MACH_DIR) FRC
201 $(ROOT_FONT_DIR)/%: $(OBJS_DIR)/% $(ROOT_MOD_DIR) $(ROOT_FONT_DIR) FRC
204 $(ROOT_MAC_DIR)/%: $(OBJS_DIR)/% $(ROOT_MOD_DIR) $(ROOT_MAC_DIR) FRC
207 $(USR_DRV_DIR)/%: $(OBJS_DIR)/% $(USR_DRV_DIR) FRC
210 $(USR_EXEC_DIR)/%: $(OBJS_DIR)/% $(USR_EXEC_DIR) FRC
213 $(USR_FS_DIR)/%: $(OBJS_DIR)/% $(USR_FS_DIR) FRC
216 $(USR_SCHED_DIR)/%: $(OBJS_DIR)/% $(USR_SCHED_DIR) FRC
219 $(USR_SOCK_DIR)/%: $(OBJS_DIR)/% $(USR_SOCK_DIR) FRC
222 $(USR_STRMOD_DIR)/%: $(OBJS_DIR)/% $(USR_STRMOD_DIR) FRC
225 $(USR_SYS_DIR)/%: $(OBJS_DIR)/% $(USR_SYS_DIR) FRC
228 $(USR_MISC_DIR)/%: $(OBJS_DIR)/% $(USR_MISC_DIR) FRC
231 $(USR_DACF_DIR)/%: $(OBJS_DIR)/% $(USR_DACF_DIR) FRC
234 $(USR_PCBE_DIR)/%: $(OBJS_DIR)/% $(USR_PCBE_DIR) FRC
237 $(USR_DTRACE_DIR)/%: $(OBJS_DIR)/% $(USR_DTRACE_DIR) FRC
240 $(USR_BRAND_DIR)/%: $(OBJS_DIR)/% $(USR_BRAND_DIR) FRC
243 $(ROOT_KICONV_DIR)/%: $(OBJS_DIR)/% $(ROOT_KICONV_DIR) FRC
246 $(ROOT_FIRMWARE_DIR)/$(MODULE):
249 $(ROOT_FIRMWARE_DIR)/$(MODULE)/%:= FILEMODE = $(CFILEMODE)
251 $(ROOT_FIRMWARE_DIR)/$(MODULE)/%: $(ROOT_FIRMWARE_DIR)/$(MODULE) $(FWDIR)/%
254 include $(SRC)/Makefile.psm.targ
257 # Target for 64b modules
262 $(ROOT_KERN_DIR_64)/%: $(OBJS_DIR)/% $(ROOT_KERN_DIR_64) FRC
269 # Targets for '.conf' file installation.
271 $(ROOT_CONFFILE): $(SRC_CONFFILE) $(ROOT_CONFFILE:%/$(CONFFILE)=%)
275 # Targets for creating links between common platforms. ROOT_PLAT_LINKS
276 # are are the /platform level while ROOT_PLAT_LINKS_2 are one level
277 # down (/platform/`uname -i`/{lib|sbin|kernel}.
282 $(ROOT_PLAT_LINKS_2):
292 # multiple builds support
294 def $(DEF_DEPS) := TARGET = def
295 all $(ALL_DEPS) := TARGET = all
296 clean $(CLEAN_DEPS) := TARGET = clean
297 clobber $(CLOBBER_DEPS) := TARGET = clobber
298 lint $(LINT_DEPS) := TARGET = lint
299 modlintlib $(MODLINTLIB_DEPS) := TARGET = modlintlib
300 modlist $(MODLIST_DEPS) := TARGET = modlist
301 modlist $(MODLIST_DEPS) := NO_STATE= -K $$MODSTATE$$$$
302 clean.lint $(CLEAN_LINT_DEPS) := TARGET = clean.lint
303 install $(INSTALL_DEPS) := TARGET = install
304 symcheck $(SYM_DEPS) := TARGET = symcheck
306 ALL_TARGS = def all clean clobber lint modlintlib \
307 clean.lint lintlib install symcheck
309 ALL_OBJ32 = $(ALL_TARGS:%=%.obj32)
312 @BUILD_TYPE=OBJ32 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
314 ALL_DEBUG32 = $(ALL_TARGS:%=%.debug32)
317 @BUILD_TYPE=DBG32 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
319 ALL_OBJ64 = $(ALL_TARGS:%=%.obj64)
322 @BUILD_TYPE=OBJ64 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
324 ALL_DEBUG64 = $(ALL_TARGS:%=%.debug64)
327 @BUILD_TYPE=DBG64 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
330 # Currently only the IP module needs symbol checking on obj64.
331 # Other modules have the same global-objs nm output for debug64 and obj64.
333 $(SISCHECK_DEPS): $(DEF_DEPS)
334 @TARG=`$(ECHO) $@ | $(CUT) -d'.' -f2`; \
335 MODSYMS=$(MODULE).symbols.$$TARG; \
336 if [ -f "$(MODULE).global-objs.$$TARG" ]; then \
337 $(GREP) -v '#' $(MODULE).global-objs.$$TARG |$(GREP) . | \
338 $(SORT) -u > $$MODSYMS.tmp; \
339 $(NM) $$TARG/$(MODULE) |$(GREP) OBJT |$(GREP) -v UNDEF | \
340 $(CUT) -d'|' -f8 |$(GREP) -v '^___const_' | \
341 $(GREP) -v '\.[0-9]*$$' |$(SORT) -u \
342 > $$MODSYMS.tmp.new; \
343 $(DIFF) $$MODSYMS.tmp $$MODSYMS.tmp.new > $$MODSYMS.diff || \
344 ($(ECHO) "warning: $(MODULE) symbol checking:" \
345 "global variable(s) introduced and/or removed."; \
346 $(CAT) $$MODSYMS.diff; exit 1) \
350 -TARG=`$(ECHO) $@ | $(CUT) -d'.' -f2`; \
351 MODSYMS=$(MODULE).symbols.$$TARG; \
352 $(RM) $$MODSYMS.tmp $$MODSYMS.tmp.new $$MODSYMS.diff Nothing_to_remove
356 -@mkdir -p $@ 2> /dev/null
358 def.targ: $(OBJS_DIR) $(ALL_TARGET)
360 all.targ: $(OBJS_DIR) $(ALL_TARGET)
362 lint.targ: $(OBJS_DIR) $(LINT_TARGET)
364 modlintlib.targ: $(OBJS_DIR) $(MOD_LINT_LIB)
366 install.targ: $(OBJS_DIR) $(INSTALL_TARGET)
369 # Support for Install.sh.
372 modlist: $(MODLIST_DEPS)
374 # paths relative to $(ROOT).
375 RELMODULE = $(ROOTMODULE:$(ROOT)/%=%)
376 RELCONF = $(ROOT_CONFFILE:$(ROOT)/%=%)
377 RELLINK = $(ROOTLINK:$(ROOT)/%=%)
378 RELUNIX = $(UNIX32_LINK:$(ROOT)/%=%)
379 RELSOFTLINKS = $(ROOTSOFTLINKS:$(ROOT)/%=%)
384 # Generate module information for Install.sh, i.e., specify what files
385 # Install.sh should include. Each line looks like
386 # <tag> <srcdir> <arg1> <arg2> ...
387 # where <tag> specifies the type of file, <srcdir> gives the source
388 # path (useful if there is an error), and <argN> is one or more
389 # additional bits of information that Install.sh needs (e.g., source
390 # directory, install directory, filtering tags). See Install.sh for
391 # details on the arguments for each tag type, especially the functions
392 # copymod, filtmod, and filtimpl.
394 # Changes to this target may require corresponding changes to
397 # Don't issue a MOD entry if it's not in the install list.
404 [ -n "$(RELMODULE)" ] && relmodule=`dirname $(RELMODULE)`;; \
407 [ -n "$(RELMODULE)" ] && \
408 relmodule=`dirname $(RELMODULE)`/$(SUBDIR64);; \
410 if [ -z "$(THISIMPL)" ]; then \
415 if [ -n "$(ROOTMODULE)" -a -n "$(INSTALL_TARGET)" ]; then \
416 if [ -z "$(MODULE)" ]; then \
417 module=`basename $(ROOTMODULE)`; \
421 tinstall="$(INSTALL_TARGET)"; \
422 for t in $$tinstall; do \
423 if [ "$(ROOTMODULE)" = $$t ]; then \
424 echo MOD $(MODSRC) $$module $$relmodule \
430 if [ -n "$(CONF_SRCDIR)" ]; then \
431 tinstall="$(INSTALL_TARGET)"; \
432 for t in $$tinstall; do \
433 if [ $(ROOT_CONFFILE) = $$t ]; then \
434 echo CONF $(MODSRC) $(RELCONF) \
435 $(MODSRC)/$(CONF_SRCDIR) $$impl $$module; \
440 if [ -n "$(ROOTLINK)" ]; then \
441 rellinks="$(RELLINK)"; \
442 for r in $$rellinks; do \
443 if [ $$class = 32 ]; then \
444 linkdir=`dirname $$r`; \
446 linkdir=`dirname $$r`/$(SUBDIR64); \
448 echo LINK $(MODSRC) $$relmodule $$module \
449 $$linkdir `basename $$r` $$impl; \
452 if [ -n "$(UNIX32_LINK)" ]; then \
453 echo SYMLINK $(MODSRC) $(SUBDIR64)/$(UNIX) \
454 `dirname $(RELUNIX)` unix $$impl $$module; \
456 trelsoftlinks="$(RELSOFTLINKS)"; \
457 for t in $$trelsoftlinks; do \
458 if [ $$class = 32 ]; then \
459 linkdir=`dirname $$t`; \
461 linkdir=`dirname $$t`/$(SUBDIR64); \
463 linkname=`basename $$t`; \
464 echo SYMLINK $(MODSRC) $(MODULE) $$linkdir $$linkname \
469 # Cleanliness is next to ...
472 -$(RM) $(CLEANFILES) Nothing_to_remove
475 -$(RM) $(CLOBBERFILES) Nothing_to_remove
478 -$(RM) $(CLEANLINTFILES) Nothing_to_remove
481 # Create fake lintlibs in the 64b dirs so
482 # global linting works
485 @$(ECHO) $(MODULE) fake lints
486 @for dir in $(LINT64_DIRS); do \
487 if [ ! -d $$dir ]; then mkdir $$dir; fi \
489 @for file in $(LINT64_FILES); do \
490 if [ ! -f $$file ]; then touch $$file; fi \
494 # In some places we also need to create fake lintlibs for 32b
495 # dirs so global linting works
498 @$(ECHO) $(MODULE) fake lints
499 @for dir in $(LINT32_DIRS); do \
500 if [ ! -d $$dir ]; then mkdir $$dir; fi \
502 @for file in $(LINT32_FILES); do \
503 if [ ! -f $$file ]; then touch $$file; fi \