xref: /illumos-gate/usr/src/uts/i86pc/Makefile.rules (revision 5328fc53d11d7151861fa272e4fb0248b8f0e145)
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 OmniOS Community Edition (OmniOSce) Association.
26#
27
28#	This Makefile defines the build rules for the directory uts/i86pc
29#	and its children. These are the source files which are i86pc
30#	"implementation architecture" dependent.
31#
32#	The following two-level ordering must be maintained in this file.
33#	  Lines are sorted first in order of decreasing specificity based on
34#	  the first directory component.  That is, i86pc rules come before
35#	  intel rules come before common rules.
36#
37#	  Lines whose initial directory components are equal are sorted
38#	  alphabetically by the remaining components.
39
40#
41#	Section 1a: C object build rules
42#
43$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/conf/%.c
44	$(COMPILE.c) -o $@ $<
45	$(CTFCONVERT_O)
46
47$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/cpu/amd_opteron/%.c
48	$(COMPILE.c) -o $@ $<
49	$(CTFCONVERT_O)
50
51$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/cpu/authenticamd/%.c
52	$(COMPILE.c) -o $@ $<
53	$(CTFCONVERT_O)
54
55$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/cpu/generic_cpu/%.c
56	$(COMPILE.c) -o $@ $<
57	$(CTFCONVERT_O)
58
59$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/cpu/genuineintel/%.c
60	$(COMPILE.c) -o $@ $<
61	$(CTFCONVERT_O)
62
63$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/%.c
64	$(COMPILE.c) -o $@ $<
65	$(CTFCONVERT_O)
66
67$(OBJS_DIR)/%.o:                $(UTSBASE)/i86pc/io/acpi_drv/%.c
68	$(COMPILE.c) -o $@ $<
69	$(CTFCONVERT_O)
70
71$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/fipe/%.c
72	$(COMPILE.c) -o $@ $<
73	$(CTFCONVERT_O)
74
75$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/acpi/acpidev/%.c
76	$(COMPILE.c) -o $@ $<
77	$(CTFCONVERT_O)
78
79$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/acpi/acpinex/%.c
80	$(COMPILE.c) -o $@ $<
81	$(CTFCONVERT_O)
82
83SBD_IOCTL	= $(UTSBASE)/i86pc/sys/sbd_ioctl.h
84DRMACH_IO	= $(UTSBASE)/i86pc/io/acpi/drmach_acpi
85DRMACH_GENERR	= $(DRMACH_IO)/sbdgenerr
86DR_IO		= $(UTSBASE)/i86pc/io/dr
87DR_GENERR	= $(DR_IO)/sbdgenerr
88
89$(DRMACH_GENERR):	$(DR_IO)/sbdgenerr.pl
90	$(RM) $@
91	$(CAT) $(DR_IO)/sbdgenerr.pl > $@
92	$(CHMOD) +x $@
93
94$(DRMACH_IO)/drmach_err.c:	$(DRMACH_GENERR) $(SBD_IOCTL)
95	$(RM) $@
96	$(DRMACH_GENERR) EX86 < $(SBD_IOCTL) > $(DRMACH_IO)/drmach_err.c
97
98$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/acpi/drmach_acpi/%.c
99	$(COMPILE.c) -o $@ $<
100	$(CTFCONVERT_O)
101
102$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/amd_iommu/%.c
103	$(COMPILE.c) -o $@ $<
104	$(CTFCONVERT_O)
105
106$(DR_GENERR):			$(DR_IO)/sbdgenerr.pl
107	$(RM) $@
108	$(CAT) $(DR_IO)/sbdgenerr.pl > $@
109	$(CHMOD) +x $@
110
111$(DR_IO)/dr_err.c:		$(DR_GENERR) $(SBD_IOCTL)
112	$(RM) $@
113	$(DR_GENERR) ESBD < $(SBD_IOCTL) > $(DR_IO)/dr_err.c
114
115$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/dr/%.c
116	$(COMPILE.c) -o $@ $<
117	$(CTFCONVERT_O)
118
119$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/ioat/%.c
120	$(COMPILE.c) -o $@ $<
121	$(CTFCONVERT_O)
122
123$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/pci/%.c
124	$(COMPILE.c) -o $@ $<
125	$(CTFCONVERT_O)
126
127$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/pciex/%.c
128	$(COMPILE.c) -o $@ $<
129	$(CTFCONVERT_O)
130
131$(OBJS_DIR)/%.o:		$(UTSBASE)/intel/io/pciex/hotplug/%.c
132	$(COMPILE.c) -o $@ $<
133	$(CTFCONVERT_O)
134
135$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/pcplusmp/%.c
136	$(COMPILE.c) -o $@ $<
137	$(CTFCONVERT_O)
138
139$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/pcplusmp/%.s
140	$(COMPILE.s) -o $@ $<
141
142$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/apix/%.c
143	$(COMPILE.c) -o $@ $<
144	$(CTFCONVERT_O)
145
146$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/ppm/%.c
147	$(COMPILE.c) -o $@ $<
148	$(CTFCONVERT_O)
149
150$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/ppm/%.s
151	$(COMPILE.s) -o $@ $<
152
153$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/psm/%.c
154	$(COMPILE.c) -o $@ $<
155	$(CTFCONVERT_O)
156
157$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/psm/%.s
158	$(COMPILE.s) -o $@ $<
159
160$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/tzmon/%.c
161	$(COMPILE.c) -o $@ $<
162	$(CTFCONVERT_O)
163
164$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/ml/%.s
165	$(COMPILE.s) -o $@ $<
166
167$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/os/%.c
168	$(COMPILE.c) -_gcc=-fno-stack-protector -o $@ $<
169	$(CTFCONVERT_O)
170
171$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/os/cpupm/%.c
172	$(COMPILE.c) -o $@ $<
173	$(CTFCONVERT_O)
174
175$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/boot/%.c
176	$(COMPILE.c) -o $@ $<
177	$(CTFCONVERT_O)
178
179$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/vm/%.c
180	$(COMPILE.c) -o $@ $<
181	$(CTFCONVERT_O)
182
183$(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/%.c
184	$(COMPILE.c) -o $@ $<
185	$(CTFCONVERT_O)
186
187$(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/ppm/%.c
188	$(COMPILE.c) -o $@ $<
189	$(CTFCONVERT_O)
190
191$(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/pciex/%.c
192	$(COMPILE.c) -o $@ $<
193	$(CTFCONVERT_O)
194
195$(OBJS_DIR)/%.o:		$(UTSBASE)/common/os/%.c
196	$(COMPILE.c) -o $@ $<
197	$(CTFCONVERT_O)
198
199$(OBJS_DIR)/%.o:		$(SRC)/common/dis/i386/%.c
200	$(COMPILE.c) -o $@ $<
201	$(CTFCONVERT_O)
202
203$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/gfx_private/%.c
204	$(COMPILE.c) -o $@ $<
205	$(CTFCONVERT_O)
206
207$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/xsvc/%.c
208	$(COMPILE.c) -o $@ $<
209	$(CTFCONVERT_O)
210
211$(OBJS_DIR)/%.o:		$(UTSBASE)/common/xen/os/%.c
212	$(COMPILE.c) -o $@ $<
213	$(CTFCONVERT_O)
214
215$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/dboot/%.c
216	$(COMPILE.c) -o $@ $<
217	$(CTFCONVERT_O)
218
219#
220# dboot stuff is always 32 bit, linked to run with phys_addr == virt_addr
221#
222DBOOT_OBJS_DIR	= dboot/$(OBJS_DIR)
223DBOOT_MACH_32	= -D_BOOT_TARGET_i386
224DBOOT_MACH_64	= -D_BOOT_TARGET_amd64
225DBOOT_DEFS	= -D_BOOT $(DBOOT_MACH_$(CLASS))
226DBOOT_DEFS	+= -D_MACHDEP -U_KERNEL -D_I32LPx
227DBOOT_FLAGS	= $(CFLAGS_XARCH_32) $(CCVERBOSE) $(CSTD) $(CERRWARN)
228DBOOT_FLAGS	+= $(CCNOAUTOINLINE)
229
230DBOOT_CC_INCL	= -I$(SRC)/common -I$(SRC)/common/util $(INCLUDE_PATH)
231DBOOT_AS_INCL	= $(AS_INC_PATH)
232
233DBOOT_AS	= $(ONBLD_TOOLS)/bin/$(MACH)/aw
234
235$(DBOOT_OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/boot/%.c
236	$(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
237
238$(DBOOT_OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/dboot/%.c
239	$(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
240
241$(DBOOT_OBJS_DIR)/%.o:		$(UTSBASE)/intel/ia32/%.s
242	$(DBOOT_AS) -P -D_ASM $(DBOOT_DEFS) $(DBOOT_AS_INCL) -o $@ $<
243
244$(DBOOT_OBJS_DIR)/%.o:		$(SRC)/common/font/%.c
245	$(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
246
247$(DBOOT_OBJS_DIR)/$(FONT).c:	$(FONT_DIR)/$(FONT_SRC).bdf
248	$(VTFONTCVT) -f source -o $@ $(FONT_DIR)/$(FONT_SRC).bdf
249
250$(DBOOT_OBJS_DIR)/%.o:		$(DBOOT_OBJS_DIR)/%.c
251	$(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
252
253$(DBOOT_OBJS_DIR)/%.o:		$(COMMONBASE)/crypto/sha1/%.c
254	$(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
255
256$(DBOOT_OBJS_DIR)/%.o:		$(DBOOT_OBJS_DIR)/%.c
257	$(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
258
259$(DBOOT_OBJS_DIR)/%.o:		$(COMMONBASE)/util/%.c
260	$(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
261
262$(DBOOT_OBJS_DIR)/%.o:		$(COMMONBASE)/util/i386/%.s
263	$(DBOOT_AS) -P -D_ASM $(DBOOT_DEFS) $(DBOOT_AS_INCL) -o $@ $<
264
265$(DBOOT_OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/dboot/%.s
266	$(DBOOT_AS) -P -D_ASM $(DBOOT_DEFS) $(DBOOT_AS_INCL) -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#
315# dtrace stubs
316#
317
318$(OBJS_DIR)/dtracestubs.s:	$(UNIX_O) $(LIBS)
319	$(NM) -u $(UNIX_O) $(LIBS) | $(GREP) __dtrace_probe_ | $(SORT) | \
320	    $(UNIQ) | $(AWK) '{ \
321	    printf("\t.globl %s\n\t.type %s,@function\n%s:\n", \
322	    $$1, $$1, $$1); }' > $(OBJS_DIR)/dtracestubs.s
323
324$(DTRACESTUBS):	$(DTRACESTUBS_O)
325	$(BUILD.SO) $(DTRACESTUBS_O)
326