Statistics
| Branch: | Revision:

root / Makefile.target @ d64477af

History | View | Annotate | Download (7.2 kB)

1
include config.mak
2

    
3
TARGET_PATH=$(SRC_PATH)/target-$(TARGET_ARCH)
4
VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw
5
DEFINES=-I. -I$(TARGET_PATH) -I$(SRC_PATH)
6
ifdef CONFIG_USER_ONLY
7
VPATH+=:$(SRC_PATH)/linux-user
8
DEFINES+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ARCH)
9
endif
10
CFLAGS=-Wall -O2 -g
11
LDFLAGS=-g
12
LIBS=
13
HELPER_CFLAGS=$(CFLAGS)
14
DYNGEN=../dyngen$(EXESUF)
15
# user emulator name
16
QEMU_USER=qemu-$(TARGET_ARCH)
17
# system emulator name
18
ifdef CONFIG_SOFTMMU
19
ifeq ($(TARGET_ARCH), i386)
20
QEMU_SYSTEM=qemu$(EXESUF)
21
else
22
QEMU_SYSTEM=qemu-system-$(TARGET_ARCH)$(EXESUF)
23
endif
24
else
25
QEMU_SYSTEM=qemu-fast
26
endif
27

    
28
ifdef CONFIG_USER_ONLY
29
PROGS=$(QEMU_USER)
30
else
31
ifeq ($(TARGET_ARCH), i386)
32

    
33
ifeq ($(ARCH), i386)
34
PROGS+=$(QEMU_SYSTEM)
35
ifndef CONFIG_SOFTMMU
36
CONFIG_STATIC=y
37
endif
38
else
39
# the system emulator using soft mmu is portable
40
ifdef CONFIG_SOFTMMU
41
PROGS+=$(QEMU_SYSTEM)
42
endif
43
endif # ARCH != i386
44

    
45
endif # TARGET_ARCH = i386
46

    
47
ifeq ($(TARGET_ARCH), ppc)
48

    
49
ifeq ($(ARCH), ppc)
50
PROGS+=$(QEMU_SYSTEM)
51
endif
52

    
53
ifeq ($(ARCH), i386)
54
ifdef CONFIG_SOFTMMU
55
PROGS+=$(QEMU_SYSTEM)
56
endif
57
endif # ARCH = i386
58

    
59
endif # TARGET_ARCH = ppc
60
endif # !CONFIG_USER_ONLY
61

    
62
ifdef CONFIG_STATIC
63
LDFLAGS+=-static
64
endif
65

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

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

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

    
96
ifeq ($(ARCH),ppc)
97
OP_CFLAGS=$(CFLAGS)
98
LDFLAGS+=-Wl,-T,$(SRC_PATH)/ppc.ld
99
endif
100

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

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

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

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

    
130
ifeq ($(ARCH),ia64)
131
OP_CFLAGS=$(CFLAGS)
132
endif
133

    
134
ifeq ($(ARCH),arm)
135
OP_CFLAGS=$(CFLAGS) -mno-sched-prolog
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
#########################################################
150

    
151
DEFINES+=-D_GNU_SOURCE
152
LIBS+=-lm
153
ifdef CONFIG_WIN32
154
LIBS+=-lwinmm
155
endif
156

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

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

    
175
# cpu emulator library
176
LIBOBJS=exec.o translate-all.o cpu-exec.o\
177
        translate.o op.o
178

    
179
ifeq ($(TARGET_ARCH), i386)
180
LIBOBJS+=helper.o helper2.o
181
ifeq ($(ARCH), i386)
182
LIBOBJS+=translate-copy.o
183
endif
184
endif
185

    
186
ifeq ($(TARGET_ARCH), ppc)
187
LIBOBJS+= op_helper.o helper.o
188
endif
189

    
190
# NOTE: the disassembler code is only needed for debugging
191
LIBOBJS+=disas.o 
192
ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
193
USE_I386_DIS=y
194
endif
195
ifeq ($(findstring amd64, $(TARGET_ARCH) $(ARCH)),amd64)
196
USE_I386_DIS=y
197
endif
198
ifdef USE_I386_DIS
199
LIBOBJS+=i386-dis.o
200
endif
201
ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
202
LIBOBJS+=alpha-dis.o
203
endif
204
ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc)
205
LIBOBJS+=ppc-dis.o
206
endif
207
ifeq ($(findstring sparc, $(TARGET_ARCH) $(ARCH)),sparc)
208
LIBOBJS+=sparc-dis.o
209
endif
210
ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
211
LIBOBJS+=arm-dis.o
212
endif
213

    
214
ifeq ($(ARCH),ia64)
215
OBJS += ia64-syscall.o
216
endif
217

    
218
all: $(PROGS)
219

    
220
$(QEMU_USER): $(OBJS)
221
	$(CC) $(LDFLAGS) -o $@ $^  $(LIBS)
222
ifeq ($(ARCH),alpha)
223
# Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
224
# the address space (31 bit so sign extending doesn't matter)
225
	echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
226
endif
227

    
228
# must use static linking to avoid leaving stuff in virtual address space
229
VL_OBJS=vl.o osdep.o block.o monitor.o
230

    
231
ifeq ($(TARGET_ARCH), i386)
232
# Hardware support
233
VL_OBJS+= ide.o ne2000.o pckbd.o vga.o sb16.o dma.o oss.o
234
VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o
235
endif
236
ifeq ($(TARGET_ARCH), ppc)
237
# Generic PPC support
238
VL_OBJS+= ppc.o
239
# PREP hardware support
240
VL_OBJS+= ide.o ne2000.o pckbd.o vga.o sb16.o dma.o oss.o
241
VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o ppc_prep.o
242
#VL_OBJS+= hw.o of.o setup.o
243
endif
244
ifdef CONFIG_GDBSTUB
245
VL_OBJS+=gdbstub.o 
246
endif
247
ifdef CONFIG_SDL
248
VL_OBJS+=sdl.o
249
endif
250
ifdef CONFIG_SLIRP
251
DEFINES+=-I$(SRC_PATH)/slirp
252
SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
253
slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
254
tcp_subr.o tcp_timer.o udp.o bootp.o debug.o
255
VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
256
endif
257

    
258
VL_LDFLAGS=
259
# specific flags are needed for non soft mmu emulator
260
ifdef CONFIG_STATIC
261
VL_LDFLAGS+=-static
262
endif
263
ifndef CONFIG_SOFTMMU
264
VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld 
265
endif
266
ifndef CONFIG_WIN32
267
VL_LIBS=-lutil
268
endif
269

    
270
$(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
271
	$(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(VL_LIBS)
272

    
273
sdl.o: sdl.c
274
	$(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
275

    
276
depend: $(SRCS)
277
	$(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
278

    
279
# libqemu 
280

    
281
libqemu.a: $(LIBOBJS)
282
	rm -f $@
283
	$(AR) rcs $@ $(LIBOBJS)
284

    
285
translate.o: translate.c gen-op.h opc.h cpu.h
286

    
287
translate-all.o: translate-all.c op.h opc.h cpu.h
288

    
289
op.h: op.o $(DYNGEN)
290
	$(DYNGEN) -o $@ $<
291

    
292
opc.h: op.o $(DYNGEN)
293
	$(DYNGEN) -c -o $@ $<
294

    
295
gen-op.h: op.o $(DYNGEN)
296
	$(DYNGEN) -g -o $@ $<
297

    
298
op.o: op.c
299
	$(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
300

    
301
helper.o: helper.c
302
	$(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
303

    
304
ifeq ($(TARGET_ARCH), i386)
305
op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h
306
endif
307

    
308
ifeq ($(TARGET_ARCH), arm)
309
op.o: op.c op_template.h
310
endif
311

    
312
ifeq ($(TARGET_ARCH), sparc)
313
op.o: op.c op_template.h
314
endif
315

    
316
ifeq ($(TARGET_ARCH), ppc)
317
op.o: op.c op_template.h op_mem.h
318
op_helper.o: op_helper_mem.h
319
endif
320

    
321
%.o: %.c
322
	$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
323

    
324
%.o: %.S
325
	$(CC) $(DEFINES) -c -o $@ $<
326

    
327
clean:
328
	rm -f *.o  *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o
329

    
330
install: all 
331
ifneq ($(PROGS),)
332
	install -m 755 -s $(PROGS) "$(bindir)"
333
endif
334

    
335
ifneq ($(wildcard .depend),)
336
include .depend
337
endif