Statistics
| Branch: | Revision:

root / Makefile.target @ 0d92ed30

History | View | Annotate | Download (12 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), ppc64)
8
TARGET_BASE_ARCH:=ppc
9
endif
10
ifeq ($(TARGET_ARCH), sparc64)
11
TARGET_BASE_ARCH:=sparc
12
endif
13
TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH)
14
VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw:$(SRC_PATH)/audio
15
DEFINES=-I. -I.. -I$(TARGET_PATH) -I$(SRC_PATH)
16
ifdef CONFIG_USER_ONLY
17
VPATH+=:$(SRC_PATH)/linux-user
18
DEFINES+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ARCH)
19
endif
20
CFLAGS=-Wall -O2 -g -fno-strict-aliasing
21
#CFLAGS+=-Werror
22
LDFLAGS=-g
23
LIBS=
24
HELPER_CFLAGS=$(CFLAGS)
25
DYNGEN=../dyngen$(EXESUF)
26
# user emulator name
27
TARGET_ARCH2=$(TARGET_ARCH)
28
ifeq ($(TARGET_ARCH),arm)
29
  ifeq ($(TARGET_WORDS_BIGENDIAN),yes)
30
    TARGET_ARCH2=armeb
31
  endif
32
endif
33
ifeq ($(TARGET_ARCH),mips)
34
  ifneq ($(TARGET_WORDS_BIGENDIAN),yes)
35
    TARGET_ARCH2=mipsel
36
  endif
37
endif
38
QEMU_USER=qemu-$(TARGET_ARCH2)
39
# system emulator name
40
ifdef CONFIG_SOFTMMU
41
ifeq ($(TARGET_ARCH), i386)
42
QEMU_SYSTEM=qemu$(EXESUF)
43
else
44
QEMU_SYSTEM=qemu-system-$(TARGET_ARCH2)$(EXESUF)
45
endif
46
else
47
QEMU_SYSTEM=qemu-fast
48
endif
49

    
50
ifdef CONFIG_USER_ONLY
51
PROGS=$(QEMU_USER)
52
else
53
PROGS+=$(QEMU_SYSTEM)
54
ifndef CONFIG_SOFTMMU
55
CONFIG_STATIC=y
56
endif
57
endif # !CONFIG_USER_ONLY
58

    
59
ifdef CONFIG_STATIC
60
LDFLAGS+=-static
61
endif
62

    
63
ifeq ($(ARCH),i386)
64
CFLAGS+=-fomit-frame-pointer
65
OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2
66
ifeq ($(HAVE_GCC3_OPTIONS),yes)
67
OP_CFLAGS+= -falign-functions=0 -fno-gcse
68
else
69
OP_CFLAGS+= -malign-functions=0
70
endif
71

    
72
ifdef TARGET_GPROF
73
USE_I386_LD=y
74
endif
75
ifdef CONFIG_STATIC
76
USE_I386_LD=y
77
endif
78
ifdef USE_I386_LD
79
LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386.ld
80
else
81
# WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
82
# that the kernel ELF loader considers as an executable. I think this
83
# is the simplest way to make it self virtualizable!
84
LDFLAGS+=-Wl,-shared
85
endif
86
endif
87

    
88
ifeq ($(ARCH),x86_64)
89
OP_CFLAGS=$(CFLAGS) -falign-functions=0
90
LDFLAGS+=-Wl,-T,$(SRC_PATH)/x86_64.ld
91
endif
92

    
93
ifeq ($(ARCH),ppc)
94
CFLAGS+= -D__powerpc__
95
OP_CFLAGS=$(CFLAGS)
96
LDFLAGS+=-Wl,-T,$(SRC_PATH)/ppc.ld
97
endif
98

    
99
ifeq ($(ARCH),s390)
100
OP_CFLAGS=$(CFLAGS)
101
LDFLAGS+=-Wl,-T,$(SRC_PATH)/s390.ld
102
endif
103

    
104
ifeq ($(ARCH),sparc)
105
CFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
106
LDFLAGS+=-m32
107
OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
108
HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat
109
# -static is used to avoid g1/g3 usage by the dynamic linker
110
LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc.ld -static
111
endif
112

    
113
ifeq ($(ARCH),sparc64)
114
CFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
115
LDFLAGS+=-m64
116
OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
117
endif
118

    
119
ifeq ($(ARCH),alpha)
120
# -msmall-data is not used because we want two-instruction relocations
121
# for the constant constructions
122
OP_CFLAGS=-Wall -O2 -g
123
# Ensure there's only a single GP
124
CFLAGS += -msmall-data
125
LDFLAGS+=-Wl,-T,$(SRC_PATH)/alpha.ld
126
endif
127

    
128
ifeq ($(ARCH),ia64)
129
CFLAGS += -mno-sdata
130
OP_CFLAGS=$(CFLAGS)
131
LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
132
endif
133

    
134
ifeq ($(ARCH),arm)
135
OP_CFLAGS=$(CFLAGS) -mno-sched-prolog -fno-omit-frame-pointer
136
LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld
137
endif
138

    
139
ifeq ($(ARCH),m68k)
140
OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer
141
LDFLAGS+=-Wl,-T,m68k.ld
142
endif
143

    
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
147
endif
148

    
149
ifeq ($(CONFIG_DARWIN),yes)
150
OP_CFLAGS+= -mdynamic-no-pic
151
LIBS+=-lmx
152
endif
153

    
154
#########################################################
155

    
156
DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
157
LIBS+=-lm
158
ifndef CONFIG_USER_ONLY
159
LIBS+=-lz
160
endif
161
ifdef CONFIG_WIN32
162
LIBS+=-lwinmm -lws2_32 -liphlpapi
163
endif
164
ifdef CONFIG_SOLARIS
165
LIBS+=-lsocket -lnsl -lresolv
166
endif
167

    
168
# profiling code
169
ifdef TARGET_GPROF
170
LDFLAGS+=-p
171
main.o: CFLAGS+=-p
172
endif
173

    
174
OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o 
175
ifeq ($(TARGET_ARCH), i386)
176
OBJS+= vm86.o
177
endif
178
ifeq ($(TARGET_ARCH), arm)
179
OBJS+=nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
180
nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
181
 nwfpe/double_cpdo.o nwfpe/extended_cpdo.o arm-semi.o
182
endif
183
SRCS:= $(OBJS:.o=.c)
184
OBJS+= libqemu.a
185

    
186
# cpu emulator library
187
LIBOBJS=exec.o kqemu.o translate-op.o translate-all.o cpu-exec.o\
188
        translate.o op.o 
189
ifdef CONFIG_SOFTFLOAT
190
LIBOBJS+=fpu/softfloat.o
191
else
192
LIBOBJS+=fpu/softfloat-native.o
193
endif
194
DEFINES+=-I$(SRC_PATH)/fpu
195

    
196
ifeq ($(TARGET_ARCH), i386)
197
LIBOBJS+=helper.o helper2.o
198
ifeq ($(ARCH), i386)
199
LIBOBJS+=translate-copy.o
200
endif
201
endif
202

    
203
ifeq ($(TARGET_ARCH), x86_64)
204
LIBOBJS+=helper.o helper2.o
205
endif
206

    
207
ifeq ($(TARGET_BASE_ARCH), ppc)
208
LIBOBJS+= op_helper.o helper.o
209
endif
210

    
211
ifeq ($(TARGET_ARCH), mips)
212
LIBOBJS+= op_helper.o helper.o
213
endif
214

    
215
ifeq ($(TARGET_BASE_ARCH), sparc)
216
LIBOBJS+= op_helper.o helper.o
217
endif
218

    
219
ifeq ($(TARGET_BASE_ARCH), arm)
220
LIBOBJS+= op_helper.o helper.o
221
endif
222

    
223
ifeq ($(TARGET_BASE_ARCH), sh4)
224
LIBOBJS+= op_helper.o helper.o
225
endif
226

    
227
# NOTE: the disassembler code is only needed for debugging
228
LIBOBJS+=disas.o 
229
ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
230
USE_I386_DIS=y
231
endif
232
ifeq ($(findstring x86_64, $(TARGET_ARCH) $(ARCH)),x86_64)
233
USE_I386_DIS=y
234
endif
235
ifdef USE_I386_DIS
236
LIBOBJS+=i386-dis.o
237
endif
238
ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
239
LIBOBJS+=alpha-dis.o
240
endif
241
ifeq ($(findstring ppc, $(TARGET_BASE_ARCH) $(ARCH)),ppc)
242
LIBOBJS+=ppc-dis.o
243
endif
244
ifeq ($(findstring mips, $(TARGET_ARCH) $(ARCH)),mips)
245
LIBOBJS+=mips-dis.o
246
endif
247
ifeq ($(findstring sparc, $(TARGET_BASE_ARCH) $(ARCH)),sparc)
248
LIBOBJS+=sparc-dis.o
249
endif
250
ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
251
LIBOBJS+=arm-dis.o
252
endif
253
ifeq ($(findstring m68k, $(TARGET_ARCH) $(ARCH)),m68k)
254
LIBOBJS+=m68k-dis.o
255
endif
256
ifeq ($(findstring sh4, $(TARGET_ARCH) $(ARCH)),sh4)
257
LIBOBJS+=sh4-dis.o
258
endif
259

    
260
ifdef CONFIG_GDBSTUB
261
OBJS+=gdbstub.o
262
endif
263

    
264
all: $(PROGS)
265

    
266
$(QEMU_USER): $(OBJS)
267
	$(CC) $(LDFLAGS) -o $@ $^  $(LIBS)
268
ifeq ($(ARCH),alpha)
269
# Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
270
# the address space (31 bit so sign extending doesn't matter)
271
	echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
272
endif
273

    
274
# must use static linking to avoid leaving stuff in virtual address space
275
VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o loader.o
276
VL_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o block-bochs.o block-vpc.o block-vvfat.o
277
ifdef CONFIG_WIN32
278
VL_OBJS+=tap-win32.o
279
endif
280

    
281
SOUND_HW = sb16.o es1370.o
282
AUDIODRV = audio.o noaudio.o wavaudio.o
283
ifdef CONFIG_SDL
284
AUDIODRV += sdlaudio.o
285
endif
286
ifdef CONFIG_OSS
287
AUDIODRV += ossaudio.o
288
endif
289
ifdef CONFIG_COREAUDIO
290
AUDIODRV += coreaudio.o
291
endif
292
ifdef CONFIG_ALSA
293
AUDIODRV += alsaaudio.o
294
LIBS += -lasound
295
endif
296
ifdef CONFIG_DSOUND
297
AUDIODRV += dsoundaudio.o
298
LIBS += -lole32 -ldxguid
299
endif
300
ifdef CONFIG_FMOD
301
AUDIODRV += fmodaudio.o
302
audio.o fmodaudio.o: DEFINES := -I$(CONFIG_FMOD_INC) $(DEFINES)
303
LIBS += $(CONFIG_FMOD_LIB)
304
endif
305
ifdef CONFIG_ADLIB
306
SOUND_HW += fmopl.o adlib.o
307
endif
308

    
309
# USB layer
310
VL_OBJS+= usb.o usb-hub.o usb-linux.o usb-hid.o usb-ohci.o
311

    
312
# PCI network cards
313
VL_OBJS+= ne2000.o rtl8139.o
314

    
315
ifeq ($(TARGET_BASE_ARCH), i386)
316
# Hardware support
317
VL_OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
318
VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o
319
VL_OBJS+= cirrus_vga.o mixeng.o apic.o parallel.o acpi.o piix_pci.o
320
VL_OBJS+= usb-uhci.o
321
DEFINES += -DHAS_AUDIO
322
endif
323
ifeq ($(TARGET_BASE_ARCH), ppc)
324
VL_OBJS+= ppc.o ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
325
VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o
326
VL_OBJS+= ppc_prep.o ppc_chrp.o cuda.o adb.o openpic.o heathrow_pic.o mixeng.o
327
VL_OBJS+= grackle_pci.o prep_pci.o unin_pci.o
328
DEFINES += -DHAS_AUDIO
329
endif
330
ifeq ($(TARGET_ARCH), mips)
331
VL_OBJS+= mips_r4k.o dma.o vga.o serial.o i8254.o i8259.o
332
#VL_OBJS+= #ide.o pckbd.o fdc.o m48t59.o
333
endif
334
ifeq ($(TARGET_BASE_ARCH), sparc)
335
ifeq ($(TARGET_ARCH), sparc64)
336
VL_OBJS+= sun4u.o ide.o pckbd.o ps2.o vga.o apb_pci.o
337
VL_OBJS+= fdc.o mc146818rtc.o serial.o m48t59.o
338
VL_OBJS+= cirrus_vga.o parallel.o
339
else
340
VL_OBJS+= sun4m.o tcx.o lance.o iommu.o m48t59.o slavio_intctl.o
341
VL_OBJS+= slavio_timer.o slavio_serial.o slavio_misc.o fdc.o esp.o
342
endif
343
endif
344
ifeq ($(TARGET_BASE_ARCH), arm)
345
VL_OBJS+= integratorcp.o versatilepb.o ps2.o smc91c111.o arm_pic.o arm_timer.o
346
VL_OBJS+= arm_boot.o pl011.o pl050.o pl080.o pl110.o pl190.o
347
VL_OBJS+= versatile_pci.o
348
endif
349
ifeq ($(TARGET_BASE_ARCH), sh4)
350
VL_OBJS+= shix.o sh7750.o sh7750_regnames.o tc58128.o
351
endif
352
ifdef CONFIG_GDBSTUB
353
VL_OBJS+=gdbstub.o 
354
endif
355
ifdef CONFIG_SDL
356
VL_OBJS+=sdl.o
357
endif
358
VL_OBJS+=vnc.o
359
ifdef CONFIG_COCOA
360
VL_OBJS+=cocoa.o
361
COCOA_LIBS=-F/System/Library/Frameworks -framework Cocoa -framework IOKit
362
ifdef CONFIG_COREAUDIO
363
COCOA_LIBS+=-framework CoreAudio
364
endif
365
endif
366
ifdef CONFIG_SLIRP
367
DEFINES+=-I$(SRC_PATH)/slirp
368
SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
369
slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
370
tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o
371
VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
372
endif
373

    
374
VL_LDFLAGS=
375
# specific flags are needed for non soft mmu emulator
376
ifdef CONFIG_STATIC
377
VL_LDFLAGS+=-static
378
endif
379
ifndef CONFIG_SOFTMMU
380
VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld 
381
endif
382
ifndef CONFIG_DARWIN
383
ifndef CONFIG_WIN32
384
ifndef CONFIG_SOLARIS
385
VL_LIBS=-lutil
386
endif
387
endif
388
endif
389
ifdef TARGET_GPROF
390
vl.o: CFLAGS+=-p
391
VL_LDFLAGS+=-p
392
endif
393

    
394
ifeq ($(ARCH),ia64)
395
VL_LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
396
endif
397

    
398
ifdef CONFIG_WIN32
399
SDL_LIBS := $(filter-out -mwindows, $(SDL_LIBS)) -mconsole
400
endif
401

    
402
$(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
403
	$(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(VL_LIBS)
404

    
405
cocoa.o: cocoa.m
406
	$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
407

    
408
sdl.o: sdl.c keymaps.c sdl_keysym.h
409
	$(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
410

    
411
vnc.o: vnc.c keymaps.c sdl_keysym.h vnchextile.h
412
	$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
413

    
414
sdlaudio.o: sdlaudio.c
415
	$(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
416

    
417
depend: $(SRCS)
418
	$(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
419

    
420
vldepend: $(VL_OBJS:.o=.c)
421
	$(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
422

    
423
# libqemu 
424

    
425
libqemu.a: $(LIBOBJS)
426
	rm -f $@
427
	$(AR) rcs $@ $(LIBOBJS)
428

    
429
translate.o: translate.c gen-op.h opc.h cpu.h
430

    
431
translate-all.o: translate-all.c opc.h cpu.h
432

    
433
translate-op.o: translate-all.c op.h opc.h cpu.h
434

    
435
op.h: op.o $(DYNGEN)
436
	$(DYNGEN) -o $@ $<
437

    
438
opc.h: op.o $(DYNGEN)
439
	$(DYNGEN) -c -o $@ $<
440

    
441
gen-op.h: op.o $(DYNGEN)
442
	$(DYNGEN) -g -o $@ $<
443

    
444
op.o: op.c
445
	$(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
446

    
447
helper.o: helper.c
448
	$(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
449

    
450
ifeq ($(TARGET_BASE_ARCH), i386)
451
op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h ops_sse.h
452
endif
453

    
454
ifeq ($(TARGET_ARCH), arm)
455
op.o: op.c op_template.h
456
pl110.o: pl110_template.h
457
endif
458

    
459
ifeq ($(TARGET_BASE_ARCH), sparc)
460
op.o: op.c op_template.h op_mem.h fop_template.h fbranch_template.h
461
magic_load.o: elf_op.h
462
endif
463

    
464
ifeq ($(TARGET_BASE_ARCH), ppc)
465
op.o: op.c op_template.h op_mem.h
466
op_helper.o: op_helper_mem.h
467
translate.o: translate.c translate_init.c
468
endif
469

    
470
ifeq ($(TARGET_ARCH), mips)
471
op.o: op.c op_template.c op_mem.c
472
op_helper.o: op_helper_mem.c
473
endif
474

    
475
loader.o: loader.c elf_ops.h
476

    
477
acpi.o: acpi.c acpi-dsdt.hex
478

    
479
#$(SRC_PATH)/hw/acpi-dsdt.hex: acpi-dsdt.dsl
480
#	iasl -tc -p $@ $<
481

    
482
ifeq ($(TARGET_ARCH), sh4)
483
op.o: op.c op_mem.c cpu.h
484
op_helper.o: op_helper.c exec.h cpu.h
485
helper.o: helper.c exec.h cpu.h
486
sh7750.o: sh7750.c sh7750_regs.h sh7750_regnames.h cpu.h
487
shix.o: shix.c sh7750_regs.h sh7750_regnames.h
488
sh7750_regnames.o: sh7750_regnames.c sh7750_regnames.h sh7750_regs.h
489
tc58128.o: tc58128.c
490
endif
491

    
492
$(OBJS) $(LIBOBJS) $(VL_OBJS): config.h ../config-host.h
493

    
494
%.o: %.c
495
	$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
496

    
497
%.o: %.S
498
	$(CC) $(DEFINES) -c -o $@ $<
499

    
500
clean:
501
	rm -f *.o  *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o fpu/*.o
502

    
503
install: all 
504
ifneq ($(PROGS),)
505
	$(INSTALL) -m 755 -s $(PROGS) "$(DESTDIR)$(bindir)"
506
endif
507

    
508
ifneq ($(wildcard .depend),)
509
include .depend
510
endif
511

    
512
ifeq (1, 0)
513
audio.o sdlaudio.o dsoundaudio.o ossaudio.o wavaudio.o noaudio.o \
514
fmodaudio.o alsaaudio.o mixeng.o sb16.o es1370.o gus.o adlib.o: \
515
CFLAGS := $(CFLAGS) -Wall -Werror -W -Wsign-compare
516
endif