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 # Copyright 2008 Sun Microsystems, Inc. All rights reserved. 22 # Use is subject to license terms. 23 # 24 # Copyright (c) 2018, Joyent, Inc. 25 26 # 27 # Path to the base of the uts directory tree (usually /usr/src/uts). 28 # 29 UTSBASE = ../.. 30 31 # 32 # Define the module and object file sets. 33 # 34 UNIX = unix 35 DBOOT = dboot 36 37 OBJECTS = $(SPECIAL_OBJS:%=$(OBJS_DIR)/%) \ 38 $(CORE_OBJS:%=$(OBJS_DIR)/%) \ 39 $(KRTLD_OBJS:%=$(OBJS_DIR)/%) \ 40 $(MACH_NOT_YET_KMODS:%=$(OBJS_DIR)/%) 41 42 LINTS = $(SPECIAL_OBJS:%.o=$(LINTS_DIR)/%.ln) \ 43 $(CORE_OBJS:%.o=$(LINTS_DIR)/%.ln) \ 44 $(KRTLD_OBJS:%.o=$(LINTS_DIR)/%.ln) \ 45 $(MACH_NOT_YET_KMODS:%.o=$(LINTS_DIR)/%.ln) \ 46 $(LINTS_DIR)/vers.ln \ 47 $(LINTS_DIR)/modstubs.ln 48 49 ROOTMODULE = $(ROOT_PSM_KERN_DIR)/$(UNIX) 50 51 UNIX_BIN = $(OBJS_DIR)/$(UNIX) 52 53 LIBS = $(GENLIB) 54 55 GENUNIX = genunix 56 GENUNIX_DIR = ../../intel/$(GENUNIX) 57 58 LIBOPTS = -L $(GENUNIX_DIR)/$(OBJS_DIR) -l $(GENUNIX) 59 60 COMMP_CTF_SRC = $(OBJS_DIR)/comm_page_ctf.c 61 62 CTFEXTRAOBJS = $(OBJS_DIR)/vers.o $(OBJS_DIR)/comm_page_ctf.o 63 64 DBOOT_OBJS_DIR = dboot/$(OBJS_DIR) 65 DBOOT_OBJECTS = $(DBOOT_OBJS:%=$(DBOOT_OBJS_DIR)/%) 66 DBOOT_BIN = $(DBOOT_OBJS_DIR)/$(DBOOT) 67 DBOOT_O = $(OBJS_DIR)/$(DBOOT).o 68 DBOOT_S = $(DBOOT_O:%.o=%.s) 69 DBOOT_LINTS = $(DBOOT_OBJS:%.o=$(DBOOT_OBJS_DIR)/%.ln) 70 DBOOT_LINT = $(i386_LINT) 71 DBOOT_LINTTAGS = -erroff=E_STATIC_UNUSED 72 73 # 74 # Include common rules. 75 # 76 include $(UTSBASE)/i86pc/Makefile.i86pc 77 78 # 79 # Define targets 80 # 81 ALL_TARGET = $(UNIX_BIN) 82 LINT_TARGET = $(LINT_LIB) $(DBOOT_LINT_LIB) 83 INSTALL_TARGET = $(UNIX_BIN) $(ROOTMODULE) 84 85 # 86 # This is UNIX_DIR. Use a short path. 87 # 88 UNIX_DIR = . 89 90 # 91 # Overrides 92 # 93 CLEANFILES += \ 94 $(UNIX_O) $(MODSTUBS_O) \ 95 $(OBJS_DIR)/vers.c \ 96 $(OBJS_DIR)/dtracestubs.s \ 97 $(DTRACESTUBS_O) $(DTRACESTUBS) \ 98 $(CTFEXTRAOBJS) \ 99 $(COMMP_CTF_SRC) 100 101 CLEANFILES += \ 102 $(DBOOT_O) $(DBOOT_S) \ 103 $(DBOOT_OBJECTS) \ 104 $(OBJS_DIR)/bios_call_src.o \ 105 $(OBJS_DIR)/bios_call_src \ 106 $(OBJS_DIR)/bios_call.s \ 107 $(DBOOT_BIN) 108 109 CLEANFILES += \ 110 $(DBOOT_OBJS_DIR)/$(VGATEXT_FONT).c \ 111 $(OBJS_DIR)/$(VGATEXT_FONT).c 112 113 CLEANFILES += \ 114 $(OBJS_DIR)/fb_swtch_src.o \ 115 $(OBJS_DIR)/fb_swtch_src \ 116 $(OBJS_DIR)/fb_swtch.s 117 118 CLEANFILES += \ 119 $(ZLIB_OBJS:%.o=$(OBJS_DIR)/%.o) \ 120 $(ZLIB_OBJS:%.o=$(OBJS_DIR)/%.ln) 121 122 CLOBBERFILES = $(CLEANFILES) $(UNIX_BIN) 123 CLEANLINTFILES += $(LINT_LIB) $(DBOOT_LINT_LIB) $(DBOOT_LINTS) 124 125 # instr_size needs a special header 126 $(OBJS_DIR)/instr_size.o := EXTRA_OPTIONS = -I$(SRC)/common/dis/i386 127 $(OBJS_DIR)/instr_size.ln := EXTRA_OPTIONS = -I$(SRC)/common/dis/i386 128 129 # 130 # When performing shadow studio builds, the pre-processed comm page 131 # output from gcc can end up confusing studio. 132 # 133 $(OBJS_DIR)/comm_page_ctf.o := CERRWARN += -_cc=-erroff=E_TKNS_IGNORED_AT_END_OF_DIR 134 135 CFLAGS += -DDIS_MEM 136 137 # 138 # For now, disable these lint checks; maintainers should endeavor 139 # to investigate and remove these for maximum lint coverage. 140 # Please do not carry these forward to new Makefiles. 141 # 142 LINTTAGS += -erroff=E_BAD_PTR_CAST_ALIGN 143 LINTTAGS += -erroff=E_SUSPICIOUS_COMPARISON 144 LINTTAGS += -erroff=E_SUPPRESSION_DIRECTIVE_UNUSED 145 LINTTAGS += -erroff=E_STATIC_UNUSED 146 LINTTAGS += -erroff=E_PTRDIFF_OVERFLOW 147 LINTTAGS += -erroff=E_ASSIGN_NARROW_CONV 148 149 CERRWARN += -_gcc=-Wno-parentheses 150 CERRWARN += -_gcc=-Wno-uninitialized 151 CERRWARN += -_gcc=-Wno-char-subscripts 152 CERRWARN += -_gcc=-Wno-unused-variable 153 CERRWARN += -_gcc=-Wno-unused-function 154 CERRWARN += -_gcc=-Wno-unused-label 155 CERRWARN += -_gcc=-Wno-type-limits 156 CERRWARN += -_gcc=-Wno-clobbered 157 CERRWARN += -_gcc=-Wno-empty-body 158 CERRWARN += -_gcc=-Wno-unused-value 159 160 # false positives 161 SMOFF += index_overflow 162 163 # needs work 164 SMOFF += all_func_returns,deref_check,signed 165 166 $(OBJS_DIR)/fmsmb.o := SMOFF += indenting 167 $(OBJS_DIR)/zutil.o := SMOFF += indenting 168 $(OBJS_DIR)/bootrd_cpio.o := SMOFF += allocating_enough_data 169 170 # Ensure that lint sees 'struct cpu' containing a fully declared 171 # embedded 'struct machcpu' 172 # 173 LINTFLAGS += -D_MACHDEP -I../../i86pc 174 175 # 176 # Default build targets. 177 # 178 .KEEP_STATE: 179 180 def: $(DEF_DEPS) 181 182 all: $(ALL_DEPS) 183 184 clean: $(CLEAN_DEPS) 185 186 clobber: $(CLOBBER_DEPS) 187 188 lint: $(LINT_DEPS) 189 190 clean.lint: $(CLEAN_LINT_DEPS) 191 192 install: $(INSTALL_DEPS) 193 194 MAPFILE_32 = $(MAPFILE) 195 MAPFILE_64 = $(MAPFILE).amd64 196 197 MAPFILE_NAME = $(MAPFILE_$(CLASS)) 198 199 $(UNIX_BIN): $(UNIX_O) $(MODSTUBS_O) $(MAPFILE_NAME) \ 200 $(GENLIB) $(DTRACESTUBS) $(DBOOT_O) 201 $(LD) -dy -b -o $@ -e dboot_image -znointerp -M $(MAPFILE_NAME) \ 202 $(UNIX_O) $(DBOOT_O) $(MODSTUBS_O) $(LIBOPTS) \ 203 $(DTRACESTUBS) 204 $(MBH_PATCH) $(UNIX_BIN) 205 $(CTFMERGE_UNIQUIFY_AGAINST_GENUNIX) 206 $(POST_PROCESS) 207 208 $(UNIX_O): $(OBJECTS) $(CTFEXTRAOBJS) 209 $(LD) -r -o $@ $(OBJECTS) $(OBJS_DIR)/vers.o 210 211 $(DBOOT_BIN): $(DBOOT_OBJS_DIR) $(DBOOT_OBJECTS) dboot/Mapfile.dboot 212 $(LD) -dn -e _start -M dboot/Mapfile.dboot \ 213 -o $(DBOOT_BIN) $(DBOOT_OBJECTS) 214 215 $(DBOOT_O): $(DBOOT_BIN) 216 @echo " .data" > $(DBOOT_S) 217 @echo " .globl dboot_image" >> $(DBOOT_S) 218 @echo "dboot_image:" >> $(DBOOT_S) 219 $(ELFEXTRACT) $(DBOOT_BIN) >> $(DBOOT_S) 220 $(COMPILE.s) -o $(DBOOT_O) $(DBOOT_S) 221 222 $(DBOOT_OBJS_DIR): 223 -@mkdir -p $@ 2> /dev/null 224 225 $(COMMP_CTF_SRC): $(UTSBASE)/i86pc/ml/comm_page.s 226 $(COMPILE.cpp) -D_GENCTF -o $@ $(UTSBASE)/i86pc/ml/comm_page.s 227 228 $(OBJS_DIR)/comm_page_ctf.o: $(COMMP_CTF_SRC) 229 $(COMPILE.c) -o $@ $< 230 $(CTFCONVERT_O) 231 232 # 233 # Special rules for generating assym.h for inclusion in assembly files. 234 # 235 $(DSF_DIR)/$(OBJS_DIR)/assym.h $(DSF_DIR)/$(OBJS_DIR)/kdi_assym.h: FRC 236 @cd $(DSF_DIR); $(MAKE) all.targ 237 238 # 239 # The global lint target builds the kernel lint library (llib-lunix.ln) 240 # which is equivalent to a lint of /unix.o. Then all kernel modules for 241 # this architecture are linted against the kernel lint library. 242 # 243 # Note: lint errors in the kernel lint library will be repeated for 244 # each module. It is important that the kernel lint library 245 # be clean to keep the textual output to a reasonable level. 246 # 247 248 $(LINT_LIB): $(LINT_LIB_DIR) $(LINTS) 249 @pwd 250 @-$(ECHO) "\n$(UNIX): (library construction):" 251 @$(LINT) -o$(UNIX) $(LINTFLAGS) $(LINTS) 252 @$(MV) $(@F) $@ 253 254 $(DBOOT_LINT_LIB): $(LINT_LIB_DIR) $(DBOOT_LINTS) 255 @pwd 256 @-$(ECHO) "\n$(DBOOT): (library construction):" 257 @$(LINT) -o$(DBOOT) $(DBOOT_LINTFLAGS) $(DBOOT_LINTS) 258 @$(MV) $(@F) $@ 259 260 lintlib: $(LINT_DEPS) 261 262 # 263 # Include common targets. 264 # 265 include $(UTSBASE)/i86pc/Makefile.targ