3 TARGET_BASE_ARCH:=$(TARGET_ARCH)
4 ifeq ($(TARGET_ARCH), x86_64)
7 ifeq ($(TARGET_ARCH), sparc64)
8 TARGET_BASE_ARCH:=sparc
10 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH)
11 VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw:$(SRC_PATH)/audio
12 DEFINES=-I. -I$(TARGET_PATH) -I$(SRC_PATH)
13 ifdef CONFIG_USER_ONLY
14 VPATH+=:$(SRC_PATH)/linux-user
15 DEFINES+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ARCH)
17 CFLAGS=-Wall -O2 -g -fno-strict-aliasing
21 HELPER_CFLAGS=$(CFLAGS)
22 DYNGEN=../dyngen$(EXESUF)
24 ifeq ($(TARGET_ARCH),arm)
25 ifeq ($(TARGET_WORDS_BIGENDIAN),yes)
31 QEMU_USER=qemu-$(TARGET_ARCH)
33 # system emulator name
35 ifeq ($(TARGET_ARCH), i386)
36 QEMU_SYSTEM=qemu$(EXESUF)
38 QEMU_SYSTEM=qemu-system-$(TARGET_ARCH)$(EXESUF)
44 ifdef CONFIG_USER_ONLY
47 ifeq ($(TARGET_ARCH), i386)
55 # the system emulator using soft mmu is portable
61 endif # TARGET_ARCH = i386
63 ifeq ($(TARGET_ARCH), x86_64)
67 endif # TARGET_ARCH = x86_64
69 ifeq ($(TARGET_ARCH), ppc)
81 ifeq ($(ARCH), x86_64)
87 endif # TARGET_ARCH = ppc
89 ifeq ($(TARGET_ARCH), sparc)
101 ifeq ($(ARCH), x86_64)
103 PROGS+=$(QEMU_SYSTEM)
105 endif # ARCH = x86_64
107 endif # TARGET_ARCH = sparc
109 ifeq ($(TARGET_ARCH), sparc64)
111 PROGS+=$(QEMU_SYSTEM)
113 endif # TARGET_ARCH = sparc64
115 endif # !CONFIG_USER_ONLY
122 CFLAGS+=-fomit-frame-pointer
123 OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2
124 ifeq ($(HAVE_GCC3_OPTIONS),yes)
125 OP_CFLAGS+= -falign-functions=0 -fno-gcse
127 OP_CFLAGS+= -malign-functions=0
137 LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386.ld
139 # WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
140 # that the kernel ELF loader considers as an executable. I think this
141 # is the simplest way to make it self virtualizable!
146 ifeq ($(ARCH),x86_64)
147 OP_CFLAGS=$(CFLAGS) -falign-functions=0
148 LDFLAGS+=-Wl,-T,$(SRC_PATH)/x86_64.ld
152 CFLAGS+= -D__powerpc__
154 LDFLAGS+=-Wl,-T,$(SRC_PATH)/ppc.ld
159 LDFLAGS+=-Wl,-T,$(SRC_PATH)/s390.ld
163 CFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
165 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
166 HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat
167 # -static is used to avoid g1/g3 usage by the dynamic linker
168 LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc.ld -static
171 ifeq ($(ARCH),sparc64)
172 CFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
174 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
178 # -msmall-data is not used because we want two-instruction relocations
179 # for the constant constructions
180 OP_CFLAGS=-Wall -O2 -g
181 # Ensure there's only a single GP
182 CFLAGS += -msmall-data
183 LDFLAGS+=-Wl,-T,$(SRC_PATH)/alpha.ld
191 OP_CFLAGS=$(CFLAGS) -mno-sched-prolog -fno-omit-frame-pointer
192 LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld
196 OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer
197 LDFLAGS+=-Wl,-T,m68k.ld
200 ifeq ($(HAVE_GCC3_OPTIONS),yes)
201 # very important to generate a return at the end of every operation
202 OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
205 ifeq ($(CONFIG_DARWIN),yes)
206 OP_CFLAGS+= -mdynamic-no-pic
210 #########################################################
212 DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
214 ifndef CONFIG_USER_ONLY
218 LIBS+=-lwinmm -lws2_32 -liphlpapi
227 OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o
228 ifeq ($(TARGET_ARCH), i386)
231 ifeq ($(TARGET_ARCH), arm)
232 OBJS+=nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
233 nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
234 nwfpe/double_cpdo.o nwfpe/extended_cpdo.o
239 # cpu emulator library
240 LIBOBJS=exec.o kqemu.o translate-op.o translate-all.o cpu-exec.o\
242 ifdef CONFIG_SOFTFLOAT
243 LIBOBJS+=fpu/softfloat.o
245 LIBOBJS+=fpu/softfloat-native.o
247 DEFINES+=-I$(SRC_PATH)/fpu
249 ifeq ($(TARGET_ARCH), i386)
250 LIBOBJS+=helper.o helper2.o
252 LIBOBJS+=translate-copy.o
256 ifeq ($(TARGET_ARCH), x86_64)
257 LIBOBJS+=helper.o helper2.o
260 ifeq ($(TARGET_ARCH), ppc)
261 LIBOBJS+= op_helper.o helper.o
264 ifeq ($(TARGET_BASE_ARCH), sparc)
265 LIBOBJS+= op_helper.o helper.o
268 ifeq ($(TARGET_BASE_ARCH), arm)
269 LIBOBJS+= op_helper.o
272 # NOTE: the disassembler code is only needed for debugging
274 ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
277 ifeq ($(findstring x86_64, $(TARGET_ARCH) $(ARCH)),x86_64)
283 ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
286 ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc)
289 ifeq ($(findstring sparc, $(TARGET_BASE_ARCH) $(ARCH)),sparc)
292 ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
297 OBJS += ia64-syscall.o
302 $(QEMU_USER): $(OBJS)
303 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
305 # Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
306 # the address space (31 bit so sign extending doesn't matter)
307 echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
310 # must use static linking to avoid leaving stuff in virtual address space
311 VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o
312 VL_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o
315 AUDIODRV = audio.o noaudio.o wavaudio.o
317 AUDIODRV += sdlaudio.o
320 AUDIODRV += ossaudio.o
323 pc.o: DEFINES := -DUSE_SB16 $(DEFINES)
326 SOUND_HW += fmopl.o adlib.o
330 AUDIODRV += fmodaudio.o
331 audio.o fmodaudio.o: DEFINES := -I$(CONFIG_FMOD_INC) $(DEFINES)
332 LIBS += $(CONFIG_FMOD_LIB)
335 ifeq ($(TARGET_BASE_ARCH), i386)
337 VL_OBJS+= ide.o ne2000.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
338 VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o
339 VL_OBJS+= cirrus_vga.o mixeng.o apic.o parallel.o
341 ifeq ($(TARGET_ARCH), ppc)
342 VL_OBJS+= ppc.o ide.o ne2000.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
343 VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o
344 VL_OBJS+= ppc_prep.o ppc_chrp.o cuda.o adb.o openpic.o mixeng.o
346 ifeq ($(TARGET_BASE_ARCH), sparc)
347 VL_OBJS+= sun4m.o tcx.o lance.o iommu.o m48t08.o magic-load.o slavio_intctl.o slavio_timer.o slavio_serial.o fdc.o esp.o
357 COCOA_LIBS=-F/System/Library/Frameworks -framework Cocoa
360 DEFINES+=-I$(SRC_PATH)/slirp
361 SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
362 slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
363 tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o
364 VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
368 # specific flags are needed for non soft mmu emulator
372 ifndef CONFIG_SOFTMMU
373 VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld
385 $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
386 $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(VL_LIBS)
389 $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
391 sdl.o: sdl.c keymaps.c sdl_keysym.h
392 $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
394 sdlaudio.o: sdlaudio.c
395 $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
398 $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
402 libqemu.a: $(LIBOBJS)
404 $(AR) rcs $@ $(LIBOBJS)
406 translate.o: translate.c gen-op.h opc.h cpu.h
408 translate-all.o: translate-all.c opc.h cpu.h
410 translate-op.o: translate-all.c op.h opc.h cpu.h
415 opc.h: op.o $(DYNGEN)
416 $(DYNGEN) -c -o $@ $<
418 gen-op.h: op.o $(DYNGEN)
419 $(DYNGEN) -g -o $@ $<
422 $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
425 $(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
427 ifeq ($(TARGET_BASE_ARCH), i386)
428 op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h ops_sse.h
431 ifeq ($(TARGET_ARCH), arm)
432 op.o: op.c op_template.h
435 ifeq ($(TARGET_BASE_ARCH), sparc)
436 op.o: op.c op_template.h op_mem.h
439 ifeq ($(TARGET_ARCH), ppc)
440 op.o: op.c op_template.h op_mem.h
441 op_helper.o: op_helper_mem.h
444 mixeng.o: mixeng.c mixeng.h mixeng_template.h
447 $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
450 $(CC) $(DEFINES) -c -o $@ $<
453 rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o
457 install -m 755 -s $(PROGS) "$(bindir)"
460 ifneq ($(wildcard .depend),)