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
51 endif # !CONFIG_USER_ONLY
58 CFLAGS+=-fomit-frame-pointer
59 OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2
60 ifeq ($(HAVE_GCC3_OPTIONS),yes)
61 OP_CFLAGS+= -falign-functions=0 -fno-gcse
63 OP_CFLAGS+= -malign-functions=0
73 LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386.ld
75 # WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
76 # that the kernel ELF loader considers as an executable. I think this
77 # is the simplest way to make it self virtualizable!
83 OP_CFLAGS=$(CFLAGS) -falign-functions=0
84 LDFLAGS+=-Wl,-T,$(SRC_PATH)/x86_64.ld
88 CFLAGS+= -D__powerpc__
90 LDFLAGS+=-Wl,-T,$(SRC_PATH)/ppc.ld
95 LDFLAGS+=-Wl,-T,$(SRC_PATH)/s390.ld
99 CFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
101 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
102 HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat
103 # -static is used to avoid g1/g3 usage by the dynamic linker
104 LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc.ld -static
107 ifeq ($(ARCH),sparc64)
108 CFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
110 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
114 # -msmall-data is not used because we want two-instruction relocations
115 # for the constant constructions
116 OP_CFLAGS=-Wall -O2 -g
117 # Ensure there's only a single GP
118 CFLAGS += -msmall-data
119 LDFLAGS+=-Wl,-T,$(SRC_PATH)/alpha.ld
125 LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
129 OP_CFLAGS=$(CFLAGS) -mno-sched-prolog -fno-omit-frame-pointer
130 LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld
134 OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer
135 LDFLAGS+=-Wl,-T,m68k.ld
138 ifeq ($(HAVE_GCC3_OPTIONS),yes)
139 # very important to generate a return at the end of every operation
140 OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
143 ifeq ($(CONFIG_DARWIN),yes)
144 OP_CFLAGS+= -mdynamic-no-pic
148 #########################################################
150 DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
152 ifndef CONFIG_USER_ONLY
156 LIBS+=-lwinmm -lws2_32 -liphlpapi
165 OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o
166 ifeq ($(TARGET_ARCH), i386)
169 ifeq ($(TARGET_ARCH), arm)
170 OBJS+=nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
171 nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
172 nwfpe/double_cpdo.o nwfpe/extended_cpdo.o arm-semi.o
177 # cpu emulator library
178 LIBOBJS=exec.o kqemu.o translate-op.o translate-all.o cpu-exec.o\
180 ifdef CONFIG_SOFTFLOAT
181 LIBOBJS+=fpu/softfloat.o
183 LIBOBJS+=fpu/softfloat-native.o
185 DEFINES+=-I$(SRC_PATH)/fpu
187 ifeq ($(TARGET_ARCH), i386)
188 LIBOBJS+=helper.o helper2.o
190 LIBOBJS+=translate-copy.o
194 ifeq ($(TARGET_ARCH), x86_64)
195 LIBOBJS+=helper.o helper2.o
198 ifeq ($(TARGET_ARCH), ppc)
199 LIBOBJS+= op_helper.o helper.o
202 ifeq ($(TARGET_ARCH), mips)
203 LIBOBJS+= op_helper.o helper.o
206 ifeq ($(TARGET_BASE_ARCH), sparc)
207 LIBOBJS+= op_helper.o helper.o
210 ifeq ($(TARGET_BASE_ARCH), arm)
211 LIBOBJS+= op_helper.o
214 # NOTE: the disassembler code is only needed for debugging
216 ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
219 ifeq ($(findstring x86_64, $(TARGET_ARCH) $(ARCH)),x86_64)
225 ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
228 ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc)
231 ifeq ($(findstring mips, $(TARGET_ARCH) $(ARCH)),mips)
234 ifeq ($(findstring sparc, $(TARGET_BASE_ARCH) $(ARCH)),sparc)
237 ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
242 OBJS += ia64-syscall.o
250 $(QEMU_USER): $(OBJS)
251 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
253 # Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
254 # the address space (31 bit so sign extending doesn't matter)
255 echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
258 # must use static linking to avoid leaving stuff in virtual address space
259 VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o
260 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
263 AUDIODRV = audio.o noaudio.o wavaudio.o
265 AUDIODRV += sdlaudio.o
268 AUDIODRV += ossaudio.o
271 pc.o: DEFINES := -DUSE_SB16 $(DEFINES)
274 SOUND_HW += fmopl.o adlib.o
278 AUDIODRV += fmodaudio.o
279 audio.o fmodaudio.o: DEFINES := -I$(CONFIG_FMOD_INC) $(DEFINES)
280 LIBS += $(CONFIG_FMOD_LIB)
283 ifeq ($(TARGET_BASE_ARCH), i386)
285 VL_OBJS+= ide.o ne2000.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
286 VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o
287 VL_OBJS+= cirrus_vga.o mixeng.o apic.o parallel.o
289 ifeq ($(TARGET_ARCH), ppc)
290 VL_OBJS+= ppc.o ide.o ne2000.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
291 VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o
292 VL_OBJS+= ppc_prep.o ppc_chrp.o cuda.o adb.o openpic.o heathrow_pic.o mixeng.o
294 ifeq ($(TARGET_ARCH), mips)
295 VL_OBJS+= mips_r4k.o dma.o vga.o serial.o ne2000.o i8259.o
296 #VL_OBJS+= #ide.o pckbd.o i8254.o fdc.o m48t59.o
298 ifeq ($(TARGET_BASE_ARCH), sparc)
299 ifeq ($(TARGET_ARCH), sparc64)
300 VL_OBJS+= sun4u.o ide.o ne2000.o pckbd.o vga.o
301 VL_OBJS+= fdc.o mc146818rtc.o serial.o m48t59.o
302 VL_OBJS+= cirrus_vga.o parallel.o
303 VL_OBJS+= magic-load.o
305 VL_OBJS+= sun4m.o tcx.o lance.o iommu.o m48t08.o magic-load.o slavio_intctl.o slavio_timer.o slavio_serial.o slavio_misc.o fdc.o esp.o
316 COCOA_LIBS=-F/System/Library/Frameworks -framework Cocoa
319 DEFINES+=-I$(SRC_PATH)/slirp
320 SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
321 slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
322 tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o
323 VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
327 # specific flags are needed for non soft mmu emulator
331 ifndef CONFIG_SOFTMMU
332 VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld
345 VL_LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
348 $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
349 $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(VL_LIBS)
352 $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
354 sdl.o: sdl.c keymaps.c sdl_keysym.h
355 $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
357 sdlaudio.o: sdlaudio.c
358 $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
361 $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
365 libqemu.a: $(LIBOBJS)
367 $(AR) rcs $@ $(LIBOBJS)
369 translate.o: translate.c gen-op.h opc.h cpu.h
371 translate-all.o: translate-all.c opc.h cpu.h
373 translate-op.o: translate-all.c op.h opc.h cpu.h
378 opc.h: op.o $(DYNGEN)
379 $(DYNGEN) -c -o $@ $<
381 gen-op.h: op.o $(DYNGEN)
382 $(DYNGEN) -g -o $@ $<
385 $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
388 $(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
390 ifeq ($(TARGET_BASE_ARCH), i386)
391 op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h ops_sse.h
394 ifeq ($(TARGET_ARCH), arm)
395 op.o: op.c op_template.h
398 ifeq ($(TARGET_BASE_ARCH), sparc)
399 op.o: op.c op_template.h op_mem.h fop_template.h fbranch_template.h
400 magic_load.o: elf_op.h
403 ifeq ($(TARGET_ARCH), ppc)
404 op.o: op.c op_template.h op_mem.h
405 op_helper.o: op_helper_mem.h
406 translate.o: translate.c translate_init.c
409 ifeq ($(TARGET_ARCH), mips)
410 op.o: op.c op_template.c op_mem.c
411 op_helper.o: op_helper_mem.c
414 mixeng.o: mixeng.c mixeng.h mixeng_template.h
417 $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
420 $(CC) $(DEFINES) -c -o $@ $<
423 rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o fpu/*.o
427 install -m 755 -s $(PROGS) "$(bindir)"
430 ifneq ($(wildcard .depend),)