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