]> git.proxmox.com Git - qemu.git/blame - Makefile.target
added qemu-mkcow man page
[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
626df76a
FB
10CFLAGS=-Wall -O2 -g
11LDFLAGS=-g
12LIBS=
626df76a
FB
13HELPER_CFLAGS=$(CFLAGS)
14DYNGEN=../dyngen
1e43adfc
FB
15# user emulator name
16QEMU_USER=qemu-$(TARGET_ARCH)
17# system emulator name
18ifdef CONFIG_SOFTMMU
1e43adfc 19QEMU_SYSTEM=qemu
0db63474
FB
20else
21QEMU_SYSTEM=qemu-fast
1e43adfc
FB
22endif
23
16e9b7de 24ifdef CONFIG_USER_ONLY
1e43adfc 25PROGS=$(QEMU_USER)
16e9b7de 26else
16e9b7de 27ifeq ($(TARGET_ARCH), i386)
c321f673
FB
28
29ifeq ($(ARCH), i386)
30PROGS+=$(QEMU_SYSTEM)
de5eaa64
FB
31ifndef CONFIG_SOFTMMU
32CONFIG_STATIC=y
33endif
38ca2abc
FB
34else
35# the system emulator using soft mmu is portable
c321f673 36ifdef CONFIG_SOFTMMU
16e9b7de
FB
37PROGS+=$(QEMU_SYSTEM)
38endif
38ca2abc 39endif # ARCH != i386
c321f673 40
38ca2abc 41endif # TARGET_ARCH = i386
728c9fd5
FB
42
43ifeq ($(TARGET_ARCH), ppc)
44
45ifeq ($(ARCH), ppc)
46PROGS+=$(QEMU_SYSTEM)
47endif
48
49ifeq ($(ARCH), i386)
50ifdef CONFIG_SOFTMMU
51PROGS+=$(QEMU_SYSTEM)
626df76a 52endif
728c9fd5
FB
53endif # ARCH = i386
54
55endif # TARGET_ARCH = ppc
56endif # !CONFIG_USER_ONLY
626df76a
FB
57
58ifdef CONFIG_STATIC
59LDFLAGS+=-static
60endif
61
62ifeq ($(ARCH),i386)
63CFLAGS+=-fomit-frame-pointer
64OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2
65ifeq ($(HAVE_GCC3_OPTIONS),yes)
66OP_CFLAGS+= -falign-functions=0
67else
68OP_CFLAGS+= -malign-functions=0
69endif
3a4739d6 70
626df76a 71ifdef TARGET_GPROF
3a4739d6
FB
72USE_I386_LD=y
73endif
74ifdef CONFIG_STATIC
75USE_I386_LD=y
76endif
77ifdef USE_I386_LD
626df76a
FB
78LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386.ld
79else
80# WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
81# that the kernel ELF loader considers as an executable. I think this
82# is the simplest way to make it self virtualizable!
83LDFLAGS+=-Wl,-shared
84endif
626df76a
FB
85endif
86
bc51c5c9
FB
87ifeq ($(ARCH),amd64)
88OP_CFLAGS=$(CFLAGS) -falign-functions=0
89LDFLAGS+=-Wl,-T,$(SRC_PATH)/amd64.ld
90endif
91
626df76a
FB
92ifeq ($(ARCH),ppc)
93OP_CFLAGS=$(CFLAGS)
94LDFLAGS+=-Wl,-T,$(SRC_PATH)/ppc.ld
95endif
96
97ifeq ($(ARCH),s390)
98OP_CFLAGS=$(CFLAGS)
99LDFLAGS+=-Wl,-T,$(SRC_PATH)/s390.ld
100endif
101
102ifeq ($(ARCH),sparc)
103CFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
104LDFLAGS+=-m32
105OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
106HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat
107# -static is used to avoid g1/g3 usage by the dynamic linker
108LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc.ld -static
109endif
110
111ifeq ($(ARCH),sparc64)
112CFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
113LDFLAGS+=-m64
114OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
115endif
116
117ifeq ($(ARCH),alpha)
118# -msmall-data is not used because we want two-instruction relocations
119# for the constant constructions
120OP_CFLAGS=-Wall -O2 -g
121# Ensure there's only a single GP
122CFLAGS += -msmall-data
123LDFLAGS+=-Wl,-T,$(SRC_PATH)/alpha.ld
124endif
125
126ifeq ($(ARCH),ia64)
127OP_CFLAGS=$(CFLAGS)
128endif
129
130ifeq ($(ARCH),arm)
131OP_CFLAGS=$(CFLAGS) -mno-sched-prolog
132LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld
133endif
134
38e584a0
FB
135ifeq ($(ARCH),m68k)
136OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer
137LDFLAGS+=-Wl,-T,m68k.ld
138endif
139
626df76a
FB
140ifeq ($(HAVE_GCC3_OPTIONS),yes)
141# very important to generate a return at the end of every operation
142OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
143endif
144
145#########################################################
146
147DEFINES+=-D_GNU_SOURCE
148LIBS+=-lm
149
150# profiling code
151ifdef TARGET_GPROF
152LDFLAGS+=-p
153main.o: CFLAGS+=-p
154endif
155
3035f7ff 156OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o
626df76a
FB
157ifeq ($(TARGET_ARCH), i386)
158OBJS+= vm86.o
159endif
f72b519c
FB
160ifeq ($(TARGET_ARCH), arm)
161OBJS+=nwfpe/softfloat.o nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
162nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
163 nwfpe/double_cpdo.o nwfpe/extended_cpdo.o
164endif
626df76a
FB
165SRCS:= $(OBJS:.o=.c)
166OBJS+= libqemu.a
167
168# cpu emulator library
3035f7ff 169LIBOBJS=exec.o translate-all.o cpu-exec.o gdbstub.o \
1e43adfc 170 translate.o op.o
626df76a
FB
171
172ifeq ($(TARGET_ARCH), i386)
1e43adfc 173LIBOBJS+=helper.o helper2.o
f72b519c
FB
174ifeq ($(ARCH), i386)
175LIBOBJS+=translate-copy.o
176endif
626df76a
FB
177endif
178
67867308 179ifeq ($(TARGET_ARCH), ppc)
728c9fd5 180LIBOBJS+= op_helper.o helper.o
67867308
FB
181endif
182
626df76a
FB
183# NOTE: the disassembler code is only needed for debugging
184LIBOBJS+=disas.o
185ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
bc51c5c9
FB
186USE_I386_DIS=y
187endif
188ifeq ($(findstring amd64, $(TARGET_ARCH) $(ARCH)),amd64)
189USE_I386_DIS=y
190endif
191ifdef USE_I386_DIS
626df76a
FB
192LIBOBJS+=i386-dis.o
193endif
194ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
195LIBOBJS+=alpha-dis.o
196endif
197ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc)
198LIBOBJS+=ppc-dis.o
199endif
200ifeq ($(findstring sparc, $(TARGET_ARCH) $(ARCH)),sparc)
201LIBOBJS+=sparc-dis.o
202endif
203ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
204LIBOBJS+=arm-dis.o
205endif
206
207ifeq ($(ARCH),ia64)
208OBJS += ia64-syscall.o
209endif
210
1e43adfc 211all: $(PROGS)
626df76a 212
1e43adfc 213$(QEMU_USER): $(OBJS)
626df76a
FB
214 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
215ifeq ($(ARCH),alpha)
216# Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
217# the address space (31 bit so sign extending doesn't matter)
218 echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
219endif
220
221# must use static linking to avoid leaving stuff in virtual address space
9dc39cba
FB
222VL_OBJS=vl.o osdep.o block.o monitor.o \
223 ide.o ne2000.o pckbd.o vga.o sb16.o dma.o oss.o \
80cabfad 224 fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o
728c9fd5
FB
225ifeq ($(TARGET_ARCH), ppc)
226VL_OBJS+= hw.o
227endif
626df76a
FB
228ifdef CONFIG_SDL
229VL_OBJS+=sdl.o
de5eaa64
FB
230ifdef CONFIG_STATIC
231SDL_LIBS:=$(SDL_STATIC_LIBS)
232endif
626df76a
FB
233endif
234
c321f673
FB
235VL_LDFLAGS=
236# specific flags are needed for non soft mmu emulator
c321f673
FB
237ifdef CONFIG_STATIC
238VL_LDFLAGS+=-static
239endif
de5eaa64
FB
240ifndef CONFIG_SOFTMMU
241VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld
242endif
c321f673 243
1e43adfc 244$(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
9dc39cba 245 $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) -lutil
626df76a
FB
246
247sdl.o: sdl.c
248 $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
249
250depend: $(SRCS)
16e9b7de 251 $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
626df76a
FB
252
253# libqemu
254
255libqemu.a: $(LIBOBJS)
256 rm -f $@
257 $(AR) rcs $@ $(LIBOBJS)
258
1e43adfc 259translate.o: translate.c gen-op.h opc.h cpu.h
626df76a 260
1e43adfc 261translate-all.o: translate-all.c op.h opc.h cpu.h
626df76a 262
1e43adfc 263op.h: op.o $(DYNGEN)
626df76a
FB
264 $(DYNGEN) -o $@ $<
265
1e43adfc 266opc.h: op.o $(DYNGEN)
626df76a
FB
267 $(DYNGEN) -c -o $@ $<
268
1e43adfc 269gen-op.h: op.o $(DYNGEN)
626df76a
FB
270 $(DYNGEN) -g -o $@ $<
271
1e43adfc 272op.o: op.c
626df76a
FB
273 $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
274
1e43adfc 275helper.o: helper.c
626df76a
FB
276 $(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
277
1e43adfc
FB
278ifeq ($(TARGET_ARCH), i386)
279op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h
280endif
281
282ifeq ($(TARGET_ARCH), arm)
283op.o: op.c op_template.h
284endif
626df76a 285
1e43adfc
FB
286ifeq ($(TARGET_ARCH), sparc)
287op.o: op.c op_template.h
288endif
626df76a 289
728c9fd5
FB
290ifeq ($(TARGET_ARCH), ppc)
291op.o: op.c op_template.h op_mem.h
292op_helper.o: op_helper_mem.h
293endif
294
626df76a
FB
295%.o: %.c
296 $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
297
f72b519c
FB
298%.o: %.S
299 $(CC) $(DEFINES) -c -o $@ $<
300
626df76a 301clean:
f72b519c 302 rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o
1e43adfc
FB
303
304install: all
305 install -m 755 -s $(PROGS) $(prefix)/bin
626df76a
FB
306
307ifneq ($(wildcard .depend),)
308include .depend
309endif