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, Version 1.0 only 6# (the "License"). You may not use this file except in compliance 7# with the License. 8# 9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10# or http://www.opensolaris.org/os/licensing. 11# See the License for the specific language governing permissions 12# and limitations under the License. 13# 14# When distributing Covered Code, include this CDDL HEADER in each 15# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16# If applicable, add the following below this CDDL HEADER, with the 17# fields enclosed by brackets "[]" replaced with your own identifying 18# information: Portions Copyright [yyyy] [name of copyright owner] 19# 20# CDDL HEADER END 21# 22# 23# Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24# Use is subject to license terms. 25# 26#ident "%Z%%M% %I% %E% SMI" 27# 28# This Makefiles contains the common targets and definitions for 29# all kernels. It is to be included in the Makefiles for specific 30# implementation architectures and processor architecture dependent 31# modules: i.e.: all driving kernel Makefiles. 32# 33 34# 35# Default rule for building the lint library directory: 36# 37$(LINT_LIB_DIR): 38 -@mkdir -p $@ 2> /dev/null 39 40# 41# All C objects depend on inline files. However, cc(1) doesn't generate 42# the correct dependency info. Also, these Makefiles don't contain a 43# separate list of C-derived object files (but it is light weight to 44# let the assembler files think they depend upon this when they don't). 45# Fortunately, the inline files won't change very often. So, for now, 46# all objects depend on the inline files. Remove this when the inliner 47# is fixed to drop correct dependency information. 48# 49$(OBJECTS): $(INLINES) 50 51# 52# Partially link .o files to generate the kmod. The fake dependency 53# on modstubs simplifies things... 54# ELFSIGN_MOD is defined in the individual KCF plug-in modules Makefiles, 55# and will sign the ELF objects using elfsign(1). 56# 57$(BINARY): $(OBJECTS) 58 $(LD) -r $(LDFLAGS) -o $@ $(OBJECTS) 59 $(CTFMERGE_UNIQUIFY_AGAINST_GENUNIX) 60 $(POST_PROCESS) 61 $(ELFSIGN_MOD) 62 63# 64# This target checks each kmod for undefined entry points. It does not 65# modify the kmod in any way. 66# 67$(MODULE).check: FRC 68 @BUILD_TYPE=DBG32 $(MAKE) $(MODULE).check.targ 69 70$(MODULE).check.targ: $(BINARY) $(OBJECTS) $(EXTRA_CHECK_OBJS) $(UNIX_O) $(MODSTUBS_O) $(GENLIB) 71 $(LD) -o /dev/null $(OBJECTS) $(EXTRA_CHECK_OBJS) $(UNIX_O) $(MODSTUBS_O) $(GENLIB) 72 73# 74# Module lint library construction targets. 75# 76MOD_LINT_LIB = $(LINT_LIB_DIR)/llib-l$(LINT_MODULE).ln 77 78$(MOD_LINT_LIB): $(LINT_LIB_DIR) $(LINTS) 79 @-$(ECHO) "\n$(OBJS_DIR)/$(MODULE): (library construction):" 80 @$(LINT) -o $(LINT_MODULE) $(LINTFLAGS) $(LINTS) 81 @$(MV) $(@F) $@ 82 83$(LINT_MODULE).lint: $(MOD_LINT_LIB) $(LINT_LIB) $(GEN_LINT_LIB) 84 @-$(ECHO) "\n$(OBJS_DIR)/$(LINT_MODULE): global crosschecks:" 85 @$(LINT) $(LINTFLAGS) $(MOD_LINT_LIB) $(LINT_LIB) $(GEN_LINT_LIB) 86 87# 88# Since assym.h is a derived file, the dependency must be explicit for 89# all files including this file. (This is only actually required in the 90# instance when the .nse_depinfo file does not exist.) It may seem that 91# the lint targets should also have a similar dependency, but they don't 92# since only C headers are included when #defined(lint) is true. The 93# actual lists are defined in */Makefile.files. 94# 95$(ASSYM_DEPS:%=$(OBJS_DIR)/%): $(DSF_DIR)/$(OBJS_DIR)/assym.h 96 97# 98# Everybody need to know how to create a modstubs.o built with the 99# appropriate flags and located in the appropriate location. 100# 101$(MODSTUBS_O): $(MODSTUBS) 102 $(COMPILE.s) -o $@ $(MODSTUBS) 103 104$(LINTS_DIR)/modstubs.ln: $(MODSTUBS) 105 @($(LHEAD) $(LINT.s) $(MODSTUBS) $(LTAIL)) 106 107# 108# Build the source file which contains the kernel's utsname, 109# with release, version and machine set as follows: 110# 111# release: contents of $(RELEASE) (Spaces replaced by '_') 112# version: contents of $(PATCHID) (Spaces replaced by '_') 113# machine: contents of $(PLATFORM) 114# 115# Build environment information is only contained in the comment section. 116# 117# The version string, normally the variable VERSION, is set to display 118# environmental information temporarily while in development because 119# it provides a little more useful information. 120# 121VERSION_STRING = ($(ECHO) $$LOGNAME [\`basename $$CODEMGR_WS\`] \\\c; date +%D) 122$(INTERNAL_RELEASE_BUILD)VERSION_STRING = $(ECHO) $(PATCHID) 123 124$(OBJS_DIR)/vers.o: $(OBJECTS) 125 $(COMPILE.c) -DUTS_RELEASE=\"`$(ECHO) $(RELEASE) | sed -e 's/ /_/g'`\" \ 126 -DUTS_VERSION=\"`$(VERSION_STRING) | sed -e 's/ /_/g'`\" \ 127 -DUTS_PLATFORM=\"$(PLATFORM)\" -o $@ $(SRC)/uts/common/os/vers.c 128 $(CTFCONVERT_O) 129 $(POST_PROCESS_O) 130 131$(LINTS_DIR)/vers.ln: $(SRC)/uts/common/os/vers.c 132 @($(LHEAD) $(LINT.c) -DUTS_RELEASE=\"\" -DUTS_VERSION=\"\" \ 133 -DUTS_PLATFORM=\"\" $(SRC)/uts/common/os/vers.c $(LTAIL)) 134 135# 136# Installation targets and rules: 137# 138$(ROOT_MOD_DIR) $(USR_MOD_DIR): 139 -$(INS.dir.root.sys) 140 141$(ROOT_MOD_DIRS_32): $(ROOT_MOD_DIR) 142 -$(INS.dir.root.sys) 143 144$(USR_MOD_DIRS_32): $(USR_MOD_DIR) 145 -$(INS.dir.root.sys) 146 147$(ROOT_MOD_DIR)/%: $(OBJS_DIR)/% $(ROOT_MOD_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_STRMOD_DIR)/%: $(OBJS_DIR)/% $(ROOT_STRMOD_DIR) FRC 166 $(INS.file) 167 168$(ROOT_IPP_DIR)/%: $(OBJS_DIR)/% $(ROOT_IPP_DIR) FRC 169 $(INS.file) 170 171$(ROOT_SYS_DIR)/%: $(OBJS_DIR)/% $(ROOT_SYS_DIR) FRC 172 $(INS.file) 173 174$(ROOT_MISC_DIR)/%: $(OBJS_DIR)/% $(ROOT_MISC_DIR) FRC 175 $(INS.file) 176 177$(ROOT_DACF_DIR)/%: $(OBJS_DIR)/% $(ROOT_DACF_DIR) FRC 178 $(INS.file) 179 180$(ROOT_CRYPTO_DIR)/%: $(OBJS_DIR)/% $(ROOT_CRYPTO_DIR) FRC 181 $(INS.file) 182 183$(ROOT_KGSS_DIR)/%: $(OBJS_DIR)/% $(ROOT_KGSS_DIR) FRC 184 $(INS.file) 185 186$(ROOT_MACH_DIR)/%: $(OBJS_DIR)/% $(ROOT_MACH_DIR) FRC 187 $(INS.file) 188 189$(ROOT_FONT_DIR)/%: $(OBJS_DIR)/% $(ROOT_MOD_DIR) $(ROOT_FONT_DIR) FRC 190 $(INS.file) 191 192$(USR_DRV_DIR)/%: $(OBJS_DIR)/% $(USR_DRV_DIR) FRC 193 $(INS.file) 194 195$(USR_EXEC_DIR)/%: $(OBJS_DIR)/% $(USR_EXEC_DIR) FRC 196 $(INS.file) 197 198$(USR_FS_DIR)/%: $(OBJS_DIR)/% $(USR_FS_DIR) FRC 199 $(INS.file) 200 201$(USR_SCHED_DIR)/%: $(OBJS_DIR)/% $(USR_SCHED_DIR) FRC 202 $(INS.file) 203 204$(USR_STRMOD_DIR)/%: $(OBJS_DIR)/% $(USR_STRMOD_DIR) FRC 205 $(INS.file) 206 207$(USR_SYS_DIR)/%: $(OBJS_DIR)/% $(USR_SYS_DIR) FRC 208 $(INS.file) 209 210$(USR_MISC_DIR)/%: $(OBJS_DIR)/% $(USR_MISC_DIR) FRC 211 $(INS.file) 212 213$(USR_DACF_DIR)/%: $(OBJS_DIR)/% $(USR_DACF_DIR) FRC 214 $(INS.file) 215 216$(USR_PCBE_DIR)/%: $(OBJS_DIR)/% $(USR_PCBE_DIR) FRC 217 $(INS.file) 218 219include $(SRC)/Makefile.psm.targ 220 221# 222# Target for 64b modules 223# 224$(ROOT_KERN_DIR_64): 225 -$(INS.dir.root.sys) 226 227$(ROOT_KERN_DIR_64)/%: $(OBJS_DIR)/% $(ROOT_KERN_DIR_64) FRC 228 $(INS.file) 229 230%/$(SUBDIR64): % 231 -$(INS.dir.root.sys) 232 233# 234# Targets for '.conf' file installation. 235# 236$(ROOT_CONFFILE): $(SRC_CONFFILE) $(ROOT_CONFFILE:%/$(CONFFILE)=%) 237 $(INS.conffile) 238 239# 240# Targets for creating links between common platforms. ROOT_PLAT_LINKS 241# are are the /platform level while ROOT_PLAT_LINKS_2 are one level 242# down (/platform/`uname -i`/{lib|sbin|kernel}. 243# 244$(ROOT_PLAT_LINKS): 245 $(INS.slink1) 246 247$(ROOT_PLAT_LINKS_2): 248 $(INS.slink2) 249 250$(USR_PLAT_LINKS): 251 $(INS.slink1) 252 253$(USR_PLAT_LINKS_2): 254 $(INS.slink2) 255 256# 257# multiple builds support 258# 259def $(DEF_DEPS) := TARGET = def 260all $(ALL_DEPS) := TARGET = all 261clean $(CLEAN_DEPS) := TARGET = clean 262clobber $(CLOBBER_DEPS) := TARGET = clobber 263lint $(LINT_DEPS) := TARGET = lint 264modlintlib $(MODLINTLIB_DEPS) := TARGET = modlintlib 265clean.lint $(CLEAN_LINT_DEPS) := TARGET = clean.lint 266install $(INSTALL_DEPS) := TARGET = install 267symcheck $(SYM_DEPS) := TARGET = symcheck 268 269 270ALL_TARGS = def all clean clobber lint modlintlib clean.lint lintlib install symcheck 271 272ALL_OBJ32 = $(ALL_TARGS:%=%.obj32) 273 274$(ALL_OBJ32): FRC 275 @BUILD_TYPE=OBJ32 VERSION='$(VERSION)' $(MAKE) $(TARGET).targ 276 277ALL_DEBUG32 = $(ALL_TARGS:%=%.debug32) 278 279$(ALL_DEBUG32): FRC 280 @BUILD_TYPE=DBG32 VERSION='$(VERSION)' $(MAKE) $(TARGET).targ 281 282ALL_OBJ64 = $(ALL_TARGS:%=%.obj64) 283 284$(ALL_OBJ64): FRC 285 @BUILD_TYPE=OBJ64 VERSION='$(VERSION)' $(MAKE) $(TARGET).targ 286 287ALL_DEBUG64 = $(ALL_TARGS:%=%.debug64) 288 289$(ALL_DEBUG64): FRC 290 @BUILD_TYPE=DBG64 VERSION='$(VERSION)' $(MAKE) $(TARGET).targ 291 292 293$(OBJS_DIR): 294 -@mkdir -p $@ 2> /dev/null 295 296def.targ: $(OBJS_DIR) $(ALL_TARGET) 297 298all.targ: $(OBJS_DIR) $(ALL_TARGET) 299 300lint.targ: $(OBJS_DIR) $(LINT_TARGET) 301 302modlintlib.targ: $(OBJS_DIR) $(MOD_LINT_LIB) 303 304install.targ: $(OBJS_DIR) $(INSTALL_TARGET) 305 306# 307# Cleanliness is next to ... 308# 309clean.targ: 310 -$(RM) $(CLEANFILES) Nothing_to_remove 311 312clobber.targ: 313 -$(RM) $(CLOBBERFILES) Nothing_to_remove 314 315clean.lint.targ: 316 -$(RM) $(CLEANLINTFILES) Nothing_to_remove 317 318# 319# Create fake lintlibs in the 64b dirs so 320# global linting works 321# 322lint64: 323 @$(ECHO) $(MODULE) fake lints 324 @for dir in $(LINT64_DIRS); do \ 325 if [ ! -d $$dir ]; then mkdir $$dir; fi \ 326 done 327 @for file in $(LINT64_FILES); do \ 328 if [ ! -f $$file ]; then touch $$file; fi \ 329 done 330 331# 332# In some places we also need to create fake lintlibs for 32b 333# dirs so global linting works 334# 335lint32: 336 @$(ECHO) $(MODULE) fake lints 337 @for dir in $(LINT32_DIRS); do \ 338 if [ ! -d $$dir ]; then mkdir $$dir; fi \ 339 done 340 @for file in $(LINT32_FILES); do \ 341 if [ ! -f $$file ]; then touch $$file; fi \ 342 done 343FRC: 344