Statistics
| Branch: | Revision:

root / Makefile.target @ ad064840

History | View | Annotate | Download (11 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
ifeq ($(TARGET_ARCH),arm)
28
  ifeq ($(TARGET_WORDS_BIGENDIAN),yes)
29
    QEMU_USER=qemu-armeb
30
  else
31
    QEMU_USER=qemu-arm
32
  endif
33
else
34
ifeq ($(TARGET_ARCH),mips)
35
  ifeq ($(TARGET_WORDS_BIGENDIAN),yes)
36
    QEMU_USER=qemu-mips
37
  else
38
    QEMU_USER=qemu-mipsel
39
  endif
40
else
41
  QEMU_USER=qemu-$(TARGET_ARCH)
42
endif
43
endif
44
# system emulator name
45
ifdef CONFIG_SOFTMMU
46
ifeq ($(TARGET_ARCH), i386)
47
QEMU_SYSTEM=qemu$(EXESUF)
48
else
49
QEMU_SYSTEM=qemu-system-$(TARGET_ARCH)$(EXESUF)
50
endif
51
else
52
QEMU_SYSTEM=qemu-fast
53
endif
54

    
55
ifdef CONFIG_USER_ONLY
56
PROGS=$(QEMU_USER)
57
else
58
PROGS+=$(QEMU_SYSTEM)
59
ifndef CONFIG_SOFTMMU
60
CONFIG_STATIC=y
61
endif
62
endif # !CONFIG_USER_ONLY
63

    
64
ifdef CONFIG_STATIC
65
LDFLAGS+=-static
66
endif
67

    
68
ifeq ($(ARCH),i386)
69
CFLAGS+=-fomit-frame-pointer
70
OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2
71
ifeq ($(HAVE_GCC3_OPTIONS),yes)
72
OP_CFLAGS+= -falign-functions=0 -fno-gcse
73
else
74
OP_CFLAGS+= -malign-functions=0
75
endif
76

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

    
93
ifeq ($(ARCH),x86_64)
94
OP_CFLAGS=$(CFLAGS) -falign-functions=0
95
LDFLAGS+=-Wl,-T,$(SRC_PATH)/x86_64.ld
96
endif
97

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

    
104
ifeq ($(ARCH),s390)
105
OP_CFLAGS=$(CFLAGS)
106
LDFLAGS+=-Wl,-T,$(SRC_PATH)/s390.ld
107
endif
108

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

    
118
ifeq ($(ARCH),sparc64)
119
CFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
120
LDFLAGS+=-m64
121
OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
122
endif
123

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

    
133
ifeq ($(ARCH),ia64)
134
CFLAGS += -mno-sdata
135
OP_CFLAGS=$(CFLAGS)
136
LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
137
endif
138

    
139
ifeq ($(ARCH),arm)
140
OP_CFLAGS=$(CFLAGS) -mno-sched-prolog -fno-omit-frame-pointer
141
LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld
142
endif
143

    
144
ifeq ($(ARCH),m68k)
145
OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer
146
LDFLAGS+=-Wl,-T,m68k.ld
147
endif
148

    
149
ifeq ($(HAVE_GCC3_OPTIONS),yes)
150
# very important to generate a return at the end of every operation
151
OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
152
endif
153

    
154
ifeq ($(CONFIG_DARWIN),yes)
155
OP_CFLAGS+= -mdynamic-no-pic
156
LIBS+=-lmx
157
endif
158

    
159
#########################################################
160

    
161
DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
162
LIBS+=-lm
163
ifndef CONFIG_USER_ONLY
164
LIBS+=-lz
165
endif
166
ifdef CONFIG_WIN32
167
LIBS+=-lwinmm -lws2_32 -liphlpapi
168
endif
169

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

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

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

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

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

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

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

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

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

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

    
255
ifeq ($(ARCH),ia64)
256
OBJS += ia64-syscall.o
257
endif
258
ifdef CONFIG_GDBSTUB
259
OBJS+=gdbstub.o
260
endif
261

    
262
all: $(PROGS)
263

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

    
272
# must use static linking to avoid leaving stuff in virtual address space
273
VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o
274
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
275
ifdef CONFIG_WIN32
276
VL_OBJS+=tap-win32.o
277
endif
278

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

    
307
# USB layer
308
VL_OBJS+= usb.o usb-uhci.o usb-linux.o usb-hid.o
309

    
310
# PCI network cards
311
VL_OBJS+= ne2000.o rtl8139.o
312

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

    
366
VL_LDFLAGS=
367
# specific flags are needed for non soft mmu emulator
368
ifdef CONFIG_STATIC
369
VL_LDFLAGS+=-static
370
endif
371
ifndef CONFIG_SOFTMMU
372
VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld 
373
endif
374
ifndef CONFIG_DARWIN
375
ifndef CONFIG_WIN32
376
VL_LIBS=-lutil
377
endif
378
endif
379
ifdef TARGET_GPROF
380
vl.o: CFLAGS+=-p
381
VL_LDFLAGS+=-p
382
endif
383

    
384
ifeq ($(ARCH),ia64)
385
VL_LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
386
endif
387

    
388
ifdef CONFIG_WIN32
389
SDL_LIBS := $(filter-out -mwindows, $(SDL_LIBS)) -mconsole
390
endif
391

    
392
$(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
393
	$(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(VL_LIBS)
394

    
395
cocoa.o: cocoa.m
396
	$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
397

    
398
sdl.o: sdl.c keymaps.c sdl_keysym.h
399
	$(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
400

    
401
sdlaudio.o: sdlaudio.c
402
	$(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
403

    
404
depend: $(SRCS)
405
	$(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
406

    
407
vldepend: $(VL_OBJS:.o=.c)
408
	$(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
409

    
410
# libqemu 
411

    
412
libqemu.a: $(LIBOBJS)
413
	rm -f $@
414
	$(AR) rcs $@ $(LIBOBJS)
415

    
416
translate.o: translate.c gen-op.h opc.h cpu.h
417

    
418
translate-all.o: translate-all.c opc.h cpu.h
419

    
420
translate-op.o: translate-all.c op.h opc.h cpu.h
421

    
422
op.h: op.o $(DYNGEN)
423
	$(DYNGEN) -o $@ $<
424

    
425
opc.h: op.o $(DYNGEN)
426
	$(DYNGEN) -c -o $@ $<
427

    
428
gen-op.h: op.o $(DYNGEN)
429
	$(DYNGEN) -g -o $@ $<
430

    
431
op.o: op.c
432
	$(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
433

    
434
helper.o: helper.c
435
	$(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
436

    
437
ifeq ($(TARGET_BASE_ARCH), i386)
438
op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h ops_sse.h
439
endif
440

    
441
ifeq ($(TARGET_ARCH), arm)
442
op.o: op.c op_template.h
443
pl110.o: pl110_template.h
444
endif
445

    
446
ifeq ($(TARGET_BASE_ARCH), sparc)
447
op.o: op.c op_template.h op_mem.h fop_template.h fbranch_template.h
448
magic_load.o: elf_op.h
449
endif
450

    
451
ifeq ($(TARGET_BASE_ARCH), ppc)
452
op.o: op.c op_template.h op_mem.h
453
op_helper.o: op_helper_mem.h
454
translate.o: translate.c translate_init.c
455
endif
456

    
457
ifeq ($(TARGET_ARCH), mips)
458
op.o: op.c op_template.c op_mem.c
459
op_helper.o: op_helper_mem.c
460
endif
461

    
462
%.o: %.c
463
	$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
464

    
465
%.o: %.S
466
	$(CC) $(DEFINES) -c -o $@ $<
467

    
468
clean:
469
	rm -f *.o  *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o fpu/*.o
470

    
471
install: all 
472
ifneq ($(PROGS),)
473
	install -m 755 -s $(PROGS) "$(DESTDIR)$(bindir)"
474
endif
475

    
476
ifneq ($(wildcard .depend),)
477
include .depend
478
endif
479

    
480
ifeq (1, 0)
481
audio.o sdlaudio.o dsoundaudio.o ossaudio.o wavaudio.o noaudio.o \
482
fmodaudio.o alsaaudio.o mixeng.o sb16.o es1370.o gus.o adlib.o: \
483
CFLAGS := $(CFLAGS) -Wall -Werror -W -Wsign-compare
484
endif