1# 2# CDDL HEADER START 3# 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. 7# 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. 12# 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] 18# 19# CDDL HEADER END 20# 21# 22# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23# Use is subject to license terms. 24# 25# This Makefiles contains the common targets and definitions for 26# all kernels. It is to be included in the Makefiles for specific 27# implementation architectures and processor architecture dependent 28# modules: i.e.: all driving kernel Makefiles. 29# 30 31# 32# Default rule for building the lint library directory: 33# 34$(LINT_LIB_DIR): 35 -@mkdir -p $@ 2> /dev/null 36 37# 38# All C objects depend on inline files. However, cc(1) doesn't generate 39# the correct dependency info. Also, these Makefiles don't contain a 40# separate list of C-derived object files (but it is light weight to 41# let the assembler files think they depend upon this when they don't). 42# Fortunately, the inline files won't change very often. So, for now, 43# all objects depend on the inline files. Remove this when the inliner 44# is fixed to drop correct dependency information. 45# 46$(OBJECTS): $(INLINES) 47 48# 49# Partially link .o files to generate the kmod. The fake dependency 50# on modstubs simplifies things... 51# ELFSIGN_MOD is defined in the individual KCF plug-in modules Makefiles, 52# and will sign the ELF objects using elfsign(1). 53# 54$(BINARY): $(OBJECTS) 55 $(LD) -r $(LDFLAGS) -o $@ $(OBJECTS) 56 $(CTFMERGE_UNIQUIFY_AGAINST_GENUNIX) 57 $(POST_PROCESS) 58 $(ELFSIGN_MOD) 59 60# 61# This target checks each kmod for undefined entry points. It does not 62# modify the kmod in any way. 63# 64$(MODULE).check: FRC 65 @BUILD_TYPE=DBG32 $(MAKE) $(MODULE).check.targ 66 67$(MODULE).check.targ: $(BINARY) $(OBJECTS) $(EXTRA_CHECK_OBJS) $(UNIX_O) $(MODSTUBS_O) $(GENLIB) 68 $(LD) -o /dev/null $(OBJECTS) $(EXTRA_CHECK_OBJS) $(UNIX_O) $(MODSTUBS_O) $(GENLIB) 69 70# 71# Module lint library construction targets. 72# 73MOD_LINT_LIB = $(LINT_LIB_DIR)/llib-l$(LINT_MODULE).ln 74 75$(MOD_LINT_LIB): $(LINT_LIB_DIR) $(LINTS) 76 @-$(ECHO) "\n$(OBJS_DIR)/$(MODULE): (library construction):" 77 @$(LINT) -o $(LINT_MODULE)-$(OBJS_DIR) $(LINTFLAGS) $(LINTS) 78 @$(MV) llib-l$(LINT_MODULE)-$(OBJS_DIR).ln $@ 79 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) $(LINT_LIB) $(GEN_LINT_LIB) 83 84# 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. 91# 92$(ASSYM_DEPS:%=$(OBJS_DIR)/%): $(DSF_DIR)/$(OBJS_DIR)/assym.h 93 94# 95# Everybody need to know how to create a modstubs.o built with the 96# appropriate flags and located in the appropriate location. 97# 98$(MODSTUBS_O): $(MODSTUBS) 99 $(COMPILE.s) -o $@ $(MODSTUBS) 100 101$(LINTS_DIR)/modstubs.ln: $(MODSTUBS) 102 @($(LHEAD) $(LINT.s) $(MODSTUBS) $(LTAIL)) 103 104# 105# Build the source file which contains the kernel's utsname, 106# with release, version and machine set as follows: 107# 108# release: contents of $(RELEASE) (Spaces replaced by '_') 109# version: contents of $(PATCHID) (Spaces replaced by '_') 110# machine: contents of $(UNAME_M) 111# 112# Build environment information is only contained in the comment section. 113# 114# The version string, normally the variable VERSION, is set to display 115# environmental information temporarily while in development because 116# it provides a little more useful information. 117# 118VERSION_STRING = ($(ECHO) $$LOGNAME [\`basename $$CODEMGR_WS\`] \\\c; date +%D) 119$(INTERNAL_RELEASE_BUILD)VERSION_STRING = $(ECHO) $(PATCHID) 120 121$(OBJS_DIR)/vers.o: $(OBJECTS) 122 $(COMPILE.c) -DUTS_RELEASE=\"`$(ECHO) $(RELEASE) | sed -e 's/ /_/g'`\" \ 123 -DUTS_VERSION=\"`$(VERSION_STRING) | sed -e 's/ /_/g'`\" \ 124 -DUTS_PLATFORM=\"$(UNAME_M)\" -o $@ $(SRC)/uts/common/os/vers.c 125 $(CTFCONVERT_O) 126 $(POST_PROCESS_O) 127 128$(LINTS_DIR)/vers.ln: $(SRC)/uts/common/os/vers.c 129 @($(LHEAD) $(LINT.c) -DUTS_RELEASE=\"\" -DUTS_VERSION=\"\" \ 130 -DUTS_PLATFORM=\"\" $(SRC)/uts/common/os/vers.c $(LTAIL)) 131 132# 133# Installation targets and rules: 134# 135$(ROOT_MOD_DIR) $(USR_MOD_DIR): 136 -$(INS.dir.root.sys) 137 138$(ROOT_MOD_DIRS_32): $(ROOT_MOD_DIR) 139 -$(INS.dir.root.sys) 140 141$(USR_MOD_DIRS_32): $(USR_MOD_DIR) 142 -$(INS.dir.root.sys) 143 144$(ROOT_MOD_DIR)/%: $(OBJS_DIR)/% $(ROOT_MOD_DIR) FRC 145 $(INS.file) 146 147$(ROOT_CPU_DIR)/%: $(OBJS_DIR)/% $(ROOT_CPU_DIR) FRC 148 $(INS.file) 149 150$(ROOT_DRV_DIR)/%: $(OBJS_DIR)/% $(ROOT_DRV_DIR) FRC 151 $(INS.file) 152 153$(ROOT_DTRACE_DIR)/%: $(OBJS_DIR)/% $(ROOT_DTRACE_DIR) FRC 154 $(INS.file) 155 156$(ROOT_EXEC_DIR)/%: $(OBJS_DIR)/% $(ROOT_EXEC_DIR) FRC 157 $(INS.file) 158 159$(ROOT_FS_DIR)/%: $(OBJS_DIR)/% $(ROOT_FS_DIR) FRC 160 $(INS.file) 161 162$(ROOT_SCHED_DIR)/%: $(OBJS_DIR)/% $(ROOT_SCHED_DIR) FRC 163 $(INS.file) 164 165$(ROOT_SOCK_DIR)/%: $(OBJS_DIR)/% $(ROOT_SOCK_DIR) FRC 166 $(INS.file) 167 168$(ROOT_STRMOD_DIR)/%: $(OBJS_DIR)/% $(ROOT_STRMOD_DIR) FRC 169 $(INS.file) 170 171$(ROOT_IPP_DIR)/%: $(OBJS_DIR)/% $(ROOT_IPP_DIR) FRC 172 $(INS.file) 173 174$(ROOT_SYS_DIR)/%: $(OBJS_DIR)/% $(ROOT_SYS_DIR) FRC 175 $(INS.file) 176 177$(ROOT_MISC_DIR)/%: $(OBJS_DIR)/% $(ROOT_MISC_DIR) FRC 178 $(INS.file) 179 180$(ROOT_DACF_DIR)/%: $(OBJS_DIR)/% $(ROOT_DACF_DIR) FRC 181 $(INS.file) 182 183$(ROOT_BRAND_DIR)/%: $(OBJS_DIR)/% $(ROOT_BRAND_DIR) FRC 184 $(INS.file) 185 186$(ROOT_CRYPTO_DIR)/%: $(OBJS_DIR)/% $(ROOT_CRYPTO_DIR) FRC 187 $(INS.file) 188 189$(ROOT_KGSS_DIR)/%: $(OBJS_DIR)/% $(ROOT_KGSS_DIR) FRC 190 $(INS.file) 191 192$(ROOT_SCSI_VHCI_DIR)/%: $(OBJS_DIR)/% $(ROOT_SCSI_VHCI_DIR) FRC 193 $(INS.file) 194 195$(ROOT_QLC_FW_DIR)/%: $(OBJS_DIR)/% $(ROOT_QLC_FW_DIR) FRC 196 $(INS.file) 197 198$(ROOT_EMLXS_FW_DIR)/%: $(OBJS_DIR)/% $(ROOT_EMLXS_FW_DIR) FRC 199 $(INS.file) 200 201$(ROOT_MACH_DIR)/%: $(OBJS_DIR)/% $(ROOT_MACH_DIR) FRC 202 $(INS.file) 203 204$(ROOT_FONT_DIR)/%: $(OBJS_DIR)/% $(ROOT_MOD_DIR) $(ROOT_FONT_DIR) FRC 205 $(INS.file) 206 207$(ROOT_MAC_DIR)/%: $(OBJS_DIR)/% $(ROOT_MOD_DIR) $(ROOT_MAC_DIR) FRC 208 $(INS.file) 209 210$(ROOT_DEVNAME_DIR)/%: $(OBJS_DIR)/% $(ROOT_DEVNAME_DIR) FRC 211 $(INS.file) 212 213$(USR_DRV_DIR)/%: $(OBJS_DIR)/% $(USR_DRV_DIR) FRC 214 $(INS.file) 215 216$(USR_EXEC_DIR)/%: $(OBJS_DIR)/% $(USR_EXEC_DIR) FRC 217 $(INS.file) 218 219$(USR_FS_DIR)/%: $(OBJS_DIR)/% $(USR_FS_DIR) FRC 220 $(INS.file) 221 222$(USR_SCHED_DIR)/%: $(OBJS_DIR)/% $(USR_SCHED_DIR) FRC 223 $(INS.file) 224 225$(USR_STRMOD_DIR)/%: $(OBJS_DIR)/% $(USR_STRMOD_DIR) FRC 226 $(INS.file) 227 228$(USR_SYS_DIR)/%: $(OBJS_DIR)/% $(USR_SYS_DIR) FRC 229 $(INS.file) 230 231$(USR_MISC_DIR)/%: $(OBJS_DIR)/% $(USR_MISC_DIR) FRC 232 $(INS.file) 233 234$(USR_DACF_DIR)/%: $(OBJS_DIR)/% $(USR_DACF_DIR) FRC 235 $(INS.file) 236 237$(USR_PCBE_DIR)/%: $(OBJS_DIR)/% $(USR_PCBE_DIR) FRC 238 $(INS.file) 239 240$(USR_DEVNAME_DIR)/%: $(OBJS_DIR)/% $(USR_DEVNAME_DIR) FRC 241 $(INS.file) 242 243$(USR_DTRACE_DIR)/%: $(OBJS_DIR)/% $(USR_DTRACE_DIR) FRC 244 $(INS.file) 245 246$(USR_BRAND_DIR)/%: $(OBJS_DIR)/% $(USR_BRAND_DIR) FRC 247 $(INS.file) 248 249$(ROOT_KICONV_DIR)/%: $(OBJS_DIR)/% $(ROOT_KICONV_DIR) FRC 250 $(INS.file) 251 252include $(SRC)/Makefile.psm.targ 253 254# 255# Target for 64b modules 256# 257$(ROOT_KERN_DIR_64): 258 -$(INS.dir.root.sys) 259 260$(ROOT_KERN_DIR_64)/%: $(OBJS_DIR)/% $(ROOT_KERN_DIR_64) FRC 261 $(INS.file) 262 263%/$(SUBDIR64): % 264 -$(INS.dir.root.sys) 265 266# 267# Targets for '.conf' file installation. 268# 269$(ROOT_CONFFILE): $(SRC_CONFFILE) $(ROOT_CONFFILE:%/$(CONFFILE)=%) 270 $(INS.conffile) 271 272# 273# Targets for creating links between common platforms. ROOT_PLAT_LINKS 274# are are the /platform level while ROOT_PLAT_LINKS_2 are one level 275# down (/platform/`uname -i`/{lib|sbin|kernel}. 276# 277$(ROOT_PLAT_LINKS): 278 $(INS.slink1) 279 280$(ROOT_PLAT_LINKS_2): 281 $(INS.slink2) 282 283$(USR_PLAT_LINKS): 284 $(INS.slink1) 285 286$(USR_PLAT_LINKS_2): 287 $(INS.slink2) 288 289# 290# multiple builds support 291# 292def $(DEF_DEPS) := TARGET = def 293all $(ALL_DEPS) := TARGET = all 294clean $(CLEAN_DEPS) := TARGET = clean 295clobber $(CLOBBER_DEPS) := TARGET = clobber 296lint $(LINT_DEPS) := TARGET = lint 297modlintlib $(MODLINTLIB_DEPS) := TARGET = modlintlib 298modlist $(MODLIST_DEPS) := TARGET = modlist 299modlist $(MODLIST_DEPS) := NO_STATE= -K $$MODSTATE$$$$ 300clean.lint $(CLEAN_LINT_DEPS) := TARGET = clean.lint 301install $(INSTALL_DEPS) := TARGET = install 302symcheck $(SYM_DEPS) := TARGET = symcheck 303 304ALL_TARGS = def all clean clobber lint modlintlib \ 305 clean.lint lintlib install symcheck 306 307ALL_OBJ32 = $(ALL_TARGS:%=%.obj32) 308 309$(ALL_OBJ32): FRC 310 @BUILD_TYPE=OBJ32 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ 311 312ALL_DEBUG32 = $(ALL_TARGS:%=%.debug32) 313 314$(ALL_DEBUG32): FRC 315 @BUILD_TYPE=DBG32 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ 316 317ALL_OBJ64 = $(ALL_TARGS:%=%.obj64) 318 319$(ALL_OBJ64): FRC 320 @BUILD_TYPE=OBJ64 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ 321 322ALL_DEBUG64 = $(ALL_TARGS:%=%.debug64) 323 324$(ALL_DEBUG64): FRC 325 @BUILD_TYPE=DBG64 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ 326 327# 328# Currently only the IP module needs symbol checking on obj64. 329# Other modules have the same global-objs nm output for debug64 and obj64. 330# 331$(SISCHECK_DEPS): $(DEF_DEPS) 332 @TARG=`$(ECHO) $@ | $(CUT) -d'.' -f2`; \ 333 MODSYMS=$(MODULE).symbols.$$TARG; \ 334 if [ -f "$(MODULE).global-objs.$$TARG" ]; then \ 335 $(GREP) -v '#' $(MODULE).global-objs.$$TARG |$(GREP) . | \ 336 $(SORT) -u > $$MODSYMS.tmp; \ 337 $(NM) $$TARG/$(MODULE) |$(GREP) OBJT |$(GREP) -v UNDEF | \ 338 $(CUT) -d'|' -f8 |$(GREP) -v '^___const_' | \ 339 $(GREP) -v '\.[0-9]*$$' |$(SORT) -u \ 340 > $$MODSYMS.tmp.new; \ 341 $(DIFF) $$MODSYMS.tmp $$MODSYMS.tmp.new > $$MODSYMS.diff || \ 342 ($(ECHO) "warning: $(MODULE) symbol checking:" \ 343 "global variable(s) introduced and/or removed."; \ 344 $(CAT) $$MODSYMS.diff; exit 1) \ 345 fi 346 347$(SISCLEAN_DEPS): 348 -TARG=`$(ECHO) $@ | $(CUT) -d'.' -f2`; \ 349 MODSYMS=$(MODULE).symbols.$$TARG; \ 350 $(RM) $$MODSYMS.tmp $$MODSYMS.tmp.new $$MODSYMS.diff Nothing_to_remove 351 352 353$(OBJS_DIR): 354 -@mkdir -p $@ 2> /dev/null 355 356def.targ: $(OBJS_DIR) $(ALL_TARGET) 357 358all.targ: $(OBJS_DIR) $(ALL_TARGET) 359 360lint.targ: $(OBJS_DIR) $(LINT_TARGET) 361 362modlintlib.targ: $(OBJS_DIR) $(MOD_LINT_LIB) 363 364install.targ: $(OBJS_DIR) $(INSTALL_TARGET) 365 366# 367# Support for Install.sh. 368# 369 370modlist: $(MODLIST_DEPS) 371 372# paths relative to $(ROOT). 373RELMODULE = $(ROOTMODULE:$(ROOT)/%=%) 374RELCONF = $(ROOT_CONFFILE:$(ROOT)/%=%) 375RELLINK = $(ROOTLINK:$(ROOT)/%=%) 376RELUNIX = $(UNIX32_LINK:$(ROOT)/%=%) 377RELSOFTLINKS = $(ROOTSOFTLINKS:$(ROOT)/%=%) 378 379MODSRC:sh= pwd 380 381# 382# Changes to this target may require corresponding changes to 383# Install.sh. 384# Don't issue a MOD entry if it's not in the install list. 385# 386$(MODLIST_DEPS): FRC 387 @case $@ in \ 388 *32) \ 389 class=32; \ 390 relmodule=`dirname $(RELMODULE)`;; \ 391 *64) \ 392 class=64; \ 393 relmodule=`dirname $(RELMODULE)`/$(SUBDIR64);; \ 394 esac; \ 395 if [ -z "$(THISIMPL)" ]; then \ 396 impl=all; \ 397 else \ 398 impl=$(THISIMPL); \ 399 fi; \ 400 if [ -n "$(ROOTMODULE)" -a -n "$(INSTALL_TARGET)" ]; then \ 401 if [ -z "$(MODULE)" ]; then \ 402 module=`basename $(ROOTMODULE)`; \ 403 else \ 404 module=$(MODULE); \ 405 fi; \ 406 tinstall="$(INSTALL_TARGET)"; \ 407 for t in $$tinstall; do \ 408 if [ "$(ROOTMODULE)" = $$t ]; then \ 409 echo MOD $$module $$relmodule \ 410 $$class $$impl $(MODSRC); \ 411 break; \ 412 fi \ 413 done \ 414 fi; \ 415 if [ -n "$(CONF_SRCDIR)" ]; then \ 416 tinstall="$(INSTALL_TARGET)"; \ 417 for t in $$tinstall; do \ 418 if [ $(ROOT_CONFFILE) = $$t ]; then \ 419 echo CONF $(RELCONF) \ 420 $(MODSRC)/$(CONF_SRCDIR) $$impl $$module; \ 421 break; \ 422 fi \ 423 done \ 424 fi; \ 425 if [ -n "$(ROOTLINK)" ]; then \ 426 rellinks="$(RELLINK)"; \ 427 for r in $$rellinks; do \ 428 if [ $$class = 32 ]; then \ 429 linkdir=`dirname $$r`; \ 430 else \ 431 linkdir=`dirname $$r`/$(SUBDIR64); \ 432 fi; \ 433 echo LINK $$relmodule $$module \ 434 $$linkdir `basename $$r` $$impl; \ 435 done \ 436 fi; \ 437 if [ -n "$(UNIX32_LINK)" ]; then \ 438 echo SYMLINK $(SUBDIR64)/$(UNIX) \ 439 `dirname $(RELUNIX)` unix $$impl $$module; \ 440 fi; \ 441 trelsoftlinks="$(RELSOFTLINKS)"; \ 442 for t in $$trelsoftlinks; do \ 443 if [ $$class = 32 ]; then \ 444 linkdir=`dirname $$t`; \ 445 else \ 446 linkdir=`dirname $$t`/$(SUBDIR64); \ 447 fi; \ 448 linkname=`basename $$t`; \ 449 echo SYMLINK $(MODULE) $$linkdir $$linkname \ 450 $$impl $$module; \ 451 done 452 453# 454# Cleanliness is next to ... 455# 456clean.targ: 457 -$(RM) $(CLEANFILES) Nothing_to_remove 458 459clobber.targ: 460 -$(RM) $(CLOBBERFILES) Nothing_to_remove 461 462clean.lint.targ: 463 -$(RM) $(CLEANLINTFILES) Nothing_to_remove 464 465# 466# Create fake lintlibs in the 64b dirs so 467# global linting works 468# 469lint64: 470 @$(ECHO) $(MODULE) fake lints 471 @for dir in $(LINT64_DIRS); do \ 472 if [ ! -d $$dir ]; then mkdir $$dir; fi \ 473 done 474 @for file in $(LINT64_FILES); do \ 475 if [ ! -f $$file ]; then touch $$file; fi \ 476 done 477 478# 479# In some places we also need to create fake lintlibs for 32b 480# dirs so global linting works 481# 482lint32: 483 @$(ECHO) $(MODULE) fake lints 484 @for dir in $(LINT32_DIRS); do \ 485 if [ ! -d $$dir ]; then mkdir $$dir; fi \ 486 done 487 @for file in $(LINT32_FILES); do \ 488 if [ ! -f $$file ]; then touch $$file; fi \ 489 done 490 491FRC: 492