]> git.proxmox.com Git - qemu.git/blame - Makefile.target
Change order of metadata update to prevent loosing guest data because of unexpected...
[qemu.git] / Makefile.target
CommitLineData
626df76a
FB
1include config.mak
2
0b0babc6
FB
3TARGET_BASE_ARCH:=$(TARGET_ARCH)
4ifeq ($(TARGET_ARCH), x86_64)
5TARGET_BASE_ARCH:=i386
6endif
540635ba
TS
7ifeq ($(TARGET_ARCH), mipsn32)
8TARGET_BASE_ARCH:=mips
9endif
fbe4f65b
TS
10ifeq ($(TARGET_ARCH), mips64)
11TARGET_BASE_ARCH:=mips
12endif
a2458627
FB
13ifeq ($(TARGET_ARCH), ppc64)
14TARGET_BASE_ARCH:=ppc
15endif
22f8a8b3
JM
16ifeq ($(TARGET_ARCH), ppc64h)
17TARGET_BASE_ARCH:=ppc
18endif
d4082e95
JM
19ifeq ($(TARGET_ARCH), ppcemb)
20TARGET_BASE_ARCH:=ppc
21endif
64b3ab24
FB
22ifeq ($(TARGET_ARCH), sparc64)
23TARGET_BASE_ARCH:=sparc
24endif
0b0babc6 25TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH)
4fb240a4 26VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw
46dc3881 27CPPFLAGS=-I. -I.. -I$(TARGET_PATH) -I$(SRC_PATH) -MMD -MT $@ -MP -DNEED_CPU_H
0b0babc6 28#CFLAGS+=-Werror
626df76a 29LIBS=
67b915a5 30DYNGEN=../dyngen$(EXESUF)
1e43adfc 31# user emulator name
0c64b9cd 32ifndef TARGET_ARCH2
c91fde65 33TARGET_ARCH2=$(TARGET_ARCH)
0c64b9cd 34endif
808c4954
FB
35ifeq ($(TARGET_ARCH),arm)
36 ifeq ($(TARGET_WORDS_BIGENDIAN),yes)
c91fde65 37 TARGET_ARCH2=armeb
808c4954 38 endif
c91fde65 39endif
908f52b0
PB
40ifeq ($(TARGET_ARCH),sh4)
41 ifeq ($(TARGET_WORDS_BIGENDIAN),yes)
42 TARGET_ARCH2=sh4eb
43 endif
44endif
01f5e596 45ifeq ($(TARGET_ARCH),mips)
c91fde65
FB
46 ifneq ($(TARGET_WORDS_BIGENDIAN),yes)
47 TARGET_ARCH2=mipsel
01f5e596 48 endif
01f5e596 49endif
540635ba
TS
50ifeq ($(TARGET_ARCH),mipsn32)
51 ifneq ($(TARGET_WORDS_BIGENDIAN),yes)
52 TARGET_ARCH2=mipsn32el
53 endif
54endif
fbe4f65b
TS
55ifeq ($(TARGET_ARCH),mips64)
56 ifneq ($(TARGET_WORDS_BIGENDIAN),yes)
57 TARGET_ARCH2=mips64el
58 endif
59endif
40293e58
FB
60
61ifdef CONFIG_USER_ONLY
62# user emulator name
63QEMU_PROG=qemu-$(TARGET_ARCH2)
64else
1e43adfc 65# system emulator name
a541f297 66ifeq ($(TARGET_ARCH), i386)
40293e58 67QEMU_PROG=qemu$(EXESUF)
0db63474 68else
40293e58 69QEMU_PROG=qemu-system-$(TARGET_ARCH2)$(EXESUF)
a541f297 70endif
de5eaa64 71endif
626df76a 72
40293e58 73PROGS=$(QEMU_PROG)
626df76a 74
6f30fa85 75# We require -O2 to avoid the stack setup prologue in EXIT_TB
ac41a620
BS
76OP_CFLAGS := -O2 -g -fno-strict-aliasing
77OP_CFLAGS += -Wall -Wundef -Wendif-labels -Wwrite-strings
6c041c54
TS
78
79# cc-option
80# Usage: OP_CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)
81
82cc-option = $(shell if $(CC) $(OP_CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
83 > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
84
85OP_CFLAGS+=$(call cc-option, -fno-reorder-blocks, "")
86OP_CFLAGS+=$(call cc-option, -fno-gcse, "")
87OP_CFLAGS+=$(call cc-option, -fno-tree-ch, "")
88OP_CFLAGS+=$(call cc-option, -fno-optimize-sibling-calls, "")
89OP_CFLAGS+=$(call cc-option, -fno-crossjumping, "")
90OP_CFLAGS+=$(call cc-option, -fno-align-labels, "")
91OP_CFLAGS+=$(call cc-option, -fno-align-jumps, "")
92OP_CFLAGS+=$(call cc-option, -fno-align-functions, $(call cc-option, -malign-functions=0, ""))
1870a74c 93OP_CFLAGS+=$(call cc-option, -fno-section-anchors, "")
6f30fa85 94
40293e58
FB
95HELPER_CFLAGS=
96
626df76a 97ifeq ($(ARCH),i386)
6f30fa85
TS
98HELPER_CFLAGS+=-fomit-frame-pointer
99OP_CFLAGS+=-mpreferred-stack-boundary=2 -fomit-frame-pointer
f2bf094e
AJ
100# op.c and helper.c need this on 32-bit x86 system to avoid
101# a compiler spill error. This can probably go away
102# once the SSE ops have been converted to TCG
103ifeq ($(HAVE_GT_GCC_3_3), true)
104I386_CFLAGS=-march=i586 -mtune=i686
105endif
bc51c5c9
FB
106endif
107
626df76a 108ifeq ($(ARCH),ppc)
6f30fa85 109CPPFLAGS+= -D__powerpc__
176a4f29 110OP_CFLAGS+= -mlongcall
626df76a
FB
111endif
112
113ifeq ($(ARCH),sparc)
40293e58 114 CFLAGS+=-ffixed-g2 -ffixed-g3
3142255c
BS
115 OP_CFLAGS+=-fno-delayed-branch -ffixed-i0
116 ifeq ($(CONFIG_SOLARIS),yes)
117 OP_CFLAGS+=-fno-omit-frame-pointer
118 else
40293e58
FB
119 CFLAGS+=-ffixed-g1 -ffixed-g6
120 HELPER_CFLAGS+=-ffixed-i0
3142255c 121 endif
fdbb4691 122endif
626df76a
FB
123
124ifeq ($(ARCH),sparc64)
3142255c
BS
125 OP_CFLAGS+=-mcpu=ultrasparc -m64 -fno-delayed-branch -ffixed-i0
126 ifneq ($(CONFIG_SOLARIS),yes)
e97b640d
BS
127 CFLAGS+=-ffixed-g5 -ffixed-g6 -ffixed-g7
128 OP_CFLAGS+=-ffixed-g5 -ffixed-g6 -ffixed-g7
129 else
130 CFLAGS+=-ffixed-g1 -ffixed-g4 -ffixed-g5 -ffixed-g7
3142255c 131 endif
626df76a
FB
132endif
133
134ifeq ($(ARCH),alpha)
6f30fa85
TS
135# -msmall-data is not used for OP_CFLAGS because we want two-instruction
136# relocations for the constant constructions
626df76a 137# Ensure there's only a single GP
40293e58 138CFLAGS+=-msmall-data
626df76a
FB
139endif
140
f54b3f92
AJ
141ifeq ($(ARCH),hppa)
142OP_CFLAGS=-O1 -fno-delayed-branch
143BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
144endif
145
626df76a 146ifeq ($(ARCH),ia64)
40293e58 147CFLAGS+=-mno-sdata
6f30fa85 148OP_CFLAGS+=-mno-sdata
626df76a
FB
149endif
150
151ifeq ($(ARCH),arm)
6f30fa85 152OP_CFLAGS+=-mno-sched-prolog -fno-omit-frame-pointer
626df76a
FB
153endif
154
38e584a0 155ifeq ($(ARCH),m68k)
6f30fa85 156OP_CFLAGS+=-fomit-frame-pointer
6f30fa85
TS
157endif
158
159ifeq ($(ARCH),mips)
9617efe8 160OP_CFLAGS+=-mabi=32 -G0 -fno-PIC -mno-abicalls -fomit-frame-pointer -fno-delayed-branch -Wa,-O0
fbe4f65b
TS
161endif
162
163ifeq ($(ARCH),mips64)
9617efe8 164OP_CFLAGS+=-mabi=n32 -G0 -fno-PIC -mno-abicalls -fomit-frame-pointer -fno-delayed-branch -Wa,-O0
83fb7adf
FB
165endif
166
40293e58
FB
167CFLAGS+=$(OS_CFLAGS) $(ARCH_CFLAGS)
168LDFLAGS+=$(OS_LDFLAGS) $(ARCH_LDFLAGS)
3142255c 169OP_CFLAGS+=$(OS_CFLAGS) $(ARCH_CFLAGS)
626df76a 170
6f30fa85 171CPPFLAGS+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
626df76a 172LIBS+=-lm
67b915a5 173ifdef CONFIG_WIN32
3db38e87 174LIBS+=-lwinmm -lws2_32 -liphlpapi
67b915a5 175endif
ec530c81
FB
176ifdef CONFIG_SOLARIS
177LIBS+=-lsocket -lnsl -lresolv
0475a5ca
TS
178ifdef NEEDS_LIBSUNMATH
179LIBS+=-lsunmath
180LDFLAGS+=-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib
181OP_CFLAGS+=-I/opt/SUNWspro/prod/include/cc
40293e58 182CFLAGS+=-I/opt/SUNWspro/prod/include/cc
f72b519c 183endif
831b7825
TS
184endif
185
7ba1e619
AL
186kvm.o: CFLAGS+=$(KVM_CFLAGS)
187kvm-all.o: CFLAGS+=$(KVM_CFLAGS)
188
40293e58 189all: $(PROGS)
626df76a 190
40293e58 191#########################################################
626df76a 192# cpu emulator library
57fec1fe 193LIBOBJS=exec.o kqemu.o translate-all.o cpu-exec.o\
cf2be984 194 translate.o host-utils.o
bf6247fb 195ifdef CONFIG_DYNGEN_OP
48ffabc6 196exec.o: dyngen-opc.h
cf2be984
BS
197LIBOBJS+=op.o
198endif
57fec1fe
FB
199# TCG code generator
200LIBOBJS+= tcg/tcg.o tcg/tcg-dyngen.o tcg/tcg-runtime.o
201CPPFLAGS+=-I$(SRC_PATH)/tcg -I$(SRC_PATH)/tcg/$(ARCH)
8289b279
BS
202ifeq ($(ARCH),sparc64)
203CPPFLAGS+=-I$(SRC_PATH)/tcg/sparc
204endif
158142c2
FB
205ifdef CONFIG_SOFTFLOAT
206LIBOBJS+=fpu/softfloat.o
207else
208LIBOBJS+=fpu/softfloat-native.o
209endif
6f30fa85 210CPPFLAGS+=-I$(SRC_PATH)/fpu
e95c8d51 211LIBOBJS+= op_helper.o helper.o
e95c8d51 212
b7bcbe95 213ifeq ($(TARGET_BASE_ARCH), arm)
eaa728ee 214LIBOBJS+= neon_helper.o iwmmxt_helper.o
e6e5906b
PB
215endif
216
cf6c1b16 217ifeq ($(TARGET_BASE_ARCH), alpha)
eaa728ee 218LIBOBJS+= alpha_palcode.o
cf6c1b16
JM
219endif
220
e7daa605 221ifeq ($(TARGET_BASE_ARCH), cris)
e7daa605
TS
222LIBOBJS+= cris-dis.o
223
224ifndef CONFIG_USER_ONLY
225LIBOBJS+= mmu.o
226endif
227endif
228
626df76a 229# NOTE: the disassembler code is only needed for debugging
5fafdf24 230LIBOBJS+=disas.o
626df76a 231ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
bc51c5c9
FB
232USE_I386_DIS=y
233endif
0b0babc6 234ifeq ($(findstring x86_64, $(TARGET_ARCH) $(ARCH)),x86_64)
bc51c5c9
FB
235USE_I386_DIS=y
236endif
237ifdef USE_I386_DIS
626df76a
FB
238LIBOBJS+=i386-dis.o
239endif
240ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
241LIBOBJS+=alpha-dis.o
242endif
a2458627 243ifeq ($(findstring ppc, $(TARGET_BASE_ARCH) $(ARCH)),ppc)
626df76a
FB
244LIBOBJS+=ppc-dis.o
245endif
fbe4f65b 246ifeq ($(findstring mips, $(TARGET_BASE_ARCH) $(ARCH)),mips)
6af0bf9c
FB
247LIBOBJS+=mips-dis.o
248endif
64b3ab24 249ifeq ($(findstring sparc, $(TARGET_BASE_ARCH) $(ARCH)),sparc)
626df76a
FB
250LIBOBJS+=sparc-dis.o
251endif
252ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
253LIBOBJS+=arm-dis.o
254endif
48024e4a
FB
255ifeq ($(findstring m68k, $(TARGET_ARCH) $(ARCH)),m68k)
256LIBOBJS+=m68k-dis.o
257endif
fdf9b3e8
FB
258ifeq ($(findstring sh4, $(TARGET_ARCH) $(ARCH)),sh4)
259LIBOBJS+=sh4-dis.o
260endif
f54b3f92
AJ
261ifeq ($(findstring hppa, $(TARGET_BASE_ARCH) $(ARCH)),hppa)
262LIBOBJS+=hppa-dis.o
263endif
8f860bb8
TS
264ifeq ($(findstring s390, $(TARGET_ARCH) $(ARCH)),s390)
265LIBOBJS+=s390-dis.o
266endif
626df76a 267
40293e58
FB
268# libqemu
269
bf6247fb 270ifdef CONFIG_DYNGEN_OP
dd48594e 271OPC_H = gen-op.h dyngen-opc.h op.h
cf2be984 272endif
dd48594e 273
40293e58
FB
274libqemu.a: $(LIBOBJS)
275 rm -f $@
276 $(AR) rcs $@ $(LIBOBJS)
277
dd48594e
PB
278translate.o: translate.c cpu.h $(OPC_H)
279
280translate-all.o: translate-all.c cpu.h $(OPC_H)
281
282tcg/tcg.o: cpu.h $(OPC_H)
40293e58 283
dd48594e 284tcg/tcg-dyngen.o: $(OPC_H)
40293e58 285
dd48594e 286tcg/tcg-runtime.o: $(OPC_H)
40293e58
FB
287
288op.h: op.o $(DYNGEN)
289 $(DYNGEN) -o $@ $<
290
57fec1fe 291dyngen-opc.h: op.o $(DYNGEN)
40293e58
FB
292 $(DYNGEN) -c -o $@ $<
293
294gen-op.h: op.o $(DYNGEN)
295 $(DYNGEN) -g -o $@ $<
296
297op.o: op.c
f2bf094e 298 $(CC) $(OP_CFLAGS) $(CPPFLAGS) $(I386_CFLAGS) -c -o $@ $<
40293e58 299
8dd3dca3
AJ
300machine.o: machine.c
301 $(CC) $(OP_CFLAGS) $(CPPFLAGS) -c -o $@ $<
302
40293e58
FB
303# HELPER_CFLAGS is used for all the code compiled with static register
304# variables
40293e58 305op_helper.o: op_helper.c
eaa728ee 306 $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) $(I386_CFLAGS) -c -o $@ $<
40293e58 307
c96402b1 308cpu-exec.o: cpu-exec.c $(OPC_H)
40293e58
FB
309 $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
310
311#########################################################
312# Linux user emulator target
313
314ifdef CONFIG_LINUX_USER
315
40293e58
FB
316ifndef TARGET_ABI_DIR
317 TARGET_ABI_DIR=$(TARGET_ARCH)
318endif
3ebdd119 319VPATH+=:$(SRC_PATH)/linux-user:$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR)
40293e58
FB
320CPPFLAGS+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR)
321
322ifdef CONFIG_STATIC
323LDFLAGS+=-static
324endif
325
326ifeq ($(ARCH),i386)
327ifdef TARGET_GPROF
328USE_I386_LD=y
329endif
330ifdef CONFIG_STATIC
331USE_I386_LD=y
332endif
333ifdef USE_I386_LD
334LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
335else
336# WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
337# that the kernel ELF loader considers as an executable. I think this
338# is the simplest way to make it self virtualizable!
339LDFLAGS+=-Wl,-shared
340endif
341endif
342
343ifeq ($(ARCH),x86_64)
344LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
345endif
346
347ifeq ($(ARCH),ppc)
348LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
349endif
350
810260a8 351ifeq ($(ARCH),ppc64)
352LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
353endif
354
40293e58
FB
355ifeq ($(ARCH),s390)
356LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
357endif
358
359ifeq ($(ARCH),sparc)
360# -static is used to avoid g1/g3 usage by the dynamic linker
361LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld -static
362endif
363
364ifeq ($(ARCH),sparc64)
365LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
366endif
367
368ifeq ($(ARCH),alpha)
369LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
370endif
371
372ifeq ($(ARCH),ia64)
373LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/$(ARCH).ld
374endif
375
376ifeq ($(ARCH),arm)
377LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
378endif
379
380ifeq ($(ARCH),m68k)
381LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
382endif
383
384ifeq ($(ARCH),mips)
385ifeq ($(WORDS_BIGENDIAN),yes)
386LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
387else
388LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH)el.ld
389endif
390endif
391
392ifeq ($(ARCH),mips64)
393ifeq ($(WORDS_BIGENDIAN),yes)
394LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
395else
396LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH)el.ld
397endif
398endif
399
6d946cda
AJ
400# profiling code
401ifdef TARGET_GPROF
402LDFLAGS+=-p
403CFLAGS+=-p
404endif
405
17e2377a 406OBJS= main.o syscall.o strace.o mmap.o signal.o path.o thunk.o \
40293e58
FB
407 elfload.o linuxload.o uaccess.o
408LIBS+= $(AIOLIBS)
409ifdef TARGET_HAS_BFLT
410OBJS+= flatload.o
411endif
412ifdef TARGET_HAS_ELFLOAD32
413OBJS+= elfload32.o
414elfload32.o: elfload.c
415endif
416
417ifeq ($(TARGET_ARCH), i386)
418OBJS+= vm86.o
419endif
420ifeq ($(TARGET_ARCH), arm)
421OBJS+=nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
422nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
423 nwfpe/double_cpdo.o nwfpe/extended_cpdo.o arm-semi.o
424endif
425ifeq ($(TARGET_ARCH), m68k)
426OBJS+= m68k-sim.o m68k-semi.o
427endif
428
1fddef4b 429ifdef CONFIG_GDBSTUB
56aebc89 430OBJS+=gdbstub.o gdbstub-xml.o
1fddef4b 431endif
626df76a 432
40293e58
FB
433OBJS+= libqemu.a
434
435# Note: this is a workaround. The real fix is to avoid compiling
436# cpu_signal_handler() in cpu-exec.c.
437signal.o: signal.c
438 $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
626df76a 439
cec7d0b6 440$(QEMU_PROG): $(OBJS) ../libqemu_user.a
40293e58 441 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
626df76a
FB
442ifeq ($(ARCH),alpha)
443# Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
444# the address space (31 bit so sign extending doesn't matter)
445 echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
446endif
447
40293e58
FB
448endif #CONFIG_LINUX_USER
449
450#########################################################
451# Darwin user emulator target
452
453ifdef CONFIG_DARWIN_USER
454
455VPATH+=:$(SRC_PATH)/darwin-user
456CPPFLAGS+=-I$(SRC_PATH)/darwin-user -I$(SRC_PATH)/darwin-user/$(TARGET_ARCH)
457
458# Leave some space for the regular program loading zone
459LDFLAGS+=-Wl,-segaddr,__STD_PROG_ZONE,0x1000 -image_base 0x0e000000
460
461LIBS+=-lmx
462
17e2377a 463OBJS= main.o commpage.o machload.o mmap.o signal.o syscall.o thunk.o
40293e58
FB
464
465OBJS+= libqemu.a
466
467ifdef CONFIG_GDBSTUB
56aebc89 468OBJS+=gdbstub.o gdbstub-xml.o
40293e58
FB
469endif
470
471# Note: this is a workaround. The real fix is to avoid compiling
472# cpu_signal_handler() in cpu-exec.c.
473signal.o: signal.c
474 $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
475
476$(QEMU_PROG): $(OBJS)
477 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
478
479endif #CONFIG_DARWIN_USER
480
84778508
BS
481#########################################################
482# BSD user emulator target
483
484ifdef CONFIG_BSD_USER
485
486VPATH+=:$(SRC_PATH)/bsd-user
487CPPFLAGS+=-I$(SRC_PATH)/bsd-user -I$(SRC_PATH)/bsd-user/$(TARGET_ARCH)
488
489ifdef CONFIG_STATIC
490LDFLAGS+=-static
491endif
492
493ifeq ($(ARCH),i386)
494ifdef TARGET_GPROF
495USE_I386_LD=y
496endif
497ifdef CONFIG_STATIC
498USE_I386_LD=y
499endif
500ifdef USE_I386_LD
501LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
502else
503# WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
504# that the kernel ELF loader considers as an executable. I think this
505# is the simplest way to make it self virtualizable!
506LDFLAGS+=-Wl,-shared
507endif
508endif
509
510ifeq ($(ARCH),x86_64)
511LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
512endif
513
514ifeq ($(ARCH),ppc)
515LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
516endif
517
518ifeq ($(ARCH),ppc64)
519LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
520endif
521
522ifeq ($(ARCH),s390)
523LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
524endif
525
526ifeq ($(ARCH),sparc)
527# -static is used to avoid g1/g3 usage by the dynamic linker
528LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld -static
529endif
530
531ifeq ($(ARCH),sparc64)
532LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
533endif
534
535ifeq ($(ARCH),alpha)
536LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
537endif
538
539ifeq ($(ARCH),ia64)
540LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/$(ARCH).ld
541endif
542
543ifeq ($(ARCH),arm)
544LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
545endif
546
547ifeq ($(ARCH),m68k)
548LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
549endif
550
551ifeq ($(ARCH),mips)
552ifeq ($(WORDS_BIGENDIAN),yes)
553LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
554else
555LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH)el.ld
556endif
557endif
558
559ifeq ($(ARCH),mips64)
560ifeq ($(WORDS_BIGENDIAN),yes)
561LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
562else
563LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH)el.ld
564endif
565endif
566
567OBJS= main.o bsdload.o elfload.o mmap.o path.o signal.o strace.o syscall.o
568OBJS+= uaccess.o
569
570OBJS+= libqemu.a
571
572ifdef CONFIG_GDBSTUB
573OBJS+=gdbstub.o
574endif
575
576# Note: this is a workaround. The real fix is to avoid compiling
577# cpu_signal_handler() in cpu-exec.c.
578signal.o: signal.c
579 $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
580
581$(QEMU_PROG): $(OBJS) ../libqemu_user.a
582 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
583
584endif #CONFIG_BSD_USER
585
40293e58
FB
586#########################################################
587# System emulator target
588ifndef CONFIG_USER_ONLY
589
559b90fb
AL
590OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o machine.o
591OBJS+=fw_cfg.o
7ba1e619
AL
592ifdef CONFIG_KVM
593OBJS+=kvm.o kvm-all.o
594endif
223d4670 595ifdef CONFIG_WIN32
40293e58 596OBJS+=block-raw-win32.o
223d4670 597else
559b90fb 598OBJS+=block-raw-posix.o
a3392f9b
AL
599endif
600
40293e58 601LIBS+=-lz
1d14ffa9 602ifdef CONFIG_ALSA
1d14ffa9
FB
603LIBS += -lasound
604endif
ca9cc28c
AZ
605ifdef CONFIG_ESD
606LIBS += -lesd
607endif
b8e59f18 608ifdef CONFIG_PA
609LIBS += -lpulse-simple
610endif
1d14ffa9 611ifdef CONFIG_DSOUND
1d14ffa9 612LIBS += -lole32 -ldxguid
85571bc7 613endif
102a52e4 614ifdef CONFIG_FMOD
102a52e4 615LIBS += $(CONFIG_FMOD_LIB)
85571bc7 616endif
2f6a1ab0
BS
617ifdef CONFIG_OSS
618LIBS += $(CONFIG_OSS_LIB)
619endif
4fb240a4
FB
620
621SOUND_HW = sb16.o es1370.o
ca9cc28c
AZ
622ifdef CONFIG_AC97
623SOUND_HW += ac97.o
624endif
1d14ffa9
FB
625ifdef CONFIG_ADLIB
626SOUND_HW += fmopl.o adlib.o
627endif
423d65f4
AZ
628ifdef CONFIG_GUS
629SOUND_HW += gus.o gusemu_hal.o gusemu_mixer.o
630endif
cc53d26d 631ifdef CONFIG_CS4231A
632SOUND_HW += cs4231a.o
633endif
85571bc7 634
8d5d2d4c
TS
635ifdef CONFIG_VNC_TLS
636CPPFLAGS += $(CONFIG_VNC_TLS_CFLAGS)
637LIBS += $(CONFIG_VNC_TLS_LIBS)
638endif
639
fb599c9a
AZ
640ifdef CONFIG_BLUEZ
641LIBS += $(CONFIG_BLUEZ_LIBS)
642endif
643
2e5d83bb 644# SCSI layer
8b17de88 645OBJS+= lsi53c895a.o esp.o
2e5d83bb 646
a594cfbf 647# USB layer
40293e58 648OBJS+= usb-ohci.o
a594cfbf 649
663e8e51 650# EEPROM emulation
40293e58 651OBJS += eeprom93xx.o
663e8e51 652
a41b2ff2 653# PCI network cards
40293e58
FB
654OBJS += eepro100.o
655OBJS += ne2000.o
656OBJS += pcnet.o
657OBJS += rtl8139.o
7c23b892 658OBJS += e1000.o
a41b2ff2 659
0b0babc6 660ifeq ($(TARGET_BASE_ARCH), i386)
a541f297 661# Hardware support
40293e58
FB
662OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o
663OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o
664OBJS+= cirrus_vga.o apic.o parallel.o acpi.o piix_pci.o
665OBJS+= usb-uhci.o vmmouse.o vmport.o vmware_vga.o
b00052e4 666CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE
67b915a5 667endif
a2458627 668ifeq ($(TARGET_BASE_ARCH), ppc)
b00052e4 669CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE
3cbee15b 670# shared objects
40293e58 671OBJS+= ppc.o ide.o vga.o $(SOUND_HW) dma.o openpic.o
3cbee15b 672# PREP target
40293e58
FB
673OBJS+= pckbd.o ps2.o serial.o i8259.o i8254.o fdc.o m48t59.o mc146818rtc.o
674OBJS+= prep_pci.o ppc_prep.o
3cbee15b 675# Mac shared devices
40293e58 676OBJS+= macio.o cuda.o adb.o mac_nvram.o mac_dbdma.o
3cbee15b 677# OldWorld PowerMac
40293e58 678OBJS+= heathrow_pic.o grackle_pci.o ppc_oldworld.o
3cbee15b 679# NewWorld PowerMac
40293e58 680OBJS+= unin_pci.o ppc_chrp.o
3cbee15b 681# PowerPC 4xx boards
40293e58 682OBJS+= pflash_cfi02.o ppc4xx_devs.o ppc405_uc.o ppc405_boards.o
a541f297 683endif
fbe4f65b 684ifeq ($(TARGET_BASE_ARCH), mips)
c171148c 685OBJS+= mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o
4ce7ff6e
AJ
686OBJS+= mips_timer.o mips_int.o dma.o vga.o serial.o i8254.o i8259.o rc4030.o
687OBJS+= g364fb.o jazz_led.o
40293e58 688OBJS+= ide.o gt64xxx.o pckbd.o ps2.o fdc.o mc146818rtc.o usb-uhci.o acpi.o ds1225y.o
4ce7ff6e 689OBJS+= piix_pci.o parallel.o cirrus_vga.o pcspk.o $(SOUND_HW)
40293e58
FB
690OBJS+= mipsnet.o
691OBJS+= pflash_cfi01.o
4ce7ff6e 692CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE
6af0bf9c 693endif
e7daa605 694ifeq ($(TARGET_BASE_ARCH), cris)
40293e58 695OBJS+= etraxfs.o
48318011 696OBJS+= etraxfs_dma.o
e62b5b13 697OBJS+= etraxfs_pic.o
48318011 698OBJS+= etraxfs_eth.o
40293e58
FB
699OBJS+= etraxfs_timer.o
700OBJS+= etraxfs_ser.o
e62b5b13
EI
701
702OBJS+= ptimer.o
48318011 703OBJS+= pflash_cfi02.o
e7daa605 704endif
64b3ab24 705ifeq ($(TARGET_BASE_ARCH), sparc)
3475187d 706ifeq ($(TARGET_ARCH), sparc64)
40293e58
FB
707OBJS+= sun4u.o ide.o pckbd.o ps2.o vga.o apb_pci.o
708OBJS+= fdc.o mc146818rtc.o serial.o m48t59.o
709OBJS+= cirrus_vga.o parallel.o ptimer.o
3475187d 710else
40293e58 711OBJS+= sun4m.o tcx.o pcnet.o iommu.o m48t59.o slavio_intctl.o
8b17de88 712OBJS+= slavio_timer.o slavio_serial.o slavio_misc.o fdc.o sparc32_dma.o
40293e58 713OBJS+= cs4231.o ptimer.o eccmemctl.o sbi.o sun4c_intctl.o
3475187d 714endif
e95c8d51 715endif
b5ff1b31 716ifeq ($(TARGET_BASE_ARCH), arm)
40293e58
FB
717OBJS+= integratorcp.o versatilepb.o ps2.o smc91c111.o arm_pic.o arm_timer.o
718OBJS+= arm_boot.o pl011.o pl031.o pl050.o pl080.o pl110.o pl181.o pl190.o
719OBJS+= versatile_pci.o ptimer.o
720OBJS+= realview_gic.o realview.o arm_sysctl.o mpcore.o
721OBJS+= armv7m.o armv7m_nvic.o stellaris.o pl022.o stellaris_enet.o
722OBJS+= pl061.o
723OBJS+= arm-semi.o
724OBJS+= pxa2xx.o pxa2xx_pic.o pxa2xx_gpio.o pxa2xx_timer.o pxa2xx_dma.o
725OBJS+= pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o pxa2xx_keypad.o
726OBJS+= pflash_cfi01.o gumstix.o
88d2c950 727OBJS+= zaurus.o ide.o serial.o nand.o ecc.o spitz.o tosa.o tc6393xb.o
b4e3104b 728OBJS+= omap1.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap_i2c.o
afbb5194 729OBJS+= omap2.o omap_dss.o soc_dma.o
40293e58 730OBJS+= palm.o tsc210x.o
942ac052 731OBJS+= nseries.o blizzard.o onenand.o vga.o cbus.o tusb6010.o usb-musb.o
58a26b47 732OBJS+= tsc2005.o bt-hci-csr.o
40293e58 733OBJS+= mst_fpga.o mainstone.o
24859b68 734OBJS+= musicpal.o pflash_cfi02.o
5a1237c4 735CPPFLAGS += -DHAS_AUDIO
b5ff1b31 736endif
fdf9b3e8 737ifeq ($(TARGET_BASE_ARCH), sh4)
40293e58 738OBJS+= shix.o r2d.o sh7750.o sh7750_regnames.o tc58128.o
ffd39257 739OBJS+= sh_timer.o ptimer.o sh_serial.o sh_intc.o sm501.o serial.o
fdf9b3e8 740endif
0633879f 741ifeq ($(TARGET_BASE_ARCH), m68k)
40293e58
FB
742OBJS+= an5206.o mcf5206.o ptimer.o mcf_uart.o mcf_intc.o mcf5208.o mcf_fec.o
743OBJS+= m68k-semi.o dummy_m68k.o
0633879f 744endif
a541f297 745ifdef CONFIG_GDBSTUB
56aebc89 746OBJS+=gdbstub.o gdbstub-xml.o
728c9fd5 747endif
5b0753e0 748ifdef CONFIG_COCOA
1d14ffa9
FB
749COCOA_LIBS=-F/System/Library/Frameworks -framework Cocoa -framework IOKit
750ifdef CONFIG_COREAUDIO
751COCOA_LIBS+=-framework CoreAudio
752endif
5b0753e0 753endif
7c1f25b4 754ifdef CONFIG_SLIRP
6f30fa85 755CPPFLAGS+=-I$(SRC_PATH)/slirp
626df76a
FB
756endif
757
40293e58 758LIBS+=$(AIOLIBS)
c321f673 759# specific flags are needed for non soft mmu emulator
c321f673 760ifdef CONFIG_STATIC
40293e58 761LDFLAGS+=-static
de5eaa64 762endif
83fb7adf 763ifndef CONFIG_DARWIN
11d9f695 764ifndef CONFIG_WIN32
ec530c81 765ifndef CONFIG_SOLARIS
b29fe3ed 766ifndef CONFIG_AIX
40293e58 767LIBS+=-lutil
11d9f695 768endif
b29fe3ed 769endif
83fb7adf 770endif
ec530c81 771endif
e3086fbf 772ifdef TARGET_GPROF
40293e58
FB
773vl.o: CFLAGS+=-p
774LDFLAGS+=-p
e3086fbf 775endif
c321f673 776
b8076a74 777ifeq ($(ARCH),ia64)
40293e58 778LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
74ccb34e
FB
779endif
780
1d14ffa9
FB
781ifdef CONFIG_WIN32
782SDL_LIBS := $(filter-out -mwindows, $(SDL_LIBS)) -mconsole
783endif
784
40293e58
FB
785# profiling code
786ifdef TARGET_GPROF
787LDFLAGS+=-p
788main.o: CFLAGS+=-p
6e1b3e4d
FB
789endif
790
40293e58 791$(QEMU_PROG): $(OBJS) ../libqemu_common.a libqemu.a
8a16d273 792 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(CURSES_LIBS) $(BRLAPI_LIBS) $(VDE_LIBS)
626df76a 793
40293e58 794endif # !CONFIG_USER_ONLY
00a67ba1 795
56aebc89
PB
796gdbstub-xml.c: $(TARGET_XML_FILES) feature_to_c.sh
797 rm -f $@
798ifeq ($(TARGET_XML_FILES),)
799 echo > $@
800else
801 $(SHELL) $(SRC_PATH)/feature_to_c.sh $@ $(TARGET_XML_FILES)
802endif
803
626df76a 804%.o: %.c
40293e58 805 $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
626df76a 806
f72b519c 807%.o: %.S
6f30fa85 808 $(CC) $(CPPFLAGS) -c -o $@ $<
f72b519c 809
626df76a 810clean:
57fec1fe
FB
811 rm -f *.o *.a *~ $(PROGS) gen-op.h dyngen-opc.h op.h nwfpe/*.o fpu/*.o
812 rm -f *.d */*.d tcg/*.o
1e43adfc 813
5fafdf24 814install: all
9b14bb04 815ifneq ($(PROGS),)
6a882643 816 $(INSTALL) -m 755 -s $(PROGS) "$(DESTDIR)$(bindir)"
9b14bb04 817endif
626df76a 818
2f96c28d
JM
819# Include automatically generated dependency files
820-include $(wildcard *.d */*.d)