3 #Uncomment following and specify proper paths/names for FMOD support
5 #FMOD_INCLUDE=/net/include/fmod
9 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_ARCH)
10 VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw:$(SRC_PATH)/audio
11 DEFINES=-I. -I$(TARGET_PATH) -I$(SRC_PATH)
12 ifdef CONFIG_USER_ONLY
13 VPATH+=:$(SRC_PATH)/linux-user
14 DEFINES+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ARCH)
16 CFLAGS=-Wall -O2 -g -fno-strict-aliasing
19 HELPER_CFLAGS=$(CFLAGS)
20 DYNGEN=../dyngen$(EXESUF)
22 QEMU_USER=qemu-$(TARGET_ARCH)
23 # system emulator name
25 ifeq ($(TARGET_ARCH), i386)
26 QEMU_SYSTEM=qemu$(EXESUF)
28 QEMU_SYSTEM=qemu-system-$(TARGET_ARCH)$(EXESUF)
34 ifdef CONFIG_USER_ONLY
37 ifeq ($(TARGET_ARCH), i386)
45 # the system emulator using soft mmu is portable
51 endif # TARGET_ARCH = i386
53 ifeq ($(TARGET_ARCH), ppc)
71 endif # TARGET_ARCH = ppc
73 ifeq ($(TARGET_ARCH), sparc)
91 endif # TARGET_ARCH = sparc
92 endif # !CONFIG_USER_ONLY
99 CFLAGS+=-fomit-frame-pointer
100 OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2
101 ifeq ($(HAVE_GCC3_OPTIONS),yes)
102 OP_CFLAGS+= -falign-functions=0 -fno-gcse
104 OP_CFLAGS+= -malign-functions=0
114 LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386.ld
116 # WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
117 # that the kernel ELF loader considers as an executable. I think this
118 # is the simplest way to make it self virtualizable!
124 OP_CFLAGS=$(CFLAGS) -falign-functions=0
125 LDFLAGS+=-Wl,-T,$(SRC_PATH)/amd64.ld
129 CFLAGS+= -D__powerpc__
131 LDFLAGS+=-Wl,-T,$(SRC_PATH)/ppc.ld
136 LDFLAGS+=-Wl,-T,$(SRC_PATH)/s390.ld
140 CFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
142 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
143 HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat
144 # -static is used to avoid g1/g3 usage by the dynamic linker
145 LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc.ld -static
148 ifeq ($(ARCH),sparc64)
149 CFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
151 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
155 # -msmall-data is not used because we want two-instruction relocations
156 # for the constant constructions
157 OP_CFLAGS=-Wall -O2 -g
158 # Ensure there's only a single GP
159 CFLAGS += -msmall-data
160 LDFLAGS+=-Wl,-T,$(SRC_PATH)/alpha.ld
168 OP_CFLAGS=$(CFLAGS) -mno-sched-prolog
169 LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld
173 OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer
174 LDFLAGS+=-Wl,-T,m68k.ld
177 ifeq ($(HAVE_GCC3_OPTIONS),yes)
178 # very important to generate a return at the end of every operation
179 OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
182 ifeq ($(CONFIG_DARWIN),yes)
183 OP_CFLAGS+= -mdynamic-no-pic
186 #########################################################
188 DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
190 ifndef CONFIG_USER_ONLY
194 LIBS+=-lwinmm -lws2_32 -liphlpapi
203 OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o
204 ifeq ($(TARGET_ARCH), i386)
207 ifeq ($(TARGET_ARCH), arm)
208 OBJS+=nwfpe/softfloat.o nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
209 nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
210 nwfpe/double_cpdo.o nwfpe/extended_cpdo.o
215 # cpu emulator library
216 LIBOBJS=exec.o translate-all.o cpu-exec.o\
219 ifeq ($(TARGET_ARCH), i386)
220 LIBOBJS+=helper.o helper2.o
222 LIBOBJS+=translate-copy.o
226 ifeq ($(TARGET_ARCH), ppc)
227 LIBOBJS+= op_helper.o helper.o
230 ifeq ($(TARGET_ARCH), sparc)
231 LIBOBJS+= op_helper.o helper.o
234 # NOTE: the disassembler code is only needed for debugging
236 ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
239 ifeq ($(findstring amd64, $(TARGET_ARCH) $(ARCH)),amd64)
245 ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
248 ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc)
251 ifeq ($(findstring sparc, $(TARGET_ARCH) $(ARCH)),sparc)
254 ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
259 OBJS += ia64-syscall.o
264 $(QEMU_USER): $(OBJS)
265 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
267 # Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
268 # the address space (31 bit so sign extending doesn't matter)
269 echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
272 # must use static linking to avoid leaving stuff in virtual address space
273 VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o
274 VL_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o
277 AUDIODRV = audio.o noaudio.o wavaudio.o
279 AUDIODRV += sdlaudio.o
282 AUDIODRV += ossaudio.o
285 pc.o: DEFINES := -DUSE_SB16 $(DEFINES)
288 SOUND_HW += fmopl.o adlib.o
292 AUDIODRV += fmodaudio.o
293 audio.o fmodaudio.o: DEFINES := -DUSE_FMOD_AUDIO -I$(FMOD_INCLUDE) $(DEFINES)
294 LDFLAGS += -L$(FMOD_LIBPATH) -Wl,-rpath,$(FMOD_LIBPATH)
295 LIBS += -lfmod-$(FMOD_VERSION)
298 ifeq ($(TARGET_ARCH), i386)
300 VL_OBJS+= ide.o ne2000.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
301 VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o
302 VL_OBJS+= cirrus_vga.o mixeng.o
304 ifeq ($(TARGET_ARCH), ppc)
305 VL_OBJS+= ppc.o ide.o ne2000.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
306 VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o
307 VL_OBJS+= ppc_prep.o ppc_chrp.o cuda.o adb.o openpic.o mixeng.o
309 ifeq ($(TARGET_ARCH), sparc)
310 VL_OBJS+= sun4m.o tcx.o lance.o iommu.o sched.o m48t08.o magic-load.o timer.o
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
340 $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
341 $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(VL_LIBS)
344 $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
347 $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
351 libqemu.a: $(LIBOBJS)
353 $(AR) rcs $@ $(LIBOBJS)
355 translate.o: translate.c gen-op.h opc.h cpu.h
357 translate-all.o: translate-all.c op.h opc.h cpu.h
362 opc.h: op.o $(DYNGEN)
363 $(DYNGEN) -c -o $@ $<
365 gen-op.h: op.o $(DYNGEN)
366 $(DYNGEN) -g -o $@ $<
369 $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
372 $(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
374 ifeq ($(TARGET_ARCH), i386)
375 op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h
378 ifeq ($(TARGET_ARCH), arm)
379 op.o: op.c op_template.h
382 ifeq ($(TARGET_ARCH), sparc)
383 op.o: op.c op_template.h op_mem.h
386 ifeq ($(TARGET_ARCH), ppc)
387 op.o: op.c op_template.h op_mem.h
388 op_helper.o: op_helper_mem.h
391 mixeng.o: mixeng.c mixeng.h mixeng_template.h
394 $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
397 $(CC) $(DEFINES) -c -o $@ $<
400 rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o
404 install -m 755 -s $(PROGS) "$(bindir)"
407 ifneq ($(wildcard .depend),)