]> git.proxmox.com Git - qemu.git/blob - Makefile.target
SPARC merge
[qemu.git] / Makefile.target
1 include config.mak
2
3 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_ARCH)
4 VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw:$(SRC_PATH)/audio
5 DEFINES=-I. -I$(TARGET_PATH) -I$(SRC_PATH)
6 ifdef CONFIG_USER_ONLY
7 VPATH+=:$(SRC_PATH)/linux-user
8 DEFINES+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ARCH)
9 endif
10 CFLAGS=-Wall -O2 -g -fno-strict-aliasing
11 LDFLAGS=-g
12 LIBS=
13 HELPER_CFLAGS=$(CFLAGS)
14 DYNGEN=../dyngen$(EXESUF)
15 # user emulator name
16 QEMU_USER=qemu-$(TARGET_ARCH)
17 # system emulator name
18 ifdef CONFIG_SOFTMMU
19 ifeq ($(TARGET_ARCH), i386)
20 QEMU_SYSTEM=qemu$(EXESUF)
21 else
22 QEMU_SYSTEM=qemu-system-$(TARGET_ARCH)$(EXESUF)
23 endif
24 else
25 QEMU_SYSTEM=qemu-fast
26 endif
27
28 ifdef CONFIG_USER_ONLY
29 PROGS=$(QEMU_USER)
30 else
31 ifeq ($(TARGET_ARCH), i386)
32
33 ifeq ($(ARCH), i386)
34 PROGS+=$(QEMU_SYSTEM)
35 ifndef CONFIG_SOFTMMU
36 CONFIG_STATIC=y
37 endif
38 else
39 # the system emulator using soft mmu is portable
40 ifdef CONFIG_SOFTMMU
41 PROGS+=$(QEMU_SYSTEM)
42 endif
43 endif # ARCH != i386
44
45 endif # TARGET_ARCH = i386
46
47 ifeq ($(TARGET_ARCH), ppc)
48
49 ifeq ($(ARCH), ppc)
50 PROGS+=$(QEMU_SYSTEM)
51 endif
52
53 ifeq ($(ARCH), i386)
54 ifdef CONFIG_SOFTMMU
55 PROGS+=$(QEMU_SYSTEM)
56 endif
57 endif # ARCH = i386
58
59 ifeq ($(ARCH), amd64)
60 ifdef CONFIG_SOFTMMU
61 PROGS+=$(QEMU_SYSTEM)
62 endif
63 endif # ARCH = amd64
64
65 endif # TARGET_ARCH = ppc
66
67 ifeq ($(TARGET_ARCH), sparc)
68
69 ifeq ($(ARCH), ppc)
70 PROGS+=$(QEMU_SYSTEM)
71 endif
72
73 ifeq ($(ARCH), i386)
74 ifdef CONFIG_SOFTMMU
75 PROGS+=$(QEMU_SYSTEM)
76 endif
77 endif # ARCH = i386
78
79 ifeq ($(ARCH), amd64)
80 ifdef CONFIG_SOFTMMU
81 PROGS+=$(QEMU_SYSTEM)
82 endif
83 endif # ARCH = amd64
84
85 endif # TARGET_ARCH = sparc
86 endif # !CONFIG_USER_ONLY
87
88 ifdef CONFIG_STATIC
89 LDFLAGS+=-static
90 endif
91
92 ifeq ($(ARCH),i386)
93 CFLAGS+=-fomit-frame-pointer
94 OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2
95 ifeq ($(HAVE_GCC3_OPTIONS),yes)
96 OP_CFLAGS+= -falign-functions=0 -fno-gcse
97 else
98 OP_CFLAGS+= -malign-functions=0
99 endif
100
101 ifdef TARGET_GPROF
102 USE_I386_LD=y
103 endif
104 ifdef CONFIG_STATIC
105 USE_I386_LD=y
106 endif
107 ifdef USE_I386_LD
108 LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386.ld
109 else
110 # WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
111 # that the kernel ELF loader considers as an executable. I think this
112 # is the simplest way to make it self virtualizable!
113 LDFLAGS+=-Wl,-shared
114 endif
115 endif
116
117 ifeq ($(ARCH),amd64)
118 OP_CFLAGS=$(CFLAGS) -falign-functions=0
119 LDFLAGS+=-Wl,-T,$(SRC_PATH)/amd64.ld
120 endif
121
122 ifeq ($(ARCH),ppc)
123 CFLAGS+= -D__powerpc__
124 OP_CFLAGS=$(CFLAGS)
125 LDFLAGS+=-Wl,-T,$(SRC_PATH)/ppc.ld
126 endif
127
128 ifeq ($(ARCH),s390)
129 OP_CFLAGS=$(CFLAGS)
130 LDFLAGS+=-Wl,-T,$(SRC_PATH)/s390.ld
131 endif
132
133 ifeq ($(ARCH),sparc)
134 CFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
135 LDFLAGS+=-m32
136 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
137 HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat
138 # -static is used to avoid g1/g3 usage by the dynamic linker
139 LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc.ld -static
140 endif
141
142 ifeq ($(ARCH),sparc64)
143 CFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
144 LDFLAGS+=-m64
145 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
146 endif
147
148 ifeq ($(ARCH),alpha)
149 # -msmall-data is not used because we want two-instruction relocations
150 # for the constant constructions
151 OP_CFLAGS=-Wall -O2 -g
152 # Ensure there's only a single GP
153 CFLAGS += -msmall-data
154 LDFLAGS+=-Wl,-T,$(SRC_PATH)/alpha.ld
155 endif
156
157 ifeq ($(ARCH),ia64)
158 OP_CFLAGS=$(CFLAGS)
159 endif
160
161 ifeq ($(ARCH),arm)
162 OP_CFLAGS=$(CFLAGS) -mno-sched-prolog
163 LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld
164 endif
165
166 ifeq ($(ARCH),m68k)
167 OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer
168 LDFLAGS+=-Wl,-T,m68k.ld
169 endif
170
171 ifeq ($(HAVE_GCC3_OPTIONS),yes)
172 # very important to generate a return at the end of every operation
173 OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
174 endif
175
176 ifeq ($(CONFIG_DARWIN),yes)
177 OP_CFLAGS+= -mdynamic-no-pic
178 LIBS+=-lmx
179 endif
180
181 #########################################################
182
183 DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
184 LIBS+=-lm
185 ifndef CONFIG_USER_ONLY
186 LIBS+=-lz
187 endif
188 ifdef CONFIG_WIN32
189 LIBS+=-lwinmm -lws2_32 -liphlpapi
190 endif
191
192 # profiling code
193 ifdef TARGET_GPROF
194 LDFLAGS+=-p
195 main.o: CFLAGS+=-p
196 endif
197
198 OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o
199 ifeq ($(TARGET_ARCH), i386)
200 OBJS+= vm86.o
201 endif
202 ifeq ($(TARGET_ARCH), arm)
203 OBJS+=nwfpe/softfloat.o nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
204 nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
205 nwfpe/double_cpdo.o nwfpe/extended_cpdo.o
206 endif
207 SRCS:= $(OBJS:.o=.c)
208 OBJS+= libqemu.a
209
210 # cpu emulator library
211 LIBOBJS=exec.o translate-all.o cpu-exec.o\
212 translate.o op.o
213
214 ifeq ($(TARGET_ARCH), i386)
215 LIBOBJS+=helper.o helper2.o
216 ifeq ($(ARCH), i386)
217 LIBOBJS+=translate-copy.o
218 endif
219 endif
220
221 ifeq ($(TARGET_ARCH), ppc)
222 LIBOBJS+= op_helper.o helper.o
223 endif
224
225 ifeq ($(TARGET_ARCH), sparc)
226 LIBOBJS+= op_helper.o helper.o
227 endif
228
229 # NOTE: the disassembler code is only needed for debugging
230 LIBOBJS+=disas.o
231 ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
232 USE_I386_DIS=y
233 endif
234 ifeq ($(findstring amd64, $(TARGET_ARCH) $(ARCH)),amd64)
235 USE_I386_DIS=y
236 endif
237 ifdef USE_I386_DIS
238 LIBOBJS+=i386-dis.o
239 endif
240 ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
241 LIBOBJS+=alpha-dis.o
242 endif
243 ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc)
244 LIBOBJS+=ppc-dis.o
245 endif
246 ifeq ($(findstring sparc, $(TARGET_ARCH) $(ARCH)),sparc)
247 LIBOBJS+=sparc-dis.o
248 endif
249 ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
250 LIBOBJS+=arm-dis.o
251 endif
252
253 ifeq ($(ARCH),ia64)
254 OBJS += ia64-syscall.o
255 endif
256
257 all: $(PROGS)
258
259 $(QEMU_USER): $(OBJS)
260 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
261 ifeq ($(ARCH),alpha)
262 # Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
263 # the address space (31 bit so sign extending doesn't matter)
264 echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
265 endif
266
267 # must use static linking to avoid leaving stuff in virtual address space
268 VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o
269 VL_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o
270
271 SOUND_HW = sb16.o
272 AUDIODRV = audio.o noaudio.o wavaudio.o
273 ifdef CONFIG_SDL
274 AUDIODRV += sdlaudio.o
275 endif
276 ifdef CONFIG_OSS
277 AUDIODRV += ossaudio.o
278 endif
279
280 pc.o: DEFINES := -DUSE_SB16 $(DEFINES)
281
282 ifdef CONFIG_ADLIB
283 SOUND_HW += fmopl.o adlib.o
284 endif
285
286 ifdef CONFIG_FMOD
287 AUDIODRV += fmodaudio.o
288 audio.o fmodaudio.o: DEFINES := -I$(CONFIG_FMOD_INC) $(DEFINES)
289 LIBS += $(CONFIG_FMOD_LIB)
290 endif
291
292 ifeq ($(TARGET_ARCH), i386)
293 # Hardware support
294 VL_OBJS+= ide.o ne2000.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
295 VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o
296 VL_OBJS+= cirrus_vga.o mixeng.o
297 endif
298 ifeq ($(TARGET_ARCH), ppc)
299 VL_OBJS+= ppc.o ide.o ne2000.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
300 VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o
301 VL_OBJS+= ppc_prep.o ppc_chrp.o cuda.o adb.o openpic.o mixeng.o
302 endif
303 ifeq ($(TARGET_ARCH), sparc)
304 VL_OBJS+= sun4m.o tcx.o lance.o iommu.o m48t08.o magic-load.o slavio_intctl.o slavio_timer.o slavio_serial.o fdc.o
305 endif
306 ifdef CONFIG_GDBSTUB
307 VL_OBJS+=gdbstub.o
308 endif
309 ifdef CONFIG_SDL
310 VL_OBJS+=sdl.o
311 endif
312 ifdef CONFIG_SLIRP
313 DEFINES+=-I$(SRC_PATH)/slirp
314 SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
315 slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
316 tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o
317 VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
318 endif
319
320 VL_LDFLAGS=
321 # specific flags are needed for non soft mmu emulator
322 ifdef CONFIG_STATIC
323 VL_LDFLAGS+=-static
324 endif
325 ifndef CONFIG_SOFTMMU
326 VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld
327 endif
328 ifndef CONFIG_DARWIN
329 ifndef CONFIG_WIN32
330 VL_LIBS=-lutil
331 endif
332 endif
333
334 $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
335 $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(VL_LIBS)
336
337 sdl.o: sdl.c keymaps.c sdl_keysym.h
338 $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
339
340 sdlaudio.o: sdlaudio.c
341 $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
342
343 depend: $(SRCS)
344 $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
345
346 # libqemu
347
348 libqemu.a: $(LIBOBJS)
349 rm -f $@
350 $(AR) rcs $@ $(LIBOBJS)
351
352 translate.o: translate.c gen-op.h opc.h cpu.h
353
354 translate-all.o: translate-all.c op.h opc.h cpu.h
355
356 op.h: op.o $(DYNGEN)
357 $(DYNGEN) -o $@ $<
358
359 opc.h: op.o $(DYNGEN)
360 $(DYNGEN) -c -o $@ $<
361
362 gen-op.h: op.o $(DYNGEN)
363 $(DYNGEN) -g -o $@ $<
364
365 op.o: op.c
366 $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
367
368 helper.o: helper.c
369 $(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
370
371 ifeq ($(TARGET_ARCH), i386)
372 op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h
373 endif
374
375 ifeq ($(TARGET_ARCH), arm)
376 op.o: op.c op_template.h
377 endif
378
379 ifeq ($(TARGET_ARCH), sparc)
380 op.o: op.c op_template.h op_mem.h
381 endif
382
383 ifeq ($(TARGET_ARCH), ppc)
384 op.o: op.c op_template.h op_mem.h
385 op_helper.o: op_helper_mem.h
386 endif
387
388 mixeng.o: mixeng.c mixeng.h mixeng_template.h
389
390 %.o: %.c
391 $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
392
393 %.o: %.S
394 $(CC) $(DEFINES) -c -o $@ $<
395
396 clean:
397 rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o
398
399 install: all
400 ifneq ($(PROGS),)
401 install -m 755 -s $(PROGS) "$(bindir)"
402 endif
403
404 ifneq ($(wildcard .depend),)
405 include .depend
406 endif