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.
24 # This Makefiles contains the common targets and definitions for
25 # all kernels. It is to be included in the Makefiles for specific
26 # implementation architectures and processor architecture dependent
27 # modules: i.e.: all driving kernel Makefiles.
31 # Default rule for building the lint library directory:
34 -@mkdir -p $@ 2> /dev/null
37 # All C objects depend on inline files. However, cc(1) doesn't generate
38 # the correct dependency info. Also, these Makefiles don't contain a
39 # separate list of C-derived object files (but it is light weight to
40 # let the assembler files think they depend upon this when they don't).
41 # Fortunately, the inline files won't change very often. So, for now,
42 # all objects depend on the inline files. Remove this when the inliner
43 # is fixed to drop correct dependency information.
45 $(OBJECTS): $(INLINES)
48 # Partially link .o files to generate the kmod. The fake dependency
49 # on modstubs simplifies things...
50 # ELFSIGN_MOD is defined in the individual KCF plug-in modules Makefiles,
51 # and will sign the ELF objects using elfsign(1).
54 $(LD) -r $(LDFLAGS) -o $@ $(OBJECTS)
55 $(CTFMERGE_UNIQUIFY_AGAINST_GENUNIX)
60 # This target checks each kmod for undefined entry points. It does not
61 # modify the kmod in any way.
64 @BUILD_TYPE=DBG32 $(MAKE) $(MODULE).check.targ
66 $(MODULE).check.targ: $(BINARY) $(OBJECTS) $(EXTRA_CHECK_OBJS) $(UNIX_O) $(MODSTUBS_O) $(GENLIB)
67 $(LD) -o /dev/null $(OBJECTS) $(EXTRA_CHECK_OBJS) $(UNIX_O) $(MODSTUBS_O) $(GENLIB)
70 # Module lint library construction targets.
72 MOD_LINT_LIB = $(LINT_LIB_DIR)/llib-l$(LINT_MODULE).ln
74 $(MOD_LINT_LIB): $(LINT_LIB_DIR) $(LINTS)
75 @-$(ECHO) "\n$(OBJS_DIR)/$(MODULE): (library construction):"
76 @($(LINT) -o $(LINT_MODULE)-$(OBJS_DIR) \
77 $(LINTFLAGS) $(LINTS) $(LTAIL))
78 @$(MV) llib-l$(LINT_MODULE)-$(OBJS_DIR).ln $@
80 $(LINT_MODULE).lint: $(MOD_LINT_LIB) $(LINT_LIB) $(GEN_LINT_LIB)
81 @-$(ECHO) "\n$(OBJS_DIR)/$(LINT_MODULE): global crosschecks:"
82 @($(LINT) $(LINTFLAGS) $(MOD_LINT_LIB) \
83 $(LINT_LIB) $(GEN_LINT_LIB) $(LTAIL))
86 # Since assym.h is a derived file, the dependency must be explicit for
87 # all files including this file. (This is only actually required in the
88 # instance when the .nse_depinfo file does not exist.) It may seem that
89 # the lint targets should also have a similar dependency, but they don't
90 # since only C headers are included when #defined(lint) is true. The
91 # actual lists are defined in */Makefile.files.
93 $(ASSYM_DEPS:%=$(OBJS_DIR)/%): $(DSF_DIR)/$(OBJS_DIR)/assym.h
96 # Everybody need to know how to create a modstubs.o built with the
97 # appropriate flags and located in the appropriate location.
99 $(MODSTUBS_O): $(MODSTUBS)
100 $(COMPILE.s) -o $@ $(MODSTUBS)
102 $(LINTS_DIR)/modstubs.ln: $(MODSTUBS)
103 @($(LHEAD) $(LINT.s) $(MODSTUBS) $(LTAIL))
106 # Build the source file which contains the kernel's utsname,
107 # with release, version and machine set as follows:
109 # release: contents of $(RELEASE) (Spaces replaced by '_')
110 # version: contents of $(PATCHID) (Spaces replaced by '_')
111 # machine: contents of $(UNAME_M)
113 # Build environment information is only contained in the comment section.
115 # The version string, normally the variable VERSION, is set to display
116 # environmental information temporarily while in development because
117 # it provides a little more useful information.
119 VERSION_STRING = ($(ECHO) $$LOGNAME [\`basename $$CODEMGR_WS\`] \\\c; date +%D)
120 $(INTERNAL_RELEASE_BUILD)VERSION_STRING = $(ECHO) $(PATCHID)
122 $(OBJS_DIR)/vers.o: $(OBJECTS)
123 $(COMPILE.c) -DUTS_RELEASE=\"`$(ECHO) $(RELEASE) | sed -e 's/ /_/g'`\" \
124 -DUTS_VERSION=\"`$(VERSION_STRING) | sed -e 's/ /_/g'`\" \
125 -DUTS_PLATFORM=\"$(UNAME_M)\" -o $@ $(SRC)/uts/common/os/vers.c
129 $(LINTS_DIR)/vers.ln: $(SRC)/uts/common/os/vers.c
130 @($(LHEAD) $(LINT.c) -DUTS_RELEASE=\"\" -DUTS_VERSION=\"\" \
131 -DUTS_PLATFORM=\"\" $(SRC)/uts/common/os/vers.c $(LTAIL))
134 # Installation targets and rules:
136 $(ROOT_MOD_DIR) $(USR_MOD_DIR):
139 $(ROOT_MOD_DIRS_32): $(ROOT_MOD_DIR)
142 $(USR_MOD_DIRS_32): $(USR_MOD_DIR)
145 $(ROOT_MOD_DIR)/%: $(OBJS_DIR)/% $(ROOT_MOD_DIR) FRC
148 $(ROOT_CPU_DIR)/%: $(OBJS_DIR)/% $(ROOT_CPU_DIR) FRC
151 $(ROOT_DRV_DIR)/%: $(OBJS_DIR)/% $(ROOT_DRV_DIR) FRC
154 $(ROOT_DTRACE_DIR)/%: $(OBJS_DIR)/% $(ROOT_DTRACE_DIR) FRC
157 $(ROOT_EXEC_DIR)/%: $(OBJS_DIR)/% $(ROOT_EXEC_DIR) FRC
160 $(ROOT_FS_DIR)/%: $(OBJS_DIR)/% $(ROOT_FS_DIR) FRC
163 $(ROOT_SCHED_DIR)/%: $(OBJS_DIR)/% $(ROOT_SCHED_DIR) FRC
166 $(ROOT_SOCK_DIR)/%: $(OBJS_DIR)/% $(ROOT_SOCK_DIR) FRC
169 $(ROOT_STRMOD_DIR)/%: $(OBJS_DIR)/% $(ROOT_STRMOD_DIR) FRC
172 $(ROOT_IPP_DIR)/%: $(OBJS_DIR)/% $(ROOT_IPP_DIR) FRC
175 $(ROOT_SYS_DIR)/%: $(OBJS_DIR)/% $(ROOT_SYS_DIR) FRC
178 $(ROOT_MISC_DIR)/%: $(OBJS_DIR)/% $(ROOT_MISC_DIR) FRC
181 $(ROOT_DACF_DIR)/%: $(OBJS_DIR)/% $(ROOT_DACF_DIR) FRC
184 $(ROOT_BRAND_DIR)/%: $(OBJS_DIR)/% $(ROOT_BRAND_DIR) FRC
187 $(ROOT_CRYPTO_DIR)/%: $(OBJS_DIR)/% $(ROOT_CRYPTO_DIR) FRC
190 $(ROOT_KGSS_DIR)/%: $(OBJS_DIR)/% $(ROOT_KGSS_DIR) FRC
193 $(ROOT_SCSI_VHCI_DIR)/%: $(OBJS_DIR)/% $(ROOT_SCSI_VHCI_DIR) FRC
196 $(ROOT_PMCS_FW_DIR)/%: $(OBJS_DIR)/% $(ROOT_PMCS_FW_DIR) FRC
199 $(ROOT_QLC_FW_DIR)/%: $(OBJS_DIR)/% $(ROOT_QLC_FW_DIR) FRC
202 $(ROOT_EMLXS_FW_DIR)/%: $(OBJS_DIR)/% $(ROOT_EMLXS_FW_DIR) FRC
205 $(ROOT_MACH_DIR)/%: $(OBJS_DIR)/% $(ROOT_MACH_DIR) FRC
208 $(ROOT_FONT_DIR)/%: $(OBJS_DIR)/% $(ROOT_MOD_DIR) $(ROOT_FONT_DIR) FRC
211 $(ROOT_MAC_DIR)/%: $(OBJS_DIR)/% $(ROOT_MOD_DIR) $(ROOT_MAC_DIR) FRC
214 $(USR_DRV_DIR)/%: $(OBJS_DIR)/% $(USR_DRV_DIR) FRC
217 $(USR_EXEC_DIR)/%: $(OBJS_DIR)/% $(USR_EXEC_DIR) FRC
220 $(USR_FS_DIR)/%: $(OBJS_DIR)/% $(USR_FS_DIR) FRC
223 $(USR_SCHED_DIR)/%: $(OBJS_DIR)/% $(USR_SCHED_DIR) FRC
226 $(USR_SOCK_DIR)/%: $(OBJS_DIR)/% $(USR_SOCK_DIR) FRC
229 $(USR_STRMOD_DIR)/%: $(OBJS_DIR)/% $(USR_STRMOD_DIR) FRC
232 $(USR_SYS_DIR)/%: $(OBJS_DIR)/% $(USR_SYS_DIR) FRC
235 $(USR_MISC_DIR)/%: $(OBJS_DIR)/% $(USR_MISC_DIR) FRC
238 $(USR_DACF_DIR)/%: $(OBJS_DIR)/% $(USR_DACF_DIR) FRC
241 $(USR_PCBE_DIR)/%: $(OBJS_DIR)/% $(USR_PCBE_DIR) FRC
244 $(USR_DTRACE_DIR)/%: $(OBJS_DIR)/% $(USR_DTRACE_DIR) FRC
247 $(USR_BRAND_DIR)/%: $(OBJS_DIR)/% $(USR_BRAND_DIR) FRC
250 $(ROOT_KICONV_DIR)/%: $(OBJS_DIR)/% $(ROOT_KICONV_DIR) FRC
253 include $(SRC)/Makefile.psm.targ
256 # Target for 64b modules
261 $(ROOT_KERN_DIR_64)/%: $(OBJS_DIR)/% $(ROOT_KERN_DIR_64) FRC
268 # Targets for '.conf' file installation.
270 $(ROOT_CONFFILE): $(SRC_CONFFILE) $(ROOT_CONFFILE:%/$(CONFFILE)=%)
274 # Targets for creating links between common platforms. ROOT_PLAT_LINKS
275 # are are the /platform level while ROOT_PLAT_LINKS_2 are one level
276 # down (/platform/`uname -i`/{lib|sbin|kernel}.
281 $(ROOT_PLAT_LINKS_2):
291 # multiple builds support
293 def $(DEF_DEPS) := TARGET = def
294 all $(ALL_DEPS) := TARGET = all
295 clean $(CLEAN_DEPS) := TARGET = clean
296 clobber $(CLOBBER_DEPS) := TARGET = clobber
297 lint $(LINT_DEPS) := TARGET = lint
298 modlintlib $(MODLINTLIB_DEPS) := TARGET = modlintlib
299 modlist $(MODLIST_DEPS) := TARGET = modlist
300 modlist $(MODLIST_DEPS) := NO_STATE= -K $$MODSTATE$$$$
301 clean.lint $(CLEAN_LINT_DEPS) := TARGET = clean.lint
302 install $(INSTALL_DEPS) := TARGET = install
303 symcheck $(SYM_DEPS) := TARGET = symcheck
305 ALL_TARGS = def all clean clobber lint modlintlib \
306 clean.lint lintlib install symcheck
308 ALL_OBJ32 = $(ALL_TARGS:%=%.obj32)
311 @BUILD_TYPE=OBJ32 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
313 ALL_DEBUG32 = $(ALL_TARGS:%=%.debug32)
316 @BUILD_TYPE=DBG32 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
318 ALL_OBJ64 = $(ALL_TARGS:%=%.obj64)
321 @BUILD_TYPE=OBJ64 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
323 ALL_DEBUG64 = $(ALL_TARGS:%=%.debug64)
326 @BUILD_TYPE=DBG64 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
329 # Currently only the IP module needs symbol checking on obj64.
330 # Other modules have the same global-objs nm output for debug64 and obj64.
332 $(SISCHECK_DEPS): $(DEF_DEPS)
333 @TARG=`$(ECHO) $@ | $(CUT) -d'.' -f2`; \
334 MODSYMS=$(MODULE).symbols.$$TARG; \
335 if [ -f "$(MODULE).global-objs.$$TARG" ]; then \
336 $(GREP) -v '#' $(MODULE).global-objs.$$TARG |$(GREP) . | \
337 $(SORT) -u > $$MODSYMS.tmp; \
338 $(NM) $$TARG/$(MODULE) |$(GREP) OBJT |$(GREP) -v UNDEF | \
339 $(CUT) -d'|' -f8 |$(GREP) -v '^___const_' | \
340 $(GREP) -v '\.[0-9]*$$' |$(SORT) -u \
341 > $$MODSYMS.tmp.new; \
342 $(DIFF) $$MODSYMS.tmp $$MODSYMS.tmp.new > $$MODSYMS.diff || \
343 ($(ECHO) "warning: $(MODULE) symbol checking:" \
344 "global variable(s) introduced and/or removed."; \
345 $(CAT) $$MODSYMS.diff; exit 1) \
349 -TARG=`$(ECHO) $@ | $(CUT) -d'.' -f2`; \
350 MODSYMS=$(MODULE).symbols.$$TARG; \
351 $(RM) $$MODSYMS.tmp $$MODSYMS.tmp.new $$MODSYMS.diff Nothing_to_remove
355 -@mkdir -p $@ 2> /dev/null
357 def.targ: $(OBJS_DIR) $(ALL_TARGET)
359 all.targ: $(OBJS_DIR) $(ALL_TARGET)
361 lint.targ: $(OBJS_DIR) $(LINT_TARGET)
363 modlintlib.targ: $(OBJS_DIR) $(MOD_LINT_LIB)
365 install.targ: $(OBJS_DIR) $(INSTALL_TARGET)
368 # Support for Install.sh.
371 modlist: $(MODLIST_DEPS)
373 # paths relative to $(ROOT).
374 RELMODULE = $(ROOTMODULE:$(ROOT)/%=%)
375 RELCONF = $(ROOT_CONFFILE:$(ROOT)/%=%)
376 RELLINK = $(ROOTLINK:$(ROOT)/%=%)
377 RELUNIX = $(UNIX32_LINK:$(ROOT)/%=%)
378 RELSOFTLINKS = $(ROOTSOFTLINKS:$(ROOT)/%=%)
383 # Generate module information for Install.sh, i.e., specify what files
384 # Install.sh should include. Each line looks like
385 # <tag> <srcdir> <arg1> <arg2> ...
386 # where <tag> specifies the type of file, <srcdir> gives the source
387 # path (useful if there is an error), and <argN> is one or more
388 # additional bits of information that Install.sh needs (e.g., source
389 # directory, install directory, filtering tags). See Install.sh for
390 # details on the arguments for each tag type, especially the functions
391 # copymod, filtmod, and filtimpl.
393 # Changes to this target may require corresponding changes to
396 # Don't issue a MOD entry if it's not in the install list.
403 [ -n "$(RELMODULE)" ] && relmodule=`dirname $(RELMODULE)`;; \
406 [ -n "$(RELMODULE)" ] && \
407 relmodule=`dirname $(RELMODULE)`/$(SUBDIR64);; \
409 if [ -z "$(THISIMPL)" ]; then \
414 if [ -n "$(ROOTMODULE)" -a -n "$(INSTALL_TARGET)" ]; then \
415 if [ -z "$(MODULE)" ]; then \
416 module=`basename $(ROOTMODULE)`; \
420 tinstall="$(INSTALL_TARGET)"; \
421 for t in $$tinstall; do \
422 if [ "$(ROOTMODULE)" = $$t ]; then \
423 echo MOD $(MODSRC) $$module $$relmodule \
429 if [ -n "$(CONF_SRCDIR)" ]; then \
430 tinstall="$(INSTALL_TARGET)"; \
431 for t in $$tinstall; do \
432 if [ $(ROOT_CONFFILE) = $$t ]; then \
433 echo CONF $(MODSRC) $(RELCONF) \
434 $(MODSRC)/$(CONF_SRCDIR) $$impl $$module; \
439 if [ -n "$(ROOTLINK)" ]; then \
440 rellinks="$(RELLINK)"; \
441 for r in $$rellinks; do \
442 if [ $$class = 32 ]; then \
443 linkdir=`dirname $$r`; \
445 linkdir=`dirname $$r`/$(SUBDIR64); \
447 echo LINK $(MODSRC) $$relmodule $$module \
448 $$linkdir `basename $$r` $$impl; \
451 if [ -n "$(UNIX32_LINK)" ]; then \
452 echo SYMLINK $(MODSRC) $(SUBDIR64)/$(UNIX) \
453 `dirname $(RELUNIX)` unix $$impl $$module; \
455 trelsoftlinks="$(RELSOFTLINKS)"; \
456 for t in $$trelsoftlinks; do \
457 if [ $$class = 32 ]; then \
458 linkdir=`dirname $$t`; \
460 linkdir=`dirname $$t`/$(SUBDIR64); \
462 linkname=`basename $$t`; \
463 echo SYMLINK $(MODSRC) $(MODULE) $$linkdir $$linkname \
468 # Cleanliness is next to ...
471 -$(RM) $(CLEANFILES) Nothing_to_remove
474 -$(RM) $(CLOBBERFILES) Nothing_to_remove
477 -$(RM) $(CLEANLINTFILES) Nothing_to_remove
480 # Create fake lintlibs in the 64b dirs so
481 # global linting works
484 @$(ECHO) $(MODULE) fake lints
485 @for dir in $(LINT64_DIRS); do \
486 if [ ! -d $$dir ]; then mkdir $$dir; fi \
488 @for file in $(LINT64_FILES); do \
489 if [ ! -f $$file ]; then touch $$file; fi \
493 # In some places we also need to create fake lintlibs for 32b
494 # dirs so global linting works
497 @$(ECHO) $(MODULE) fake lints
498 @for dir in $(LINT32_DIRS); do \
499 if [ ! -d $$dir ]; then mkdir $$dir; fi \
501 @for file in $(LINT32_FILES); do \
502 if [ ! -f $$file ]; then touch $$file; fi \