blob: 1b578d0fd2c56ebf278b9f16fd46799d5c34542e [file] [log] [blame]
bellard626df762003-08-10 21:39:31 +00001include config.mak
2
bellard1e43adf2003-09-30 20:54:24 +00003TARGET_PATH=$(SRC_PATH)/target-$(TARGET_ARCH)
bellard80cabfa2004-03-14 12:20:30 +00004VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw
bellard3035f7f2004-03-21 17:02:00 +00005DEFINES=-I. -I$(TARGET_PATH) -I$(SRC_PATH)
6ifdef CONFIG_USER_ONLY
7VPATH+=:$(SRC_PATH)/linux-user
8DEFINES+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ARCH)
9endif
bellard626df762003-08-10 21:39:31 +000010CFLAGS=-Wall -O2 -g
11LDFLAGS=-g
12LIBS=
bellard626df762003-08-10 21:39:31 +000013HELPER_CFLAGS=$(CFLAGS)
bellard67b915a2004-03-31 23:37:16 +000014DYNGEN=../dyngen$(EXESUF)
bellard1e43adf2003-09-30 20:54:24 +000015# user emulator name
16QEMU_USER=qemu-$(TARGET_ARCH)
17# system emulator name
18ifdef CONFIG_SOFTMMU
bellard67b915a2004-03-31 23:37:16 +000019QEMU_SYSTEM=qemu$(EXESUF)
bellard0db63472003-10-27 21:37:46 +000020else
21QEMU_SYSTEM=qemu-fast
bellard1e43adf2003-09-30 20:54:24 +000022endif
23
bellard16e9b7d2003-10-27 21:09:52 +000024ifdef CONFIG_USER_ONLY
bellard1e43adf2003-09-30 20:54:24 +000025PROGS=$(QEMU_USER)
bellard16e9b7d2003-10-27 21:09:52 +000026else
bellard16e9b7d2003-10-27 21:09:52 +000027ifeq ($(TARGET_ARCH), i386)
bellardc321f672003-10-30 01:18:42 +000028
29ifeq ($(ARCH), i386)
bellard16e9b7d2003-10-27 21:09:52 +000030PROGS+=$(QEMU_SYSTEM)
bellardde5eaa62003-11-16 23:18:17 +000031ifndef CONFIG_SOFTMMU
32CONFIG_STATIC=y
33endif
bellard38ca2ab2004-03-13 18:32:13 +000034else
35# the system emulator using soft mmu is portable
bellardc321f672003-10-30 01:18:42 +000036ifdef CONFIG_SOFTMMU
37PROGS+=$(QEMU_SYSTEM)
38endif
bellard38ca2ab2004-03-13 18:32:13 +000039endif # ARCH != i386
bellardc321f672003-10-30 01:18:42 +000040
bellard38ca2ab2004-03-13 18:32:13 +000041endif # TARGET_ARCH = i386
bellard728c9fd2004-01-05 00:08:14 +000042
43ifeq ($(TARGET_ARCH), ppc)
44
45ifeq ($(ARCH), ppc)
46PROGS+=$(QEMU_SYSTEM)
bellard626df762003-08-10 21:39:31 +000047endif
48
bellard728c9fd2004-01-05 00:08:14 +000049ifeq ($(ARCH), i386)
50ifdef CONFIG_SOFTMMU
51PROGS+=$(QEMU_SYSTEM)
52endif
53endif # ARCH = i386
54
55endif # TARGET_ARCH = ppc
56endif # !CONFIG_USER_ONLY
57
bellard626df762003-08-10 21:39:31 +000058ifdef CONFIG_STATIC
59LDFLAGS+=-static
60endif
61
62ifeq ($(ARCH),i386)
63CFLAGS+=-fomit-frame-pointer
64OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2
65ifeq ($(HAVE_GCC3_OPTIONS),yes)
66OP_CFLAGS+= -falign-functions=0
67else
68OP_CFLAGS+= -malign-functions=0
69endif
bellard3a4739d2003-10-28 00:48:22 +000070
bellard626df762003-08-10 21:39:31 +000071ifdef TARGET_GPROF
bellard3a4739d2003-10-28 00:48:22 +000072USE_I386_LD=y
73endif
74ifdef CONFIG_STATIC
75USE_I386_LD=y
76endif
77ifdef USE_I386_LD
bellard626df762003-08-10 21:39:31 +000078LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386.ld
79else
80# WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
81# that the kernel ELF loader considers as an executable. I think this
82# is the simplest way to make it self virtualizable!
83LDFLAGS+=-Wl,-shared
84endif
bellard626df762003-08-10 21:39:31 +000085endif
86
bellardbc51c5c2004-03-17 23:46:04 +000087ifeq ($(ARCH),amd64)
88OP_CFLAGS=$(CFLAGS) -falign-functions=0
89LDFLAGS+=-Wl,-T,$(SRC_PATH)/amd64.ld
90endif
91
bellard626df762003-08-10 21:39:31 +000092ifeq ($(ARCH),ppc)
93OP_CFLAGS=$(CFLAGS)
94LDFLAGS+=-Wl,-T,$(SRC_PATH)/ppc.ld
95endif
96
97ifeq ($(ARCH),s390)
98OP_CFLAGS=$(CFLAGS)
99LDFLAGS+=-Wl,-T,$(SRC_PATH)/s390.ld
100endif
101
102ifeq ($(ARCH),sparc)
103CFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
104LDFLAGS+=-m32
105OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
106HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat
107# -static is used to avoid g1/g3 usage by the dynamic linker
108LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc.ld -static
109endif
110
111ifeq ($(ARCH),sparc64)
112CFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
113LDFLAGS+=-m64
114OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
115endif
116
117ifeq ($(ARCH),alpha)
118# -msmall-data is not used because we want two-instruction relocations
119# for the constant constructions
120OP_CFLAGS=-Wall -O2 -g
121# Ensure there's only a single GP
122CFLAGS += -msmall-data
123LDFLAGS+=-Wl,-T,$(SRC_PATH)/alpha.ld
124endif
125
126ifeq ($(ARCH),ia64)
127OP_CFLAGS=$(CFLAGS)
128endif
129
130ifeq ($(ARCH),arm)
131OP_CFLAGS=$(CFLAGS) -mno-sched-prolog
132LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld
133endif
134
bellard38e584a2003-08-10 22:14:22 +0000135ifeq ($(ARCH),m68k)
136OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer
137LDFLAGS+=-Wl,-T,m68k.ld
138endif
139
bellard626df762003-08-10 21:39:31 +0000140ifeq ($(HAVE_GCC3_OPTIONS),yes)
141# very important to generate a return at the end of every operation
142OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
143endif
144
145#########################################################
146
147DEFINES+=-D_GNU_SOURCE
148LIBS+=-lm
bellard67b915a2004-03-31 23:37:16 +0000149ifdef CONFIG_WIN32
150LIBS+=-lwinmm
151endif
bellard626df762003-08-10 21:39:31 +0000152
153# profiling code
154ifdef TARGET_GPROF
155LDFLAGS+=-p
156main.o: CFLAGS+=-p
157endif
158
bellard3035f7f2004-03-21 17:02:00 +0000159OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o
bellard626df762003-08-10 21:39:31 +0000160ifeq ($(TARGET_ARCH), i386)
161OBJS+= vm86.o
162endif
bellardf72b5192004-02-16 21:55:35 +0000163ifeq ($(TARGET_ARCH), arm)
164OBJS+=nwfpe/softfloat.o nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
165nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
166 nwfpe/double_cpdo.o nwfpe/extended_cpdo.o
167endif
bellard626df762003-08-10 21:39:31 +0000168SRCS:= $(OBJS:.o=.c)
169OBJS+= libqemu.a
170
171# cpu emulator library
bellard858693c2004-03-31 18:52:07 +0000172LIBOBJS=exec.o translate-all.o cpu-exec.o\
bellard1e43adf2003-09-30 20:54:24 +0000173 translate.o op.o
bellard626df762003-08-10 21:39:31 +0000174
175ifeq ($(TARGET_ARCH), i386)
bellard1e43adf2003-09-30 20:54:24 +0000176LIBOBJS+=helper.o helper2.o
bellardf72b5192004-02-16 21:55:35 +0000177ifeq ($(ARCH), i386)
178LIBOBJS+=translate-copy.o
179endif
bellard626df762003-08-10 21:39:31 +0000180endif
181
bellard67867302003-11-23 17:05:30 +0000182ifeq ($(TARGET_ARCH), ppc)
bellard728c9fd2004-01-05 00:08:14 +0000183LIBOBJS+= op_helper.o helper.o
bellard67867302003-11-23 17:05:30 +0000184endif
185
bellard626df762003-08-10 21:39:31 +0000186# NOTE: the disassembler code is only needed for debugging
187LIBOBJS+=disas.o
188ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
bellardbc51c5c2004-03-17 23:46:04 +0000189USE_I386_DIS=y
190endif
191ifeq ($(findstring amd64, $(TARGET_ARCH) $(ARCH)),amd64)
192USE_I386_DIS=y
193endif
194ifdef USE_I386_DIS
bellard626df762003-08-10 21:39:31 +0000195LIBOBJS+=i386-dis.o
196endif
197ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
198LIBOBJS+=alpha-dis.o
199endif
200ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc)
201LIBOBJS+=ppc-dis.o
202endif
203ifeq ($(findstring sparc, $(TARGET_ARCH) $(ARCH)),sparc)
204LIBOBJS+=sparc-dis.o
205endif
206ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
207LIBOBJS+=arm-dis.o
208endif
209
210ifeq ($(ARCH),ia64)
211OBJS += ia64-syscall.o
212endif
213
bellard1e43adf2003-09-30 20:54:24 +0000214all: $(PROGS)
bellard626df762003-08-10 21:39:31 +0000215
bellard1e43adf2003-09-30 20:54:24 +0000216$(QEMU_USER): $(OBJS)
bellard626df762003-08-10 21:39:31 +0000217 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
218ifeq ($(ARCH),alpha)
219# Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
220# the address space (31 bit so sign extending doesn't matter)
221 echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
222endif
223
224# must use static linking to avoid leaving stuff in virtual address space
bellard67b915a2004-03-31 23:37:16 +0000225VL_OBJS=vl.o osdep.o block.o monitor.o \
bellard9dc39cb2004-03-14 21:38:27 +0000226 ide.o ne2000.o pckbd.o vga.o sb16.o dma.o oss.o \
bellard80cabfa2004-03-14 12:20:30 +0000227 fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o
bellard67b915a2004-03-31 23:37:16 +0000228ifdef CONFIG_GDBSTUB
229VL_OBJS+=gdbstub.o
230endif
bellard728c9fd2004-01-05 00:08:14 +0000231ifeq ($(TARGET_ARCH), ppc)
232VL_OBJS+= hw.o
233endif
bellard626df762003-08-10 21:39:31 +0000234ifdef CONFIG_SDL
235VL_OBJS+=sdl.o
bellardde5eaa62003-11-16 23:18:17 +0000236ifdef CONFIG_STATIC
237SDL_LIBS:=$(SDL_STATIC_LIBS)
238endif
bellard626df762003-08-10 21:39:31 +0000239endif
240
bellardc321f672003-10-30 01:18:42 +0000241VL_LDFLAGS=
242# specific flags are needed for non soft mmu emulator
bellardc321f672003-10-30 01:18:42 +0000243ifdef CONFIG_STATIC
244VL_LDFLAGS+=-static
245endif
bellardde5eaa62003-11-16 23:18:17 +0000246ifndef CONFIG_SOFTMMU
247VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld
248endif
bellardc321f672003-10-30 01:18:42 +0000249
bellard1e43adf2003-09-30 20:54:24 +0000250$(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
bellard9dc39cb2004-03-14 21:38:27 +0000251 $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) -lutil
bellard626df762003-08-10 21:39:31 +0000252
253sdl.o: sdl.c
254 $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
255
256depend: $(SRCS)
bellard16e9b7d2003-10-27 21:09:52 +0000257 $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
bellard626df762003-08-10 21:39:31 +0000258
259# libqemu
260
261libqemu.a: $(LIBOBJS)
262 rm -f $@
263 $(AR) rcs $@ $(LIBOBJS)
264
bellard1e43adf2003-09-30 20:54:24 +0000265translate.o: translate.c gen-op.h opc.h cpu.h
bellard626df762003-08-10 21:39:31 +0000266
bellard1e43adf2003-09-30 20:54:24 +0000267translate-all.o: translate-all.c op.h opc.h cpu.h
bellard626df762003-08-10 21:39:31 +0000268
bellard1e43adf2003-09-30 20:54:24 +0000269op.h: op.o $(DYNGEN)
bellard626df762003-08-10 21:39:31 +0000270 $(DYNGEN) -o $@ $<
271
bellard1e43adf2003-09-30 20:54:24 +0000272opc.h: op.o $(DYNGEN)
bellard626df762003-08-10 21:39:31 +0000273 $(DYNGEN) -c -o $@ $<
274
bellard1e43adf2003-09-30 20:54:24 +0000275gen-op.h: op.o $(DYNGEN)
bellard626df762003-08-10 21:39:31 +0000276 $(DYNGEN) -g -o $@ $<
277
bellard1e43adf2003-09-30 20:54:24 +0000278op.o: op.c
bellard626df762003-08-10 21:39:31 +0000279 $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
280
bellard1e43adf2003-09-30 20:54:24 +0000281helper.o: helper.c
bellard626df762003-08-10 21:39:31 +0000282 $(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
283
bellard1e43adf2003-09-30 20:54:24 +0000284ifeq ($(TARGET_ARCH), i386)
285op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h
286endif
bellard626df762003-08-10 21:39:31 +0000287
bellard1e43adf2003-09-30 20:54:24 +0000288ifeq ($(TARGET_ARCH), arm)
289op.o: op.c op_template.h
290endif
291
292ifeq ($(TARGET_ARCH), sparc)
293op.o: op.c op_template.h
294endif
bellard626df762003-08-10 21:39:31 +0000295
bellard728c9fd2004-01-05 00:08:14 +0000296ifeq ($(TARGET_ARCH), ppc)
297op.o: op.c op_template.h op_mem.h
298op_helper.o: op_helper_mem.h
299endif
300
bellard626df762003-08-10 21:39:31 +0000301%.o: %.c
302 $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
303
bellardf72b5192004-02-16 21:55:35 +0000304%.o: %.S
305 $(CC) $(DEFINES) -c -o $@ $<
306
bellard626df762003-08-10 21:39:31 +0000307clean:
bellardf72b5192004-02-16 21:55:35 +0000308 rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o
bellard1e43adf2003-09-30 20:54:24 +0000309
310install: all
bellard9b14bb02004-03-26 22:43:34 +0000311ifneq ($(PROGS),)
bellard1e43adf2003-09-30 20:54:24 +0000312 install -m 755 -s $(PROGS) $(prefix)/bin
bellard9b14bb02004-03-26 22:43:34 +0000313endif
bellard626df762003-08-10 21:39:31 +0000314
315ifneq ($(wildcard .depend),)
316include .depend
317endif