Statistics
| Branch: | Revision:

root / Makefile.target @ 97eb5b14

History | View | Annotate | Download (6 kB)

1
include config.mak
2

    
3
TARGET_PATH=$(SRC_PATH)/target-$(TARGET_ARCH)
4
VPATH=$(SRC_PATH):$(TARGET_PATH)
5
CFLAGS=-Wall -O2 -g
6
LDFLAGS=-g
7
LIBS=
8
DEFINES=-I. -I$(TARGET_PATH) -I$(SRC_PATH)
9
HELPER_CFLAGS=$(CFLAGS)
10
DYNGEN=../dyngen
11
# user emulator name
12
QEMU_USER=qemu-$(TARGET_ARCH)
13
# system emulator name
14
ifdef CONFIG_SOFTMMU
15
QEMU_SYSTEM=qemu
16
else
17
QEMU_SYSTEM=qemu-fast
18
endif
19

    
20
ifdef CONFIG_USER_ONLY
21
PROGS=$(QEMU_USER)
22
else
23
ifeq ($(TARGET_ARCH), i386)
24

    
25
ifeq ($(ARCH), i386)
26
PROGS+=$(QEMU_SYSTEM)
27
ifndef CONFIG_SOFTMMU
28
CONFIG_STATIC=y
29
endif
30
endif
31

    
32
ifeq ($(ARCH), ppc)
33
ifdef CONFIG_SOFTMMU
34
PROGS+=$(QEMU_SYSTEM)
35
endif
36
endif
37

    
38
endif
39

    
40
ifeq ($(TARGET_ARCH), ppc)
41

    
42
ifeq ($(ARCH), ppc)
43
PROGS+=$(QEMU_SYSTEM)
44
endif
45

    
46
ifeq ($(ARCH), i386)
47
ifdef CONFIG_SOFTMMU
48
PROGS+=$(QEMU_SYSTEM)
49
endif
50
endif # ARCH = i386
51

    
52
endif # TARGET_ARCH = ppc
53
endif # !CONFIG_USER_ONLY
54

    
55
ifdef CONFIG_STATIC
56
LDFLAGS+=-static
57
endif
58

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

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

    
84
ifeq ($(ARCH),ppc)
85
OP_CFLAGS=$(CFLAGS)
86
LDFLAGS+=-Wl,-T,$(SRC_PATH)/ppc.ld
87
endif
88

    
89
ifeq ($(ARCH),s390)
90
OP_CFLAGS=$(CFLAGS)
91
LDFLAGS+=-Wl,-T,$(SRC_PATH)/s390.ld
92
endif
93

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

    
103
ifeq ($(ARCH),sparc64)
104
CFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
105
LDFLAGS+=-m64
106
OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
107
endif
108

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

    
118
ifeq ($(ARCH),ia64)
119
OP_CFLAGS=$(CFLAGS)
120
endif
121

    
122
ifeq ($(ARCH),arm)
123
OP_CFLAGS=$(CFLAGS) -mno-sched-prolog
124
LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld
125
endif
126

    
127
ifeq ($(ARCH),m68k)
128
OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer
129
LDFLAGS+=-Wl,-T,m68k.ld
130
endif
131

    
132
ifeq ($(HAVE_GCC3_OPTIONS),yes)
133
# very important to generate a return at the end of every operation
134
OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
135
endif
136

    
137
#########################################################
138

    
139
DEFINES+=-D_GNU_SOURCE
140
LIBS+=-lm
141

    
142
# profiling code
143
ifdef TARGET_GPROF
144
LDFLAGS+=-p
145
main.o: CFLAGS+=-p
146
endif
147

    
148
OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o
149
ifeq ($(TARGET_ARCH), i386)
150
OBJS+= vm86.o
151
endif
152
ifeq ($(TARGET_ARCH), arm)
153
OBJS+=nwfpe/softfloat.o nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
154
nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
155
 nwfpe/double_cpdo.o nwfpe/extended_cpdo.o
156
endif
157
SRCS:= $(OBJS:.o=.c)
158
OBJS+= libqemu.a
159

    
160
# cpu emulator library
161
LIBOBJS=thunk.o exec.o translate-all.o cpu-exec.o gdbstub.o \
162
        translate.o op.o
163

    
164
ifeq ($(TARGET_ARCH), i386)
165
LIBOBJS+=helper.o helper2.o
166
ifeq ($(ARCH), i386)
167
LIBOBJS+=translate-copy.o
168
endif
169
endif
170

    
171
ifeq ($(TARGET_ARCH), ppc)
172
LIBOBJS+= op_helper.o helper.o
173
endif
174

    
175
# NOTE: the disassembler code is only needed for debugging
176
LIBOBJS+=disas.o 
177
ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
178
LIBOBJS+=i386-dis.o
179
endif
180
ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
181
LIBOBJS+=alpha-dis.o
182
endif
183
ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc)
184
LIBOBJS+=ppc-dis.o
185
endif
186
ifeq ($(findstring sparc, $(TARGET_ARCH) $(ARCH)),sparc)
187
LIBOBJS+=sparc-dis.o
188
endif
189
ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
190
LIBOBJS+=arm-dis.o
191
endif
192

    
193
ifeq ($(ARCH),ia64)
194
OBJS += ia64-syscall.o
195
endif
196

    
197
all: $(PROGS)
198

    
199
$(QEMU_USER): $(OBJS)
200
	$(CC) $(LDFLAGS) -o $@ $^  $(LIBS)
201
ifeq ($(ARCH),alpha)
202
# Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
203
# the address space (31 bit so sign extending doesn't matter)
204
	echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
205
endif
206

    
207
# must use static linking to avoid leaving stuff in virtual address space
208
VL_OBJS=vl.o block.o ide.o vga.o sb16.o dma.o oss.o fdc.o osdep.o
209
ifeq ($(TARGET_ARCH), i386)
210
VL_OBJS+=linux_boot.o	
211
endif
212
ifeq ($(TARGET_ARCH), ppc)
213
VL_OBJS+= hw.o
214
endif
215
ifdef CONFIG_SDL
216
VL_OBJS+=sdl.o
217
ifdef CONFIG_STATIC
218
SDL_LIBS:=$(SDL_STATIC_LIBS)
219
endif
220
endif
221

    
222
VL_LDFLAGS=
223
# specific flags are needed for non soft mmu emulator
224
ifdef CONFIG_STATIC
225
VL_LDFLAGS+=-static
226
endif
227
ifndef CONFIG_SOFTMMU
228
VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld 
229
endif
230

    
231
$(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
232
	$(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS)
233

    
234
sdl.o: sdl.c
235
	$(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
236

    
237
depend: $(SRCS)
238
	$(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
239

    
240
# libqemu 
241

    
242
libqemu.a: $(LIBOBJS)
243
	rm -f $@
244
	$(AR) rcs $@ $(LIBOBJS)
245

    
246
translate.o: translate.c gen-op.h opc.h cpu.h
247

    
248
translate-all.o: translate-all.c op.h opc.h cpu.h
249

    
250
op.h: op.o $(DYNGEN)
251
	$(DYNGEN) -o $@ $<
252

    
253
opc.h: op.o $(DYNGEN)
254
	$(DYNGEN) -c -o $@ $<
255

    
256
gen-op.h: op.o $(DYNGEN)
257
	$(DYNGEN) -g -o $@ $<
258

    
259
op.o: op.c
260
	$(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
261

    
262
helper.o: helper.c
263
	$(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
264

    
265
ifeq ($(TARGET_ARCH), i386)
266
op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h
267
endif
268

    
269
ifeq ($(TARGET_ARCH), arm)
270
op.o: op.c op_template.h
271
endif
272

    
273
ifeq ($(TARGET_ARCH), sparc)
274
op.o: op.c op_template.h
275
endif
276

    
277
ifeq ($(TARGET_ARCH), ppc)
278
op.o: op.c op_template.h op_mem.h
279
op_helper.o: op_helper_mem.h
280
endif
281

    
282
%.o: %.c
283
	$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
284

    
285
%.o: %.S
286
	$(CC) $(DEFINES) -c -o $@ $<
287

    
288
clean:
289
	rm -f *.o  *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o
290

    
291
install: all 
292
	install -m 755 -s $(PROGS) $(prefix)/bin
293

    
294
ifneq ($(wildcard .depend),)
295
include .depend
296
endif