xref: /illumos-gate/usr/src/uts/i86pc/Makefile.rules (revision 7f3d7c9289dee6488b3cd2848a68c0b8580d750c)
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
86$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/i86pc_ktest/%.c
87	$(COMPILE.c) -o $@ $<
88	$(CTFCONVERT_O)
89
90SBD_IOCTL	= $(UTSBASE)/i86pc/sys/sbd_ioctl.h
91DRMACH_IO	= $(UTSBASE)/i86pc/io/acpi/drmach_acpi
92DRMACH_GENERR	= $(DRMACH_IO)/sbdgenerr
93DR_IO		= $(UTSBASE)/i86pc/io/dr
94DR_GENERR	= $(DR_IO)/sbdgenerr
95
96$(DRMACH_GENERR):	$(DR_IO)/sbdgenerr.pl
97	$(RM) $@
98	$(CAT) $(DR_IO)/sbdgenerr.pl > $@
99	$(CHMOD) +x $@
100
101$(DRMACH_IO)/drmach_err.c:	$(DRMACH_GENERR) $(SBD_IOCTL)
102	$(RM) $@
103	$(DRMACH_GENERR) EX86 < $(SBD_IOCTL) > $(DRMACH_IO)/drmach_err.c
104
105$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/acpi/drmach_acpi/%.c
106	$(COMPILE.c) -o $@ $<
107	$(CTFCONVERT_O)
108
109$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/amd_iommu/%.c
110	$(COMPILE.c) -o $@ $<
111	$(CTFCONVERT_O)
112
113$(DR_GENERR):			$(DR_IO)/sbdgenerr.pl
114	$(RM) $@
115	$(CAT) $(DR_IO)/sbdgenerr.pl > $@
116	$(CHMOD) +x $@
117
118$(DR_IO)/dr_err.c:		$(DR_GENERR) $(SBD_IOCTL)
119	$(RM) $@
120	$(DR_GENERR) ESBD < $(SBD_IOCTL) > $(DR_IO)/dr_err.c
121
122$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/dr/%.c
123	$(COMPILE.c) -o $@ $<
124	$(CTFCONVERT_O)
125
126$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/ioat/%.c
127	$(COMPILE.c) -o $@ $<
128	$(CTFCONVERT_O)
129
130$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/pci/%.c
131	$(COMPILE.c) -o $@ $<
132	$(CTFCONVERT_O)
133
134$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/pciex/%.c
135	$(COMPILE.c) -o $@ $<
136	$(CTFCONVERT_O)
137
138$(OBJS_DIR)/%.o:		$(UTSBASE)/intel/io/pciex/hotplug/%.c
139	$(COMPILE.c) -o $@ $<
140	$(CTFCONVERT_O)
141
142$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/pcplusmp/%.c
143	$(COMPILE.c) -o $@ $<
144	$(CTFCONVERT_O)
145
146$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/pcplusmp/%.S
147	$(COMPILE.s) -o $@ $<
148
149$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/apix/%.c
150	$(COMPILE.c) -o $@ $<
151	$(CTFCONVERT_O)
152
153$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/ppm/%.c
154	$(COMPILE.c) -o $@ $<
155	$(CTFCONVERT_O)
156
157$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/ppm/%.S
158	$(COMPILE.s) -o $@ $<
159
160$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/psm/%.c
161	$(COMPILE.c) -o $@ $<
162	$(CTFCONVERT_O)
163
164$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/psm/%.S
165	$(COMPILE.s) -o $@ $<
166
167$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/tzmon/%.c
168	$(COMPILE.c) -o $@ $<
169	$(CTFCONVERT_O)
170
171$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/ml/%.S
172	$(COMPILE.s) -o $@ $<
173
174$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/os/%.c
175	$(COMPILE.c) -_gcc=-fno-stack-protector -o $@ $<
176	$(CTFCONVERT_O)
177
178$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/os/cpupm/%.c
179	$(COMPILE.c) -o $@ $<
180	$(CTFCONVERT_O)
181
182$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/promif/%.c
183	$(COMPILE.c) -o $@ $<
184	$(CTFCONVERT_O)
185
186$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/boot/%.c
187	$(COMPILE.c) -o $@ $<
188	$(CTFCONVERT_O)
189
190$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/vm/%.c
191	$(COMPILE.c) -o $@ $<
192	$(CTFCONVERT_O)
193
194$(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/%.c
195	$(COMPILE.c) -o $@ $<
196	$(CTFCONVERT_O)
197
198$(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/ppm/%.c
199	$(COMPILE.c) -o $@ $<
200	$(CTFCONVERT_O)
201
202$(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/pciex/%.c
203	$(COMPILE.c) -o $@ $<
204	$(CTFCONVERT_O)
205
206$(OBJS_DIR)/%.o:		$(UTSBASE)/common/os/%.c
207	$(COMPILE.c) -o $@ $<
208	$(CTFCONVERT_O)
209
210$(OBJS_DIR)/%.o:		$(SRC)/common/dis/i386/%.c
211	$(COMPILE.c) -o $@ $<
212	$(CTFCONVERT_O)
213
214$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/gfx_private/%.c
215	$(COMPILE.c) -o $@ $<
216	$(CTFCONVERT_O)
217
218$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/xsvc/%.c
219	$(COMPILE.c) -o $@ $<
220	$(CTFCONVERT_O)
221
222$(OBJS_DIR)/%.o:		$(UTSBASE)/common/xen/os/%.c
223	$(COMPILE.c) -o $@ $<
224	$(CTFCONVERT_O)
225
226$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/dboot/%.c
227	$(COMPILE.c) -o $@ $<
228	$(CTFCONVERT_O)
229
230#
231# dboot stuff is always 32 bit, linked to run with phys_addr == virt_addr
232#
233DBOOT_OBJS_DIR	= dboot/$(OBJS_DIR)
234DBOOT_MACH_32	= -D_BOOT_TARGET_i386
235DBOOT_MACH_64	= -D_BOOT_TARGET_amd64
236DBOOT_DEFS	= -D_BOOT $(DBOOT_MACH_$(CLASS))
237DBOOT_DEFS	+= -D_MACHDEP -U_KERNEL
238DBOOT_FLAGS	= $(CFLAGS_XARCH_32) $(NO_SIMD) $(CCVERBOSE) $(CSTD) $(CERRWARN)
239DBOOT_FLAGS	+= $(CCNOAUTOINLINE) $(COPTFLAG) $(CSOURCEDEBUGFLAGS)
240DBOOT_ASFLAGS	= $(ASFLAGS_XARCH_32) -D_ASM
241
242DBOOT_CC_INCL	= -I$(SRC)/common -I$(SRC)/common/util $(INCLUDE_PATH)
243DBOOT_AS_INCL	= $(AS_INC_PATH)
244
245$(DBOOT_OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/boot/%.c
246	$(i386_CC) $(DBOOT_FLAGS) $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
247
248$(DBOOT_OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/dboot/%.c
249	$(i386_CC) $(DBOOT_FLAGS) $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
250
251$(DBOOT_OBJS_DIR)/%.o:		$(SRC)/common/font/%.c
252	$(i386_CC) $(DBOOT_FLAGS) $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
253
254$(DBOOT_OBJS_DIR)/$(FONT).c:	$(FONT_DIR)/$(FONT_SRC).bdf
255	$(VTFONTCVT) -f source -o $@ $(FONT_DIR)/$(FONT_SRC).bdf
256
257$(DBOOT_OBJS_DIR)/%.o:		$(DBOOT_OBJS_DIR)/%.c
258	$(i386_CC) $(DBOOT_FLAGS) $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
259
260$(DBOOT_OBJS_DIR)/%.o:		$(COMMONBASE)/crypto/sha1/%.c
261	$(i386_CC) $(DBOOT_FLAGS) $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
262
263$(DBOOT_OBJS_DIR)/%.o:		$(COMMONBASE)/util/%.c
264	$(i386_CC) $(DBOOT_FLAGS) $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
265
266$(DBOOT_OBJS_DIR)/%.o:		$(COMMONBASE)/util/i386/%.S
267	$(AS) $(DBOOT_DEFS) $(DBOOT_ASFLAGS) $(DBOOT_AS_INCL) -c -o $@ $<
268
269$(DBOOT_OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/dboot/%.S
270	$(AS) $(DBOOT_DEFS) $(DBOOT_ASFLAGS) $(DBOOT_AS_INCL) -c -o $@ $<
271
272#
273# Stuff to build bios_call.o for the kernel.
274#
275MAPFILE_BIOS	= $(UTSBASE)/i86pc/conf/Mapfile.bios
276$(OBJS_DIR)/bios_call.o:    $(UTSBASE)/i86pc/ml/bios_call_src.S
277	$(COMPILE.s) -o $(OBJS_DIR)/bios_call_src.o \
278		$(UTSBASE)/i86pc/ml/bios_call_src.S
279	$(LD) -dn -M $(MAPFILE_BIOS)  \
280		-o $(OBJS_DIR)/bios_call_src $(OBJS_DIR)/bios_call_src.o
281	@echo "  .data"				> $(OBJS_DIR)/bios_call.s
282	@echo "  .globl bios_image"		>> $(OBJS_DIR)/bios_call.s
283	@echo "bios_image:"			>> $(OBJS_DIR)/bios_call.s
284	$(ELFEXTRACT) $(OBJS_DIR)/bios_call_src	>> $(OBJS_DIR)/bios_call.s
285	@echo "  .align 4"			>> $(OBJS_DIR)/bios_call.s
286	@echo "  .globl bios_size"		>> $(OBJS_DIR)/bios_call.s
287	@echo "bios_size:"			>> $(OBJS_DIR)/bios_call.s
288	@echo "  .long . - bios_image"		>> $(OBJS_DIR)/bios_call.s
289	$(COMPILE.s) -o $@ $(OBJS_DIR)/bios_call.s
290
291#
292# Stuff to build fb_swtch.o for the kernel.
293#
294MAPFILE_FBSWTCH	= $(UTSBASE)/i86pc/conf/Mapfile.fb_swtch
295$(OBJS_DIR)/fb_swtch.o:    $(UTSBASE)/i86pc/ml/fb_swtch_src.S
296	$(COMPILE.s) -o $(OBJS_DIR)/fb_swtch_src.o \
297		$(UTSBASE)/i86pc/ml/fb_swtch_src.S
298	$(LD) -dn -M $(MAPFILE_FBSWTCH)  \
299		-o $(OBJS_DIR)/fb_swtch_src $(OBJS_DIR)/fb_swtch_src.o
300	@echo "  .data"				> $(OBJS_DIR)/fb_swtch.s
301	@echo "  .globl fb_swtch_image"		>> $(OBJS_DIR)/fb_swtch.s
302	@echo "fb_swtch_image:"			>> $(OBJS_DIR)/fb_swtch.s
303	$(ELFEXTRACT) $(OBJS_DIR)/fb_swtch_src	>> $(OBJS_DIR)/fb_swtch.s
304	@echo "  .align 4"			>> $(OBJS_DIR)/fb_swtch.s
305	@echo "  .globl fb_swtch_size"		>> $(OBJS_DIR)/fb_swtch.s
306	@echo "fb_swtch_size:"			>> $(OBJS_DIR)/fb_swtch.s
307	@echo "  .long . - fb_swtch_image"	>> $(OBJS_DIR)/fb_swtch.s
308	$(COMPILE.s) -o $@ $(OBJS_DIR)/fb_swtch.s
309
310# ridiculous contortions ---
311ATOMIC_SUBDIR_32	= i386
312ATOMIC_SUBDIR_64	= amd64
313ATOMIC_SUBDIR		= $(ATOMIC_SUBDIR_$(CLASS))
314
315$(OBJS_DIR)/%.o:		$(SRC)/common/atomic/$(ATOMIC_SUBDIR)/%.s
316	$(COMPILE.s) -o $@ $<
317
318$(OBJS_DIR)/%.o:		$(SRC)/common/atomic/$(ATOMIC_SUBDIR)/%.S
319	$(COMPILE.s) -o $@ $<
320
321#
322# dtrace stubs
323#
324
325$(OBJS_DIR)/dtracestubs.s:	$(UNIX_O) $(LIBS)
326	$(NM) -u $(UNIX_O) $(LIBS) | \
327	$(EGREP) '(__dtrace_probe_|smap_(disable|enable))' | $(SORT) | \
328	    $(UNIQ) | $(AWK) '{ \
329	    printf("\t.globl %s\n\t.type %s,@function\n%s:\n", \
330	    $$1, $$1, $$1); }' > $(OBJS_DIR)/dtracestubs.s
331
332$(DTRACESTUBS):	$(DTRACESTUBS_O)
333	$(BUILD.SO) $(DTRACESTUBS_O)
334