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