root / Makefile.target @ bc51c5c9
History | View | Annotate | Download (6.3 kB)
1 |
include config.mak |
---|---|
2 |
|
3 |
TARGET_PATH=$(SRC_PATH)/target-$(TARGET_ARCH) |
4 |
VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw |
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 |
else |
31 |
# the system emulator using soft mmu is portable |
32 |
ifdef CONFIG_SOFTMMU |
33 |
PROGS+=$(QEMU_SYSTEM) |
34 |
endif |
35 |
endif # ARCH != i386 |
36 |
|
37 |
endif # TARGET_ARCH = i386 |
38 |
|
39 |
ifeq ($(TARGET_ARCH), ppc) |
40 |
|
41 |
ifeq ($(ARCH), ppc) |
42 |
PROGS+=$(QEMU_SYSTEM) |
43 |
endif |
44 |
|
45 |
ifeq ($(ARCH), i386) |
46 |
ifdef CONFIG_SOFTMMU |
47 |
PROGS+=$(QEMU_SYSTEM) |
48 |
endif |
49 |
endif # ARCH = i386 |
50 |
|
51 |
endif # TARGET_ARCH = ppc |
52 |
endif # !CONFIG_USER_ONLY |
53 |
|
54 |
ifdef CONFIG_STATIC |
55 |
LDFLAGS+=-static |
56 |
endif |
57 |
|
58 |
ifeq ($(ARCH),i386) |
59 |
CFLAGS+=-fomit-frame-pointer |
60 |
OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2 |
61 |
ifeq ($(HAVE_GCC3_OPTIONS),yes) |
62 |
OP_CFLAGS+= -falign-functions=0 |
63 |
else |
64 |
OP_CFLAGS+= -malign-functions=0 |
65 |
endif |
66 |
|
67 |
ifdef TARGET_GPROF |
68 |
USE_I386_LD=y |
69 |
endif |
70 |
ifdef CONFIG_STATIC |
71 |
USE_I386_LD=y |
72 |
endif |
73 |
ifdef USE_I386_LD |
74 |
LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386.ld |
75 |
else |
76 |
# WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object |
77 |
# that the kernel ELF loader considers as an executable. I think this |
78 |
# is the simplest way to make it self virtualizable! |
79 |
LDFLAGS+=-Wl,-shared |
80 |
endif |
81 |
endif |
82 |
|
83 |
ifeq ($(ARCH),amd64) |
84 |
OP_CFLAGS=$(CFLAGS) -falign-functions=0 |
85 |
LDFLAGS+=-Wl,-T,$(SRC_PATH)/amd64.ld |
86 |
endif |
87 |
|
88 |
ifeq ($(ARCH),ppc) |
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 |
OP_CFLAGS=$(CFLAGS) |
124 |
endif |
125 |
|
126 |
ifeq ($(ARCH),arm) |
127 |
OP_CFLAGS=$(CFLAGS) -mno-sched-prolog |
128 |
LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld |
129 |
endif |
130 |
|
131 |
ifeq ($(ARCH),m68k) |
132 |
OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer |
133 |
LDFLAGS+=-Wl,-T,m68k.ld |
134 |
endif |
135 |
|
136 |
ifeq ($(HAVE_GCC3_OPTIONS),yes) |
137 |
# very important to generate a return at the end of every operation |
138 |
OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls |
139 |
endif |
140 |
|
141 |
######################################################### |
142 |
|
143 |
DEFINES+=-D_GNU_SOURCE |
144 |
LIBS+=-lm |
145 |
|
146 |
# profiling code |
147 |
ifdef TARGET_GPROF |
148 |
LDFLAGS+=-p |
149 |
main.o: CFLAGS+=-p |
150 |
endif |
151 |
|
152 |
OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o |
153 |
ifeq ($(TARGET_ARCH), i386) |
154 |
OBJS+= vm86.o |
155 |
endif |
156 |
ifeq ($(TARGET_ARCH), arm) |
157 |
OBJS+=nwfpe/softfloat.o nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \ |
158 |
nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \ |
159 |
nwfpe/double_cpdo.o nwfpe/extended_cpdo.o |
160 |
endif |
161 |
SRCS:= $(OBJS:.o=.c) |
162 |
OBJS+= libqemu.a |
163 |
|
164 |
# cpu emulator library |
165 |
LIBOBJS=thunk.o exec.o translate-all.o cpu-exec.o gdbstub.o \ |
166 |
translate.o op.o |
167 |
|
168 |
ifeq ($(TARGET_ARCH), i386) |
169 |
LIBOBJS+=helper.o helper2.o |
170 |
ifeq ($(ARCH), i386) |
171 |
LIBOBJS+=translate-copy.o |
172 |
endif |
173 |
endif |
174 |
|
175 |
ifeq ($(TARGET_ARCH), ppc) |
176 |
LIBOBJS+= op_helper.o helper.o |
177 |
endif |
178 |
|
179 |
# NOTE: the disassembler code is only needed for debugging |
180 |
LIBOBJS+=disas.o |
181 |
ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386) |
182 |
USE_I386_DIS=y |
183 |
endif |
184 |
ifeq ($(findstring amd64, $(TARGET_ARCH) $(ARCH)),amd64) |
185 |
USE_I386_DIS=y |
186 |
endif |
187 |
ifdef USE_I386_DIS |
188 |
LIBOBJS+=i386-dis.o |
189 |
endif |
190 |
ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha) |
191 |
LIBOBJS+=alpha-dis.o |
192 |
endif |
193 |
ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc) |
194 |
LIBOBJS+=ppc-dis.o |
195 |
endif |
196 |
ifeq ($(findstring sparc, $(TARGET_ARCH) $(ARCH)),sparc) |
197 |
LIBOBJS+=sparc-dis.o |
198 |
endif |
199 |
ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm) |
200 |
LIBOBJS+=arm-dis.o |
201 |
endif |
202 |
|
203 |
ifeq ($(ARCH),ia64) |
204 |
OBJS += ia64-syscall.o |
205 |
endif |
206 |
|
207 |
all: $(PROGS) |
208 |
|
209 |
$(QEMU_USER): $(OBJS) |
210 |
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) |
211 |
ifeq ($(ARCH),alpha) |
212 |
# Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of |
213 |
# the address space (31 bit so sign extending doesn't matter) |
214 |
echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc |
215 |
endif |
216 |
|
217 |
# must use static linking to avoid leaving stuff in virtual address space |
218 |
VL_OBJS=vl.o osdep.o block.o monitor.o \ |
219 |
ide.o ne2000.o pckbd.o vga.o sb16.o dma.o oss.o \ |
220 |
fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o |
221 |
ifeq ($(TARGET_ARCH), ppc) |
222 |
VL_OBJS+= hw.o |
223 |
endif |
224 |
ifdef CONFIG_SDL |
225 |
VL_OBJS+=sdl.o |
226 |
ifdef CONFIG_STATIC |
227 |
SDL_LIBS:=$(SDL_STATIC_LIBS) |
228 |
endif |
229 |
endif |
230 |
|
231 |
VL_LDFLAGS= |
232 |
# specific flags are needed for non soft mmu emulator |
233 |
ifdef CONFIG_STATIC |
234 |
VL_LDFLAGS+=-static |
235 |
endif |
236 |
ifndef CONFIG_SOFTMMU |
237 |
VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld |
238 |
endif |
239 |
|
240 |
$(QEMU_SYSTEM): $(VL_OBJS) libqemu.a |
241 |
$(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) -lutil |
242 |
|
243 |
sdl.o: sdl.c |
244 |
$(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $< |
245 |
|
246 |
depend: $(SRCS) |
247 |
$(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend |
248 |
|
249 |
# libqemu |
250 |
|
251 |
libqemu.a: $(LIBOBJS) |
252 |
rm -f $@ |
253 |
$(AR) rcs $@ $(LIBOBJS) |
254 |
|
255 |
translate.o: translate.c gen-op.h opc.h cpu.h |
256 |
|
257 |
translate-all.o: translate-all.c op.h opc.h cpu.h |
258 |
|
259 |
op.h: op.o $(DYNGEN) |
260 |
$(DYNGEN) -o $@ $< |
261 |
|
262 |
opc.h: op.o $(DYNGEN) |
263 |
$(DYNGEN) -c -o $@ $< |
264 |
|
265 |
gen-op.h: op.o $(DYNGEN) |
266 |
$(DYNGEN) -g -o $@ $< |
267 |
|
268 |
op.o: op.c |
269 |
$(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $< |
270 |
|
271 |
helper.o: helper.c |
272 |
$(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $< |
273 |
|
274 |
ifeq ($(TARGET_ARCH), i386) |
275 |
op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h |
276 |
endif |
277 |
|
278 |
ifeq ($(TARGET_ARCH), arm) |
279 |
op.o: op.c op_template.h |
280 |
endif |
281 |
|
282 |
ifeq ($(TARGET_ARCH), sparc) |
283 |
op.o: op.c op_template.h |
284 |
endif |
285 |
|
286 |
ifeq ($(TARGET_ARCH), ppc) |
287 |
op.o: op.c op_template.h op_mem.h |
288 |
op_helper.o: op_helper_mem.h |
289 |
endif |
290 |
|
291 |
%.o: %.c |
292 |
$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $< |
293 |
|
294 |
%.o: %.S |
295 |
$(CC) $(DEFINES) -c -o $@ $< |
296 |
|
297 |
clean: |
298 |
rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o |
299 |
|
300 |
install: all |
301 |
install -m 755 -s $(PROGS) $(prefix)/bin |
302 |
|
303 |
ifneq ($(wildcard .depend),) |
304 |
include .depend |
305 |
endif |