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
189 LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
193 OP_CFLAGS=$(CFLAGS) -mno-sched-prolog -fno-omit-frame-pointer
194 LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld
198 OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer
199 LDFLAGS+=-Wl,-T,m68k.ld
202 ifeq ($(HAVE_GCC3_OPTIONS),yes)
203 # very important to generate a return at the end of every operation
204 OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
207 ifeq ($(CONFIG_DARWIN),yes)
208 OP_CFLAGS+= -mdynamic-no-pic
212 #########################################################
214 DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
216 ifndef CONFIG_USER_ONLY
220 LIBS+=-lwinmm -lws2_32 -liphlpapi
229 OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o
230 ifeq ($(TARGET_ARCH), i386)
233 ifeq ($(TARGET_ARCH), arm)
234 OBJS+=nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
235 nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
236 nwfpe/double_cpdo.o nwfpe/extended_cpdo.o
241 # cpu emulator library
242 LIBOBJS=exec.o kqemu.o translate-op.o translate-all.o cpu-exec.o\
244 ifdef CONFIG_SOFTFLOAT
245 LIBOBJS+=fpu/softfloat.o
247 LIBOBJS+=fpu/softfloat-native.o
249 DEFINES+=-I$(SRC_PATH)/fpu
251 ifeq ($(TARGET_ARCH), i386)
252 LIBOBJS+=helper.o helper2.o
254 LIBOBJS+=translate-copy.o
258 ifeq ($(TARGET_ARCH), x86_64)
259 LIBOBJS+=helper.o helper2.o
262 ifeq ($(TARGET_ARCH), ppc)
263 LIBOBJS+= op_helper.o helper.o
266 ifeq ($(TARGET_BASE_ARCH), sparc)
267 LIBOBJS+= op_helper.o helper.o
270 ifeq ($(TARGET_BASE_ARCH), arm)
271 LIBOBJS+= op_helper.o
274 # NOTE: the disassembler code is only needed for debugging
276 ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
279 ifeq ($(findstring x86_64, $(TARGET_ARCH) $(ARCH)),x86_64)
285 ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
288 ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc)
291 ifeq ($(findstring sparc, $(TARGET_BASE_ARCH) $(ARCH)),sparc)
294 ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
299 OBJS += ia64-syscall.o
304 $(QEMU_USER): $(OBJS)
305 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
307 # Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
308 # the address space (31 bit so sign extending doesn't matter)
309 echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
312 # must use static linking to avoid leaving stuff in virtual address space
313 VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o
314 VL_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o
317 AUDIODRV = audio.o noaudio.o wavaudio.o
319 AUDIODRV += sdlaudio.o
322 AUDIODRV += ossaudio.o
325 pc.o: DEFINES := -DUSE_SB16 $(DEFINES)
328 SOUND_HW += fmopl.o adlib.o
332 AUDIODRV += fmodaudio.o
333 audio.o fmodaudio.o: DEFINES := -I$(CONFIG_FMOD_INC) $(DEFINES)
334 LIBS += $(CONFIG_FMOD_LIB)
337 ifeq ($(TARGET_BASE_ARCH), i386)
339 VL_OBJS+= ide.o ne2000.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
340 VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o
341 VL_OBJS+= cirrus_vga.o mixeng.o apic.o parallel.o
343 ifeq ($(TARGET_ARCH), ppc)
344 VL_OBJS+= ppc.o ide.o ne2000.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
345 VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o
346 VL_OBJS+= ppc_prep.o ppc_chrp.o cuda.o adb.o openpic.o mixeng.o
348 ifeq ($(TARGET_BASE_ARCH), sparc)
349 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
359 COCOA_LIBS=-F/System/Library/Frameworks -framework Cocoa
362 DEFINES+=-I$(SRC_PATH)/slirp
363 SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
364 slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
365 tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o
366 VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
370 # specific flags are needed for non soft mmu emulator
374 ifndef CONFIG_SOFTMMU
375 VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld
388 VL_LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
391 $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
392 $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(VL_LIBS)
395 $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
397 sdl.o: sdl.c keymaps.c sdl_keysym.h
398 $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
400 sdlaudio.o: sdlaudio.c
401 $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
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
441 ifeq ($(TARGET_BASE_ARCH), sparc)
442 op.o: op.c op_template.h op_mem.h
445 ifeq ($(TARGET_ARCH), ppc)
446 op.o: op.c op_template.h op_mem.h
447 op_helper.o: op_helper_mem.h
450 mixeng.o: mixeng.c mixeng.h mixeng_template.h
453 $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
456 $(CC) $(DEFINES) -c -o $@ $<
459 rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o
463 install -m 755 -s $(PROGS) "$(bindir)"
466 ifneq ($(wildcard .depend),)