Statistics
| Branch: | Revision:

root / Makefile.target @ 83469015

History | View | Annotate | Download (9.8 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
PROGS+=$(QEMU_SYSTEM)
48
ifndef CONFIG_SOFTMMU
49
CONFIG_STATIC=y
50
endif
51
endif # !CONFIG_USER_ONLY
52

    
53
ifdef CONFIG_STATIC
54
LDFLAGS+=-static
55
endif
56

    
57
ifeq ($(ARCH),i386)
58
CFLAGS+=-fomit-frame-pointer
59
OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2
60
ifeq ($(HAVE_GCC3_OPTIONS),yes)
61
OP_CFLAGS+= -falign-functions=0 -fno-gcse
62
else
63
OP_CFLAGS+= -malign-functions=0
64
endif
65

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

    
82
ifeq ($(ARCH),x86_64)
83
OP_CFLAGS=$(CFLAGS) -falign-functions=0
84
LDFLAGS+=-Wl,-T,$(SRC_PATH)/x86_64.ld
85
endif
86

    
87
ifeq ($(ARCH),ppc)
88
CFLAGS+= -D__powerpc__
89
OP_CFLAGS=$(CFLAGS)
90
LDFLAGS+=-Wl,-T,$(SRC_PATH)/ppc.ld
91
endif
92

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

    
98
ifeq ($(ARCH),sparc)
99
CFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
100
LDFLAGS+=-m32
101
OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
102
HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat
103
# -static is used to avoid g1/g3 usage by the dynamic linker
104
LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc.ld -static
105
endif
106

    
107
ifeq ($(ARCH),sparc64)
108
CFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
109
LDFLAGS+=-m64
110
OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
111
endif
112

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

    
122
ifeq ($(ARCH),ia64)
123
CFLAGS += -mno-sdata
124
OP_CFLAGS=$(CFLAGS)
125
LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
126
endif
127

    
128
ifeq ($(ARCH),arm)
129
OP_CFLAGS=$(CFLAGS) -mno-sched-prolog -fno-omit-frame-pointer
130
LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld
131
endif
132

    
133
ifeq ($(ARCH),m68k)
134
OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer
135
LDFLAGS+=-Wl,-T,m68k.ld
136
endif
137

    
138
ifeq ($(HAVE_GCC3_OPTIONS),yes)
139
# very important to generate a return at the end of every operation
140
OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
141
endif
142

    
143
ifeq ($(CONFIG_DARWIN),yes)
144
OP_CFLAGS+= -mdynamic-no-pic
145
LIBS+=-lmx
146
endif
147

    
148
#########################################################
149

    
150
DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
151
LIBS+=-lm
152
ifndef CONFIG_USER_ONLY
153
LIBS+=-lz
154
endif
155
ifdef CONFIG_WIN32
156
LIBS+=-lwinmm -lws2_32 -liphlpapi
157
endif
158

    
159
# profiling code
160
ifdef TARGET_GPROF
161
LDFLAGS+=-p
162
main.o: CFLAGS+=-p
163
endif
164

    
165
OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o 
166
ifeq ($(TARGET_ARCH), i386)
167
OBJS+= vm86.o
168
endif
169
ifeq ($(TARGET_ARCH), arm)
170
OBJS+=nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
171
nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
172
 nwfpe/double_cpdo.o nwfpe/extended_cpdo.o arm-semi.o
173
endif
174
SRCS:= $(OBJS:.o=.c)
175
OBJS+= libqemu.a
176

    
177
# cpu emulator library
178
LIBOBJS=exec.o kqemu.o translate-op.o translate-all.o cpu-exec.o\
179
        translate.o op.o 
180
ifdef CONFIG_SOFTFLOAT
181
LIBOBJS+=fpu/softfloat.o
182
else
183
LIBOBJS+=fpu/softfloat-native.o
184
endif
185
DEFINES+=-I$(SRC_PATH)/fpu
186

    
187
ifeq ($(TARGET_ARCH), i386)
188
LIBOBJS+=helper.o helper2.o
189
ifeq ($(ARCH), i386)
190
LIBOBJS+=translate-copy.o
191
endif
192
endif
193

    
194
ifeq ($(TARGET_ARCH), x86_64)
195
LIBOBJS+=helper.o helper2.o
196
endif
197

    
198
ifeq ($(TARGET_ARCH), ppc)
199
LIBOBJS+= op_helper.o helper.o
200
endif
201

    
202
ifeq ($(TARGET_ARCH), mips)
203
LIBOBJS+= op_helper.o helper.o
204
endif
205

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

    
210
ifeq ($(TARGET_BASE_ARCH), arm)
211
LIBOBJS+= op_helper.o
212
endif
213

    
214
# NOTE: the disassembler code is only needed for debugging
215
LIBOBJS+=disas.o 
216
ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
217
USE_I386_DIS=y
218
endif
219
ifeq ($(findstring x86_64, $(TARGET_ARCH) $(ARCH)),x86_64)
220
USE_I386_DIS=y
221
endif
222
ifdef USE_I386_DIS
223
LIBOBJS+=i386-dis.o
224
endif
225
ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
226
LIBOBJS+=alpha-dis.o
227
endif
228
ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc)
229
LIBOBJS+=ppc-dis.o
230
endif
231
ifeq ($(findstring mips, $(TARGET_ARCH) $(ARCH)),mips)
232
LIBOBJS+=mips-dis.o
233
endif
234
ifeq ($(findstring sparc, $(TARGET_BASE_ARCH) $(ARCH)),sparc)
235
LIBOBJS+=sparc-dis.o
236
endif
237
ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
238
LIBOBJS+=arm-dis.o
239
endif
240

    
241
ifeq ($(ARCH),ia64)
242
OBJS += ia64-syscall.o
243
endif
244
ifdef CONFIG_GDBSTUB
245
OBJS+=gdbstub.o
246
endif
247

    
248
all: $(PROGS)
249

    
250
$(QEMU_USER): $(OBJS)
251
	$(CC) $(LDFLAGS) -o $@ $^  $(LIBS)
252
ifeq ($(ARCH),alpha)
253
# Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
254
# the address space (31 bit so sign extending doesn't matter)
255
	echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
256
endif
257

    
258
# must use static linking to avoid leaving stuff in virtual address space
259
VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o
260
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
261

    
262
SOUND_HW = sb16.o
263
AUDIODRV = audio.o noaudio.o wavaudio.o
264
ifdef CONFIG_SDL
265
AUDIODRV += sdlaudio.o
266
endif
267
ifdef CONFIG_OSS
268
AUDIODRV += ossaudio.o
269
endif
270

    
271
pc.o: DEFINES := -DUSE_SB16 $(DEFINES)
272

    
273
ifdef CONFIG_ADLIB
274
SOUND_HW += fmopl.o adlib.o
275
endif
276

    
277
ifdef CONFIG_FMOD
278
AUDIODRV += fmodaudio.o
279
audio.o fmodaudio.o: DEFINES := -I$(CONFIG_FMOD_INC) $(DEFINES)
280
LIBS += $(CONFIG_FMOD_LIB)
281
endif
282

    
283
ifeq ($(TARGET_BASE_ARCH), i386)
284
# Hardware support
285
VL_OBJS+= ide.o ne2000.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
286
VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o
287
VL_OBJS+= cirrus_vga.o mixeng.o apic.o parallel.o
288
endif
289
ifeq ($(TARGET_ARCH), ppc)
290
VL_OBJS+= ppc.o ide.o ne2000.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
291
VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o
292
VL_OBJS+= ppc_prep.o ppc_chrp.o cuda.o adb.o openpic.o heathrow_pic.o mixeng.o
293
endif
294
ifeq ($(TARGET_ARCH), mips)
295
VL_OBJS+= mips_r4k.o dma.o vga.o serial.o ne2000.o i8259.o
296
#VL_OBJS+= #ide.o pckbd.o i8254.o fdc.o m48t59.o
297
endif
298
ifeq ($(TARGET_BASE_ARCH), sparc)
299
ifeq ($(TARGET_ARCH), sparc64)
300
VL_OBJS+= sun4u.o ide.o ne2000.o pckbd.o vga.o
301
VL_OBJS+= fdc.o mc146818rtc.o serial.o m48t59.o
302
VL_OBJS+= cirrus_vga.o parallel.o
303
VL_OBJS+= magic-load.o
304
else
305
VL_OBJS+= sun4m.o tcx.o lance.o iommu.o m48t08.o magic-load.o slavio_intctl.o slavio_timer.o slavio_serial.o slavio_misc.o fdc.o esp.o
306
endif
307
endif
308
ifdef CONFIG_GDBSTUB
309
VL_OBJS+=gdbstub.o 
310
endif
311
ifdef CONFIG_SDL
312
VL_OBJS+=sdl.o
313
endif
314
ifdef CONFIG_COCOA
315
VL_OBJS+=cocoa.o
316
COCOA_LIBS=-F/System/Library/Frameworks -framework Cocoa
317
endif
318
ifdef CONFIG_SLIRP
319
DEFINES+=-I$(SRC_PATH)/slirp
320
SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
321
slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
322
tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o
323
VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
324
endif
325

    
326
VL_LDFLAGS=
327
# specific flags are needed for non soft mmu emulator
328
ifdef CONFIG_STATIC
329
VL_LDFLAGS+=-static
330
endif
331
ifndef CONFIG_SOFTMMU
332
VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld 
333
endif
334
ifndef CONFIG_DARWIN
335
ifndef CONFIG_WIN32
336
VL_LIBS=-lutil
337
endif
338
endif
339
ifdef TARGET_GPROF
340
vl.o: CFLAGS+=-p
341
VL_LDFLAGS+=-p
342
endif
343

    
344
ifeq ($(ARCH),ia64)
345
VL_LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
346
endif
347

    
348
$(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
349
	$(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(VL_LIBS)
350

    
351
cocoa.o: cocoa.m
352
	$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
353

    
354
sdl.o: sdl.c keymaps.c sdl_keysym.h
355
	$(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
356

    
357
sdlaudio.o: sdlaudio.c
358
	$(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
359

    
360
depend: $(SRCS)
361
	$(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
362

    
363
# libqemu 
364

    
365
libqemu.a: $(LIBOBJS)
366
	rm -f $@
367
	$(AR) rcs $@ $(LIBOBJS)
368

    
369
translate.o: translate.c gen-op.h opc.h cpu.h
370

    
371
translate-all.o: translate-all.c opc.h cpu.h
372

    
373
translate-op.o: translate-all.c op.h opc.h cpu.h
374

    
375
op.h: op.o $(DYNGEN)
376
	$(DYNGEN) -o $@ $<
377

    
378
opc.h: op.o $(DYNGEN)
379
	$(DYNGEN) -c -o $@ $<
380

    
381
gen-op.h: op.o $(DYNGEN)
382
	$(DYNGEN) -g -o $@ $<
383

    
384
op.o: op.c
385
	$(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
386

    
387
helper.o: helper.c
388
	$(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
389

    
390
ifeq ($(TARGET_BASE_ARCH), i386)
391
op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h ops_sse.h
392
endif
393

    
394
ifeq ($(TARGET_ARCH), arm)
395
op.o: op.c op_template.h
396
endif
397

    
398
ifeq ($(TARGET_BASE_ARCH), sparc)
399
op.o: op.c op_template.h op_mem.h fop_template.h fbranch_template.h
400
magic_load.o: elf_op.h
401
endif
402

    
403
ifeq ($(TARGET_ARCH), ppc)
404
op.o: op.c op_template.h op_mem.h
405
op_helper.o: op_helper_mem.h
406
translate.o: translate.c translate_init.c
407
endif
408

    
409
ifeq ($(TARGET_ARCH), mips)
410
op.o: op.c op_template.c op_mem.c
411
op_helper.o: op_helper_mem.c
412
endif
413

    
414
mixeng.o: mixeng.c mixeng.h mixeng_template.h
415

    
416
%.o: %.c
417
	$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
418

    
419
%.o: %.S
420
	$(CC) $(DEFINES) -c -o $@ $<
421

    
422
clean:
423
	rm -f *.o  *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o fpu/*.o
424

    
425
install: all 
426
ifneq ($(PROGS),)
427
	install -m 755 -s $(PROGS) "$(bindir)"
428
endif
429

    
430
ifneq ($(wildcard .depend),)
431
include .depend
432
endif