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)
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)
59 endif # TARGET_ARCH = ppc
60 endif # !CONFIG_USER_ONLY
67 CFLAGS+=-fomit-frame-pointer
68 OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2
69 ifeq ($(HAVE_GCC3_OPTIONS),yes)
70 OP_CFLAGS+= -falign-functions=0
72 OP_CFLAGS+= -malign-functions=0
82 LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386.ld
84 # WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
85 # that the kernel ELF loader considers as an executable. I think this
86 # is the simplest way to make it self virtualizable!
92 OP_CFLAGS=$(CFLAGS) -falign-functions=0
93 LDFLAGS+=-Wl,-T,$(SRC_PATH)/amd64.ld
98 LDFLAGS+=-Wl,-T,$(SRC_PATH)/ppc.ld
103 LDFLAGS+=-Wl,-T,$(SRC_PATH)/s390.ld
107 CFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
109 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
110 HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat
111 # -static is used to avoid g1/g3 usage by the dynamic linker
112 LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc.ld -static
115 ifeq ($(ARCH),sparc64)
116 CFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
118 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
122 # -msmall-data is not used because we want two-instruction relocations
123 # for the constant constructions
124 OP_CFLAGS=-Wall -O2 -g
125 # Ensure there's only a single GP
126 CFLAGS += -msmall-data
127 LDFLAGS+=-Wl,-T,$(SRC_PATH)/alpha.ld
135 OP_CFLAGS=$(CFLAGS) -mno-sched-prolog
136 LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld
140 OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer
141 LDFLAGS+=-Wl,-T,m68k.ld
144 ifeq ($(HAVE_GCC3_OPTIONS),yes)
145 # very important to generate a return at the end of every operation
146 OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
149 #########################################################
151 DEFINES+=-D_GNU_SOURCE
163 OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o
164 ifeq ($(TARGET_ARCH), i386)
167 ifeq ($(TARGET_ARCH), arm)
168 OBJS+=nwfpe/softfloat.o nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
169 nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
170 nwfpe/double_cpdo.o nwfpe/extended_cpdo.o
175 # cpu emulator library
176 LIBOBJS=exec.o translate-all.o cpu-exec.o\
179 ifeq ($(TARGET_ARCH), i386)
180 LIBOBJS+=helper.o helper2.o
182 LIBOBJS+=translate-copy.o
186 ifeq ($(TARGET_ARCH), ppc)
187 LIBOBJS+= op_helper.o helper.o
190 # NOTE: the disassembler code is only needed for debugging
192 ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
195 ifeq ($(findstring amd64, $(TARGET_ARCH) $(ARCH)),amd64)
201 ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
204 ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc)
207 ifeq ($(findstring sparc, $(TARGET_ARCH) $(ARCH)),sparc)
210 ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
215 OBJS += ia64-syscall.o
220 $(QEMU_USER): $(OBJS)
221 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
223 # Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
224 # the address space (31 bit so sign extending doesn't matter)
225 echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
228 # must use static linking to avoid leaving stuff in virtual address space
229 VL_OBJS=vl.o osdep.o block.o monitor.o
231 ifeq ($(TARGET_ARCH), i386)
233 VL_OBJS+= ide.o ne2000.o pckbd.o vga.o sb16.o dma.o oss.o
234 VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o
236 ifeq ($(TARGET_ARCH), ppc)
237 # Generic PPC support
239 # PREP hardware support
240 VL_OBJS+= ide.o ne2000.o pckbd.o vga.o sb16.o dma.o oss.o
241 VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o ppc_prep.o
242 #VL_OBJS+= hw.o of.o setup.o
251 DEFINES+=-I$(SRC_PATH)/slirp
252 SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
253 slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
254 tcp_subr.o tcp_timer.o udp.o bootp.o debug.o
255 VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
259 # specific flags are needed for non soft mmu emulator
263 ifndef CONFIG_SOFTMMU
264 VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld
270 $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
271 $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(VL_LIBS)
274 $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
277 $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
281 libqemu.a: $(LIBOBJS)
283 $(AR) rcs $@ $(LIBOBJS)
285 translate.o: translate.c gen-op.h opc.h cpu.h
287 translate-all.o: translate-all.c op.h opc.h cpu.h
292 opc.h: op.o $(DYNGEN)
293 $(DYNGEN) -c -o $@ $<
295 gen-op.h: op.o $(DYNGEN)
296 $(DYNGEN) -g -o $@ $<
299 $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
302 $(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
304 ifeq ($(TARGET_ARCH), i386)
305 op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h
308 ifeq ($(TARGET_ARCH), arm)
309 op.o: op.c op_template.h
312 ifeq ($(TARGET_ARCH), sparc)
313 op.o: op.c op_template.h
316 ifeq ($(TARGET_ARCH), ppc)
317 op.o: op.c op_template.h op_mem.h
318 op_helper.o: op_helper_mem.h
322 $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
325 $(CC) $(DEFINES) -c -o $@ $<
328 rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o
332 install -m 755 -s $(PROGS) "$(bindir)"
335 ifneq ($(wildcard .depend),)