root / Makefile.target @ f68c781c
History | View | Annotate | Download (9.7 kB)
1 |
include config.mak |
---|---|
2 |
|
3 |
TARGET_BASE_ARCH:=$(TARGET_ARCH) |
4 |
ifeq ($(TARGET_ARCH), x86_64) |
5 |
TARGET_BASE_ARCH:=i386 |
6 |
endif |
7 |
ifeq ($(TARGET_ARCH), sparc64) |
8 |
TARGET_BASE_ARCH:=sparc |
9 |
endif |
10 |
TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH) |
11 |
VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw:$(SRC_PATH)/audio |
12 |
DEFINES=-I. -I$(TARGET_PATH) -I$(SRC_PATH) |
13 |
ifdef CONFIG_USER_ONLY |
14 |
VPATH+=:$(SRC_PATH)/linux-user |
15 |
DEFINES+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ARCH) |
16 |
endif |
17 |
CFLAGS=-Wall -O2 -g -fno-strict-aliasing |
18 |
#CFLAGS+=-Werror |
19 |
LDFLAGS=-g |
20 |
LIBS= |
21 |
HELPER_CFLAGS=$(CFLAGS) |
22 |
DYNGEN=../dyngen$(EXESUF) |
23 |
# user emulator name |
24 |
ifeq ($(TARGET_ARCH),arm) |
25 |
ifeq ($(TARGET_WORDS_BIGENDIAN),yes) |
26 |
QEMU_USER=qemu-armeb |
27 |
else |
28 |
QEMU_USER=qemu-arm |
29 |
endif |
30 |
else |
31 |
QEMU_USER=qemu-$(TARGET_ARCH) |
32 |
endif |
33 |
# system emulator name |
34 |
ifdef CONFIG_SOFTMMU |
35 |
ifeq ($(TARGET_ARCH), i386) |
36 |
QEMU_SYSTEM=qemu$(EXESUF) |
37 |
else |
38 |
QEMU_SYSTEM=qemu-system-$(TARGET_ARCH)$(EXESUF) |
39 |
endif |
40 |
else |
41 |
QEMU_SYSTEM=qemu-fast |
42 |
endif |
43 |
|
44 |
ifdef CONFIG_USER_ONLY |
45 |
PROGS=$(QEMU_USER) |
46 |
else |
47 |
PROGS+=$(QEMU_SYSTEM) |
48 |
ifndef CONFIG_SOFTMMU |
49 |
CONFIG_STATIC=y |
50 |
endif |
51 |
endif # !CONFIG_USER_ONLY |
52 |
|
53 |
ifdef CONFIG_STATIC |
54 |
LDFLAGS+=-static |
55 |
endif |
56 |
|
57 |
ifeq ($(ARCH),i386) |
58 |
CFLAGS+=-fomit-frame-pointer |
59 |
OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2 |
60 |
ifeq ($(HAVE_GCC3_OPTIONS),yes) |
61 |
OP_CFLAGS+= -falign-functions=0 -fno-gcse |
62 |
else |
63 |
OP_CFLAGS+= -malign-functions=0 |
64 |
endif |
65 |
|
66 |
ifdef TARGET_GPROF |
67 |
USE_I386_LD=y |
68 |
endif |
69 |
ifdef CONFIG_STATIC |
70 |
USE_I386_LD=y |
71 |
endif |
72 |
ifdef USE_I386_LD |
73 |
LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386.ld |
74 |
else |
75 |
# WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object |
76 |
# that the kernel ELF loader considers as an executable. I think this |
77 |
# is the simplest way to make it self virtualizable! |
78 |
LDFLAGS+=-Wl,-shared |
79 |
endif |
80 |
endif |
81 |
|
82 |
ifeq ($(ARCH),x86_64) |
83 |
OP_CFLAGS=$(CFLAGS) -falign-functions=0 |
84 |
LDFLAGS+=-Wl,-T,$(SRC_PATH)/x86_64.ld |
85 |
endif |
86 |
|
87 |
ifeq ($(ARCH),ppc) |
88 |
CFLAGS+= -D__powerpc__ |
89 |
OP_CFLAGS=$(CFLAGS) |
90 |
LDFLAGS+=-Wl,-T,$(SRC_PATH)/ppc.ld |
91 |
endif |
92 |
|
93 |
ifeq ($(ARCH),s390) |
94 |
OP_CFLAGS=$(CFLAGS) |
95 |
LDFLAGS+=-Wl,-T,$(SRC_PATH)/s390.ld |
96 |
endif |
97 |
|
98 |
ifeq ($(ARCH),sparc) |
99 |
CFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6 |
100 |
LDFLAGS+=-m32 |
101 |
OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0 |
102 |
HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat |
103 |
# -static is used to avoid g1/g3 usage by the dynamic linker |
104 |
LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc.ld -static |
105 |
endif |
106 |
|
107 |
ifeq ($(ARCH),sparc64) |
108 |
CFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6 |
109 |
LDFLAGS+=-m64 |
110 |
OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0 |
111 |
endif |
112 |
|
113 |
ifeq ($(ARCH),alpha) |
114 |
# -msmall-data is not used because we want two-instruction relocations |
115 |
# for the constant constructions |
116 |
OP_CFLAGS=-Wall -O2 -g |
117 |
# Ensure there's only a single GP |
118 |
CFLAGS += -msmall-data |
119 |
LDFLAGS+=-Wl,-T,$(SRC_PATH)/alpha.ld |
120 |
endif |
121 |
|
122 |
ifeq ($(ARCH),ia64) |
123 |
CFLAGS += -mno-sdata |
124 |
OP_CFLAGS=$(CFLAGS) |
125 |
LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld |
126 |
endif |
127 |
|
128 |
ifeq ($(ARCH),arm) |
129 |
OP_CFLAGS=$(CFLAGS) -mno-sched-prolog -fno-omit-frame-pointer |
130 |
LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld |
131 |
endif |
132 |
|
133 |
ifeq ($(ARCH),m68k) |
134 |
OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer |
135 |
LDFLAGS+=-Wl,-T,m68k.ld |
136 |
endif |
137 |
|
138 |
ifeq ($(HAVE_GCC3_OPTIONS),yes) |
139 |
# very important to generate a return at the end of every operation |
140 |
OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls |
141 |
endif |
142 |
|
143 |
ifeq ($(CONFIG_DARWIN),yes) |
144 |
OP_CFLAGS+= -mdynamic-no-pic |
145 |
LIBS+=-lmx |
146 |
endif |
147 |
|
148 |
######################################################### |
149 |
|
150 |
DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE |
151 |
LIBS+=-lm |
152 |
ifndef CONFIG_USER_ONLY |
153 |
LIBS+=-lz |
154 |
endif |
155 |
ifdef CONFIG_WIN32 |
156 |
LIBS+=-lwinmm -lws2_32 -liphlpapi |
157 |
endif |
158 |
|
159 |
# profiling code |
160 |
ifdef TARGET_GPROF |
161 |
LDFLAGS+=-p |
162 |
main.o: CFLAGS+=-p |
163 |
endif |
164 |
|
165 |
OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o |
166 |
ifeq ($(TARGET_ARCH), i386) |
167 |
OBJS+= vm86.o |
168 |
endif |
169 |
ifeq ($(TARGET_ARCH), arm) |
170 |
OBJS+=nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \ |
171 |
nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \ |
172 |
nwfpe/double_cpdo.o nwfpe/extended_cpdo.o arm-semi.o |
173 |
endif |
174 |
SRCS:= $(OBJS:.o=.c) |
175 |
OBJS+= libqemu.a |
176 |
|
177 |
# cpu emulator library |
178 |
LIBOBJS=exec.o kqemu.o translate-op.o translate-all.o cpu-exec.o\ |
179 |
translate.o op.o |
180 |
ifdef CONFIG_SOFTFLOAT |
181 |
LIBOBJS+=fpu/softfloat.o |
182 |
else |
183 |
LIBOBJS+=fpu/softfloat-native.o |
184 |
endif |
185 |
DEFINES+=-I$(SRC_PATH)/fpu |
186 |
|
187 |
ifeq ($(TARGET_ARCH), i386) |
188 |
LIBOBJS+=helper.o helper2.o |
189 |
ifeq ($(ARCH), i386) |
190 |
LIBOBJS+=translate-copy.o |
191 |
endif |
192 |
endif |
193 |
|
194 |
ifeq ($(TARGET_ARCH), x86_64) |
195 |
LIBOBJS+=helper.o helper2.o |
196 |
endif |
197 |
|
198 |
ifeq ($(TARGET_ARCH), ppc) |
199 |
LIBOBJS+= op_helper.o helper.o |
200 |
endif |
201 |
|
202 |
ifeq ($(TARGET_ARCH), mips) |
203 |
LIBOBJS+= op_helper.o helper.o |
204 |
endif |
205 |
|
206 |
ifeq ($(TARGET_BASE_ARCH), sparc) |
207 |
LIBOBJS+= op_helper.o helper.o |
208 |
endif |
209 |
|
210 |
ifeq ($(TARGET_BASE_ARCH), arm) |
211 |
LIBOBJS+= op_helper.o |
212 |
endif |
213 |
|
214 |
# NOTE: the disassembler code is only needed for debugging |
215 |
LIBOBJS+=disas.o |
216 |
ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386) |
217 |
USE_I386_DIS=y |
218 |
endif |
219 |
ifeq ($(findstring x86_64, $(TARGET_ARCH) $(ARCH)),x86_64) |
220 |
USE_I386_DIS=y |
221 |
endif |
222 |
ifdef USE_I386_DIS |
223 |
LIBOBJS+=i386-dis.o |
224 |
endif |
225 |
ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha) |
226 |
LIBOBJS+=alpha-dis.o |
227 |
endif |
228 |
ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc) |
229 |
LIBOBJS+=ppc-dis.o |
230 |
endif |
231 |
ifeq ($(findstring mips, $(TARGET_ARCH) $(ARCH)),mips) |
232 |
LIBOBJS+=mips-dis.o |
233 |
endif |
234 |
ifeq ($(findstring sparc, $(TARGET_BASE_ARCH) $(ARCH)),sparc) |
235 |
LIBOBJS+=sparc-dis.o |
236 |
endif |
237 |
ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm) |
238 |
LIBOBJS+=arm-dis.o |
239 |
endif |
240 |
|
241 |
ifeq ($(ARCH),ia64) |
242 |
OBJS += ia64-syscall.o |
243 |
endif |
244 |
ifdef CONFIG_GDBSTUB |
245 |
OBJS+=gdbstub.o |
246 |
endif |
247 |
|
248 |
all: $(PROGS) |
249 |
|
250 |
$(QEMU_USER): $(OBJS) |
251 |
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) |
252 |
ifeq ($(ARCH),alpha) |
253 |
# Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of |
254 |
# the address space (31 bit so sign extending doesn't matter) |
255 |
echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc |
256 |
endif |
257 |
|
258 |
# must use static linking to avoid leaving stuff in virtual address space |
259 |
VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o |
260 |
VL_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o block-bochs.o block-vpc.o block-vvfat.o |
261 |
|
262 |
SOUND_HW = sb16.o |
263 |
AUDIODRV = audio.o noaudio.o wavaudio.o |
264 |
ifdef CONFIG_SDL |
265 |
AUDIODRV += sdlaudio.o |
266 |
endif |
267 |
ifdef CONFIG_OSS |
268 |
AUDIODRV += ossaudio.o |
269 |
endif |
270 |
|
271 |
pc.o: DEFINES := -DUSE_SB16 $(DEFINES) |
272 |
|
273 |
ifdef CONFIG_ADLIB |
274 |
SOUND_HW += fmopl.o adlib.o |
275 |
endif |
276 |
|
277 |
ifdef CONFIG_FMOD |
278 |
AUDIODRV += fmodaudio.o |
279 |
audio.o fmodaudio.o: DEFINES := -I$(CONFIG_FMOD_INC) $(DEFINES) |
280 |
LIBS += $(CONFIG_FMOD_LIB) |
281 |
endif |
282 |
|
283 |
ifeq ($(TARGET_BASE_ARCH), i386) |
284 |
# Hardware support |
285 |
VL_OBJS+= ide.o ne2000.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV) |
286 |
VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o |
287 |
VL_OBJS+= cirrus_vga.o mixeng.o apic.o parallel.o |
288 |
endif |
289 |
ifeq ($(TARGET_ARCH), ppc) |
290 |
VL_OBJS+= ppc.o ide.o ne2000.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV) |
291 |
VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o |
292 |
VL_OBJS+= ppc_prep.o ppc_chrp.o cuda.o adb.o openpic.o heathrow_pic.o mixeng.o |
293 |
endif |
294 |
ifeq ($(TARGET_ARCH), mips) |
295 |
VL_OBJS+= mips_r4k.o dma.o vga.o serial.o ne2000.o i8259.o |
296 |
#VL_OBJS+= #ide.o pckbd.o i8254.o fdc.o m48t59.o |
297 |
endif |
298 |
ifeq ($(TARGET_BASE_ARCH), sparc) |
299 |
ifeq ($(TARGET_ARCH), sparc64) |
300 |
VL_OBJS+= sun4u.o m48t08.o magic-load.o slavio_serial.o |
301 |
else |
302 |
VL_OBJS+= sun4m.o tcx.o lance.o iommu.o m48t08.o magic-load.o slavio_intctl.o slavio_timer.o slavio_serial.o slavio_misc.o fdc.o esp.o |
303 |
endif |
304 |
endif |
305 |
ifdef CONFIG_GDBSTUB |
306 |
VL_OBJS+=gdbstub.o |
307 |
endif |
308 |
ifdef CONFIG_SDL |
309 |
VL_OBJS+=sdl.o |
310 |
endif |
311 |
ifdef CONFIG_COCOA |
312 |
VL_OBJS+=cocoa.o |
313 |
COCOA_LIBS=-F/System/Library/Frameworks -framework Cocoa |
314 |
endif |
315 |
ifdef CONFIG_SLIRP |
316 |
DEFINES+=-I$(SRC_PATH)/slirp |
317 |
SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \ |
318 |
slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \ |
319 |
tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o |
320 |
VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS)) |
321 |
endif |
322 |
|
323 |
VL_LDFLAGS= |
324 |
# specific flags are needed for non soft mmu emulator |
325 |
ifdef CONFIG_STATIC |
326 |
VL_LDFLAGS+=-static |
327 |
endif |
328 |
ifndef CONFIG_SOFTMMU |
329 |
VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld |
330 |
endif |
331 |
ifndef CONFIG_DARWIN |
332 |
ifndef CONFIG_WIN32 |
333 |
VL_LIBS=-lutil |
334 |
endif |
335 |
endif |
336 |
ifdef TARGET_GPROF |
337 |
vl.o: CFLAGS+=-p |
338 |
VL_LDFLAGS+=-p |
339 |
endif |
340 |
|
341 |
ifeq ($(ARCH),ia64) |
342 |
VL_LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld |
343 |
endif |
344 |
|
345 |
$(QEMU_SYSTEM): $(VL_OBJS) libqemu.a |
346 |
$(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(VL_LIBS) |
347 |
|
348 |
cocoa.o: cocoa.m |
349 |
$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $< |
350 |
|
351 |
sdl.o: sdl.c keymaps.c sdl_keysym.h |
352 |
$(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $< |
353 |
|
354 |
sdlaudio.o: sdlaudio.c |
355 |
$(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $< |
356 |
|
357 |
depend: $(SRCS) |
358 |
$(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend |
359 |
|
360 |
# libqemu |
361 |
|
362 |
libqemu.a: $(LIBOBJS) |
363 |
rm -f $@ |
364 |
$(AR) rcs $@ $(LIBOBJS) |
365 |
|
366 |
translate.o: translate.c gen-op.h opc.h cpu.h |
367 |
|
368 |
translate-all.o: translate-all.c opc.h cpu.h |
369 |
|
370 |
translate-op.o: translate-all.c op.h opc.h cpu.h |
371 |
|
372 |
op.h: op.o $(DYNGEN) |
373 |
$(DYNGEN) -o $@ $< |
374 |
|
375 |
opc.h: op.o $(DYNGEN) |
376 |
$(DYNGEN) -c -o $@ $< |
377 |
|
378 |
gen-op.h: op.o $(DYNGEN) |
379 |
$(DYNGEN) -g -o $@ $< |
380 |
|
381 |
op.o: op.c |
382 |
$(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $< |
383 |
|
384 |
helper.o: helper.c |
385 |
$(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $< |
386 |
|
387 |
ifeq ($(TARGET_BASE_ARCH), i386) |
388 |
op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h ops_sse.h |
389 |
endif |
390 |
|
391 |
ifeq ($(TARGET_ARCH), arm) |
392 |
op.o: op.c op_template.h |
393 |
endif |
394 |
|
395 |
ifeq ($(TARGET_BASE_ARCH), sparc) |
396 |
op.o: op.c op_template.h op_mem.h fop_template.h fbranch_template.h |
397 |
magic_load.o: elf_op.h |
398 |
endif |
399 |
|
400 |
ifeq ($(TARGET_ARCH), ppc) |
401 |
op.o: op.c op_template.h op_mem.h |
402 |
op_helper.o: op_helper_mem.h |
403 |
translate.o: translate.c translate_init.c |
404 |
endif |
405 |
|
406 |
ifeq ($(TARGET_ARCH), mips) |
407 |
op.o: op.c op_template.c op_mem.c |
408 |
op_helper.o: op_helper_mem.c |
409 |
endif |
410 |
|
411 |
mixeng.o: mixeng.c mixeng.h mixeng_template.h |
412 |
|
413 |
%.o: %.c |
414 |
$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $< |
415 |
|
416 |
%.o: %.S |
417 |
$(CC) $(DEFINES) -c -o $@ $< |
418 |
|
419 |
clean: |
420 |
rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o fpu/*.o |
421 |
|
422 |
install: all |
423 |
ifneq ($(PROGS),) |
424 |
install -m 755 -s $(PROGS) "$(bindir)" |
425 |
endif |
426 |
|
427 |
ifneq ($(wildcard .depend),) |
428 |
include .depend |
429 |
endif |