Statistics
| Branch: | Revision:

root / Makefile.target @ 664e0f19

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

    
41
ifdef CONFIG_USER_ONLY
42
PROGS=$(QEMU_USER)
43
else
44
ifeq ($(TARGET_ARCH), i386)
45

    
46
ifeq ($(ARCH), i386)
47
PROGS+=$(QEMU_SYSTEM)
48
ifndef CONFIG_SOFTMMU
49
CONFIG_STATIC=y
50
endif
51
else
52
# the system emulator using soft mmu is portable
53
ifdef CONFIG_SOFTMMU
54
PROGS+=$(QEMU_SYSTEM)
55
endif
56
endif # ARCH != i386
57

    
58
endif # TARGET_ARCH = i386
59

    
60
ifeq ($(TARGET_ARCH), x86_64)
61
ifdef CONFIG_SOFTMMU
62
PROGS+=$(QEMU_SYSTEM)
63
endif
64
endif # TARGET_ARCH = x86_64
65

    
66
ifeq ($(TARGET_ARCH), ppc)
67

    
68
ifeq ($(ARCH), ppc)
69
PROGS+=$(QEMU_SYSTEM)
70
endif
71

    
72
ifeq ($(ARCH), i386)
73
ifdef CONFIG_SOFTMMU
74
PROGS+=$(QEMU_SYSTEM)
75
endif
76
endif # ARCH = i386
77

    
78
ifeq ($(ARCH), x86_64)
79
ifdef CONFIG_SOFTMMU
80
PROGS+=$(QEMU_SYSTEM)
81
endif
82
endif # ARCH = x86_64
83

    
84
endif # TARGET_ARCH = ppc
85

    
86
ifeq ($(TARGET_ARCH), sparc)
87

    
88
ifeq ($(ARCH), ppc)
89
PROGS+=$(QEMU_SYSTEM)
90
endif
91

    
92
ifeq ($(ARCH), i386)
93
ifdef CONFIG_SOFTMMU
94
PROGS+=$(QEMU_SYSTEM)
95
endif
96
endif # ARCH = i386
97

    
98
ifeq ($(ARCH), x86_64)
99
ifdef CONFIG_SOFTMMU
100
PROGS+=$(QEMU_SYSTEM)
101
endif
102
endif # ARCH = x86_64
103

    
104
endif # TARGET_ARCH = sparc
105
endif # !CONFIG_USER_ONLY
106

    
107
ifdef CONFIG_STATIC
108
LDFLAGS+=-static
109
endif
110

    
111
ifeq ($(ARCH),i386)
112
CFLAGS+=-fomit-frame-pointer
113
OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2
114
ifeq ($(HAVE_GCC3_OPTIONS),yes)
115
OP_CFLAGS+= -falign-functions=0 -fno-gcse
116
else
117
OP_CFLAGS+= -malign-functions=0
118
endif
119

    
120
ifdef TARGET_GPROF
121
USE_I386_LD=y
122
endif
123
ifdef CONFIG_STATIC
124
USE_I386_LD=y
125
endif
126
ifdef USE_I386_LD
127
LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386.ld
128
else
129
# WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
130
# that the kernel ELF loader considers as an executable. I think this
131
# is the simplest way to make it self virtualizable!
132
LDFLAGS+=-Wl,-shared
133
endif
134
endif
135

    
136
ifeq ($(ARCH),x86_64)
137
OP_CFLAGS=$(CFLAGS) -falign-functions=0
138
LDFLAGS+=-Wl,-T,$(SRC_PATH)/x86_64.ld
139
endif
140

    
141
ifeq ($(ARCH),ppc)
142
CFLAGS+= -D__powerpc__
143
OP_CFLAGS=$(CFLAGS)
144
LDFLAGS+=-Wl,-T,$(SRC_PATH)/ppc.ld
145
endif
146

    
147
ifeq ($(ARCH),s390)
148
OP_CFLAGS=$(CFLAGS)
149
LDFLAGS+=-Wl,-T,$(SRC_PATH)/s390.ld
150
endif
151

    
152
ifeq ($(ARCH),sparc)
153
CFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
154
LDFLAGS+=-m32
155
OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
156
HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat
157
# -static is used to avoid g1/g3 usage by the dynamic linker
158
LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc.ld -static
159
endif
160

    
161
ifeq ($(ARCH),sparc64)
162
CFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
163
LDFLAGS+=-m64
164
OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
165
endif
166

    
167
ifeq ($(ARCH),alpha)
168
# -msmall-data is not used because we want two-instruction relocations
169
# for the constant constructions
170
OP_CFLAGS=-Wall -O2 -g
171
# Ensure there's only a single GP
172
CFLAGS += -msmall-data
173
LDFLAGS+=-Wl,-T,$(SRC_PATH)/alpha.ld
174
endif
175

    
176
ifeq ($(ARCH),ia64)
177
OP_CFLAGS=$(CFLAGS)
178
endif
179

    
180
ifeq ($(ARCH),arm)
181
OP_CFLAGS=$(CFLAGS) -mno-sched-prolog
182
LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld
183
endif
184

    
185
ifeq ($(ARCH),m68k)
186
OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer
187
LDFLAGS+=-Wl,-T,m68k.ld
188
endif
189

    
190
ifeq ($(HAVE_GCC3_OPTIONS),yes)
191
# very important to generate a return at the end of every operation
192
OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
193
endif
194

    
195
ifeq ($(CONFIG_DARWIN),yes)
196
OP_CFLAGS+= -mdynamic-no-pic
197
LIBS+=-lmx
198
endif
199

    
200
#########################################################
201

    
202
DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
203
LIBS+=-lm
204
ifndef CONFIG_USER_ONLY
205
LIBS+=-lz
206
endif
207
ifdef CONFIG_WIN32
208
LIBS+=-lwinmm -lws2_32 -liphlpapi
209
endif
210

    
211
# profiling code
212
ifdef TARGET_GPROF
213
LDFLAGS+=-p
214
main.o: CFLAGS+=-p
215
endif
216

    
217
OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o 
218
ifeq ($(TARGET_ARCH), i386)
219
OBJS+= vm86.o
220
endif
221
ifeq ($(TARGET_ARCH), arm)
222
OBJS+=nwfpe/softfloat.o nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
223
nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
224
 nwfpe/double_cpdo.o nwfpe/extended_cpdo.o
225
endif
226
SRCS:= $(OBJS:.o=.c)
227
OBJS+= libqemu.a
228

    
229
# cpu emulator library
230
LIBOBJS=exec.o translate-all.o cpu-exec.o\
231
        translate.o op.o
232

    
233
ifeq ($(TARGET_ARCH), i386)
234
LIBOBJS+=helper.o helper2.o
235
ifeq ($(ARCH), i386)
236
LIBOBJS+=translate-copy.o
237
endif
238
endif
239

    
240
ifeq ($(TARGET_ARCH), x86_64)
241
LIBOBJS+=helper.o helper2.o
242
endif
243

    
244
ifeq ($(TARGET_ARCH), ppc)
245
LIBOBJS+= op_helper.o helper.o
246
endif
247

    
248
ifeq ($(TARGET_ARCH), sparc)
249
LIBOBJS+= op_helper.o helper.o
250
endif
251

    
252
# NOTE: the disassembler code is only needed for debugging
253
LIBOBJS+=disas.o 
254
ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
255
USE_I386_DIS=y
256
endif
257
ifeq ($(findstring x86_64, $(TARGET_ARCH) $(ARCH)),x86_64)
258
USE_I386_DIS=y
259
endif
260
ifdef USE_I386_DIS
261
LIBOBJS+=i386-dis.o
262
endif
263
ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
264
LIBOBJS+=alpha-dis.o
265
endif
266
ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc)
267
LIBOBJS+=ppc-dis.o
268
endif
269
ifeq ($(findstring sparc, $(TARGET_ARCH) $(ARCH)),sparc)
270
LIBOBJS+=sparc-dis.o
271
endif
272
ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
273
LIBOBJS+=arm-dis.o
274
endif
275

    
276
ifeq ($(ARCH),ia64)
277
OBJS += ia64-syscall.o
278
endif
279

    
280
all: $(PROGS)
281

    
282
$(QEMU_USER): $(OBJS)
283
	$(CC) $(LDFLAGS) -o $@ $^  $(LIBS)
284
ifeq ($(ARCH),alpha)
285
# Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
286
# the address space (31 bit so sign extending doesn't matter)
287
	echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
288
endif
289

    
290
# must use static linking to avoid leaving stuff in virtual address space
291
VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o 
292
VL_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o
293

    
294
SOUND_HW = sb16.o
295
AUDIODRV = audio.o noaudio.o wavaudio.o
296
ifdef CONFIG_SDL
297
AUDIODRV += sdlaudio.o
298
endif
299
ifdef CONFIG_OSS
300
AUDIODRV += ossaudio.o
301
endif
302

    
303
pc.o: DEFINES := -DUSE_SB16 $(DEFINES)
304

    
305
ifdef CONFIG_ADLIB
306
SOUND_HW += fmopl.o adlib.o
307
endif
308

    
309
ifdef CONFIG_FMOD
310
AUDIODRV += fmodaudio.o
311
audio.o fmodaudio.o: DEFINES := -I$(CONFIG_FMOD_INC) $(DEFINES)
312
LIBS += $(CONFIG_FMOD_LIB)
313
endif
314

    
315
ifeq ($(TARGET_BASE_ARCH), i386)
316
# Hardware support
317
VL_OBJS+= ide.o ne2000.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
318
VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o
319
VL_OBJS+= cirrus_vga.o mixeng.o apic.o
320
endif
321
ifeq ($(TARGET_ARCH), ppc)
322
VL_OBJS+= ppc.o ide.o ne2000.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
323
VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o
324
VL_OBJS+= ppc_prep.o ppc_chrp.o cuda.o adb.o openpic.o mixeng.o
325
endif
326
ifeq ($(TARGET_ARCH), sparc)
327
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
328
endif
329
ifdef CONFIG_GDBSTUB
330
VL_OBJS+=gdbstub.o 
331
endif
332
ifdef CONFIG_SDL
333
VL_OBJS+=sdl.o
334
endif
335
ifdef CONFIG_SLIRP
336
DEFINES+=-I$(SRC_PATH)/slirp
337
SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
338
slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
339
tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o
340
VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
341
endif
342

    
343
VL_LDFLAGS=
344
# specific flags are needed for non soft mmu emulator
345
ifdef CONFIG_STATIC
346
VL_LDFLAGS+=-static
347
endif
348
ifndef CONFIG_SOFTMMU
349
VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld 
350
endif
351
ifndef CONFIG_DARWIN
352
ifndef CONFIG_WIN32
353
VL_LIBS=-lutil
354
endif
355
endif
356

    
357
$(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
358
	$(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(VL_LIBS)
359

    
360
sdl.o: sdl.c keymaps.c sdl_keysym.h
361
	$(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
362

    
363
sdlaudio.o: sdlaudio.c
364
	$(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
365

    
366
depend: $(SRCS)
367
	$(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
368

    
369
# libqemu 
370

    
371
libqemu.a: $(LIBOBJS)
372
	rm -f $@
373
	$(AR) rcs $@ $(LIBOBJS)
374

    
375
translate.o: translate.c gen-op.h opc.h cpu.h
376

    
377
translate-all.o: translate-all.c op.h opc.h cpu.h
378

    
379
op.h: op.o $(DYNGEN)
380
	$(DYNGEN) -o $@ $<
381

    
382
opc.h: op.o $(DYNGEN)
383
	$(DYNGEN) -c -o $@ $<
384

    
385
gen-op.h: op.o $(DYNGEN)
386
	$(DYNGEN) -g -o $@ $<
387

    
388
op.o: op.c
389
	$(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
390

    
391
helper.o: helper.c
392
	$(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
393

    
394
ifeq ($(TARGET_BASE_ARCH), i386)
395
op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h ops_sse.h
396
endif
397

    
398
ifeq ($(TARGET_ARCH), arm)
399
op.o: op.c op_template.h
400
endif
401

    
402
ifeq ($(TARGET_ARCH), sparc)
403
op.o: op.c op_template.h op_mem.h
404
endif
405

    
406
ifeq ($(TARGET_ARCH), ppc)
407
op.o: op.c op_template.h op_mem.h
408
op_helper.o: op_helper_mem.h
409
endif
410

    
411
mixeng.o: mixeng.c mixeng.h mixeng_template.h
412

    
413
%.o: %.c
414
	$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
415

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

    
419
clean:
420
	rm -f *.o  *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o
421

    
422
install: all 
423
ifneq ($(PROGS),)
424
	install -m 755 -s $(PROGS) "$(bindir)"
425
endif
426

    
427
ifneq ($(wildcard .depend),)
428
include .depend
429
endif