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.
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.
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]
23 # Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
24 # Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com>
27 # This Makefile defines the build rules for the directory uts/i86pc
28 # and its children. These are the source files which are i86pc
29 # "implementation architecture" dependent.
31 # The following two-level ordering must be maintained in this file.
32 # Lines are sorted first in order of decreasing specificity based on
33 # the first directory component. That is, i86pc rules come before
34 # intel rules come before common rules.
36 # Lines whose initial directory components are equal are sorted
37 # alphabetically by the remaining components.
40 # Section 1: C object build rules
42 $(OBJS_DIR)/%.o: $(SRCTOP)/arch/x86/kernel/conf/%.c
46 $(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/cpu/amd_opteron/%.c
50 $(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/cpu/authenticamd/%.c
54 $(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/cpu/generic_cpu/%.c
58 $(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/cpu/genuineintel/%.c
62 $(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/%.c
66 $(OBJS_DIR)/%.o: $(SRCTOP)/arch/x86/kernel/io/%.c
70 $(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/acpi_drv/%.c
74 $(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/fipe/%.c
78 $(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/acpi/acpidev/%.c
82 $(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/acpi/acpinex/%.c
86 SBD_IOCTL = $(SRCTOP)/arch/x86/kernel/include/sys/sbd_ioctl.h
87 DRMACH_IO = $(UTSBASE)/i86pc/io/acpi/drmach_acpi
88 DRMACH_GENERR = $(DRMACH_IO)/sbdgenerr
89 DR_IO = $(UTSBASE)/i86pc/io/dr
90 DR_GENERR = $(DR_IO)/sbdgenerr
92 $(DRMACH_GENERR): $(DR_IO)/sbdgenerr.pl
94 $(CAT) $(DR_IO)/sbdgenerr.pl > $@
97 $(DRMACH_IO)/drmach_err.c: $(DRMACH_GENERR) $(SBD_IOCTL)
99 $(DRMACH_GENERR) EX86 < $(SBD_IOCTL) > $(DRMACH_IO)/drmach_err.c
101 $(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/acpi/drmach_acpi/%.c
102 $(COMPILE.c) -o $@ $<
105 $(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/amd_iommu/%.c
106 $(COMPILE.c) -o $@ $<
109 $(DR_GENERR): $(DR_IO)/sbdgenerr.pl
111 $(CAT) $(DR_IO)/sbdgenerr.pl > $@
114 $(DR_IO)/dr_err.c: $(DR_GENERR) $(SBD_IOCTL)
116 $(DR_GENERR) ESBD < $(SBD_IOCTL) > $(DR_IO)/dr_err.c
118 $(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/dr/%.c
119 $(COMPILE.c) -o $@ $<
122 $(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/ioat/%.c
123 $(COMPILE.c) -o $@ $<
126 $(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/pci/%.c
127 $(COMPILE.c) -o $@ $<
130 $(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/pciex/%.c
131 $(COMPILE.c) -o $@ $<
134 $(OBJS_DIR)/%.o: $(UTSBASE)/intel/io/pciex/hotplug/%.c
135 $(COMPILE.c) -o $@ $<
138 $(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/pcplusmp/%.c
139 $(COMPILE.c) -o $@ $<
142 $(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/pcplusmp/%.s
143 $(COMPILE.s) -o $@ $<
145 $(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/apix/%.c
146 $(COMPILE.c) -o $@ $<
149 $(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/ppm/%.c
150 $(COMPILE.c) -o $@ $<
153 $(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/ppm/%.s
154 $(COMPILE.s) -o $@ $<
156 $(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/psm/%.c
157 $(COMPILE.c) -o $@ $<
160 $(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/psm/%.s
161 $(COMPILE.s) -o $@ $<
163 $(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/tzmon/%.c
164 $(COMPILE.c) -o $@ $<
167 $(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/ml/%.s
168 $(COMPILE.s) -o $@ $<
170 $(OBJS_DIR)/%.o: $(SRCTOP)/arch/x86/kernel/ml/%.s
171 $(COMPILE.s) -o $@ $<
173 $(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/os/%.c
174 $(COMPILE.c) -fno-stack-protector -o $@ $<
177 $(OBJS_DIR)/%.o: $(SRCTOP)/arch/x86/kernel/os/%.c
178 $(COMPILE.c) -fno-stack-protector -o $@ $<
181 $(OBJS_DIR)/%.o: $(SRCTOP)/arch/x86/kernel/os/cpupm/%.c
182 $(COMPILE.c) -o $@ $<
185 $(OBJS_DIR)/%.o: $(SRCTOP)/arch/x86/kernel/boot/%.c
186 $(COMPILE.c) -o $@ $<
189 $(OBJS_DIR)/%.o: $(SRCTOP)/arch/x86/kernel/vm/%.c
190 $(COMPILE.c) -o $@ $<
193 $(OBJS_DIR)/%.o: $(UTSBASE)/common/io/%.c
194 $(COMPILE.c) -o $@ $<
197 $(OBJS_DIR)/%.o: $(UTSBASE)/common/io/ppm/%.c
198 $(COMPILE.c) -o $@ $<
201 $(OBJS_DIR)/%.o: $(UTSBASE)/common/io/pciex/%.c
202 $(COMPILE.c) -o $@ $<
205 $(OBJS_DIR)/%.o: $(SRCTOP)/kernel/os/%.c
206 $(COMPILE.c) -o $@ $<
209 $(OBJS_DIR)/%.o: $(SRC)/common/dis/i386/%.c
210 $(COMPILE.c) -o $@ $<
213 $(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/gfx_private/%.c
214 $(COMPILE.c) -o $@ $<
217 $(OBJS_DIR)/%.o: $(UTSBASE)/i86pc/io/xsvc/%.c
218 $(COMPILE.c) -o $@ $<
221 $(OBJS_DIR)/%.o: $(SRCTOP)/arch/x86/kernel/dboot/%.c
222 $(COMPILE.c) -o $@ $<
226 # dboot stuff is always 32 bit, linked to run with phys_addr == virt_addr
228 DBOOT_OBJS_DIR = dboot/$(OBJS_DIR)
229 DBOOT_MACH_32 = -D_BOOT_TARGET_i386
230 DBOOT_MACH_64 = -D_BOOT_TARGET_amd64
231 DBOOT_DEFS = -D_BOOT $(DBOOT_MACH_$(CLASS))
232 DBOOT_DEFS += -D_MACHDEP -U_KERNEL -D_I32LPx
233 DBOOT_FLAGS = $(C99MODE) $(CERRWARN) $(CCNOAUTOINLINE)
235 DBOOT_CC_INCL = -I$(SRC)/common -I$(SRC)/common/util $(INCLUDE_PATH) \
236 -I$(SRCTOP)/arch/x86/kernel/dboot
237 DBOOT_AS_INCL = $(AS_INC_PATH)
239 DBOOT_AS = $($(MACH)_AS)
241 $(DBOOT_OBJS_DIR)/%.o: $(SRCTOP)/arch/x86/kernel/boot/%.c
242 $(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
244 $(DBOOT_OBJS_DIR)/%.o: $(SRCTOP)/arch/x86/kernel/dboot/%.c
245 $(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
247 $(DBOOT_OBJS_DIR)/%.o: $(UTSBASE)/intel/ia32/%.s
248 $(DBOOT_AS) -D_ASM $(DBOOT_DEFS) $(DBOOT_AS_INCL) -o $@ $<
250 $(DBOOT_OBJS_DIR)/%.o: $(SRCTOP)/kernel/font/%.c
251 $(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
253 $(DBOOT_OBJS_DIR)/$(VGATEXT_FONT).c: \
254 $(VGATEXT_FONT_DIR)/$(VGATEXT_FONT_SRC).bdf \
255 $(SRCTOP)/tools/bdf_to_c.awk
256 $(AWK) -f $(SRCTOP)/tools/bdf_to_c.awk \
257 $(VGATEXT_FONT_DIR)/$(VGATEXT_FONT_SRC).bdf > $@
259 $(DBOOT_OBJS_DIR)/%.o: $(DBOOT_OBJS_DIR)/%.c
260 $(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
262 $(DBOOT_OBJS_DIR)/%.o: $(COMMONBASE)/crypto/sha1/%.c
263 $(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
265 $(DBOOT_OBJS_DIR)/%.o: $(DBOOT_OBJS_DIR)/%.c
266 $(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
268 $(DBOOT_OBJS_DIR)/%.o: $(COMMONBASE)/util/%.c
269 $(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
271 $(DBOOT_OBJS_DIR)/%.o: $(COMMONBASE)/util/i386/%.s
272 $(DBOOT_AS) -D_ASM $(DBOOT_DEFS) $(DBOOT_AS_INCL) -o $@ $<
274 $(DBOOT_OBJS_DIR)/%.o: $(SRCTOP)/arch/x86/kernel/dboot/%.s
275 $(DBOOT_AS) -D_ASM $(DBOOT_DEFS) $(DBOOT_AS_INCL) -o $@ $<
278 # Stuff to build bios_call.o for the kernel.
280 MAPFILE_BIOS = $(SRCTOP)/arch/x86/kernel/boot/mapfile-bios
281 $(OBJS_DIR)/bios_call.o: $(SRCTOP)/arch/x86/kernel/boot/bios_call_src.s
282 $(COMPILE.s) -o $(OBJS_DIR)/bios_call_src.o \
283 $(SRCTOP)/arch/x86/kernel/boot/bios_call_src.s
284 $(LD) -dn -M $(MAPFILE_BIOS) \
285 -o $(OBJS_DIR)/bios_call_src $(OBJS_DIR)/bios_call_src.o
286 @echo " .data" > $(OBJS_DIR)/bios_call.s
287 @echo " .globl bios_image" >> $(OBJS_DIR)/bios_call.s
288 @echo "bios_image:" >> $(OBJS_DIR)/bios_call.s
289 $(ELFEXTRACT) $(OBJS_DIR)/bios_call_src >> $(OBJS_DIR)/bios_call.s
290 @echo " .align 4" >> $(OBJS_DIR)/bios_call.s
291 @echo " .globl bios_size" >> $(OBJS_DIR)/bios_call.s
292 @echo "bios_size:" >> $(OBJS_DIR)/bios_call.s
293 @echo " .long . - bios_image" >> $(OBJS_DIR)/bios_call.s
294 $(COMPILE.s) -o $@ $(OBJS_DIR)/bios_call.s
297 # Stuff to build fb_swtch.o for the kernel.
299 MAPFILE_FBSWTCH = $(SRCTOP)/arch/x86/kernel/boot/mapfile-fb_swtch
300 $(OBJS_DIR)/fb_swtch.o: $(SRCTOP)/arch/x86/kernel/boot/fb_swtch_src.s
301 $(COMPILE.s) -o $(OBJS_DIR)/fb_swtch_src.o \
302 $(SRCTOP)/arch/x86/kernel/boot/fb_swtch_src.s
303 $(LD) -dn -M $(MAPFILE_FBSWTCH) \
304 -o $(OBJS_DIR)/fb_swtch_src $(OBJS_DIR)/fb_swtch_src.o
305 @echo " .data" > $(OBJS_DIR)/fb_swtch.s
306 @echo " .globl fb_swtch_image" >> $(OBJS_DIR)/fb_swtch.s
307 @echo "fb_swtch_image:" >> $(OBJS_DIR)/fb_swtch.s
308 $(ELFEXTRACT) $(OBJS_DIR)/fb_swtch_src >> $(OBJS_DIR)/fb_swtch.s
309 @echo " .align 4" >> $(OBJS_DIR)/fb_swtch.s
310 @echo " .globl fb_swtch_size" >> $(OBJS_DIR)/fb_swtch.s
311 @echo "fb_swtch_size:" >> $(OBJS_DIR)/fb_swtch.s
312 @echo " .long . - fb_swtch_image" >> $(OBJS_DIR)/fb_swtch.s
313 $(COMPILE.s) -o $@ $(OBJS_DIR)/fb_swtch.s
315 # ridiculous contortions ---
316 ATOMIC_SUBDIR_32 = i386
317 ATOMIC_SUBDIR_64 = amd64
318 ATOMIC_SUBDIR = $(ATOMIC_SUBDIR_$(CLASS))
320 $(OBJS_DIR)/%.o: $(SRC)/common/atomic/$(ATOMIC_SUBDIR)/%.s
321 $(COMPILE.s) -o $@ $<
327 $(OBJS_DIR)/dtracestubs.s: $(UNIX_O) $(LIBS)
328 $(NM) -Pu $(UNIX_O) $(LIBS) | $(GREP) __dtrace_probe_ | $(SORT) | \
329 $(UNIQ) | $(AWK) '{ \
330 printf("\t.globl %s\n\t.type %s,@function\n%s:\n", \
331 $$1, $$1, $$1); }' > $(OBJS_DIR)/dtracestubs.s
333 $(DTRACESTUBS): $(DTRACESTUBS_O)
334 $(BUILD.SO) $(DTRACESTUBS_O)