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