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# 23# Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. 24# Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com> 25# Copyright 2019 Joyent, Inc. 26# Copyright 2019 OmniOS Community Edition (OmniOSce) Association. 27# Copyright 2022 Oxide Computer Company 28# 29 30# This Makefile defines the build rules for the directory uts/i86pc 31# and its children. These are the source files which are i86pc 32# "implementation architecture" dependent. 33# 34# The following two-level ordering must be maintained in this file. 35# Lines are sorted first in order of decreasing specificity based on 36# the first directory component. That is, i86pc rules come before 37# intel rules come before common rules. 38# 39# Lines whose initial directory components are equal are sorted 40# alphabetically by the remaining components. 41 42# 43# Section 1a: C object build rules 44# 45$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/conf/%.c 46 $(COMPILE.c) -o $@ $< 47 $(CTFCONVERT_O) 48 49$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/cpu/amd_opteron/%.c 50 $(COMPILE.c) -o $@ $< 51 $(CTFCONVERT_O) 52 53$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/cpu/authenticamd/%.c 54 $(COMPILE.c) -o $@ $< 55 $(CTFCONVERT_O) 56 57$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/cpu/generic_cpu/%.c 58 $(COMPILE.c) -o $@ $< 59 $(CTFCONVERT_O) 60 61$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/cpu/genuineintel/%.c 62 $(COMPILE.c) -o $@ $< 63 $(CTFCONVERT_O) 64 65$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/%.c 66 $(COMPILE.c) -o $@ $< 67 $(CTFCONVERT_O) 68 69$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/acpi_drv/%.c 70 $(COMPILE.c) -o $@ $< 71 $(CTFCONVERT_O) 72 73$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/fipe/%.c 74 $(COMPILE.c) -o $@ $< 75 $(CTFCONVERT_O) 76 77$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/acpi/acpidev/%.c 78 $(COMPILE.c) -o $@ $< 79 $(CTFCONVERT_O) 80 81$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/acpi/acpinex/%.c 82 $(COMPILE.c) -o $@ $< 83 $(CTFCONVERT_O) 84 85SBD_IOCTL = $(UTSBASE)/i86pc/sys/sbd_ioctl.h 86DRMACH_IO = $(UTSBASE)/i86pc/io/acpi/drmach_acpi 87DRMACH_GENERR = $(DRMACH_IO)/sbdgenerr 88DR_IO = $(UTSBASE)/i86pc/io/dr 89DR_GENERR = $(DR_IO)/sbdgenerr 90 91$(DRMACH_GENERR): $(DR_IO)/sbdgenerr.pl 92 $(RM) $@ 93 $(CAT) $(DR_IO)/sbdgenerr.pl > $@ 94 $(CHMOD) +x $@ 95 96$(DRMACH_IO)/drmach_err.c: $(DRMACH_GENERR) $(SBD_IOCTL) 97 $(RM) $@ 98 $(DRMACH_GENERR) EX86 < $(SBD_IOCTL) > $(DRMACH_IO)/drmach_err.c 99 100$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/acpi/drmach_acpi/%.c 101 $(COMPILE.c) -o $@ $< 102 $(CTFCONVERT_O) 103 104$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/amd_iommu/%.c 105 $(COMPILE.c) -o $@ $< 106 $(CTFCONVERT_O) 107 108$(DR_GENERR): $(DR_IO)/sbdgenerr.pl 109 $(RM) $@ 110 $(CAT) $(DR_IO)/sbdgenerr.pl > $@ 111 $(CHMOD) +x $@ 112 113$(DR_IO)/dr_err.c: $(DR_GENERR) $(SBD_IOCTL) 114 $(RM) $@ 115 $(DR_GENERR) ESBD < $(SBD_IOCTL) > $(DR_IO)/dr_err.c 116 117$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/dr/%.c 118 $(COMPILE.c) -o $@ $< 119 $(CTFCONVERT_O) 120 121$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/ioat/%.c 122 $(COMPILE.c) -o $@ $< 123 $(CTFCONVERT_O) 124 125$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/pci/%.c 126 $(COMPILE.c) -o $@ $< 127 $(CTFCONVERT_O) 128 129$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/pciex/%.c 130 $(COMPILE.c) -o $@ $< 131 $(CTFCONVERT_O) 132 133$(OBJS_DIR)/%.o: $(UTSBASE)/intel/io/pciex/hotplug/%.c 134 $(COMPILE.c) -o $@ $< 135 $(CTFCONVERT_O) 136 137$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/pcplusmp/%.c 138 $(COMPILE.c) -o $@ $< 139 $(CTFCONVERT_O) 140 141$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/pcplusmp/%.S 142 $(COMPILE.s) -o $@ $< 143 144$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/apix/%.c 145 $(COMPILE.c) -o $@ $< 146 $(CTFCONVERT_O) 147 148$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/ppm/%.c 149 $(COMPILE.c) -o $@ $< 150 $(CTFCONVERT_O) 151 152$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/ppm/%.S 153 $(COMPILE.s) -o $@ $< 154 155$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/psm/%.c 156 $(COMPILE.c) -o $@ $< 157 $(CTFCONVERT_O) 158 159$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/psm/%.S 160 $(COMPILE.s) -o $@ $< 161 162$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/tzmon/%.c 163 $(COMPILE.c) -o $@ $< 164 $(CTFCONVERT_O) 165 166$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/ml/%.S 167 $(COMPILE.s) -o $@ $< 168 169$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/os/%.c 170 $(COMPILE.c) -_gcc=-fno-stack-protector -o $@ $< 171 $(CTFCONVERT_O) 172 173$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/os/cpupm/%.c 174 $(COMPILE.c) -o $@ $< 175 $(CTFCONVERT_O) 176 177$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/promif/%.c 178 $(COMPILE.c) -o $@ $< 179 $(CTFCONVERT_O) 180 181$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/boot/%.c 182 $(COMPILE.c) -o $@ $< 183 $(CTFCONVERT_O) 184 185$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/vm/%.c 186 $(COMPILE.c) -o $@ $< 187 $(CTFCONVERT_O) 188 189$(OBJS_DIR)/%.o: $(UTSBASE)/common/io/%.c 190 $(COMPILE.c) -o $@ $< 191 $(CTFCONVERT_O) 192 193$(OBJS_DIR)/%.o: $(UTSBASE)/common/io/ppm/%.c 194 $(COMPILE.c) -o $@ $< 195 $(CTFCONVERT_O) 196 197$(OBJS_DIR)/%.o: $(UTSBASE)/common/io/pciex/%.c 198 $(COMPILE.c) -o $@ $< 199 $(CTFCONVERT_O) 200 201$(OBJS_DIR)/%.o: $(UTSBASE)/common/os/%.c 202 $(COMPILE.c) -o $@ $< 203 $(CTFCONVERT_O) 204 205$(OBJS_DIR)/%.o: $(SRC)/common/dis/i386/%.c 206 $(COMPILE.c) -o $@ $< 207 $(CTFCONVERT_O) 208 209$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/gfx_private/%.c 210 $(COMPILE.c) -o $@ $< 211 $(CTFCONVERT_O) 212 213$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/xsvc/%.c 214 $(COMPILE.c) -o $@ $< 215 $(CTFCONVERT_O) 216 217$(OBJS_DIR)/%.o: $(UTSBASE)/common/xen/os/%.c 218 $(COMPILE.c) -o $@ $< 219 $(CTFCONVERT_O) 220 221$(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/dboot/%.c 222 $(COMPILE.c) -o $@ $< 223 $(CTFCONVERT_O) 224 225# 226# dboot stuff is always 32 bit, linked to run with phys_addr == virt_addr 227# 228DBOOT_OBJS_DIR = dboot/$(OBJS_DIR) 229DBOOT_MACH_32 = -D_BOOT_TARGET_i386 230DBOOT_MACH_64 = -D_BOOT_TARGET_amd64 231DBOOT_DEFS = -D_BOOT $(DBOOT_MACH_$(CLASS)) 232DBOOT_DEFS += -D_MACHDEP -U_KERNEL -D_I32LPx 233DBOOT_FLAGS = $(CFLAGS_XARCH_32) $(CCVERBOSE) $(CSTD) $(CERRWARN) 234DBOOT_FLAGS += $(CCNOAUTOINLINE) 235DBOOT_ASFLAGS = $(ASFLAGS_XARCH_32) -D_ASM 236 237DBOOT_CC_INCL = -I$(SRC)/common -I$(SRC)/common/util $(INCLUDE_PATH) 238DBOOT_AS_INCL = $(AS_INC_PATH) 239 240$(DBOOT_OBJS_DIR)/%.o: $(UTSBASE)/i86pc/boot/%.c 241 $(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $< 242 243$(DBOOT_OBJS_DIR)/%.o: $(UTSBASE)/i86pc/dboot/%.c 244 $(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $< 245 246$(DBOOT_OBJS_DIR)/%.o: $(SRC)/common/font/%.c 247 $(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $< 248 249$(DBOOT_OBJS_DIR)/$(FONT).c: $(FONT_DIR)/$(FONT_SRC).bdf 250 $(VTFONTCVT) -f source -o $@ $(FONT_DIR)/$(FONT_SRC).bdf 251 252$(DBOOT_OBJS_DIR)/%.o: $(DBOOT_OBJS_DIR)/%.c 253 $(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $< 254 255$(DBOOT_OBJS_DIR)/%.o: $(COMMONBASE)/crypto/sha1/%.c 256 $(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $< 257 258$(DBOOT_OBJS_DIR)/%.o: $(DBOOT_OBJS_DIR)/%.c 259 $(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $< 260 261$(DBOOT_OBJS_DIR)/%.o: $(COMMONBASE)/util/%.c 262 $(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $< 263 264$(DBOOT_OBJS_DIR)/%.o: $(COMMONBASE)/util/i386/%.S 265 $(AS) $(DBOOT_DEFS) $(DBOOT_ASFLAGS) $(DBOOT_AS_INCL) -c -o $@ $< 266 267$(DBOOT_OBJS_DIR)/%.o: $(UTSBASE)/i86pc/dboot/%.S 268 $(AS) $(DBOOT_DEFS) $(DBOOT_ASFLAGS) $(DBOOT_AS_INCL) -c -o $@ $< 269 270# 271# Stuff to build bios_call.o for the kernel. 272# 273MAPFILE_BIOS = $(UTSBASE)/i86pc/conf/Mapfile.bios 274$(OBJS_DIR)/bios_call.o: $(UTSBASE)/i86pc/ml/bios_call_src.S 275 $(COMPILE.s) -o $(OBJS_DIR)/bios_call_src.o \ 276 $(UTSBASE)/i86pc/ml/bios_call_src.S 277 $(LD) -dn -M $(MAPFILE_BIOS) \ 278 -o $(OBJS_DIR)/bios_call_src $(OBJS_DIR)/bios_call_src.o 279 @echo " .data" > $(OBJS_DIR)/bios_call.s 280 @echo " .globl bios_image" >> $(OBJS_DIR)/bios_call.s 281 @echo "bios_image:" >> $(OBJS_DIR)/bios_call.s 282 $(ELFEXTRACT) $(OBJS_DIR)/bios_call_src >> $(OBJS_DIR)/bios_call.s 283 @echo " .align 4" >> $(OBJS_DIR)/bios_call.s 284 @echo " .globl bios_size" >> $(OBJS_DIR)/bios_call.s 285 @echo "bios_size:" >> $(OBJS_DIR)/bios_call.s 286 @echo " .long . - bios_image" >> $(OBJS_DIR)/bios_call.s 287 $(COMPILE.s) -o $@ $(OBJS_DIR)/bios_call.s 288 289# 290# Stuff to build fb_swtch.o for the kernel. 291# 292MAPFILE_FBSWTCH = $(UTSBASE)/i86pc/conf/Mapfile.fb_swtch 293$(OBJS_DIR)/fb_swtch.o: $(UTSBASE)/i86pc/ml/fb_swtch_src.S 294 $(COMPILE.s) -o $(OBJS_DIR)/fb_swtch_src.o \ 295 $(UTSBASE)/i86pc/ml/fb_swtch_src.S 296 $(LD) -dn -M $(MAPFILE_FBSWTCH) \ 297 -o $(OBJS_DIR)/fb_swtch_src $(OBJS_DIR)/fb_swtch_src.o 298 @echo " .data" > $(OBJS_DIR)/fb_swtch.s 299 @echo " .globl fb_swtch_image" >> $(OBJS_DIR)/fb_swtch.s 300 @echo "fb_swtch_image:" >> $(OBJS_DIR)/fb_swtch.s 301 $(ELFEXTRACT) $(OBJS_DIR)/fb_swtch_src >> $(OBJS_DIR)/fb_swtch.s 302 @echo " .align 4" >> $(OBJS_DIR)/fb_swtch.s 303 @echo " .globl fb_swtch_size" >> $(OBJS_DIR)/fb_swtch.s 304 @echo "fb_swtch_size:" >> $(OBJS_DIR)/fb_swtch.s 305 @echo " .long . - fb_swtch_image" >> $(OBJS_DIR)/fb_swtch.s 306 $(COMPILE.s) -o $@ $(OBJS_DIR)/fb_swtch.s 307 308# ridiculous contortions --- 309ATOMIC_SUBDIR_32 = i386 310ATOMIC_SUBDIR_64 = amd64 311ATOMIC_SUBDIR = $(ATOMIC_SUBDIR_$(CLASS)) 312 313$(OBJS_DIR)/%.o: $(SRC)/common/atomic/$(ATOMIC_SUBDIR)/%.s 314 $(COMPILE.s) -o $@ $< 315 316$(OBJS_DIR)/%.o: $(SRC)/common/atomic/$(ATOMIC_SUBDIR)/%.S 317 $(COMPILE.s) -o $@ $< 318 319# 320# dtrace stubs 321# 322 323$(OBJS_DIR)/dtracestubs.s: $(UNIX_O) $(LIBS) 324 $(NM) -u $(UNIX_O) $(LIBS) | \ 325 $(EGREP) '(__dtrace_probe_|smap_(disable|enable))' | $(SORT) | \ 326 $(UNIQ) | $(AWK) '{ \ 327 printf("\t.globl %s\n\t.type %s,@function\n%s:\n", \ 328 $$1, $$1, $$1); }' > $(OBJS_DIR)/dtracestubs.s 329 330$(DTRACESTUBS): $(DTRACESTUBS_O) 331 $(BUILD.SO) $(DTRACESTUBS_O) 332