]> git.proxmox.com Git - qemu.git/blame - Makefile.target
win32 load_kernel() fix
[qemu.git] / Makefile.target
CommitLineData
626df76a
FB
1include config.mak
2
1e43adfc 3TARGET_PATH=$(SRC_PATH)/target-$(TARGET_ARCH)
80cabfad 4VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw
3035f7ff
FB
5DEFINES=-I. -I$(TARGET_PATH) -I$(SRC_PATH)
6ifdef CONFIG_USER_ONLY
7VPATH+=:$(SRC_PATH)/linux-user
8DEFINES+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ARCH)
9endif
ab2572d7 10CFLAGS=-Wall -O2 -g -fno-strict-aliasing
626df76a
FB
11LDFLAGS=-g
12LIBS=
626df76a 13HELPER_CFLAGS=$(CFLAGS)
67b915a5 14DYNGEN=../dyngen$(EXESUF)
1e43adfc
FB
15# user emulator name
16QEMU_USER=qemu-$(TARGET_ARCH)
17# system emulator name
18ifdef CONFIG_SOFTMMU
a541f297 19ifeq ($(TARGET_ARCH), i386)
67b915a5 20QEMU_SYSTEM=qemu$(EXESUF)
0db63474 21else
a541f297
FB
22QEMU_SYSTEM=qemu-system-$(TARGET_ARCH)$(EXESUF)
23endif
24else
0db63474 25QEMU_SYSTEM=qemu-fast
1e43adfc
FB
26endif
27
16e9b7de 28ifdef CONFIG_USER_ONLY
1e43adfc 29PROGS=$(QEMU_USER)
16e9b7de 30else
16e9b7de 31ifeq ($(TARGET_ARCH), i386)
c321f673
FB
32
33ifeq ($(ARCH), i386)
34PROGS+=$(QEMU_SYSTEM)
de5eaa64
FB
35ifndef CONFIG_SOFTMMU
36CONFIG_STATIC=y
37endif
38ca2abc
FB
38else
39# the system emulator using soft mmu is portable
c321f673 40ifdef CONFIG_SOFTMMU
16e9b7de
FB
41PROGS+=$(QEMU_SYSTEM)
42endif
38ca2abc 43endif # ARCH != i386
c321f673 44
38ca2abc 45endif # TARGET_ARCH = i386
728c9fd5
FB
46
47ifeq ($(TARGET_ARCH), ppc)
48
49ifeq ($(ARCH), ppc)
50PROGS+=$(QEMU_SYSTEM)
51endif
52
53ifeq ($(ARCH), i386)
54ifdef CONFIG_SOFTMMU
55PROGS+=$(QEMU_SYSTEM)
626df76a 56endif
728c9fd5
FB
57endif # ARCH = i386
58
75dfaa1e
FB
59ifeq ($(ARCH), amd64)
60ifdef CONFIG_SOFTMMU
61PROGS+=$(QEMU_SYSTEM)
62endif
63endif # ARCH = amd64
64
728c9fd5
FB
65endif # TARGET_ARCH = ppc
66endif # !CONFIG_USER_ONLY
626df76a
FB
67
68ifdef CONFIG_STATIC
69LDFLAGS+=-static
70endif
71
72ifeq ($(ARCH),i386)
73CFLAGS+=-fomit-frame-pointer
74OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2
75ifeq ($(HAVE_GCC3_OPTIONS),yes)
3611a29c 76OP_CFLAGS+= -falign-functions=0 -fno-gcse
626df76a
FB
77else
78OP_CFLAGS+= -malign-functions=0
79endif
3a4739d6 80
626df76a 81ifdef TARGET_GPROF
3a4739d6
FB
82USE_I386_LD=y
83endif
84ifdef CONFIG_STATIC
85USE_I386_LD=y
86endif
87ifdef USE_I386_LD
626df76a
FB
88LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386.ld
89else
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!
93LDFLAGS+=-Wl,-shared
94endif
626df76a
FB
95endif
96
bc51c5c9
FB
97ifeq ($(ARCH),amd64)
98OP_CFLAGS=$(CFLAGS) -falign-functions=0
99LDFLAGS+=-Wl,-T,$(SRC_PATH)/amd64.ld
100endif
101
626df76a 102ifeq ($(ARCH),ppc)
83fb7adf 103CFLAGS+= -D__powerpc__
626df76a
FB
104OP_CFLAGS=$(CFLAGS)
105LDFLAGS+=-Wl,-T,$(SRC_PATH)/ppc.ld
106endif
107
108ifeq ($(ARCH),s390)
109OP_CFLAGS=$(CFLAGS)
110LDFLAGS+=-Wl,-T,$(SRC_PATH)/s390.ld
111endif
112
113ifeq ($(ARCH),sparc)
114CFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
115LDFLAGS+=-m32
116OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
117HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat
118# -static is used to avoid g1/g3 usage by the dynamic linker
119LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc.ld -static
120endif
121
122ifeq ($(ARCH),sparc64)
123CFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
124LDFLAGS+=-m64
125OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
126endif
127
128ifeq ($(ARCH),alpha)
129# -msmall-data is not used because we want two-instruction relocations
130# for the constant constructions
131OP_CFLAGS=-Wall -O2 -g
132# Ensure there's only a single GP
133CFLAGS += -msmall-data
134LDFLAGS+=-Wl,-T,$(SRC_PATH)/alpha.ld
135endif
136
137ifeq ($(ARCH),ia64)
138OP_CFLAGS=$(CFLAGS)
139endif
140
141ifeq ($(ARCH),arm)
142OP_CFLAGS=$(CFLAGS) -mno-sched-prolog
143LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld
144endif
145
38e584a0
FB
146ifeq ($(ARCH),m68k)
147OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer
148LDFLAGS+=-Wl,-T,m68k.ld
149endif
150
626df76a
FB
151ifeq ($(HAVE_GCC3_OPTIONS),yes)
152# very important to generate a return at the end of every operation
153OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
154endif
155
83fb7adf
FB
156ifeq ($(CONFIG_DARWIN),yes)
157OP_CFLAGS+= -mdynamic-no-pic
158endif
159
626df76a
FB
160#########################################################
161
d5249393 162DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
626df76a 163LIBS+=-lm
b932caba
FB
164ifndef CONFIG_USER_ONLY
165LIBS+=-lz
166endif
67b915a5 167ifdef CONFIG_WIN32
3db38e87 168LIBS+=-lwinmm -lws2_32 -liphlpapi
67b915a5 169endif
626df76a
FB
170
171# profiling code
172ifdef TARGET_GPROF
173LDFLAGS+=-p
174main.o: CFLAGS+=-p
175endif
176
3035f7ff 177OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o
626df76a
FB
178ifeq ($(TARGET_ARCH), i386)
179OBJS+= vm86.o
180endif
f72b519c
FB
181ifeq ($(TARGET_ARCH), arm)
182OBJS+=nwfpe/softfloat.o nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
183nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
184 nwfpe/double_cpdo.o nwfpe/extended_cpdo.o
185endif
626df76a
FB
186SRCS:= $(OBJS:.o=.c)
187OBJS+= libqemu.a
188
189# cpu emulator library
858693c6 190LIBOBJS=exec.o translate-all.o cpu-exec.o\
1e43adfc 191 translate.o op.o
626df76a
FB
192
193ifeq ($(TARGET_ARCH), i386)
1e43adfc 194LIBOBJS+=helper.o helper2.o
f72b519c
FB
195ifeq ($(ARCH), i386)
196LIBOBJS+=translate-copy.o
197endif
626df76a
FB
198endif
199
67867308 200ifeq ($(TARGET_ARCH), ppc)
728c9fd5 201LIBOBJS+= op_helper.o helper.o
67867308
FB
202endif
203
626df76a
FB
204# NOTE: the disassembler code is only needed for debugging
205LIBOBJS+=disas.o
206ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
bc51c5c9
FB
207USE_I386_DIS=y
208endif
209ifeq ($(findstring amd64, $(TARGET_ARCH) $(ARCH)),amd64)
210USE_I386_DIS=y
211endif
212ifdef USE_I386_DIS
626df76a
FB
213LIBOBJS+=i386-dis.o
214endif
215ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
216LIBOBJS+=alpha-dis.o
217endif
218ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc)
219LIBOBJS+=ppc-dis.o
220endif
221ifeq ($(findstring sparc, $(TARGET_ARCH) $(ARCH)),sparc)
222LIBOBJS+=sparc-dis.o
223endif
224ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
225LIBOBJS+=arm-dis.o
226endif
227
228ifeq ($(ARCH),ia64)
229OBJS += ia64-syscall.o
230endif
231
1e43adfc 232all: $(PROGS)
626df76a 233
1e43adfc 234$(QEMU_USER): $(OBJS)
626df76a
FB
235 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
236ifeq ($(ARCH),alpha)
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
240endif
241
242# must use static linking to avoid leaving stuff in virtual address space
b932caba
FB
243VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o
244VL_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o
a541f297
FB
245
246ifeq ($(TARGET_ARCH), i386)
247# Hardware support
248VL_OBJS+= ide.o ne2000.o pckbd.o vga.o sb16.o dma.o oss.o
d6bfa22f
FB
249VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o
250VL_OBJS+= cirrus_vga.o
67b915a5 251endif
728c9fd5 252ifeq ($(TARGET_ARCH), ppc)
95ea3fa1 253VL_OBJS+= ppc.o ide.o ne2000.o pckbd.o vga.o sb16.o dma.o oss.o
64201201 254VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o
95ea3fa1 255VL_OBJS+= ppc_prep.o ppc_chrp.o cuda.o adb.o openpic.o
a541f297
FB
256endif
257ifdef CONFIG_GDBSTUB
258VL_OBJS+=gdbstub.o
728c9fd5 259endif
626df76a
FB
260ifdef CONFIG_SDL
261VL_OBJS+=sdl.o
de5eaa64 262endif
7c1f25b4
FB
263ifdef CONFIG_SLIRP
264DEFINES+=-I$(SRC_PATH)/slirp
265SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
266slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
c7f74643 267tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o
7c1f25b4 268VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
626df76a
FB
269endif
270
c321f673
FB
271VL_LDFLAGS=
272# specific flags are needed for non soft mmu emulator
c321f673
FB
273ifdef CONFIG_STATIC
274VL_LDFLAGS+=-static
275endif
de5eaa64
FB
276ifndef CONFIG_SOFTMMU
277VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld
278endif
83fb7adf 279ifndef CONFIG_DARWIN
11d9f695
FB
280ifndef CONFIG_WIN32
281VL_LIBS=-lutil
282endif
83fb7adf 283endif
c321f673 284
1e43adfc 285$(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
11d9f695 286 $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(VL_LIBS)
626df76a
FB
287
288sdl.o: sdl.c
289 $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
290
291depend: $(SRCS)
16e9b7de 292 $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
626df76a
FB
293
294# libqemu
295
296libqemu.a: $(LIBOBJS)
297 rm -f $@
298 $(AR) rcs $@ $(LIBOBJS)
299
1e43adfc 300translate.o: translate.c gen-op.h opc.h cpu.h
626df76a 301
1e43adfc 302translate-all.o: translate-all.c op.h opc.h cpu.h
626df76a 303
1e43adfc 304op.h: op.o $(DYNGEN)
626df76a
FB
305 $(DYNGEN) -o $@ $<
306
1e43adfc 307opc.h: op.o $(DYNGEN)
626df76a
FB
308 $(DYNGEN) -c -o $@ $<
309
1e43adfc 310gen-op.h: op.o $(DYNGEN)
626df76a
FB
311 $(DYNGEN) -g -o $@ $<
312
1e43adfc 313op.o: op.c
626df76a
FB
314 $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
315
1e43adfc 316helper.o: helper.c
626df76a
FB
317 $(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
318
1e43adfc
FB
319ifeq ($(TARGET_ARCH), i386)
320op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h
321endif
322
323ifeq ($(TARGET_ARCH), arm)
324op.o: op.c op_template.h
325endif
626df76a 326
1e43adfc
FB
327ifeq ($(TARGET_ARCH), sparc)
328op.o: op.c op_template.h
329endif
626df76a 330
728c9fd5
FB
331ifeq ($(TARGET_ARCH), ppc)
332op.o: op.c op_template.h op_mem.h
333op_helper.o: op_helper_mem.h
334endif
335
626df76a
FB
336%.o: %.c
337 $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
338
f72b519c
FB
339%.o: %.S
340 $(CC) $(DEFINES) -c -o $@ $<
341
626df76a 342clean:
7c1f25b4 343 rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o
1e43adfc
FB
344
345install: all
9b14bb04 346ifneq ($(PROGS),)
11d9f695 347 install -m 755 -s $(PROGS) "$(bindir)"
9b14bb04 348endif
626df76a
FB
349
350ifneq ($(wildcard .depend),)
351include .depend
352endif