3 TARGET_BASE_ARCH:=$(TARGET_ARCH)
4 ifeq ($(TARGET_ARCH), x86_64)
7 ifeq ($(TARGET_ARCH), ppc64)
10 ifeq ($(TARGET_ARCH), sparc64)
11 TARGET_BASE_ARCH:=sparc
13 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH)
14 VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw:$(SRC_PATH)/audio
15 DEFINES=-I. -I.. -I$(TARGET_PATH) -I$(SRC_PATH)
16 ifdef CONFIG_USER_ONLY
17 VPATH+=:$(SRC_PATH)/linux-user
18 DEFINES+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ARCH)
20 CFLAGS=-Wall -O2 -g -fno-strict-aliasing
24 HELPER_CFLAGS=$(CFLAGS)
25 DYNGEN=../dyngen$(EXESUF)
27 ifeq ($(TARGET_ARCH),arm)
28 ifeq ($(TARGET_WORDS_BIGENDIAN),yes)
34 ifeq ($(TARGET_ARCH),mips)
35 ifeq ($(TARGET_WORDS_BIGENDIAN),yes)
41 QEMU_USER=qemu-$(TARGET_ARCH)
44 # system emulator name
46 ifeq ($(TARGET_ARCH), i386)
47 QEMU_SYSTEM=qemu$(EXESUF)
49 QEMU_SYSTEM=qemu-system-$(TARGET_ARCH)$(EXESUF)
55 ifdef CONFIG_USER_ONLY
62 endif # !CONFIG_USER_ONLY
69 CFLAGS+=-fomit-frame-pointer
70 OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2
71 ifeq ($(HAVE_GCC3_OPTIONS),yes)
72 OP_CFLAGS+= -falign-functions=0 -fno-gcse
74 OP_CFLAGS+= -malign-functions=0
84 LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386.ld
86 # WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
87 # that the kernel ELF loader considers as an executable. I think this
88 # is the simplest way to make it self virtualizable!
94 OP_CFLAGS=$(CFLAGS) -falign-functions=0
95 LDFLAGS+=-Wl,-T,$(SRC_PATH)/x86_64.ld
99 CFLAGS+= -D__powerpc__
101 LDFLAGS+=-Wl,-T,$(SRC_PATH)/ppc.ld
106 LDFLAGS+=-Wl,-T,$(SRC_PATH)/s390.ld
110 CFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
112 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
113 HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat
114 # -static is used to avoid g1/g3 usage by the dynamic linker
115 LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc.ld -static
118 ifeq ($(ARCH),sparc64)
119 CFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
121 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
125 # -msmall-data is not used because we want two-instruction relocations
126 # for the constant constructions
127 OP_CFLAGS=-Wall -O2 -g
128 # Ensure there's only a single GP
129 CFLAGS += -msmall-data
130 LDFLAGS+=-Wl,-T,$(SRC_PATH)/alpha.ld
136 LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
140 OP_CFLAGS=$(CFLAGS) -mno-sched-prolog -fno-omit-frame-pointer
141 LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld
145 OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer
146 LDFLAGS+=-Wl,-T,m68k.ld
149 ifeq ($(HAVE_GCC3_OPTIONS),yes)
150 # very important to generate a return at the end of every operation
151 OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
154 ifeq ($(CONFIG_DARWIN),yes)
155 OP_CFLAGS+= -mdynamic-no-pic
159 #########################################################
161 DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
163 ifndef CONFIG_USER_ONLY
167 LIBS+=-lwinmm -lws2_32 -liphlpapi
176 OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o
177 ifeq ($(TARGET_ARCH), i386)
180 ifeq ($(TARGET_ARCH), arm)
181 OBJS+=nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
182 nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
183 nwfpe/double_cpdo.o nwfpe/extended_cpdo.o arm-semi.o
188 # cpu emulator library
189 LIBOBJS=exec.o kqemu.o translate-op.o translate-all.o cpu-exec.o\
191 ifdef CONFIG_SOFTFLOAT
192 LIBOBJS+=fpu/softfloat.o
194 LIBOBJS+=fpu/softfloat-native.o
196 DEFINES+=-I$(SRC_PATH)/fpu
198 ifeq ($(TARGET_ARCH), i386)
199 LIBOBJS+=helper.o helper2.o
201 LIBOBJS+=translate-copy.o
205 ifeq ($(TARGET_ARCH), x86_64)
206 LIBOBJS+=helper.o helper2.o
209 ifeq ($(TARGET_BASE_ARCH), ppc)
210 LIBOBJS+= op_helper.o helper.o
213 ifeq ($(TARGET_ARCH), mips)
214 LIBOBJS+= op_helper.o helper.o
217 ifeq ($(TARGET_BASE_ARCH), sparc)
218 LIBOBJS+= op_helper.o helper.o
221 ifeq ($(TARGET_BASE_ARCH), arm)
222 LIBOBJS+= op_helper.o helper.o
225 # NOTE: the disassembler code is only needed for debugging
227 ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
230 ifeq ($(findstring x86_64, $(TARGET_ARCH) $(ARCH)),x86_64)
236 ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
239 ifeq ($(findstring ppc, $(TARGET_BASE_ARCH) $(ARCH)),ppc)
242 ifeq ($(findstring mips, $(TARGET_ARCH) $(ARCH)),mips)
245 ifeq ($(findstring sparc, $(TARGET_BASE_ARCH) $(ARCH)),sparc)
248 ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
251 ifeq ($(findstring m68k, $(TARGET_ARCH) $(ARCH)),m68k)
261 $(QEMU_USER): $(OBJS)
262 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
264 # Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
265 # the address space (31 bit so sign extending doesn't matter)
266 echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
269 # must use static linking to avoid leaving stuff in virtual address space
270 VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o loader.o
271 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
276 SOUND_HW = sb16.o es1370.o
277 AUDIODRV = audio.o noaudio.o wavaudio.o
279 AUDIODRV += sdlaudio.o
282 AUDIODRV += ossaudio.o
284 ifdef CONFIG_COREAUDIO
285 AUDIODRV += coreaudio.o
288 AUDIODRV += alsaaudio.o
292 AUDIODRV += dsoundaudio.o
293 LIBS += -lole32 -ldxguid
296 AUDIODRV += fmodaudio.o
297 audio.o fmodaudio.o: DEFINES := -I$(CONFIG_FMOD_INC) $(DEFINES)
298 LIBS += $(CONFIG_FMOD_LIB)
301 SOUND_HW += fmopl.o adlib.o
305 VL_OBJS+= usb.o usb-hub.o usb-uhci.o usb-linux.o usb-hid.o
308 VL_OBJS+= ne2000.o rtl8139.o
310 ifeq ($(TARGET_BASE_ARCH), i386)
312 VL_OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
313 VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o
314 VL_OBJS+= cirrus_vga.o mixeng.o apic.o parallel.o
315 DEFINES += -DHAS_AUDIO
317 ifeq ($(TARGET_BASE_ARCH), ppc)
318 VL_OBJS+= ppc.o ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
319 VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o
320 VL_OBJS+= ppc_prep.o ppc_chrp.o cuda.o adb.o openpic.o heathrow_pic.o mixeng.o
321 DEFINES += -DHAS_AUDIO
323 ifeq ($(TARGET_ARCH), mips)
324 VL_OBJS+= mips_r4k.o dma.o vga.o serial.o i8254.o i8259.o
325 #VL_OBJS+= #ide.o pckbd.o fdc.o m48t59.o
327 ifeq ($(TARGET_BASE_ARCH), sparc)
328 ifeq ($(TARGET_ARCH), sparc64)
329 VL_OBJS+= sun4u.o ide.o pckbd.o ps2.o vga.o
330 VL_OBJS+= fdc.o mc146818rtc.o serial.o m48t59.o
331 VL_OBJS+= cirrus_vga.o parallel.o
333 VL_OBJS+= sun4m.o tcx.o lance.o iommu.o m48t59.o slavio_intctl.o
334 VL_OBJS+= slavio_timer.o slavio_serial.o slavio_misc.o fdc.o esp.o
337 ifeq ($(TARGET_BASE_ARCH), arm)
338 VL_OBJS+= integratorcp.o versatilepb.o ps2.o smc91c111.o arm_pic.o arm_timer.o
339 VL_OBJS+= pl011.o pl050.o pl080.o pl110.o pl190.o
349 COCOA_LIBS=-F/System/Library/Frameworks -framework Cocoa -framework IOKit
350 ifdef CONFIG_COREAUDIO
351 COCOA_LIBS+=-framework CoreAudio
355 DEFINES+=-I$(SRC_PATH)/slirp
356 SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
357 slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
358 tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o
359 VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
363 # specific flags are needed for non soft mmu emulator
367 ifndef CONFIG_SOFTMMU
368 VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld
381 VL_LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
385 SDL_LIBS := $(filter-out -mwindows, $(SDL_LIBS)) -mconsole
388 $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
389 $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(VL_LIBS)
392 $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
394 sdl.o: sdl.c keymaps.c sdl_keysym.h
395 $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
397 sdlaudio.o: sdlaudio.c
398 $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
401 $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
403 vldepend: $(VL_OBJS:.o=.c)
404 $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
408 libqemu.a: $(LIBOBJS)
410 $(AR) rcs $@ $(LIBOBJS)
412 translate.o: translate.c gen-op.h opc.h cpu.h
414 translate-all.o: translate-all.c opc.h cpu.h
416 translate-op.o: translate-all.c op.h opc.h cpu.h
421 opc.h: op.o $(DYNGEN)
422 $(DYNGEN) -c -o $@ $<
424 gen-op.h: op.o $(DYNGEN)
425 $(DYNGEN) -g -o $@ $<
428 $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
431 $(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
433 ifeq ($(TARGET_BASE_ARCH), i386)
434 op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h ops_sse.h
437 ifeq ($(TARGET_ARCH), arm)
438 op.o: op.c op_template.h
439 pl110.o: pl110_template.h
442 ifeq ($(TARGET_BASE_ARCH), sparc)
443 op.o: op.c op_template.h op_mem.h fop_template.h fbranch_template.h
444 magic_load.o: elf_op.h
447 ifeq ($(TARGET_BASE_ARCH), ppc)
448 op.o: op.c op_template.h op_mem.h
449 op_helper.o: op_helper_mem.h
450 translate.o: translate.c translate_init.c
453 ifeq ($(TARGET_ARCH), mips)
454 op.o: op.c op_template.c op_mem.c
455 op_helper.o: op_helper_mem.c
458 loader.o: loader.c elf_ops.h
461 $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
464 $(CC) $(DEFINES) -c -o $@ $<
467 rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o fpu/*.o
471 $(INSTALL) -m 755 -s $(PROGS) "$(DESTDIR)$(bindir)"
474 ifneq ($(wildcard .depend),)
479 audio.o sdlaudio.o dsoundaudio.o ossaudio.o wavaudio.o noaudio.o \
480 fmodaudio.o alsaaudio.o mixeng.o sb16.o es1370.o gus.o adlib.o: \
481 CFLAGS := $(CFLAGS) -Wall -Werror -W -Wsign-compare