blob: 9c8373334519f8f4869aa106d8b5563e3f511ae0 [file] [log] [blame]
bellard626df762003-08-10 21:39:31 +00001include config.mak
2
bellard0b0babc2005-01-03 23:38:40 +00003TARGET_BASE_ARCH:=$(TARGET_ARCH)
4ifeq ($(TARGET_ARCH), x86_64)
5TARGET_BASE_ARCH:=i386
6endif
ths540635b2007-09-30 01:58:33 +00007ifeq ($(TARGET_ARCH), mipsn32)
8TARGET_BASE_ARCH:=mips
9endif
thsfbe4f652007-04-01 11:16:48 +000010ifeq ($(TARGET_ARCH), mips64)
11TARGET_BASE_ARCH:=mips
12endif
bellarda2458622005-07-23 22:39:53 +000013ifeq ($(TARGET_ARCH), ppc64)
14TARGET_BASE_ARCH:=ppc
15endif
j_mayer22f8a8b2007-10-14 08:38:29 +000016ifeq ($(TARGET_ARCH), ppc64h)
17TARGET_BASE_ARCH:=ppc
18endif
j_mayerd4082e92007-04-24 07:34:03 +000019ifeq ($(TARGET_ARCH), ppcemb)
20TARGET_BASE_ARCH:=ppc
21endif
bellard64b3ab22005-01-30 22:43:42 +000022ifeq ($(TARGET_ARCH), sparc64)
23TARGET_BASE_ARCH:=sparc
24endif
bellard0b0babc2005-01-03 23:38:40 +000025TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH)
bellard4fb240a2007-11-07 19:24:02 +000026VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw
pbrookfaf07962007-11-11 02:51:17 +000027CPPFLAGS=-I. -I.. -I$(TARGET_PATH) -I$(SRC_PATH) -MMD -MP -DNEED_CPU_H
bellard0b0babc2005-01-03 23:38:40 +000028#CFLAGS+=-Werror
bellard626df762003-08-10 21:39:31 +000029LIBS=
bellard67b915a2004-03-31 23:37:16 +000030DYNGEN=../dyngen$(EXESUF)
bellard1e43adf2003-09-30 20:54:24 +000031# user emulator name
bellard0c64b9c2008-01-06 18:27:58 +000032ifndef TARGET_ARCH2
bellardc91fde62006-05-02 22:52:36 +000033TARGET_ARCH2=$(TARGET_ARCH)
bellard0c64b9c2008-01-06 18:27:58 +000034endif
bellard808c4952004-12-19 23:33:47 +000035ifeq ($(TARGET_ARCH),arm)
36 ifeq ($(TARGET_WORDS_BIGENDIAN),yes)
bellardc91fde62006-05-02 22:52:36 +000037 TARGET_ARCH2=armeb
bellard808c4952004-12-19 23:33:47 +000038 endif
bellardc91fde62006-05-02 22:52:36 +000039endif
pbrook908f52b2006-06-18 19:16:53 +000040ifeq ($(TARGET_ARCH),sh4)
41 ifeq ($(TARGET_WORDS_BIGENDIAN),yes)
42 TARGET_ARCH2=sh4eb
43 endif
44endif
bellard01f5e592005-12-06 21:42:17 +000045ifeq ($(TARGET_ARCH),mips)
bellardc91fde62006-05-02 22:52:36 +000046 ifneq ($(TARGET_WORDS_BIGENDIAN),yes)
47 TARGET_ARCH2=mipsel
bellard01f5e592005-12-06 21:42:17 +000048 endif
bellard808c4952004-12-19 23:33:47 +000049endif
ths540635b2007-09-30 01:58:33 +000050ifeq ($(TARGET_ARCH),mipsn32)
51 ifneq ($(TARGET_WORDS_BIGENDIAN),yes)
52 TARGET_ARCH2=mipsn32el
53 endif
54endif
thsfbe4f652007-04-01 11:16:48 +000055ifeq ($(TARGET_ARCH),mips64)
56 ifneq ($(TARGET_WORDS_BIGENDIAN),yes)
57 TARGET_ARCH2=mips64el
58 endif
59endif
bellard1e43adf2003-09-30 20:54:24 +000060
bellard16e9b7d2003-10-27 21:09:52 +000061ifdef CONFIG_USER_ONLY
bellard40293e52008-01-31 11:32:10 +000062# user emulator name
63QEMU_PROG=qemu-$(TARGET_ARCH2)
bellard16e9b7d2003-10-27 21:09:52 +000064else
bellard40293e52008-01-31 11:32:10 +000065# system emulator name
66ifeq ($(TARGET_ARCH), i386)
67QEMU_PROG=qemu$(EXESUF)
68else
69QEMU_PROG=qemu-system-$(TARGET_ARCH2)$(EXESUF)
bellardde5eaa62003-11-16 23:18:17 +000070endif
bellard40293e52008-01-31 11:32:10 +000071endif
bellard728c9fd2004-01-05 00:08:14 +000072
bellard40293e52008-01-31 11:32:10 +000073PROGS=$(QEMU_PROG)
bellard626df762003-08-10 21:39:31 +000074
ths6f30fa82007-01-05 01:00:47 +000075# We require -O2 to avoid the stack setup prologue in EXIT_TB
ths6c041c52007-03-18 23:23:31 +000076OP_CFLAGS := -Wall -O2 -g -fno-strict-aliasing
77
78# cc-option
79# Usage: OP_CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)
80
81cc-option = $(shell if $(CC) $(OP_CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
82 > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
83
84OP_CFLAGS+=$(call cc-option, -fno-reorder-blocks, "")
85OP_CFLAGS+=$(call cc-option, -fno-gcse, "")
86OP_CFLAGS+=$(call cc-option, -fno-tree-ch, "")
87OP_CFLAGS+=$(call cc-option, -fno-optimize-sibling-calls, "")
88OP_CFLAGS+=$(call cc-option, -fno-crossjumping, "")
89OP_CFLAGS+=$(call cc-option, -fno-align-labels, "")
90OP_CFLAGS+=$(call cc-option, -fno-align-jumps, "")
91OP_CFLAGS+=$(call cc-option, -fno-align-functions, $(call cc-option, -malign-functions=0, ""))
ths1870a742007-09-13 03:24:53 +000092OP_CFLAGS+=$(call cc-option, -fno-section-anchors, "")
ths6f30fa82007-01-05 01:00:47 +000093
bellard40293e52008-01-31 11:32:10 +000094HELPER_CFLAGS=
95
bellard626df762003-08-10 21:39:31 +000096ifeq ($(ARCH),i386)
ths6f30fa82007-01-05 01:00:47 +000097HELPER_CFLAGS+=-fomit-frame-pointer
98OP_CFLAGS+=-mpreferred-stack-boundary=2 -fomit-frame-pointer
bellardbc51c5c2004-03-17 23:46:04 +000099endif
100
bellard626df762003-08-10 21:39:31 +0000101ifeq ($(ARCH),ppc)
ths6f30fa82007-01-05 01:00:47 +0000102CPPFLAGS+= -D__powerpc__
bellard626df762003-08-10 21:39:31 +0000103endif
104
105ifeq ($(ARCH),sparc)
bellard40293e52008-01-31 11:32:10 +0000106 CFLAGS+=-ffixed-g2 -ffixed-g3
blueswir131422552007-04-16 18:27:06 +0000107 OP_CFLAGS+=-fno-delayed-branch -ffixed-i0
108 ifeq ($(CONFIG_SOLARIS),yes)
109 OP_CFLAGS+=-fno-omit-frame-pointer
110 else
bellard40293e52008-01-31 11:32:10 +0000111 CFLAGS+=-ffixed-g1 -ffixed-g6
112 HELPER_CFLAGS+=-ffixed-i0
blueswir131422552007-04-16 18:27:06 +0000113 endif
bellardfdbb4692006-06-14 17:32:25 +0000114endif
bellard626df762003-08-10 21:39:31 +0000115
116ifeq ($(ARCH),sparc64)
bellard40293e52008-01-31 11:32:10 +0000117 CFLAGS+=-ffixed-g1 -ffixed-g4 -ffixed-g5 -ffixed-g7
blueswir131422552007-04-16 18:27:06 +0000118 OP_CFLAGS+=-mcpu=ultrasparc -m64 -fno-delayed-branch -ffixed-i0
119 ifneq ($(CONFIG_SOLARIS),yes)
blueswir131422552007-04-16 18:27:06 +0000120 OP_CFLAGS+=-ffixed-g1 -ffixed-g4 -ffixed-g5 -ffixed-g7
121 endif
bellard626df762003-08-10 21:39:31 +0000122endif
123
124ifeq ($(ARCH),alpha)
ths6f30fa82007-01-05 01:00:47 +0000125# -msmall-data is not used for OP_CFLAGS because we want two-instruction
126# relocations for the constant constructions
bellard626df762003-08-10 21:39:31 +0000127# Ensure there's only a single GP
bellard40293e52008-01-31 11:32:10 +0000128CFLAGS+=-msmall-data
bellard626df762003-08-10 21:39:31 +0000129endif
130
131ifeq ($(ARCH),ia64)
bellard40293e52008-01-31 11:32:10 +0000132CFLAGS+=-mno-sdata
ths6f30fa82007-01-05 01:00:47 +0000133OP_CFLAGS+=-mno-sdata
bellard626df762003-08-10 21:39:31 +0000134endif
135
136ifeq ($(ARCH),arm)
ths6f30fa82007-01-05 01:00:47 +0000137OP_CFLAGS+=-mno-sched-prolog -fno-omit-frame-pointer
bellard626df762003-08-10 21:39:31 +0000138endif
139
bellard38e584a2003-08-10 22:14:22 +0000140ifeq ($(ARCH),m68k)
ths6f30fa82007-01-05 01:00:47 +0000141OP_CFLAGS+=-fomit-frame-pointer
ths6f30fa82007-01-05 01:00:47 +0000142endif
143
144ifeq ($(ARCH),mips)
ths9617efe2007-05-08 21:05:55 +0000145OP_CFLAGS+=-mabi=32 -G0 -fno-PIC -mno-abicalls -fomit-frame-pointer -fno-delayed-branch -Wa,-O0
thsfbe4f652007-04-01 11:16:48 +0000146endif
147
148ifeq ($(ARCH),mips64)
ths9617efe2007-05-08 21:05:55 +0000149OP_CFLAGS+=-mabi=n32 -G0 -fno-PIC -mno-abicalls -fomit-frame-pointer -fno-delayed-branch -Wa,-O0
bellard38e584a2003-08-10 22:14:22 +0000150endif
151
bellard40293e52008-01-31 11:32:10 +0000152CFLAGS+=$(OS_CFLAGS) $(ARCH_CFLAGS)
153LDFLAGS+=$(OS_LDFLAGS) $(ARCH_LDFLAGS)
blueswir131422552007-04-16 18:27:06 +0000154OP_CFLAGS+=$(OS_CFLAGS) $(ARCH_CFLAGS)
bellard626df762003-08-10 21:39:31 +0000155
ths6f30fa82007-01-05 01:00:47 +0000156CPPFLAGS+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
bellard626df762003-08-10 21:39:31 +0000157LIBS+=-lm
bellard67b915a2004-03-31 23:37:16 +0000158ifdef CONFIG_WIN32
bellard3db38e82004-07-14 17:19:55 +0000159LIBS+=-lwinmm -lws2_32 -liphlpapi
bellard67b915a2004-03-31 23:37:16 +0000160endif
bellardec530c82006-04-25 22:36:06 +0000161ifdef CONFIG_SOLARIS
162LIBS+=-lsocket -lnsl -lresolv
ths0475a5c2007-04-01 18:54:44 +0000163ifdef NEEDS_LIBSUNMATH
164LIBS+=-lsunmath
165LDFLAGS+=-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib
166OP_CFLAGS+=-I/opt/SUNWspro/prod/include/cc
bellard40293e52008-01-31 11:32:10 +0000167CFLAGS+=-I/opt/SUNWspro/prod/include/cc
ths0475a5c2007-04-01 18:54:44 +0000168endif
bellardec530c82006-04-25 22:36:06 +0000169endif
bellard626df762003-08-10 21:39:31 +0000170
bellard40293e52008-01-31 11:32:10 +0000171all: $(PROGS)
bellard626df762003-08-10 21:39:31 +0000172
bellard40293e52008-01-31 11:32:10 +0000173#########################################################
bellard626df762003-08-10 21:39:31 +0000174# cpu emulator library
bellard57fec1f2008-02-01 10:50:11 +0000175LIBOBJS=exec.o kqemu.o translate-all.o cpu-exec.o\
j_mayerf1548da2007-09-29 12:15:39 +0000176 translate.o op.o host-utils.o
bellard57fec1f2008-02-01 10:50:11 +0000177# TCG code generator
178LIBOBJS+= tcg/tcg.o tcg/tcg-dyngen.o tcg/tcg-runtime.o
179CPPFLAGS+=-I$(SRC_PATH)/tcg -I$(SRC_PATH)/tcg/$(ARCH)
blueswir18289b272008-02-27 17:53:27 +0000180ifeq ($(ARCH),sparc64)
181CPPFLAGS+=-I$(SRC_PATH)/tcg/sparc
182endif
bellard158142c2005-03-13 16:54:06 +0000183ifdef CONFIG_SOFTFLOAT
184LIBOBJS+=fpu/softfloat.o
185else
186LIBOBJS+=fpu/softfloat-native.o
187endif
ths6f30fa82007-01-05 01:00:47 +0000188CPPFLAGS+=-I$(SRC_PATH)/fpu
bellard626df762003-08-10 21:39:31 +0000189
190ifeq ($(TARGET_ARCH), i386)
bellard1e43adf2003-09-30 20:54:24 +0000191LIBOBJS+=helper.o helper2.o
bellard626df762003-08-10 21:39:31 +0000192endif
193
bellard0b0babc2005-01-03 23:38:40 +0000194ifeq ($(TARGET_ARCH), x86_64)
195LIBOBJS+=helper.o helper2.o
196endif
197
bellarda2458622005-07-23 22:39:53 +0000198ifeq ($(TARGET_BASE_ARCH), ppc)
bellard728c9fd2004-01-05 00:08:14 +0000199LIBOBJS+= op_helper.o helper.o
bellard67867302003-11-23 17:05:30 +0000200endif
201
thsfbe4f652007-04-01 11:16:48 +0000202ifeq ($(TARGET_BASE_ARCH), mips)
bellard6af0bf92005-07-02 14:58:51 +0000203LIBOBJS+= op_helper.o helper.o
204endif
205
bellard64b3ab22005-01-30 22:43:42 +0000206ifeq ($(TARGET_BASE_ARCH), sparc)
bellarde95c8d52004-09-30 22:22:08 +0000207LIBOBJS+= op_helper.o helper.o
208endif
209
bellardb7bcbe92005-02-22 19:27:29 +0000210ifeq ($(TARGET_BASE_ARCH), arm)
bellardb5ff1b32005-11-26 10:38:39 +0000211LIBOBJS+= op_helper.o helper.o
bellardb7bcbe92005-02-22 19:27:29 +0000212endif
213
bellardfdf9b3e2006-04-27 21:07:38 +0000214ifeq ($(TARGET_BASE_ARCH), sh4)
215LIBOBJS+= op_helper.o helper.o
216endif
217
pbrooke6e59062006-10-22 00:18:54 +0000218ifeq ($(TARGET_BASE_ARCH), m68k)
pbrook06338792007-05-23 19:58:11 +0000219LIBOBJS+= op_helper.o helper.o
pbrooke6e59062006-10-22 00:18:54 +0000220endif
221
j_mayercf6c1b12007-04-05 20:46:02 +0000222ifeq ($(TARGET_BASE_ARCH), alpha)
223LIBOBJS+= op_helper.o helper.o alpha_palcode.o
224endif
225
thse7daa602007-10-08 13:38:27 +0000226ifeq ($(TARGET_BASE_ARCH), cris)
227LIBOBJS+= op_helper.o helper.o
228LIBOBJS+= cris-dis.o
229
230ifndef CONFIG_USER_ONLY
231LIBOBJS+= mmu.o
232endif
233endif
234
bellard626df762003-08-10 21:39:31 +0000235# NOTE: the disassembler code is only needed for debugging
ths5fafdf22007-09-16 21:08:06 +0000236LIBOBJS+=disas.o
bellard626df762003-08-10 21:39:31 +0000237ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
bellardbc51c5c2004-03-17 23:46:04 +0000238USE_I386_DIS=y
239endif
bellard0b0babc2005-01-03 23:38:40 +0000240ifeq ($(findstring x86_64, $(TARGET_ARCH) $(ARCH)),x86_64)
bellardbc51c5c2004-03-17 23:46:04 +0000241USE_I386_DIS=y
242endif
243ifdef USE_I386_DIS
bellard626df762003-08-10 21:39:31 +0000244LIBOBJS+=i386-dis.o
245endif
246ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
247LIBOBJS+=alpha-dis.o
248endif
bellarda2458622005-07-23 22:39:53 +0000249ifeq ($(findstring ppc, $(TARGET_BASE_ARCH) $(ARCH)),ppc)
bellard626df762003-08-10 21:39:31 +0000250LIBOBJS+=ppc-dis.o
251endif
thsfbe4f652007-04-01 11:16:48 +0000252ifeq ($(findstring mips, $(TARGET_BASE_ARCH) $(ARCH)),mips)
bellard6af0bf92005-07-02 14:58:51 +0000253LIBOBJS+=mips-dis.o
254endif
bellard64b3ab22005-01-30 22:43:42 +0000255ifeq ($(findstring sparc, $(TARGET_BASE_ARCH) $(ARCH)),sparc)
bellard626df762003-08-10 21:39:31 +0000256LIBOBJS+=sparc-dis.o
257endif
258ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
259LIBOBJS+=arm-dis.o
260endif
bellard48024e42005-11-06 16:52:11 +0000261ifeq ($(findstring m68k, $(TARGET_ARCH) $(ARCH)),m68k)
262LIBOBJS+=m68k-dis.o
263endif
bellardfdf9b3e2006-04-27 21:07:38 +0000264ifeq ($(findstring sh4, $(TARGET_ARCH) $(ARCH)),sh4)
265LIBOBJS+=sh4-dis.o
266endif
ths8f860bb2007-07-31 23:44:21 +0000267ifeq ($(findstring s390, $(TARGET_ARCH) $(ARCH)),s390)
268LIBOBJS+=s390-dis.o
269endif
bellard626df762003-08-10 21:39:31 +0000270
bellard40293e52008-01-31 11:32:10 +0000271# libqemu
272
pbrookdd485942008-02-01 22:45:04 +0000273OPC_H = gen-op.h dyngen-opc.h op.h
274
bellard40293e52008-01-31 11:32:10 +0000275libqemu.a: $(LIBOBJS)
276 rm -f $@
277 $(AR) rcs $@ $(LIBOBJS)
278
pbrookdd485942008-02-01 22:45:04 +0000279translate.o: translate.c cpu.h $(OPC_H)
bellard40293e52008-01-31 11:32:10 +0000280
pbrookdd485942008-02-01 22:45:04 +0000281translate-all.o: translate-all.c cpu.h $(OPC_H)
bellard40293e52008-01-31 11:32:10 +0000282
pbrookdd485942008-02-01 22:45:04 +0000283tcg/tcg.o: cpu.h $(OPC_H)
284
285tcg/tcg-dyngen.o: $(OPC_H)
286
287tcg/tcg-runtime.o: $(OPC_H)
bellard40293e52008-01-31 11:32:10 +0000288
289op.h: op.o $(DYNGEN)
290 $(DYNGEN) -o $@ $<
291
bellard57fec1f2008-02-01 10:50:11 +0000292dyngen-opc.h: op.o $(DYNGEN)
bellard40293e52008-01-31 11:32:10 +0000293 $(DYNGEN) -c -o $@ $<
294
295gen-op.h: op.o $(DYNGEN)
296 $(DYNGEN) -g -o $@ $<
297
298op.o: op.c
299 $(CC) $(OP_CFLAGS) $(CPPFLAGS) -c -o $@ $<
300
301# HELPER_CFLAGS is used for all the code compiled with static register
302# variables
303ifeq ($(TARGET_BASE_ARCH), i386)
304# XXX: rename helper.c to op_helper.c
305helper.o: helper.c
306 $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
307else
308op_helper.o: op_helper.c
309 $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
310endif
311
312cpu-exec.o: cpu-exec.c
313 $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
314
315#########################################################
316# Linux user emulator target
317
318ifdef CONFIG_LINUX_USER
319
320VPATH+=:$(SRC_PATH)/linux-user
321ifndef TARGET_ABI_DIR
322 TARGET_ABI_DIR=$(TARGET_ARCH)
323endif
324CPPFLAGS+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR)
325
326ifdef CONFIG_STATIC
327LDFLAGS+=-static
328endif
329
330ifeq ($(ARCH),i386)
331ifdef TARGET_GPROF
332USE_I386_LD=y
333endif
334ifdef CONFIG_STATIC
335USE_I386_LD=y
336endif
337ifdef USE_I386_LD
338LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
339else
340# WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
341# that the kernel ELF loader considers as an executable. I think this
342# is the simplest way to make it self virtualizable!
343LDFLAGS+=-Wl,-shared
344endif
345endif
346
347ifeq ($(ARCH),x86_64)
348LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
349endif
350
351ifeq ($(ARCH),ppc)
352LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
353endif
354
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
400OBJS= main.o syscall.o strace.o mmap.o signal.o path.o osdep.o thunk.o \
401 elfload.o linuxload.o uaccess.o
402LIBS+= $(AIOLIBS)
403ifdef TARGET_HAS_BFLT
404OBJS+= flatload.o
405endif
406ifdef TARGET_HAS_ELFLOAD32
407OBJS+= elfload32.o
408elfload32.o: elfload.c
409endif
410
411ifeq ($(TARGET_ARCH), i386)
412OBJS+= vm86.o
413endif
414ifeq ($(TARGET_ARCH), arm)
415OBJS+=nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
416nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
417 nwfpe/double_cpdo.o nwfpe/extended_cpdo.o arm-semi.o
418endif
419ifeq ($(TARGET_ARCH), m68k)
420OBJS+= m68k-sim.o m68k-semi.o
421endif
422
bellard1fddef42005-04-17 19:16:13 +0000423ifdef CONFIG_GDBSTUB
424OBJS+=gdbstub.o
425endif
bellard626df762003-08-10 21:39:31 +0000426
bellard40293e52008-01-31 11:32:10 +0000427OBJS+= libqemu.a
bellard626df762003-08-10 21:39:31 +0000428
bellard40293e52008-01-31 11:32:10 +0000429# Note: this is a workaround. The real fix is to avoid compiling
430# cpu_signal_handler() in cpu-exec.c.
431signal.o: signal.c
432 $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
433
434$(QEMU_PROG): $(OBJS)
435 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
bellard626df762003-08-10 21:39:31 +0000436ifeq ($(ARCH),alpha)
437# Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
438# the address space (31 bit so sign extending doesn't matter)
439 echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
440endif
441
bellard40293e52008-01-31 11:32:10 +0000442endif #CONFIG_LINUX_USER
443
444#########################################################
445# Darwin user emulator target
446
447ifdef CONFIG_DARWIN_USER
448
449VPATH+=:$(SRC_PATH)/darwin-user
450CPPFLAGS+=-I$(SRC_PATH)/darwin-user -I$(SRC_PATH)/darwin-user/$(TARGET_ARCH)
451
452# Leave some space for the regular program loading zone
453LDFLAGS+=-Wl,-segaddr,__STD_PROG_ZONE,0x1000 -image_base 0x0e000000
454
455LIBS+=-lmx
456
457OBJS= main.o commpage.o machload.o mmap.o osdep.o signal.o syscall.o thunk.o
458
459OBJS+= libqemu.a
460
461ifdef CONFIG_GDBSTUB
462OBJS+=gdbstub.o
ths223d4672007-12-15 17:28:36 +0000463endif
bellarda541f292004-04-12 20:39:29 +0000464
bellard40293e52008-01-31 11:32:10 +0000465# Note: this is a workaround. The real fix is to avoid compiling
466# cpu_signal_handler() in cpu-exec.c.
467signal.o: signal.c
468 $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
469
470$(QEMU_PROG): $(OBJS)
471 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
472
473endif #CONFIG_DARWIN_USER
474
475#########################################################
476# System emulator target
477ifndef CONFIG_USER_ONLY
478
479OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o
480ifdef CONFIG_WIN32
481OBJS+=block-raw-win32.o
482else
483OBJS+=block-raw-posix.o
484endif
485
486LIBS+=-lz
bellard1d14ffa2005-10-30 18:58:22 +0000487ifdef CONFIG_ALSA
bellard1d14ffa2005-10-30 18:58:22 +0000488LIBS += -lasound
489endif
balrogca9cc282008-01-14 04:24:29 +0000490ifdef CONFIG_ESD
491LIBS += -lesd
492endif
bellard1d14ffa2005-10-30 18:58:22 +0000493ifdef CONFIG_DSOUND
bellard1d14ffa2005-10-30 18:58:22 +0000494LIBS += -lole32 -ldxguid
495endif
bellard102a52e2004-11-14 19:57:29 +0000496ifdef CONFIG_FMOD
bellard102a52e2004-11-14 19:57:29 +0000497LIBS += $(CONFIG_FMOD_LIB)
bellard85571bc2004-11-07 18:04:02 +0000498endif
bellard4fb240a2007-11-07 19:24:02 +0000499
500SOUND_HW = sb16.o es1370.o
balrogca9cc282008-01-14 04:24:29 +0000501ifdef CONFIG_AC97
502SOUND_HW += ac97.o
503endif
bellard1d14ffa2005-10-30 18:58:22 +0000504ifdef CONFIG_ADLIB
505SOUND_HW += fmopl.o adlib.o
506endif
balrog423d65f2008-01-14 22:09:11 +0000507ifdef CONFIG_GUS
508SOUND_HW += gus.o gusemu_hal.o gusemu_mixer.o
509endif
bellard85571bc2004-11-07 18:04:02 +0000510
ths8d5d2d42007-08-25 01:37:51 +0000511ifdef CONFIG_VNC_TLS
512CPPFLAGS += $(CONFIG_VNC_TLS_CFLAGS)
513LIBS += $(CONFIG_VNC_TLS_LIBS)
514endif
515
pbrook2e5d83b2006-05-25 23:58:51 +0000516# SCSI layer
blueswir18b17de82008-03-02 08:48:47 +0000517OBJS+= lsi53c895a.o esp.o
pbrook2e5d83b2006-05-25 23:58:51 +0000518
bellarda594cfb2005-11-06 16:13:29 +0000519# USB layer
bellard40293e52008-01-31 11:32:10 +0000520OBJS+= usb-ohci.o
bellarda594cfb2005-11-06 16:13:29 +0000521
ths663e8e52007-04-02 12:35:34 +0000522# EEPROM emulation
bellard40293e52008-01-31 11:32:10 +0000523OBJS += eeprom93xx.o
ths663e8e52007-04-02 12:35:34 +0000524
pbrooka41b2ff2006-02-05 04:14:41 +0000525# PCI network cards
bellard40293e52008-01-31 11:32:10 +0000526OBJS += eepro100.o
527OBJS += ne2000.o
528OBJS += pcnet.o
529OBJS += rtl8139.o
balrog7c23b892008-02-03 02:20:18 +0000530OBJS += e1000.o
pbrooka41b2ff2006-02-05 04:14:41 +0000531
bellard0b0babc2005-01-03 23:38:40 +0000532ifeq ($(TARGET_BASE_ARCH), i386)
bellarda541f292004-04-12 20:39:29 +0000533# Hardware support
bellard40293e52008-01-31 11:32:10 +0000534OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o
535OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o
536OBJS+= cirrus_vga.o apic.o parallel.o acpi.o piix_pci.o
537OBJS+= usb-uhci.o vmmouse.o vmport.o vmware_vga.o
balrogb00052e2007-04-30 02:22:06 +0000538CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE
bellard67b915a2004-03-31 23:37:16 +0000539endif
bellarda2458622005-07-23 22:39:53 +0000540ifeq ($(TARGET_BASE_ARCH), ppc)
balrogb00052e2007-04-30 02:22:06 +0000541CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE
j_mayer3cbee152007-10-28 23:42:18 +0000542# shared objects
bellard40293e52008-01-31 11:32:10 +0000543OBJS+= ppc.o ide.o vga.o $(SOUND_HW) dma.o openpic.o
j_mayer3cbee152007-10-28 23:42:18 +0000544# PREP target
bellard40293e52008-01-31 11:32:10 +0000545OBJS+= pckbd.o ps2.o serial.o i8259.o i8254.o fdc.o m48t59.o mc146818rtc.o
546OBJS+= prep_pci.o ppc_prep.o
j_mayer3cbee152007-10-28 23:42:18 +0000547# Mac shared devices
bellard40293e52008-01-31 11:32:10 +0000548OBJS+= macio.o cuda.o adb.o mac_nvram.o mac_dbdma.o
j_mayer3cbee152007-10-28 23:42:18 +0000549# OldWorld PowerMac
bellard40293e52008-01-31 11:32:10 +0000550OBJS+= heathrow_pic.o grackle_pci.o ppc_oldworld.o
j_mayer3cbee152007-10-28 23:42:18 +0000551# NewWorld PowerMac
bellard40293e52008-01-31 11:32:10 +0000552OBJS+= unin_pci.o ppc_chrp.o
j_mayer3cbee152007-10-28 23:42:18 +0000553# PowerPC 4xx boards
bellard40293e52008-01-31 11:32:10 +0000554OBJS+= pflash_cfi02.o ppc4xx_devs.o ppc405_uc.o ppc405_boards.o
bellarda541f292004-04-12 20:39:29 +0000555endif
thsfbe4f652007-04-01 11:16:48 +0000556ifeq ($(TARGET_BASE_ARCH), mips)
bellard40293e52008-01-31 11:32:10 +0000557OBJS+= mips_r4k.o mips_malta.o mips_pica61.o mips_mipssim.o
558OBJS+= mips_timer.o mips_int.o dma.o vga.o serial.o i8254.o i8259.o
559OBJS+= jazz_led.o
560OBJS+= ide.o gt64xxx.o pckbd.o ps2.o fdc.o mc146818rtc.o usb-uhci.o acpi.o ds1225y.o
561OBJS+= piix_pci.o parallel.o cirrus_vga.o $(SOUND_HW)
562OBJS+= mipsnet.o
563OBJS+= pflash_cfi01.o
ths83b1fb82007-04-11 22:46:06 +0000564CPPFLAGS += -DHAS_AUDIO
bellard6af0bf92005-07-02 14:58:51 +0000565endif
thse7daa602007-10-08 13:38:27 +0000566ifeq ($(TARGET_BASE_ARCH), cris)
bellard40293e52008-01-31 11:32:10 +0000567OBJS+= etraxfs.o
edgar_igle62b5b12008-03-14 01:04:24 +0000568OBJS+= etraxfs_pic.o
bellard40293e52008-01-31 11:32:10 +0000569OBJS+= etraxfs_timer.o
570OBJS+= etraxfs_ser.o
edgar_igle62b5b12008-03-14 01:04:24 +0000571
572OBJS+= ptimer.o
573OBJS+= pflash_cfi01.o
thse7daa602007-10-08 13:38:27 +0000574endif
bellard64b3ab22005-01-30 22:43:42 +0000575ifeq ($(TARGET_BASE_ARCH), sparc)
bellard34751872005-07-02 14:31:34 +0000576ifeq ($(TARGET_ARCH), sparc64)
bellard40293e52008-01-31 11:32:10 +0000577OBJS+= sun4u.o ide.o pckbd.o ps2.o vga.o apb_pci.o
578OBJS+= fdc.o mc146818rtc.o serial.o m48t59.o
579OBJS+= cirrus_vga.o parallel.o ptimer.o
bellard34751872005-07-02 14:31:34 +0000580else
bellard40293e52008-01-31 11:32:10 +0000581OBJS+= sun4m.o tcx.o pcnet.o iommu.o m48t59.o slavio_intctl.o
blueswir18b17de82008-03-02 08:48:47 +0000582OBJS+= slavio_timer.o slavio_serial.o slavio_misc.o fdc.o sparc32_dma.o
bellard40293e52008-01-31 11:32:10 +0000583OBJS+= cs4231.o ptimer.o eccmemctl.o sbi.o sun4c_intctl.o
bellard34751872005-07-02 14:31:34 +0000584endif
bellarde95c8d52004-09-30 22:22:08 +0000585endif
bellardb5ff1b32005-11-26 10:38:39 +0000586ifeq ($(TARGET_BASE_ARCH), arm)
bellard40293e52008-01-31 11:32:10 +0000587OBJS+= integratorcp.o versatilepb.o ps2.o smc91c111.o arm_pic.o arm_timer.o
588OBJS+= arm_boot.o pl011.o pl031.o pl050.o pl080.o pl110.o pl181.o pl190.o
589OBJS+= versatile_pci.o ptimer.o
590OBJS+= realview_gic.o realview.o arm_sysctl.o mpcore.o
591OBJS+= armv7m.o armv7m_nvic.o stellaris.o pl022.o stellaris_enet.o
592OBJS+= pl061.o
593OBJS+= arm-semi.o
594OBJS+= pxa2xx.o pxa2xx_pic.o pxa2xx_gpio.o pxa2xx_timer.o pxa2xx_dma.o
595OBJS+= pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o pxa2xx_keypad.o
596OBJS+= pflash_cfi01.o gumstix.o
597OBJS+= spitz.o ide.o serial.o nand.o ecc.o
balrogb4e31042008-03-06 21:07:38 +0000598OBJS+= omap1.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap_i2c.o
bellard40293e52008-01-31 11:32:10 +0000599OBJS+= palm.o tsc210x.o
600OBJS+= mst_fpga.o mainstone.o
balrog5a1237c2007-05-02 02:11:51 +0000601CPPFLAGS += -DHAS_AUDIO
bellardb5ff1b32005-11-26 10:38:39 +0000602endif
bellardfdf9b3e2006-04-27 21:07:38 +0000603ifeq ($(TARGET_BASE_ARCH), sh4)
bellard40293e52008-01-31 11:32:10 +0000604OBJS+= shix.o r2d.o sh7750.o sh7750_regnames.o tc58128.o
605OBJS+= sh_timer.o ptimer.o sh_serial.o sh_intc.o
bellardfdf9b3e2006-04-27 21:07:38 +0000606endif
pbrook06338792007-05-23 19:58:11 +0000607ifeq ($(TARGET_BASE_ARCH), m68k)
bellard40293e52008-01-31 11:32:10 +0000608OBJS+= an5206.o mcf5206.o ptimer.o mcf_uart.o mcf_intc.o mcf5208.o mcf_fec.o
609OBJS+= m68k-semi.o dummy_m68k.o
pbrook06338792007-05-23 19:58:11 +0000610endif
bellarda541f292004-04-12 20:39:29 +0000611ifdef CONFIG_GDBSTUB
bellard40293e52008-01-31 11:32:10 +0000612OBJS+=gdbstub.o
bellard728c9fd2004-01-05 00:08:14 +0000613endif
bellard5b0753e2005-03-01 21:37:28 +0000614ifdef CONFIG_COCOA
bellard1d14ffa2005-10-30 18:58:22 +0000615COCOA_LIBS=-F/System/Library/Frameworks -framework Cocoa -framework IOKit
616ifdef CONFIG_COREAUDIO
617COCOA_LIBS+=-framework CoreAudio
618endif
bellard5b0753e2005-03-01 21:37:28 +0000619endif
bellard7c1f25b2004-04-22 00:02:08 +0000620ifdef CONFIG_SLIRP
ths6f30fa82007-01-05 01:00:47 +0000621CPPFLAGS+=-I$(SRC_PATH)/slirp
bellard626df762003-08-10 21:39:31 +0000622endif
623
bellard40293e52008-01-31 11:32:10 +0000624LIBS+=$(AIOLIBS)
bellardc321f672003-10-30 01:18:42 +0000625# specific flags are needed for non soft mmu emulator
bellardc321f672003-10-30 01:18:42 +0000626ifdef CONFIG_STATIC
bellard40293e52008-01-31 11:32:10 +0000627LDFLAGS+=-static
bellardde5eaa62003-11-16 23:18:17 +0000628endif
bellard83fb7ad2004-07-05 21:25:26 +0000629ifndef CONFIG_DARWIN
bellard11d9f692004-04-02 20:55:59 +0000630ifndef CONFIG_WIN32
bellardec530c82006-04-25 22:36:06 +0000631ifndef CONFIG_SOLARIS
bellard40293e52008-01-31 11:32:10 +0000632LIBS+=-lutil
bellard11d9f692004-04-02 20:55:59 +0000633endif
bellard83fb7ad2004-07-05 21:25:26 +0000634endif
bellardec530c82006-04-25 22:36:06 +0000635endif
bellarde3086fb2005-02-10 21:48:51 +0000636ifdef TARGET_GPROF
bellard40293e52008-01-31 11:32:10 +0000637vl.o: CFLAGS+=-p
638LDFLAGS+=-p
bellarde3086fb2005-02-10 21:48:51 +0000639endif
bellardc321f672003-10-30 01:18:42 +0000640
bellardb8076a72005-04-07 22:20:31 +0000641ifeq ($(ARCH),ia64)
bellard40293e52008-01-31 11:32:10 +0000642LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
ths8a0ef212007-11-18 22:34:46 +0000643endif
644
bellard1d14ffa2005-10-30 18:58:22 +0000645ifdef CONFIG_WIN32
646SDL_LIBS := $(filter-out -mwindows, $(SDL_LIBS)) -mconsole
647endif
648
bellard40293e52008-01-31 11:32:10 +0000649# profiling code
650ifdef TARGET_GPROF
651LDFLAGS+=-p
652main.o: CFLAGS+=-p
bellard6e1b3e42006-08-17 17:41:26 +0000653endif
654
bellard40293e52008-01-31 11:32:10 +0000655$(QEMU_PROG): $(OBJS) ../libqemu_common.a libqemu.a
balrog4d3b6f62008-02-10 16:33:14 +0000656 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(CURSES_LIBS)
bellard626df762003-08-10 21:39:31 +0000657
bellard40293e52008-01-31 11:32:10 +0000658endif # !CONFIG_USER_ONLY
bellard00a67ba2006-10-28 12:19:07 +0000659
bellard626df762003-08-10 21:39:31 +0000660%.o: %.c
bellard40293e52008-01-31 11:32:10 +0000661 $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
bellard626df762003-08-10 21:39:31 +0000662
bellardf72b5192004-02-16 21:55:35 +0000663%.o: %.S
ths6f30fa82007-01-05 01:00:47 +0000664 $(CC) $(CPPFLAGS) -c -o $@ $<
bellardf72b5192004-02-16 21:55:35 +0000665
bellard626df762003-08-10 21:39:31 +0000666clean:
bellard57fec1f2008-02-01 10:50:11 +0000667 rm -f *.o *.a *~ $(PROGS) gen-op.h dyngen-opc.h op.h nwfpe/*.o fpu/*.o
668 rm -f *.d */*.d tcg/*.o
bellard1e43adf2003-09-30 20:54:24 +0000669
ths5fafdf22007-09-16 21:08:06 +0000670install: all
bellard9b14bb02004-03-26 22:43:34 +0000671ifneq ($(PROGS),)
pbrook6a882642006-04-17 13:57:12 +0000672 $(INSTALL) -m 755 -s $(PROGS) "$(DESTDIR)$(bindir)"
bellard9b14bb02004-03-26 22:43:34 +0000673endif
bellard626df762003-08-10 21:39:31 +0000674
j_mayer2f96c282007-10-28 13:07:12 +0000675# Include automatically generated dependency files
676-include $(wildcard *.d */*.d)