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