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