Home | History | Annotate | Download | only in uts
      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 #
     73 MOD_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 #
    118 VERSION_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 $(USR_DRV_DIR)/%:	$(OBJS_DIR)/% $(USR_DRV_DIR) FRC
    211 	$(INS.file)
    212 
    213 $(USR_EXEC_DIR)/%:	$(OBJS_DIR)/% $(USR_EXEC_DIR) FRC
    214 	$(INS.file)
    215 
    216 $(USR_FS_DIR)/%:	$(OBJS_DIR)/% $(USR_FS_DIR) FRC
    217 	$(INS.file)
    218 
    219 $(USR_SCHED_DIR)/%:	$(OBJS_DIR)/% $(USR_SCHED_DIR) FRC
    220 	$(INS.file)
    221 
    222 $(USR_STRMOD_DIR)/%:	$(OBJS_DIR)/% $(USR_STRMOD_DIR) FRC
    223 	$(INS.file)
    224 
    225 $(USR_SYS_DIR)/%:	$(OBJS_DIR)/% $(USR_SYS_DIR) FRC
    226 	$(INS.file)
    227 
    228 $(USR_MISC_DIR)/%:	$(OBJS_DIR)/% $(USR_MISC_DIR) FRC
    229 	$(INS.file)
    230 
    231 $(USR_DACF_DIR)/%:	$(OBJS_DIR)/% $(USR_DACF_DIR) FRC
    232 	$(INS.file)
    233 
    234 $(USR_PCBE_DIR)/%:	$(OBJS_DIR)/% $(USR_PCBE_DIR) FRC
    235 	$(INS.file)
    236 
    237 $(USR_DTRACE_DIR)/%:	$(OBJS_DIR)/% $(USR_DTRACE_DIR) FRC
    238 	$(INS.file)
    239 
    240 $(USR_BRAND_DIR)/%:	$(OBJS_DIR)/% $(USR_BRAND_DIR) FRC
    241 	$(INS.file)
    242 
    243 $(ROOT_KICONV_DIR)/%:	$(OBJS_DIR)/% $(ROOT_KICONV_DIR) FRC
    244 	$(INS.file)
    245 
    246 include $(SRC)/Makefile.psm.targ
    247 
    248 #
    249 #	Target for 64b modules
    250 #
    251 $(ROOT_KERN_DIR_64):
    252 	-$(INS.dir.root.sys)
    253 
    254 $(ROOT_KERN_DIR_64)/%:	$(OBJS_DIR)/% $(ROOT_KERN_DIR_64) FRC
    255 	$(INS.file)
    256 
    257 %/$(SUBDIR64):		%
    258 	-$(INS.dir.root.sys)
    259 
    260 #
    261 #	Targets for '.conf' file installation.
    262 #
    263 $(ROOT_CONFFILE):	$(SRC_CONFFILE)	$(ROOT_CONFFILE:%/$(CONFFILE)=%)
    264 	$(INS.conffile)
    265 
    266 #
    267 #	Targets for creating links between common platforms. ROOT_PLAT_LINKS
    268 #	are are the /platform level while ROOT_PLAT_LINKS_2 are one level
    269 #	down (/platform/`uname -i`/{lib|sbin|kernel}.
    270 #
    271 $(ROOT_PLAT_LINKS):
    272 	$(INS.slink1)
    273 
    274 $(ROOT_PLAT_LINKS_2):
    275 	$(INS.slink2)
    276 
    277 $(USR_PLAT_LINKS):
    278 	$(INS.slink1)
    279 
    280 $(USR_PLAT_LINKS_2):
    281 	$(INS.slink2)
    282 
    283 #
    284 # multiple builds support
    285 #
    286 def $(DEF_DEPS)			:= TARGET = def
    287 all $(ALL_DEPS)			:= TARGET = all
    288 clean $(CLEAN_DEPS)		:= TARGET = clean
    289 clobber $(CLOBBER_DEPS)		:= TARGET = clobber
    290 lint $(LINT_DEPS)		:= TARGET = lint
    291 modlintlib $(MODLINTLIB_DEPS)	:= TARGET = modlintlib
    292 modlist	$(MODLIST_DEPS)		:= TARGET = modlist
    293 modlist	$(MODLIST_DEPS)		:= NO_STATE= -K $$MODSTATE$$$$
    294 clean.lint $(CLEAN_LINT_DEPS)	:= TARGET = clean.lint
    295 install $(INSTALL_DEPS)		:= TARGET = install
    296 symcheck $(SYM_DEPS)		:= TARGET = symcheck
    297 
    298 ALL_TARGS	= def all clean clobber lint modlintlib \
    299 		  clean.lint lintlib install symcheck
    300 
    301 ALL_OBJ32	= $(ALL_TARGS:%=%.obj32)
    302 
    303 $(ALL_OBJ32):	FRC
    304 	@BUILD_TYPE=OBJ32 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
    305 
    306 ALL_DEBUG32	= $(ALL_TARGS:%=%.debug32)
    307 
    308 $(ALL_DEBUG32):	FRC
    309 	@BUILD_TYPE=DBG32 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
    310 
    311 ALL_OBJ64	= $(ALL_TARGS:%=%.obj64)
    312 
    313 $(ALL_OBJ64):	FRC
    314 	@BUILD_TYPE=OBJ64 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
    315 
    316 ALL_DEBUG64	= $(ALL_TARGS:%=%.debug64)
    317 
    318 $(ALL_DEBUG64):	FRC
    319 	@BUILD_TYPE=DBG64 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
    320 
    321 #
    322 #	Currently only the IP module needs symbol checking on obj64.
    323 #	Other modules have the same global-objs nm output for debug64 and obj64.
    324 #
    325 $(SISCHECK_DEPS):	$(DEF_DEPS)
    326 	@TARG=`$(ECHO) $@ | $(CUT) -d'.' -f2`; \
    327 	MODSYMS=$(MODULE).symbols.$$TARG; \
    328 	if [ -f "$(MODULE).global-objs.$$TARG" ]; then \
    329 		$(GREP) -v '#' $(MODULE).global-objs.$$TARG |$(GREP) . | \
    330 		    $(SORT) -u > $$MODSYMS.tmp; \
    331 		$(NM) $$TARG/$(MODULE) |$(GREP) OBJT |$(GREP) -v UNDEF | \
    332 		    $(CUT) -d'|' -f8 |$(GREP) -v '^___const_' | \
    333 		    $(GREP) -v '\.[0-9]*$$' |$(SORT) -u \
    334 		    > $$MODSYMS.tmp.new; \
    335 		$(DIFF) $$MODSYMS.tmp $$MODSYMS.tmp.new > $$MODSYMS.diff || \
    336 		    ($(ECHO) "warning: $(MODULE) symbol checking:" \
    337 		    "global variable(s) introduced and/or removed."; \
    338 		    $(CAT) $$MODSYMS.diff; exit 1) \
    339 	fi
    340 
    341 $(SISCLEAN_DEPS):
    342 	-TARG=`$(ECHO) $@ | $(CUT) -d'.' -f2`; \
    343 	MODSYMS=$(MODULE).symbols.$$TARG; \
    344 	$(RM) $$MODSYMS.tmp $$MODSYMS.tmp.new $$MODSYMS.diff Nothing_to_remove
    345 
    346 
    347 $(OBJS_DIR):
    348 	-@mkdir -p $@ 2> /dev/null
    349 
    350 def.targ:		$(OBJS_DIR) $(ALL_TARGET)
    351 
    352 all.targ:		$(OBJS_DIR) $(ALL_TARGET)
    353 
    354 lint.targ:		$(OBJS_DIR) $(LINT_TARGET)
    355 
    356 modlintlib.targ:	$(OBJS_DIR) $(MOD_LINT_LIB)
    357 
    358 install.targ:		$(OBJS_DIR) $(INSTALL_TARGET)
    359 
    360 #
    361 # Support for Install.sh.
    362 #
    363 
    364 modlist:	$(MODLIST_DEPS)
    365 
    366 # paths relative to $(ROOT).
    367 RELMODULE = $(ROOTMODULE:$(ROOT)/%=%)
    368 RELCONF = $(ROOT_CONFFILE:$(ROOT)/%=%)
    369 RELLINK = $(ROOTLINK:$(ROOT)/%=%)
    370 RELUNIX = $(UNIX32_LINK:$(ROOT)/%=%)
    371 RELSOFTLINKS = $(ROOTSOFTLINKS:$(ROOT)/%=%)
    372 
    373 MODSRC:sh=		pwd
    374 
    375 #
    376 # Changes to this target may require corresponding changes to
    377 # Install.sh.
    378 # Don't issue a MOD entry if it's not in the install list.
    379 #
    380 $(MODLIST_DEPS): FRC
    381 	@case $@ in \
    382 	*32) \
    383 		class=32; \
    384 		relmodule=`dirname $(RELMODULE)`;; \
    385 	*64) \
    386 		class=64; \
    387 		relmodule=`dirname $(RELMODULE)`/$(SUBDIR64);; \
    388 	esac; \
    389 	if [ -z "$(THISIMPL)" ]; then \
    390 		impl=all; \
    391 	else \
    392 		impl=$(THISIMPL); \
    393 	fi; \
    394 	if [ -n "$(ROOTMODULE)" -a -n "$(INSTALL_TARGET)" ]; then \
    395 		if [ -z "$(MODULE)" ]; then \
    396 			module=`basename $(ROOTMODULE)`; \
    397 		else \
    398 			module=$(MODULE); \
    399 		fi; \
    400 		tinstall="$(INSTALL_TARGET)"; \
    401 		for t in $$tinstall; do \
    402 			if [ "$(ROOTMODULE)" = $$t ]; then \
    403 				echo MOD $$module $$relmodule \
    404 				    $$class $$impl $(MODSRC); \
    405 				break; \
    406 			fi \
    407 		done \
    408 	fi; \
    409 	if [ -n "$(CONF_SRCDIR)" ]; then \
    410 		tinstall="$(INSTALL_TARGET)"; \
    411 		for t in $$tinstall; do \
    412 			if [ $(ROOT_CONFFILE) = $$t ]; then \
    413 				echo CONF $(RELCONF) \
    414 				    $(MODSRC)/$(CONF_SRCDIR) $$impl $$module; \
    415 				break; \
    416 			fi \
    417 		done \
    418 	fi; \
    419 	if [ -n "$(ROOTLINK)" ]; then \
    420 		rellinks="$(RELLINK)"; \
    421 		for r in $$rellinks; do \
    422 		if [ $$class = 32 ]; then \
    423 			linkdir=`dirname $$r`; \
    424 		else \
    425 			linkdir=`dirname $$r`/$(SUBDIR64); \
    426 		fi; \
    427 		echo LINK $$relmodule $$module \
    428 			$$linkdir `basename $$r` $$impl; \
    429 		done \
    430 	fi; \
    431 	if [ -n "$(UNIX32_LINK)" ]; then \
    432 		echo SYMLINK $(SUBDIR64)/$(UNIX) \
    433 		    `dirname $(RELUNIX)` unix $$impl $$module; \
    434 	fi; \
    435 	trelsoftlinks="$(RELSOFTLINKS)"; \
    436 	for t in $$trelsoftlinks; do \
    437 		if [ $$class = 32 ]; then \
    438 			linkdir=`dirname $$t`; \
    439 		else \
    440 			linkdir=`dirname $$t`/$(SUBDIR64); \
    441 		fi; \
    442 		linkname=`basename $$t`; \
    443 		echo SYMLINK $(MODULE) $$linkdir $$linkname \
    444 		    $$impl $$module; \
    445 	done
    446 
    447 #
    448 #	Cleanliness is next to ...
    449 #
    450 clean.targ:
    451 	-$(RM) $(CLEANFILES) Nothing_to_remove
    452 
    453 clobber.targ:
    454 	-$(RM) $(CLOBBERFILES) Nothing_to_remove
    455 
    456 clean.lint.targ:
    457 	-$(RM) $(CLEANLINTFILES) Nothing_to_remove
    458 
    459 #
    460 #	Create fake lintlibs in the 64b dirs so
    461 #	global linting works
    462 #
    463 lint64:
    464 	@$(ECHO) $(MODULE) fake lints
    465 	@for dir in $(LINT64_DIRS); do \
    466 		if [ ! -d $$dir ]; then mkdir $$dir; fi \
    467 	done
    468 	@for file in $(LINT64_FILES); do \
    469 		if [ ! -f $$file ]; then touch $$file; fi \
    470 	done
    471 
    472 #
    473 #	In some places we also need to create fake lintlibs for 32b
    474 #	dirs so global linting works
    475 #
    476 lint32:
    477 	@$(ECHO) $(MODULE) fake lints
    478 	@for dir in $(LINT32_DIRS); do \
    479 		if [ ! -d $$dir ]; then mkdir $$dir; fi \
    480 	done
    481 	@for file in $(LINT32_FILES); do \
    482 		if [ ! -f $$file ]; then touch $$file; fi \
    483 	done
    484 
    485 FRC:
    486