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 TARGET_ARCH2=$(TARGET_ARCH)
28 ifeq ($(TARGET_ARCH),arm)
29 ifeq ($(TARGET_WORDS_BIGENDIAN),yes)
33 ifeq ($(TARGET_ARCH),mips)
34 ifneq ($(TARGET_WORDS_BIGENDIAN),yes)
38 QEMU_USER=qemu-$(TARGET_ARCH2)
39 # system emulator name
41 ifeq ($(TARGET_ARCH), i386)
42 QEMU_SYSTEM=qemu$(EXESUF)
44 QEMU_SYSTEM=qemu-system-$(TARGET_ARCH2)$(EXESUF)
50 ifdef CONFIG_USER_ONLY
57 endif # !CONFIG_USER_ONLY
64 CFLAGS+=-fomit-frame-pointer
65 OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2
66 ifeq ($(HAVE_GCC3_OPTIONS),yes)
67 OP_CFLAGS+= -falign-functions=0 -fno-gcse
69 OP_CFLAGS+= -malign-functions=0
79 LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386.ld
81 # WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
82 # that the kernel ELF loader considers as an executable. I think this
83 # is the simplest way to make it self virtualizable!
89 OP_CFLAGS=$(CFLAGS) -falign-functions=0
90 LDFLAGS+=-Wl,-T,$(SRC_PATH)/x86_64.ld
94 CFLAGS+= -D__powerpc__
96 LDFLAGS+=-Wl,-T,$(SRC_PATH)/ppc.ld
101 LDFLAGS+=-Wl,-T,$(SRC_PATH)/s390.ld
105 ifeq ($(CONFIG_SOLARIS),yes)
106 CFLAGS+=-mcpu=ultrasparc -m32 -ffixed-g2 -ffixed-g3
108 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -fno-omit-frame-pointer -ffixed-i0
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
119 ifeq ($(ARCH),sparc64)
120 CFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
122 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
126 # -msmall-data is not used because we want two-instruction relocations
127 # for the constant constructions
128 OP_CFLAGS=-Wall -O2 -g
129 # Ensure there's only a single GP
130 CFLAGS += -msmall-data
131 LDFLAGS+=-Wl,-T,$(SRC_PATH)/alpha.ld
137 LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
141 OP_CFLAGS=$(CFLAGS) -mno-sched-prolog -fno-omit-frame-pointer
142 LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld
146 OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer
147 LDFLAGS+=-Wl,-T,m68k.ld
150 ifeq ($(HAVE_GCC3_OPTIONS),yes)
151 # very important to generate a return at the end of every operation
152 OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
155 ifeq ($(CONFIG_DARWIN),yes)
156 OP_CFLAGS+= -mdynamic-no-pic
160 #########################################################
162 DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
164 ifndef CONFIG_USER_ONLY
168 LIBS+=-lwinmm -lws2_32 -liphlpapi
171 LIBS+=-lsocket -lnsl -lresolv
180 OBJS= main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o \
181 elfload.o linuxload.o
182 ifdef TARGET_HAS_BFLT
186 ifeq ($(TARGET_ARCH), i386)
189 ifeq ($(TARGET_ARCH), arm)
190 OBJS+=nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
191 nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
192 nwfpe/double_cpdo.o nwfpe/extended_cpdo.o arm-semi.o
197 # cpu emulator library
198 LIBOBJS=exec.o kqemu.o translate-op.o translate-all.o cpu-exec.o\
200 ifdef CONFIG_SOFTFLOAT
201 LIBOBJS+=fpu/softfloat.o
203 LIBOBJS+=fpu/softfloat-native.o
205 DEFINES+=-I$(SRC_PATH)/fpu
207 ifeq ($(TARGET_ARCH), i386)
208 LIBOBJS+=helper.o helper2.o
210 LIBOBJS+=translate-copy.o
214 ifeq ($(TARGET_ARCH), x86_64)
215 LIBOBJS+=helper.o helper2.o
218 ifeq ($(TARGET_BASE_ARCH), ppc)
219 LIBOBJS+= op_helper.o helper.o
222 ifeq ($(TARGET_ARCH), mips)
223 LIBOBJS+= op_helper.o helper.o
226 ifeq ($(TARGET_BASE_ARCH), sparc)
227 LIBOBJS+= op_helper.o helper.o
230 ifeq ($(TARGET_BASE_ARCH), arm)
231 LIBOBJS+= op_helper.o helper.o
234 ifeq ($(TARGET_BASE_ARCH), sh4)
235 LIBOBJS+= op_helper.o helper.o
238 # NOTE: the disassembler code is only needed for debugging
240 ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
243 ifeq ($(findstring x86_64, $(TARGET_ARCH) $(ARCH)),x86_64)
249 ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
252 ifeq ($(findstring ppc, $(TARGET_BASE_ARCH) $(ARCH)),ppc)
255 ifeq ($(findstring mips, $(TARGET_ARCH) $(ARCH)),mips)
258 ifeq ($(findstring sparc, $(TARGET_BASE_ARCH) $(ARCH)),sparc)
261 ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
264 ifeq ($(findstring m68k, $(TARGET_ARCH) $(ARCH)),m68k)
267 ifeq ($(findstring sh4, $(TARGET_ARCH) $(ARCH)),sh4)
277 $(QEMU_USER): $(OBJS)
278 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
280 # Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
281 # the address space (31 bit so sign extending doesn't matter)
282 echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
285 # must use static linking to avoid leaving stuff in virtual address space
286 VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o loader.o
287 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
292 SOUND_HW = sb16.o es1370.o
293 AUDIODRV = audio.o noaudio.o wavaudio.o
295 AUDIODRV += sdlaudio.o
298 AUDIODRV += ossaudio.o
300 ifdef CONFIG_COREAUDIO
301 AUDIODRV += coreaudio.o
304 AUDIODRV += alsaaudio.o
308 AUDIODRV += dsoundaudio.o
309 LIBS += -lole32 -ldxguid
312 AUDIODRV += fmodaudio.o
313 audio.o fmodaudio.o: DEFINES := -I$(CONFIG_FMOD_INC) $(DEFINES)
314 LIBS += $(CONFIG_FMOD_LIB)
317 SOUND_HW += fmopl.o adlib.o
321 VL_OBJS+= scsi-disk.o cdrom.o lsi53c895a.o
324 VL_OBJS+= usb.o usb-hub.o usb-linux.o usb-hid.o usb-ohci.o usb-msd.o
327 VL_OBJS+= ne2000.o rtl8139.o
329 ifeq ($(TARGET_BASE_ARCH), i386)
331 VL_OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
332 VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o
333 VL_OBJS+= cirrus_vga.o mixeng.o apic.o parallel.o acpi.o piix_pci.o
335 DEFINES += -DHAS_AUDIO
337 ifeq ($(TARGET_BASE_ARCH), ppc)
338 VL_OBJS+= ppc.o ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
339 VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o
340 VL_OBJS+= ppc_prep.o ppc_chrp.o cuda.o adb.o openpic.o heathrow_pic.o mixeng.o
341 VL_OBJS+= grackle_pci.o prep_pci.o unin_pci.o
342 DEFINES += -DHAS_AUDIO
344 ifeq ($(TARGET_ARCH), mips)
345 VL_OBJS+= mips_r4k.o dma.o vga.o serial.o i8254.o i8259.o
346 #VL_OBJS+= #ide.o pckbd.o fdc.o m48t59.o
348 ifeq ($(TARGET_BASE_ARCH), sparc)
349 ifeq ($(TARGET_ARCH), sparc64)
350 VL_OBJS+= sun4u.o ide.o pckbd.o ps2.o vga.o apb_pci.o
351 VL_OBJS+= fdc.o mc146818rtc.o serial.o m48t59.o
352 VL_OBJS+= cirrus_vga.o parallel.o
354 VL_OBJS+= sun4m.o tcx.o lance.o iommu.o m48t59.o slavio_intctl.o
355 VL_OBJS+= slavio_timer.o slavio_serial.o slavio_misc.o fdc.o esp.o
358 ifeq ($(TARGET_BASE_ARCH), arm)
359 VL_OBJS+= integratorcp.o versatilepb.o ps2.o smc91c111.o arm_pic.o arm_timer.o
360 VL_OBJS+= arm_boot.o pl011.o pl050.o pl080.o pl110.o pl190.o
361 VL_OBJS+= versatile_pci.o
363 ifeq ($(TARGET_BASE_ARCH), sh4)
364 VL_OBJS+= shix.o sh7750.o sh7750_regnames.o tc58128.o
375 COCOA_LIBS=-F/System/Library/Frameworks -framework Cocoa -framework IOKit
376 ifdef CONFIG_COREAUDIO
377 COCOA_LIBS+=-framework CoreAudio
381 DEFINES+=-I$(SRC_PATH)/slirp
382 SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
383 slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
384 tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o
385 VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
389 # specific flags are needed for non soft mmu emulator
393 ifndef CONFIG_SOFTMMU
394 VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld
398 ifndef CONFIG_SOLARIS
409 VL_LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
413 SDL_LIBS := $(filter-out -mwindows, $(SDL_LIBS)) -mconsole
416 $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
417 $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(VL_LIBS)
420 $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
422 sdl.o: sdl.c keymaps.c sdl_keysym.h
423 $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
425 vnc.o: vnc.c keymaps.c sdl_keysym.h vnchextile.h
426 $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
428 sdlaudio.o: sdlaudio.c
429 $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
432 $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
434 vldepend: $(VL_OBJS:.o=.c)
435 $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
439 libqemu.a: $(LIBOBJS)
441 $(AR) rcs $@ $(LIBOBJS)
443 translate.o: translate.c gen-op.h opc.h cpu.h
445 translate-all.o: translate-all.c opc.h cpu.h
447 translate-op.o: translate-all.c op.h opc.h cpu.h
452 opc.h: op.o $(DYNGEN)
453 $(DYNGEN) -c -o $@ $<
455 gen-op.h: op.o $(DYNGEN)
456 $(DYNGEN) -g -o $@ $<
459 $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
462 $(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
464 ifeq ($(TARGET_BASE_ARCH), i386)
465 op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h ops_sse.h
468 ifeq ($(TARGET_ARCH), arm)
469 op.o: op.c op_template.h
470 pl110.o: pl110_template.h
473 ifeq ($(TARGET_BASE_ARCH), sparc)
474 op.o: op.c op_template.h op_mem.h fop_template.h fbranch_template.h
475 magic_load.o: elf_op.h
478 ifeq ($(TARGET_BASE_ARCH), ppc)
479 op.o: op.c op_template.h op_mem.h
480 op_helper.o: op_helper_mem.h
481 translate.o: translate.c translate_init.c
484 ifeq ($(TARGET_ARCH), mips)
485 op.o: op.c op_template.c op_mem.c
486 op_helper.o: op_helper_mem.c
489 loader.o: loader.c elf_ops.h
491 acpi.o: acpi.c acpi-dsdt.hex
493 ifdef BUILD_ACPI_TABLES
494 $(SRC_PATH)/hw/acpi-dsdt.hex: acpi-dsdt.dsl
498 ifeq ($(TARGET_ARCH), sh4)
499 op.o: op.c op_mem.c cpu.h
500 op_helper.o: op_helper.c exec.h cpu.h
501 helper.o: helper.c exec.h cpu.h
502 sh7750.o: sh7750.c sh7750_regs.h sh7750_regnames.h cpu.h
503 shix.o: shix.c sh7750_regs.h sh7750_regnames.h
504 sh7750_regnames.o: sh7750_regnames.c sh7750_regnames.h sh7750_regs.h
508 $(OBJS) $(LIBOBJS) $(VL_OBJS): config.h ../config-host.h
511 $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
514 $(CC) $(DEFINES) -c -o $@ $<
517 rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o fpu/*.o
521 $(INSTALL) -m 755 -s $(PROGS) "$(DESTDIR)$(bindir)"
524 ifneq ($(wildcard .depend),)
529 audio.o sdlaudio.o dsoundaudio.o ossaudio.o wavaudio.o noaudio.o \
530 fmodaudio.o alsaaudio.o mixeng.o sb16.o es1370.o gus.o adlib.o: \
531 CFLAGS := $(CFLAGS) -Wall -Werror -W -Wsign-compare