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