xref: /illumos-gate/usr/src/uts/i86pc/Makefile.rules (revision 7a6d80f1660abd4755c68cbd094d4a914681d26e)
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)
235
236DBOOT_CC_INCL	= -I$(SRC)/common -I$(SRC)/common/util $(INCLUDE_PATH)
237DBOOT_AS_INCL	= $(AS_INC_PATH)
238
239DBOOT_AS	= $(ONBLD_TOOLS)/bin/$(MACH)/aw
240
241$(DBOOT_OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/boot/%.c
242	$(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
243
244$(DBOOT_OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/dboot/%.c
245	$(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
246
247$(DBOOT_OBJS_DIR)/%.o:		$(SRC)/common/font/%.c
248	$(i386_CC) $(DBOOT_FLAGS) -O $(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) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
255
256$(DBOOT_OBJS_DIR)/%.o:		$(COMMONBASE)/crypto/sha1/%.c
257	$(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
258
259$(DBOOT_OBJS_DIR)/%.o:		$(DBOOT_OBJS_DIR)/%.c
260	$(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
261
262$(DBOOT_OBJS_DIR)/%.o:		$(COMMONBASE)/util/%.c
263	$(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
264
265$(DBOOT_OBJS_DIR)/%.o:		$(COMMONBASE)/util/i386/%.s
266	$(DBOOT_AS) -P -D_ASM $(DBOOT_DEFS) $(DBOOT_AS_INCL) -o $@ $<
267
268$(DBOOT_OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/dboot/%.s
269	$(DBOOT_AS) -P -D_ASM $(DBOOT_DEFS) $(DBOOT_AS_INCL) -o $@ $<
270
271#
272# Stuff to build bios_call.o for the kernel.
273#
274MAPFILE_BIOS	= $(UTSBASE)/i86pc/conf/Mapfile.bios
275$(OBJS_DIR)/bios_call.o:    $(UTSBASE)/i86pc/ml/bios_call_src.s
276	$(COMPILE.s) -o $(OBJS_DIR)/bios_call_src.o \
277		$(UTSBASE)/i86pc/ml/bios_call_src.s
278	$(LD) -dn -M $(MAPFILE_BIOS)  \
279		-o $(OBJS_DIR)/bios_call_src $(OBJS_DIR)/bios_call_src.o
280	@echo "  .data"				> $(OBJS_DIR)/bios_call.s
281	@echo "  .globl bios_image"		>> $(OBJS_DIR)/bios_call.s
282	@echo "bios_image:"			>> $(OBJS_DIR)/bios_call.s
283	$(ELFEXTRACT) $(OBJS_DIR)/bios_call_src	>> $(OBJS_DIR)/bios_call.s
284	@echo "  .align 4"			>> $(OBJS_DIR)/bios_call.s
285	@echo "  .globl bios_size"		>> $(OBJS_DIR)/bios_call.s
286	@echo "bios_size:"			>> $(OBJS_DIR)/bios_call.s
287	@echo "  .long . - bios_image"		>> $(OBJS_DIR)/bios_call.s
288	$(COMPILE.s) -o $@ $(OBJS_DIR)/bios_call.s
289
290#
291# Stuff to build fb_swtch.o for the kernel.
292#
293MAPFILE_FBSWTCH	= $(UTSBASE)/i86pc/conf/Mapfile.fb_swtch
294$(OBJS_DIR)/fb_swtch.o:    $(UTSBASE)/i86pc/ml/fb_swtch_src.s
295	$(COMPILE.s) -o $(OBJS_DIR)/fb_swtch_src.o \
296		$(UTSBASE)/i86pc/ml/fb_swtch_src.s
297	$(LD) -dn -M $(MAPFILE_FBSWTCH)  \
298		-o $(OBJS_DIR)/fb_swtch_src $(OBJS_DIR)/fb_swtch_src.o
299	@echo "  .data"				> $(OBJS_DIR)/fb_swtch.s
300	@echo "  .globl fb_swtch_image"		>> $(OBJS_DIR)/fb_swtch.s
301	@echo "fb_swtch_image:"			>> $(OBJS_DIR)/fb_swtch.s
302	$(ELFEXTRACT) $(OBJS_DIR)/fb_swtch_src	>> $(OBJS_DIR)/fb_swtch.s
303	@echo "  .align 4"			>> $(OBJS_DIR)/fb_swtch.s
304	@echo "  .globl fb_swtch_size"		>> $(OBJS_DIR)/fb_swtch.s
305	@echo "fb_swtch_size:"			>> $(OBJS_DIR)/fb_swtch.s
306	@echo "  .long . - fb_swtch_image"	>> $(OBJS_DIR)/fb_swtch.s
307	$(COMPILE.s) -o $@ $(OBJS_DIR)/fb_swtch.s
308
309# ridiculous contortions ---
310ATOMIC_SUBDIR_32	= i386
311ATOMIC_SUBDIR_64	= amd64
312ATOMIC_SUBDIR		= $(ATOMIC_SUBDIR_$(CLASS))
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