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 CPPFLAGS=-I. -I.. -I$(TARGET_PATH) -I$(SRC_PATH)
16 ifdef CONFIG_USER_ONLY
17 VPATH+=:$(SRC_PATH)/linux-user
18 CPPFLAGS+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ARCH)
24 HELPER_CFLAGS=$(CFLAGS)
25 DYNGEN=../dyngen$(EXESUF)
27 TARGET_ARCH2=$(TARGET_ARCH)
28 ifeq ($(TARGET_ARCH),arm)
29 ifeq ($(TARGET_WORDS_BIGENDIAN),yes)
33 ifeq ($(TARGET_ARCH),sh4)
34 ifeq ($(TARGET_WORDS_BIGENDIAN),yes)
38 ifeq ($(TARGET_ARCH),mips)
39 ifneq ($(TARGET_WORDS_BIGENDIAN),yes)
43 QEMU_USER=qemu-$(TARGET_ARCH2)
44 # system emulator name
46 ifeq ($(TARGET_ARCH), i386)
47 QEMU_SYSTEM=qemu$(EXESUF)
49 QEMU_SYSTEM=qemu-system-$(TARGET_ARCH2)$(EXESUF)
55 ifdef CONFIG_USER_ONLY
62 endif # !CONFIG_USER_ONLY
68 # We require -O2 to avoid the stack setup prologue in EXIT_TB
69 OP_CFLAGS = -Wall -O2 -g -fno-strict-aliasing
72 HELPER_CFLAGS+=-fomit-frame-pointer
73 OP_CFLAGS+=-mpreferred-stack-boundary=2 -fomit-frame-pointer
74 ifeq ($(HAVE_GCC3_OPTIONS),yes)
75 OP_CFLAGS+= -falign-functions=0 -fno-gcse
77 OP_CFLAGS+= -malign-functions=0
86 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
88 # WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
89 # that the kernel ELF loader considers as an executable. I think this
90 # is the simplest way to make it self virtualizable!
91 BASE_LDFLAGS+=-Wl,-shared
96 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
100 CPPFLAGS+= -D__powerpc__
101 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
105 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
109 ifeq ($(CONFIG_SOLARIS),yes)
110 BASE_CFLAGS+=-mcpu=ultrasparc -m32 -ffixed-g2 -ffixed-g3
112 OP_CFLAGS+=-fno-delayed-branch -fno-omit-frame-pointer -ffixed-i0
114 BASE_CFLAGS+=-mcpu=ultrasparc -m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
116 OP_CFLAGS+=-fno-delayed-branch -ffixed-i0
117 HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat
118 # -static is used to avoid g1/g3 usage by the dynamic linker
119 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld -static
123 ifeq ($(ARCH),sparc64)
124 BASE_CFLAGS+=-mcpu=ultrasparc -m64 -ffixed-g1 -ffixed-g4 -ffixed-g5 -ffixed-g7
126 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
127 OP_CFLAGS+=-mcpu=ultrasparc -m64 -ffixed-g1 -ffixed-g4 -ffixed-g5 -ffixed-g7 -fno-delayed-branch -ffixed-i0
131 # -msmall-data is not used for OP_CFLAGS because we want two-instruction
132 # relocations for the constant constructions
133 # Ensure there's only a single GP
134 BASE_CFLAGS+=-msmall-data
135 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
139 BASE_CFLAGS+=-mno-sdata
140 OP_CFLAGS+=-mno-sdata
141 BASE_LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/$(ARCH).ld
145 OP_CFLAGS+=-mno-sched-prolog -fno-omit-frame-pointer
146 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
150 OP_CFLAGS+=-fomit-frame-pointer
151 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
155 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
158 ifeq ($(HAVE_GCC3_OPTIONS),yes)
159 # very important to generate a return at the end of every operation
160 OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
163 ifeq ($(CONFIG_DARWIN),yes)
167 OP_CFLAGS+=$(OS_CFLAGS)
169 #########################################################
171 CPPFLAGS+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
173 ifndef CONFIG_USER_ONLY
177 LIBS+=-lwinmm -lws2_32 -liphlpapi
180 LIBS+=-lsocket -lnsl -lresolv
186 main.o: BASE_CFLAGS+=-p
189 OBJS= main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o \
190 elfload.o linuxload.o
191 ifdef TARGET_HAS_BFLT
195 ifeq ($(TARGET_ARCH), i386)
198 ifeq ($(TARGET_ARCH), arm)
199 OBJS+=nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
200 nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
201 nwfpe/double_cpdo.o nwfpe/extended_cpdo.o arm-semi.o
203 ifeq ($(TARGET_ARCH), m68k)
204 OBJS+= m68k-sim.o m68k-semi.o
209 # cpu emulator library
210 LIBOBJS=exec.o kqemu.o translate-op.o translate-all.o cpu-exec.o\
212 ifdef CONFIG_SOFTFLOAT
213 LIBOBJS+=fpu/softfloat.o
215 LIBOBJS+=fpu/softfloat-native.o
217 CPPFLAGS+=-I$(SRC_PATH)/fpu
219 ifeq ($(TARGET_ARCH), i386)
220 LIBOBJS+=helper.o helper2.o
222 LIBOBJS+=translate-copy.o
226 ifeq ($(TARGET_ARCH), x86_64)
227 LIBOBJS+=helper.o helper2.o
230 ifeq ($(TARGET_BASE_ARCH), ppc)
231 LIBOBJS+= op_helper.o helper.o
234 ifeq ($(TARGET_ARCH), mips)
235 LIBOBJS+= op_helper.o helper.o
238 ifeq ($(TARGET_BASE_ARCH), sparc)
239 LIBOBJS+= op_helper.o helper.o
242 ifeq ($(TARGET_BASE_ARCH), arm)
243 LIBOBJS+= op_helper.o helper.o
246 ifeq ($(TARGET_BASE_ARCH), sh4)
247 LIBOBJS+= op_helper.o helper.o
250 ifeq ($(TARGET_BASE_ARCH), m68k)
254 # NOTE: the disassembler code is only needed for debugging
256 ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
259 ifeq ($(findstring x86_64, $(TARGET_ARCH) $(ARCH)),x86_64)
265 ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
268 ifeq ($(findstring ppc, $(TARGET_BASE_ARCH) $(ARCH)),ppc)
271 ifeq ($(findstring mips, $(TARGET_ARCH) $(ARCH)),mips)
274 ifeq ($(findstring sparc, $(TARGET_BASE_ARCH) $(ARCH)),sparc)
277 ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
280 ifeq ($(findstring m68k, $(TARGET_ARCH) $(ARCH)),m68k)
283 ifeq ($(findstring sh4, $(TARGET_ARCH) $(ARCH)),sh4)
293 $(QEMU_USER): $(OBJS)
294 $(CC) $(LDFLAGS) $(BASE_LDFLAGS) -o $@ $^ $(LIBS)
296 # Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
297 # the address space (31 bit so sign extending doesn't matter)
298 echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
301 # must use static linking to avoid leaving stuff in virtual address space
302 VL_OBJS=vl.o osdep.o readline.o monitor.o pci.o console.o loader.o isa_mmio.o
303 VL_OBJS+=block.o block-raw.o
304 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 block-qcow2.o
309 SOUND_HW = sb16.o es1370.o
310 AUDIODRV = audio.o noaudio.o wavaudio.o
312 AUDIODRV += sdlaudio.o
315 AUDIODRV += ossaudio.o
317 ifdef CONFIG_COREAUDIO
318 AUDIODRV += coreaudio.o
321 AUDIODRV += alsaaudio.o
325 AUDIODRV += dsoundaudio.o
326 LIBS += -lole32 -ldxguid
329 AUDIODRV += fmodaudio.o
330 audio.o fmodaudio.o: CPPFLAGS := -I$(CONFIG_FMOD_INC) $(CPPFLAGS)
331 LIBS += $(CONFIG_FMOD_LIB)
334 SOUND_HW += fmopl.o adlib.o
336 AUDIODRV+= wavcapture.o
339 VL_OBJS+= scsi-disk.o cdrom.o lsi53c895a.o
342 VL_OBJS+= usb.o usb-hub.o usb-linux.o usb-hid.o usb-ohci.o usb-msd.o
345 VL_OBJS+= ne2000.o rtl8139.o pcnet.o
347 ifeq ($(TARGET_BASE_ARCH), i386)
349 VL_OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
350 VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o
351 VL_OBJS+= cirrus_vga.o mixeng.o apic.o parallel.o acpi.o piix_pci.o
353 CPPFLAGS += -DHAS_AUDIO
355 ifeq ($(TARGET_BASE_ARCH), ppc)
356 VL_OBJS+= ppc.o ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
357 VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o
358 VL_OBJS+= ppc_prep.o ppc_chrp.o cuda.o adb.o openpic.o heathrow_pic.o mixeng.o
359 VL_OBJS+= grackle_pci.o prep_pci.o unin_pci.o
360 CPPFLAGS += -DHAS_AUDIO
362 ifeq ($(TARGET_ARCH), mips)
363 VL_OBJS+= mips_r4k.o mips_timer.o dma.o vga.o serial.o i8254.o i8259.o ide.o
364 VL_OBJS+= mc146818rtc.o #pckbd.o fdc.o m48t59.o
366 ifeq ($(TARGET_BASE_ARCH), sparc)
367 ifeq ($(TARGET_ARCH), sparc64)
368 VL_OBJS+= sun4u.o ide.o pckbd.o ps2.o vga.o apb_pci.o
369 VL_OBJS+= fdc.o mc146818rtc.o serial.o m48t59.o
370 VL_OBJS+= cirrus_vga.o parallel.o
372 VL_OBJS+= sun4m.o tcx.o pcnet.o iommu.o m48t59.o slavio_intctl.o
373 VL_OBJS+= slavio_timer.o slavio_serial.o slavio_misc.o fdc.o esp.o sparc32_dma.o
377 ifeq ($(TARGET_BASE_ARCH), arm)
378 VL_OBJS+= integratorcp.o versatilepb.o ps2.o smc91c111.o arm_pic.o arm_timer.o
379 VL_OBJS+= arm_boot.o pl011.o pl050.o pl080.o pl110.o pl190.o
380 VL_OBJS+= versatile_pci.o
381 VL_OBJS+= arm_gic.o realview.o arm_sysctl.o
383 ifeq ($(TARGET_BASE_ARCH), sh4)
384 VL_OBJS+= shix.o sh7750.o sh7750_regnames.o tc58128.o
395 COCOA_LIBS=-F/System/Library/Frameworks -framework Cocoa -framework IOKit
396 ifdef CONFIG_COREAUDIO
397 COCOA_LIBS+=-framework CoreAudio
401 CPPFLAGS+=-I$(SRC_PATH)/slirp
402 SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
403 slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
404 tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o
405 VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
409 # specific flags are needed for non soft mmu emulator
413 ifndef CONFIG_SOFTMMU
414 VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld
418 ifndef CONFIG_SOLARIS
424 vl.o: BASE_CFLAGS+=-p
429 VL_LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
432 ifeq ($(ARCH),sparc64)
434 VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc64.ld
438 SDL_LIBS := $(filter-out -mwindows, $(SDL_LIBS)) -mconsole
441 $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
442 $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(VL_LIBS)
445 $(CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
447 sdl.o: sdl.c keymaps.c sdl_keysym.h
448 $(CC) $(CFLAGS) $(CPPFLAGS) $(SDL_CFLAGS) $(BASE_CFLAGS) -c -o $@ $<
450 vnc.o: vnc.c keymaps.c sdl_keysym.h vnchextile.h
451 $(CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
453 sdlaudio.o: sdlaudio.c
454 $(CC) $(CFLAGS) $(CPPFLAGS) $(SDL_CFLAGS) $(BASE_CFLAGS) -c -o $@ $<
457 $(CC) -MM $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) $^ 1>.depend
459 vldepend: $(VL_OBJS:.o=.c)
460 $(CC) -MM $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) $^ 1>.depend
464 libqemu.a: $(LIBOBJS)
466 $(AR) rcs $@ $(LIBOBJS)
468 translate.o: translate.c gen-op.h opc.h cpu.h
470 translate-all.o: translate-all.c opc.h cpu.h
472 translate-op.o: translate-all.c op.h opc.h cpu.h
477 opc.h: op.o $(DYNGEN)
478 $(DYNGEN) -c -o $@ $<
480 gen-op.h: op.o $(DYNGEN)
481 $(DYNGEN) -g -o $@ $<
484 $(CC) $(OP_CFLAGS) $(CPPFLAGS) -c -o $@ $<
486 # HELPER_CFLAGS is used for all the code compiled with static register
488 ifeq ($(TARGET_BASE_ARCH), i386)
489 # XXX: rename helper.c to op_helper.c
491 $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
493 op_helper.o: op_helper.c
494 $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
497 cpu-exec.o: cpu-exec.c
498 $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
500 # Note: this is a workaround. The real fix is to avoid compiling
501 # cpu_signal_handler() in cpu-exec.c.
503 $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
505 ifeq ($(TARGET_BASE_ARCH), i386)
506 op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h ops_sse.h
509 ifeq ($(TARGET_ARCH), arm)
510 op.o: op.c op_template.h
511 pl110.o: pl110_template.h
514 ifeq ($(TARGET_BASE_ARCH), sparc)
515 op.o: op.c op_template.h op_mem.h fop_template.h fbranch_template.h
516 magic_load.o: elf_op.h
519 ifeq ($(TARGET_BASE_ARCH), ppc)
520 op.o: op.c op_template.h op_mem.h
521 op_helper.o: op_helper_mem.h
522 translate.o: translate.c translate_init.c
525 ifeq ($(TARGET_ARCH), mips)
526 op.o: op.c op_template.c op_mem.c
527 op_helper.o: op_helper_mem.c
530 loader.o: loader.c elf_ops.h
532 ifeq ($(TARGET_ARCH), sh4)
533 op.o: op.c op_mem.c cpu.h
534 op_helper.o: op_helper.c exec.h cpu.h
535 helper.o: helper.c exec.h cpu.h
536 sh7750.o: sh7750.c sh7750_regs.h sh7750_regnames.h cpu.h
537 shix.o: shix.c sh7750_regs.h sh7750_regnames.h
538 sh7750_regnames.o: sh7750_regnames.c sh7750_regnames.h sh7750_regs.h
542 $(OBJS) $(LIBOBJS) $(VL_OBJS): config.h ../config-host.h
545 $(CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
548 $(CC) $(CPPFLAGS) -c -o $@ $<
551 rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o fpu/*.o
555 $(INSTALL) -m 755 -s $(PROGS) "$(DESTDIR)$(bindir)"
558 ifneq ($(wildcard .depend),)
563 audio.o sdlaudio.o dsoundaudio.o ossaudio.o wavaudio.o noaudio.o \
564 fmodaudio.o alsaaudio.o mixeng.o sb16.o es1370.o gus.o adlib.o: \
565 CFLAGS := $(CFLAGS) -Wall -Werror -W -Wsign-compare