xref: /illumos-gate/usr/src/uts/i86pc/Makefile.rules (revision 549ec3fff108310966327d1dc9004551b63210b7)
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 2007 Sun Microsystems, Inc.  All rights reserved.
24# Use is subject to license terms.
25#
26# ident	"%Z%%M%	%I%	%E% SMI"
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, sun4u rules come before
36#	  sparc 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/amd_opteron/%.s
53	$(COMPILE.s) -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/generic_cpu/%.s
60	$(COMPILE.s) -o $@ $<
61
62$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/%.c
63	$(COMPILE.c) -o $@ $<
64	$(CTFCONVERT_O)
65
66$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/mc/%.c
67	$(COMPILE.c) -o $@ $<
68	$(CTFCONVERT_O)
69
70$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/pci/%.c
71	$(COMPILE.c) -o $@ $<
72	$(CTFCONVERT_O)
73
74$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/pciex/%.c
75	$(COMPILE.c) -o $@ $<
76	$(CTFCONVERT_O)
77
78$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/pcplusmp/%.c
79	$(COMPILE.c) -o $@ $<
80	$(CTFCONVERT_O)
81
82$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/pcplusmp/%.s
83	$(COMPILE.s) -o $@ $<
84
85$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/psm/%.c
86	$(COMPILE.c) -o $@ $<
87	$(CTFCONVERT_O)
88
89$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/psm/%.s
90	$(COMPILE.s) -o $@ $<
91
92$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/tzmon/%.c
93	$(COMPILE.c) -o $@ $<
94	$(CTFCONVERT_O)
95
96$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/ml/%.s
97	$(COMPILE.s) -o $@ $<
98
99$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/os/%.c
100	$(COMPILE.c) -o $@ $<
101	$(CTFCONVERT_O)
102
103$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/boot/%.c
104	$(COMPILE.c) -o $@ $<
105	$(CTFCONVERT_O)
106
107$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/vm/%.c
108	$(COMPILE.c) -o $@ $<
109	$(CTFCONVERT_O)
110
111$(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/%.c
112	$(COMPILE.c) -o $@ $<
113	$(CTFCONVERT_O)
114
115$(OBJS_DIR)/%.o:		$(UTSBASE)/common/os/%.c
116	$(COMPILE.c) -o $@ $<
117	$(CTFCONVERT_O)
118
119$(OBJS_DIR)/%.o:		$(SRC)/common/dis/i386/%.c
120	$(COMPILE.c) -o $@ $<
121	$(CTFCONVERT_O)
122
123$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/gfx_private/%.c
124	$(COMPILE.c) -o $@ $<
125	$(CTFCONVERT_O)
126
127$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/xsvc/%.c
128	$(COMPILE.c) -o $@ $<
129	$(CTFCONVERT_O)
130
131#
132# dboot stuff is always 32 bit, linked to run with phys_addr == virt_addr
133#
134DBOOT_OBJS_DIR	= dboot/$(OBJS_DIR)
135DBOOT_MACH_32	= -D_BOOT_TARGET_i386
136DBOOT_MACH_64	= -D_BOOT_TARGET_amd64
137DBOOT_DEFS	= -D_BOOT $(DBOOT_MACH_$(CLASS))
138DBOOT_DEFS	+= -D_MACHDEP -D_KMEMUSER -U_KERNEL -D_I32LPx
139
140DBOOT_CC_INCL	= -I$(SRC)/common $(INCLUDE_PATH)
141DBOOT_AS_INCL	= $(AS_INC_PATH)
142
143DBOOT_AS	= $(ONBLD_TOOLS)/bin/$(MACH)/aw
144
145DBOOT_LINTS_DIR	= $(DBOOT_OBJS_DIR)
146DBOOT_LINTFLAGS_i86pc	= $(LINTFLAGS_i386_32) $(LINTTAGS_i386_32)
147
148DBOOT_LINTFLAGS = $(DBOOT_LINTFLAGS_$(PLATFORM)) $(C99LMODE) $(CPPFLAGS) \
149	$(DBOOT_DEFS)
150DBOOT_LOCAL_LINTFLAGS   = -c -dirout=$(DBOOT_LINTS_DIR) -I$(SRC)/common \
151	$(DBOOT_LINTFLAGS)
152
153$(DBOOT_OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/boot/%.c
154	$(i386_CC) $(CERRWARN) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
155
156$(DBOOT_OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/dboot/%.c
157	$(i386_CC) $(CERRWARN) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
158
159$(DBOOT_OBJS_DIR)/%.o:		$(COMMONBASE)/util/%.c
160	$(i386_CC) $(CERRWARN) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
161
162$(DBOOT_OBJS_DIR)/%.o:		$(COMMONBASE)/util/i386/%.s
163	$(DBOOT_AS) -P -D_ASM $(DBOOT_DEFS) $(DBOOT_AS_INCL) -o $@ $<
164
165$(DBOOT_OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/dboot/%.s
166	$(DBOOT_AS) -P -D_ASM $(DBOOT_DEFS) $(DBOOT_AS_INCL) -o $@ $<
167
168#
169# Stuff to build bios_call.o for the kernel.
170#
171MAPFILE_BIOS	= $(UTSBASE)/i86pc/conf/Mapfile.bios
172$(OBJS_DIR)/bios_call.o:    $(UTSBASE)/i86pc/ml/bios_call_src.s
173	$(COMPILE.s) -o $(OBJS_DIR)/bios_call_src.o \
174		$(UTSBASE)/i86pc/ml/bios_call_src.s
175	$(LD) -dn -M $(MAPFILE_BIOS)  \
176		-o $(OBJS_DIR)/bios_call_src $(OBJS_DIR)/bios_call_src.o
177	@echo "  .data"				> $(OBJS_DIR)/bios_call.s
178	@echo "  .globl bios_image"		>> $(OBJS_DIR)/bios_call.s
179	@echo "bios_image:"			>> $(OBJS_DIR)/bios_call.s
180	$(ELFEXTRACT) $(OBJS_DIR)/bios_call_src	>> $(OBJS_DIR)/bios_call.s
181	@echo "  .align 4"			>> $(OBJS_DIR)/bios_call.s
182	@echo "  .globl bios_size"		>> $(OBJS_DIR)/bios_call.s
183	@echo "bios_size:"			>> $(OBJS_DIR)/bios_call.s
184	@echo "  .long . - bios_image"		>> $(OBJS_DIR)/bios_call.s
185	$(COMPILE.s) -o $@ $(OBJS_DIR)/bios_call.s
186
187# ridiculous contortions ---
188ATOMIC_SUBDIR_32	= i386
189ATOMIC_SUBDIR_64	= amd64
190ATOMIC_SUBDIR		= $(ATOMIC_SUBDIR_$(CLASS))
191
192$(OBJS_DIR)/%.o:		$(SRC)/common/atomic/$(ATOMIC_SUBDIR)/%.s
193	$(COMPILE.s) -o $@ $<
194
195$(OBJS_DIR)/%.o:		$(SRC)/common/mc/mc-amd/%.c
196	$(COMPILE.c) -o $@ $<
197	$(CTFCONVERT_O)
198
199#
200# dtrace stubs
201#
202
203$(OBJS_DIR)/dtracestubs.s:	$(UNIX_O) $(LIBS)
204	nm -u $(UNIX_O) $(LIBS) | grep __dtrace_probe_ | sort | uniq | nawk '{ \
205	    printf("\t.globl %s\n\t.type %s,@function\n%s:\n", \
206	    $$1, $$1, $$1); }' > $(OBJS_DIR)/dtracestubs.s
207
208$(DTRACESTUBS):	$(DTRACESTUBS_O)
209	$(BUILD.SO) $(DTRACESTUBS_O)
210
211#
212#	Section 1b: Lint `object' build rules
213#
214$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86pc/conf/%.c
215	@($(LHEAD) $(LINT.c) $< $(LTAIL))
216
217$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86pc/cpu/amd_opteron/%.c
218	@($(LHEAD) $(LINT.c) $< $(LTAIL))
219
220$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86pc/cpu/amd_opteron/%.s
221	@($(LHEAD) $(LINT.s) $< $(LTAIL))
222
223$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86pc/cpu/generic_cpu/%.c
224	@($(LHEAD) $(LINT.c) $< $(LTAIL))
225
226$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86pc/cpu/generic_cpu/%.s
227	@($(LHEAD) $(LINT.s) $< $(LTAIL))
228
229$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86pc/io/%.c
230	@($(LHEAD) $(LINT.c) $< $(LTAIL))
231
232$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86pc/io/mc/%.c
233	@($(LHEAD) $(LINT.c) $< $(LTAIL))
234
235$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86pc/io/pci/%.c
236	@($(LHEAD) $(LINT.c) $< $(LTAIL))
237
238$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86pc/io/pciex/%.c
239	@($(LHEAD) $(LINT.c) $< $(LTAIL))
240
241$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86pc/io/pcplusmp/%.c
242	@($(LHEAD) $(LINT.c) $< $(LTAIL))
243
244$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86pc/io/pcplusmp/%.s
245	@($(LHEAD) $(LINT.s) $< $(LTAIL))
246
247$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86pc/io/psm/%.c
248	@($(LHEAD) $(LINT.c) $< $(LTAIL))
249
250$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86pc/io/psm/%.s
251	@($(LHEAD) $(LINT.s) $< $(LTAIL))
252
253$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86pc/io/tzmon/%.c
254	@($(LHEAD) $(LINT.c) $< $(LTAIL))
255
256$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86pc/ml/%.s
257	@($(LHEAD) $(LINT.s) $< $(LTAIL))
258
259$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86pc/os/%.c
260	@($(LHEAD) $(LINT.c) $< $(LTAIL))
261
262$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86pc/boot/%.c
263	@($(LHEAD) $(LINT.c) $< $(LTAIL))
264
265$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86pc/vm/%.c
266	@($(LHEAD) $(LINT.c) $< $(LTAIL))
267
268$(LINTS_DIR)/%.ln:		$(UTSBASE)/common/io/%.c
269	@($(LHEAD) $(LINT.c) $< $(LTAIL))
270
271$(LINTS_DIR)/%.ln:		$(UTSBASE)/common/os/%.c
272	@($(LHEAD) $(LINT.c) $< $(LTAIL))
273
274$(LINTS_DIR)/%.ln:		$(SRC)/common/dis/i386/%.c
275	@($(LHEAD) $(LINT.c) $< $(LTAIL))
276
277$(LINTS_DIR)/%.ln:		$(SRC)/common/atomic/%.c
278	@($(LHEAD) $(LINT.c) $< $(LTAIL))
279
280$(LINTS_DIR)/%.ln:		$(SRC)/common/mc/mc-amd/%.c
281	@($(LHEAD) $(LINT.c) $< $(LTAIL))
282
283$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86pc/io/gfx_private/%.c
284	@($(LHEAD) $(LINT.c) $< $(LTAIL))
285
286$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86pc/io/xsvc/%.c
287	@($(LHEAD) $(LINT.c) $< $(LTAIL))
288
289#
290# bios call has a funky name change while building
291#
292$(LINTS_DIR)/bios_call.ln:	$(UTSBASE)/i86pc/ml/bios_call_src.s
293	@($(LHEAD) $(LINT.s) $(UTSBASE)/i86pc/ml/bios_call_src.s  $(LTAIL))
294	@mv $(LINTS_DIR)/bios_call_src.ln $(LINTS_DIR)/bios_call.ln
295
296#
297# dboot always compiles in 32-bit mode, so force lint to be 32-bit mode too.
298#
299$(DBOOT_LINTS_DIR)/%.ln: $(UTSBASE)/i86pc/dboot/%.c
300	@($(LHEAD) $(DBOOT_LINT) $(DBOOT_LOCAL_LINTFLAGS) $< $(LTAIL))
301
302$(DBOOT_LINTS_DIR)/%.ln: $(UTSBASE)/i86pc/dboot/%.s
303	@($(LHEAD) $(DBOOT_LINT) $(DBOOT_LOCAL_LINTFLAGS) $< $(LTAIL))
304
305$(DBOOT_LINTS_DIR)/%.ln: $(UTSBASE)/i86pc/boot/%.c
306	@($(LHEAD) $(DBOOT_LINT) $(DBOOT_LOCAL_LINTFLAGS) $< $(LTAIL))
307
308$(DBOOT_LINTS_DIR)/%.ln: $(COMMONBASE)/util/%.c
309	@($(LHEAD) $(DBOOT_LINT) $(DBOOT_LOCAL_LINTFLAGS) $< $(LTAIL))
310
311$(DBOOT_LINTS_DIR)/%.ln: $(COMMONBASE)/util/i386/%.s
312	@($(LHEAD) $(DBOOT_LINT) $(DBOOT_LOCAL_LINTFLAGS) $< $(LTAIL))
313
314