3 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_ARCH)
4 VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw:$(SRC_PATH)/audio
5 DEFINES=-I. -I$(TARGET_PATH) -I$(SRC_PATH)
7 VPATH+=:$(SRC_PATH)/linux-user
8 DEFINES+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ARCH)
10 CFLAGS=-Wall -O2 -g -fno-strict-aliasing
13 HELPER_CFLAGS=$(CFLAGS)
14 DYNGEN=../dyngen$(EXESUF)
16 QEMU_USER=qemu-$(TARGET_ARCH)
17 # system emulator name
19 ifeq ($(TARGET_ARCH), i386)
20 QEMU_SYSTEM=qemu$(EXESUF)
22 QEMU_SYSTEM=qemu-system-$(TARGET_ARCH)$(EXESUF)
28 ifdef CONFIG_USER_ONLY
31 ifeq ($(TARGET_ARCH), i386)
39 # the system emulator using soft mmu is portable
45 endif # TARGET_ARCH = i386
47 ifeq ($(TARGET_ARCH), ppc)
65 endif # TARGET_ARCH = ppc
67 ifeq ($(TARGET_ARCH), sparc)
85 endif # TARGET_ARCH = sparc
86 endif # !CONFIG_USER_ONLY
93 CFLAGS+=-fomit-frame-pointer
94 OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2
95 ifeq ($(HAVE_GCC3_OPTIONS),yes)
96 OP_CFLAGS+= -falign-functions=0 -fno-gcse
98 OP_CFLAGS+= -malign-functions=0
108 LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386.ld
110 # WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
111 # that the kernel ELF loader considers as an executable. I think this
112 # is the simplest way to make it self virtualizable!
118 OP_CFLAGS=$(CFLAGS) -falign-functions=0
119 LDFLAGS+=-Wl,-T,$(SRC_PATH)/amd64.ld
123 CFLAGS+= -D__powerpc__
125 LDFLAGS+=-Wl,-T,$(SRC_PATH)/ppc.ld
130 LDFLAGS+=-Wl,-T,$(SRC_PATH)/s390.ld
134 CFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
136 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
137 HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat
138 # -static is used to avoid g1/g3 usage by the dynamic linker
139 LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc.ld -static
142 ifeq ($(ARCH),sparc64)
143 CFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
145 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
149 # -msmall-data is not used because we want two-instruction relocations
150 # for the constant constructions
151 OP_CFLAGS=-Wall -O2 -g
152 # Ensure there's only a single GP
153 CFLAGS += -msmall-data
154 LDFLAGS+=-Wl,-T,$(SRC_PATH)/alpha.ld
162 OP_CFLAGS=$(CFLAGS) -mno-sched-prolog
163 LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld
167 OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer
168 LDFLAGS+=-Wl,-T,m68k.ld
171 ifeq ($(HAVE_GCC3_OPTIONS),yes)
172 # very important to generate a return at the end of every operation
173 OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
176 ifeq ($(CONFIG_DARWIN),yes)
177 OP_CFLAGS+= -mdynamic-no-pic
180 #########################################################
182 DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
184 ifndef CONFIG_USER_ONLY
188 LIBS+=-lwinmm -lws2_32 -liphlpapi
197 OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o
198 ifeq ($(TARGET_ARCH), i386)
201 ifeq ($(TARGET_ARCH), arm)
202 OBJS+=nwfpe/softfloat.o nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
203 nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
204 nwfpe/double_cpdo.o nwfpe/extended_cpdo.o
209 # cpu emulator library
210 LIBOBJS=exec.o translate-all.o cpu-exec.o\
213 ifeq ($(TARGET_ARCH), i386)
214 LIBOBJS+=helper.o helper2.o
216 LIBOBJS+=translate-copy.o
220 ifeq ($(TARGET_ARCH), ppc)
221 LIBOBJS+= op_helper.o helper.o
224 ifeq ($(TARGET_ARCH), sparc)
225 LIBOBJS+= op_helper.o helper.o
228 # NOTE: the disassembler code is only needed for debugging
230 ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
233 ifeq ($(findstring amd64, $(TARGET_ARCH) $(ARCH)),amd64)
239 ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
242 ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc)
245 ifeq ($(findstring sparc, $(TARGET_ARCH) $(ARCH)),sparc)
248 ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
253 OBJS += ia64-syscall.o
258 $(QEMU_USER): $(OBJS)
259 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
261 # Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
262 # the address space (31 bit so sign extending doesn't matter)
263 echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
266 # must use static linking to avoid leaving stuff in virtual address space
267 VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o
268 VL_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o
271 AUDIODRV = audio.o noaudio.o wavaudio.o
273 AUDIODRV += sdlaudio.o
276 AUDIODRV += ossaudio.o
279 pc.o: DEFINES := -DUSE_SB16 $(DEFINES)
282 SOUND_HW += fmopl.o adlib.o
286 AUDIODRV += fmodaudio.o
287 audio.o fmodaudio.o: DEFINES := -I$(CONFIG_FMOD_INC) $(DEFINES)
288 LIBS += $(CONFIG_FMOD_LIB)
291 ifeq ($(TARGET_ARCH), i386)
293 VL_OBJS+= ide.o ne2000.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
294 VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o
295 VL_OBJS+= cirrus_vga.o mixeng.o
297 ifeq ($(TARGET_ARCH), ppc)
298 VL_OBJS+= ppc.o ide.o ne2000.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
299 VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o
300 VL_OBJS+= ppc_prep.o ppc_chrp.o cuda.o adb.o openpic.o mixeng.o
302 ifeq ($(TARGET_ARCH), sparc)
303 VL_OBJS+= sun4m.o tcx.o lance.o iommu.o sched.o m48t08.o magic-load.o timer.o
312 DEFINES+=-I$(SRC_PATH)/slirp
313 SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
314 slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
315 tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o
316 VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
320 # specific flags are needed for non soft mmu emulator
324 ifndef CONFIG_SOFTMMU
325 VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld
333 $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
334 $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(VL_LIBS)
336 sdl.o: sdl.c keymaps.c sdl_keysym.h
337 $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
339 sdlaudio.o: sdlaudio.c
340 $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
343 $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
347 libqemu.a: $(LIBOBJS)
349 $(AR) rcs $@ $(LIBOBJS)
351 translate.o: translate.c gen-op.h opc.h cpu.h
353 translate-all.o: translate-all.c op.h opc.h cpu.h
358 opc.h: op.o $(DYNGEN)
359 $(DYNGEN) -c -o $@ $<
361 gen-op.h: op.o $(DYNGEN)
362 $(DYNGEN) -g -o $@ $<
365 $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
368 $(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
370 ifeq ($(TARGET_ARCH), i386)
371 op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h
374 ifeq ($(TARGET_ARCH), arm)
375 op.o: op.c op_template.h
378 ifeq ($(TARGET_ARCH), sparc)
379 op.o: op.c op_template.h op_mem.h
382 ifeq ($(TARGET_ARCH), ppc)
383 op.o: op.c op_template.h op_mem.h
384 op_helper.o: op_helper_mem.h
387 mixeng.o: mixeng.c mixeng.h mixeng_template.h
390 $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
393 $(CC) $(DEFINES) -c -o $@ $<
396 rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o
400 install -m 755 -s $(PROGS) "$(bindir)"
403 ifneq ($(wildcard .depend),)