3 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_ARCH)
4 VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw
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
66 endif # !CONFIG_USER_ONLY
73 CFLAGS+=-fomit-frame-pointer
74 OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2
75 ifeq ($(HAVE_GCC3_OPTIONS),yes)
76 OP_CFLAGS+= -falign-functions=0 -fno-gcse
78 OP_CFLAGS+= -malign-functions=0
88 LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386.ld
90 # WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
91 # that the kernel ELF loader considers as an executable. I think this
92 # is the simplest way to make it self virtualizable!
98 OP_CFLAGS=$(CFLAGS) -falign-functions=0
99 LDFLAGS+=-Wl,-T,$(SRC_PATH)/amd64.ld
103 CFLAGS+= -D__powerpc__
105 LDFLAGS+=-Wl,-T,$(SRC_PATH)/ppc.ld
110 LDFLAGS+=-Wl,-T,$(SRC_PATH)/s390.ld
114 CFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
116 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
117 HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat
118 # -static is used to avoid g1/g3 usage by the dynamic linker
119 LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc.ld -static
122 ifeq ($(ARCH),sparc64)
123 CFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
125 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
129 # -msmall-data is not used because we want two-instruction relocations
130 # for the constant constructions
131 OP_CFLAGS=-Wall -O2 -g
132 # Ensure there's only a single GP
133 CFLAGS += -msmall-data
134 LDFLAGS+=-Wl,-T,$(SRC_PATH)/alpha.ld
142 OP_CFLAGS=$(CFLAGS) -mno-sched-prolog
143 LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld
147 OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer
148 LDFLAGS+=-Wl,-T,m68k.ld
151 ifeq ($(HAVE_GCC3_OPTIONS),yes)
152 # very important to generate a return at the end of every operation
153 OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
156 ifeq ($(CONFIG_DARWIN),yes)
157 OP_CFLAGS+= -mdynamic-no-pic
160 #########################################################
162 DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
164 ifndef CONFIG_USER_ONLY
168 LIBS+=-lwinmm -lws2_32 -liphlpapi
177 OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o
178 ifeq ($(TARGET_ARCH), i386)
181 ifeq ($(TARGET_ARCH), arm)
182 OBJS+=nwfpe/softfloat.o nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
183 nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
184 nwfpe/double_cpdo.o nwfpe/extended_cpdo.o
189 # cpu emulator library
190 LIBOBJS=exec.o translate-all.o cpu-exec.o\
193 ifeq ($(TARGET_ARCH), i386)
194 LIBOBJS+=helper.o helper2.o
196 LIBOBJS+=translate-copy.o
200 ifeq ($(TARGET_ARCH), ppc)
201 LIBOBJS+= op_helper.o helper.o
204 # NOTE: the disassembler code is only needed for debugging
206 ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
209 ifeq ($(findstring amd64, $(TARGET_ARCH) $(ARCH)),amd64)
215 ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
218 ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc)
221 ifeq ($(findstring sparc, $(TARGET_ARCH) $(ARCH)),sparc)
224 ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
229 OBJS += ia64-syscall.o
234 $(QEMU_USER): $(OBJS)
235 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
237 # Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
238 # the address space (31 bit so sign extending doesn't matter)
239 echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
242 # must use static linking to avoid leaving stuff in virtual address space
243 VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o
244 VL_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o
246 ifeq ($(TARGET_ARCH), i386)
248 VL_OBJS+= ide.o ne2000.o pckbd.o vga.o sb16.o dma.o oss.o
249 VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o
250 VL_OBJS+= cirrus_vga.o
252 ifeq ($(TARGET_ARCH), ppc)
253 VL_OBJS+= ppc.o ide.o ne2000.o pckbd.o vga.o sb16.o dma.o oss.o
254 VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o
255 VL_OBJS+= ppc_prep.o ppc_chrp.o cuda.o adb.o openpic.o
264 DEFINES+=-I$(SRC_PATH)/slirp
265 SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
266 slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
267 tcp_subr.o tcp_timer.o udp.o bootp.o debug.o
268 VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
272 # specific flags are needed for non soft mmu emulator
276 ifndef CONFIG_SOFTMMU
277 VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld
285 $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
286 $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(VL_LIBS)
289 $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
292 $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
296 libqemu.a: $(LIBOBJS)
298 $(AR) rcs $@ $(LIBOBJS)
300 translate.o: translate.c gen-op.h opc.h cpu.h
302 translate-all.o: translate-all.c op.h opc.h cpu.h
307 opc.h: op.o $(DYNGEN)
308 $(DYNGEN) -c -o $@ $<
310 gen-op.h: op.o $(DYNGEN)
311 $(DYNGEN) -g -o $@ $<
314 $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
317 $(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
319 ifeq ($(TARGET_ARCH), i386)
320 op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h
323 ifeq ($(TARGET_ARCH), arm)
324 op.o: op.c op_template.h
327 ifeq ($(TARGET_ARCH), sparc)
328 op.o: op.c op_template.h
331 ifeq ($(TARGET_ARCH), ppc)
332 op.o: op.c op_template.h op_mem.h
333 op_helper.o: op_helper_mem.h
337 $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
340 $(CC) $(DEFINES) -c -o $@ $<
343 rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o
347 install -m 755 -s $(PROGS) "$(bindir)"
350 ifneq ($(wildcard .depend),)