]>
Commit | Line | Data |
---|---|---|
626df76a FB |
1 | include config.mak |
2 | ||
1e43adfc | 3 | TARGET_PATH=$(SRC_PATH)/target-$(TARGET_ARCH) |
85571bc7 | 4 | VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw:$(SRC_PATH)/audio |
3035f7ff FB |
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 | |
ab2572d7 | 10 | CFLAGS=-Wall -O2 -g -fno-strict-aliasing |
626df76a FB |
11 | LDFLAGS=-g |
12 | LIBS= | |
626df76a | 13 | HELPER_CFLAGS=$(CFLAGS) |
67b915a5 | 14 | DYNGEN=../dyngen$(EXESUF) |
1e43adfc FB |
15 | # user emulator name |
16 | QEMU_USER=qemu-$(TARGET_ARCH) | |
17 | # system emulator name | |
18 | ifdef CONFIG_SOFTMMU | |
a541f297 | 19 | ifeq ($(TARGET_ARCH), i386) |
67b915a5 | 20 | QEMU_SYSTEM=qemu$(EXESUF) |
0db63474 | 21 | else |
a541f297 FB |
22 | QEMU_SYSTEM=qemu-system-$(TARGET_ARCH)$(EXESUF) |
23 | endif | |
24 | else | |
0db63474 | 25 | QEMU_SYSTEM=qemu-fast |
1e43adfc FB |
26 | endif |
27 | ||
16e9b7de | 28 | ifdef CONFIG_USER_ONLY |
1e43adfc | 29 | PROGS=$(QEMU_USER) |
16e9b7de | 30 | else |
16e9b7de | 31 | ifeq ($(TARGET_ARCH), i386) |
c321f673 FB |
32 | |
33 | ifeq ($(ARCH), i386) | |
34 | PROGS+=$(QEMU_SYSTEM) | |
de5eaa64 FB |
35 | ifndef CONFIG_SOFTMMU |
36 | CONFIG_STATIC=y | |
37 | endif | |
38ca2abc FB |
38 | else |
39 | # the system emulator using soft mmu is portable | |
c321f673 | 40 | ifdef CONFIG_SOFTMMU |
16e9b7de FB |
41 | PROGS+=$(QEMU_SYSTEM) |
42 | endif | |
38ca2abc | 43 | endif # ARCH != i386 |
c321f673 | 44 | |
38ca2abc | 45 | endif # TARGET_ARCH = i386 |
728c9fd5 FB |
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) | |
626df76a | 56 | endif |
728c9fd5 FB |
57 | endif # ARCH = i386 |
58 | ||
75dfaa1e FB |
59 | ifeq ($(ARCH), amd64) |
60 | ifdef CONFIG_SOFTMMU | |
61 | PROGS+=$(QEMU_SYSTEM) | |
62 | endif | |
63 | endif # ARCH = amd64 | |
64 | ||
728c9fd5 | 65 | endif # TARGET_ARCH = ppc |
e95c8d51 FB |
66 | |
67 | ifeq ($(TARGET_ARCH), sparc) | |
68 | ||
69 | ifeq ($(ARCH), ppc) | |
70 | PROGS+=$(QEMU_SYSTEM) | |
71 | endif | |
72 | ||
73 | ifeq ($(ARCH), i386) | |
74 | ifdef CONFIG_SOFTMMU | |
75 | PROGS+=$(QEMU_SYSTEM) | |
76 | endif | |
77 | endif # ARCH = i386 | |
78 | ||
79 | ifeq ($(ARCH), amd64) | |
80 | ifdef CONFIG_SOFTMMU | |
81 | PROGS+=$(QEMU_SYSTEM) | |
82 | endif | |
83 | endif # ARCH = amd64 | |
84 | ||
85 | endif # TARGET_ARCH = sparc | |
728c9fd5 | 86 | endif # !CONFIG_USER_ONLY |
626df76a FB |
87 | |
88 | ifdef CONFIG_STATIC | |
89 | LDFLAGS+=-static | |
90 | endif | |
91 | ||
92 | ifeq ($(ARCH),i386) | |
93 | CFLAGS+=-fomit-frame-pointer | |
94 | OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2 | |
95 | ifeq ($(HAVE_GCC3_OPTIONS),yes) | |
3611a29c | 96 | OP_CFLAGS+= -falign-functions=0 -fno-gcse |
626df76a FB |
97 | else |
98 | OP_CFLAGS+= -malign-functions=0 | |
99 | endif | |
3a4739d6 | 100 | |
626df76a | 101 | ifdef TARGET_GPROF |
3a4739d6 FB |
102 | USE_I386_LD=y |
103 | endif | |
104 | ifdef CONFIG_STATIC | |
105 | USE_I386_LD=y | |
106 | endif | |
107 | ifdef USE_I386_LD | |
626df76a FB |
108 | LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386.ld |
109 | else | |
110 | # WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object | |
111 | # that the kernel ELF loader considers as an executable. I think this | |
112 | # is the simplest way to make it self virtualizable! | |
113 | LDFLAGS+=-Wl,-shared | |
114 | endif | |
626df76a FB |
115 | endif |
116 | ||
bc51c5c9 FB |
117 | ifeq ($(ARCH),amd64) |
118 | OP_CFLAGS=$(CFLAGS) -falign-functions=0 | |
119 | LDFLAGS+=-Wl,-T,$(SRC_PATH)/amd64.ld | |
120 | endif | |
121 | ||
626df76a | 122 | ifeq ($(ARCH),ppc) |
83fb7adf | 123 | CFLAGS+= -D__powerpc__ |
626df76a FB |
124 | OP_CFLAGS=$(CFLAGS) |
125 | LDFLAGS+=-Wl,-T,$(SRC_PATH)/ppc.ld | |
126 | endif | |
127 | ||
128 | ifeq ($(ARCH),s390) | |
129 | OP_CFLAGS=$(CFLAGS) | |
130 | LDFLAGS+=-Wl,-T,$(SRC_PATH)/s390.ld | |
131 | endif | |
132 | ||
133 | ifeq ($(ARCH),sparc) | |
134 | CFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6 | |
135 | LDFLAGS+=-m32 | |
136 | OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0 | |
137 | HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat | |
138 | # -static is used to avoid g1/g3 usage by the dynamic linker | |
139 | LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc.ld -static | |
140 | endif | |
141 | ||
142 | ifeq ($(ARCH),sparc64) | |
143 | CFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6 | |
144 | LDFLAGS+=-m64 | |
145 | OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0 | |
146 | endif | |
147 | ||
148 | ifeq ($(ARCH),alpha) | |
149 | # -msmall-data is not used because we want two-instruction relocations | |
150 | # for the constant constructions | |
151 | OP_CFLAGS=-Wall -O2 -g | |
152 | # Ensure there's only a single GP | |
153 | CFLAGS += -msmall-data | |
154 | LDFLAGS+=-Wl,-T,$(SRC_PATH)/alpha.ld | |
155 | endif | |
156 | ||
157 | ifeq ($(ARCH),ia64) | |
158 | OP_CFLAGS=$(CFLAGS) | |
159 | endif | |
160 | ||
161 | ifeq ($(ARCH),arm) | |
162 | OP_CFLAGS=$(CFLAGS) -mno-sched-prolog | |
163 | LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld | |
164 | endif | |
165 | ||
38e584a0 FB |
166 | ifeq ($(ARCH),m68k) |
167 | OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer | |
168 | LDFLAGS+=-Wl,-T,m68k.ld | |
169 | endif | |
170 | ||
626df76a FB |
171 | ifeq ($(HAVE_GCC3_OPTIONS),yes) |
172 | # very important to generate a return at the end of every operation | |
173 | OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls | |
174 | endif | |
175 | ||
83fb7adf FB |
176 | ifeq ($(CONFIG_DARWIN),yes) |
177 | OP_CFLAGS+= -mdynamic-no-pic | |
178 | endif | |
179 | ||
626df76a FB |
180 | ######################################################### |
181 | ||
d5249393 | 182 | DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE |
626df76a | 183 | LIBS+=-lm |
b932caba FB |
184 | ifndef CONFIG_USER_ONLY |
185 | LIBS+=-lz | |
186 | endif | |
67b915a5 | 187 | ifdef CONFIG_WIN32 |
3db38e87 | 188 | LIBS+=-lwinmm -lws2_32 -liphlpapi |
67b915a5 | 189 | endif |
626df76a FB |
190 | |
191 | # profiling code | |
192 | ifdef TARGET_GPROF | |
193 | LDFLAGS+=-p | |
194 | main.o: CFLAGS+=-p | |
195 | endif | |
196 | ||
3035f7ff | 197 | OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o |
626df76a FB |
198 | ifeq ($(TARGET_ARCH), i386) |
199 | OBJS+= vm86.o | |
200 | endif | |
f72b519c FB |
201 | ifeq ($(TARGET_ARCH), arm) |
202 | OBJS+=nwfpe/softfloat.o nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \ | |
203 | nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \ | |
204 | nwfpe/double_cpdo.o nwfpe/extended_cpdo.o | |
205 | endif | |
626df76a FB |
206 | SRCS:= $(OBJS:.o=.c) |
207 | OBJS+= libqemu.a | |
208 | ||
209 | # cpu emulator library | |
858693c6 | 210 | LIBOBJS=exec.o translate-all.o cpu-exec.o\ |
1e43adfc | 211 | translate.o op.o |
626df76a FB |
212 | |
213 | ifeq ($(TARGET_ARCH), i386) | |
1e43adfc | 214 | LIBOBJS+=helper.o helper2.o |
f72b519c FB |
215 | ifeq ($(ARCH), i386) |
216 | LIBOBJS+=translate-copy.o | |
217 | endif | |
626df76a FB |
218 | endif |
219 | ||
67867308 | 220 | ifeq ($(TARGET_ARCH), ppc) |
728c9fd5 | 221 | LIBOBJS+= op_helper.o helper.o |
67867308 FB |
222 | endif |
223 | ||
e95c8d51 FB |
224 | ifeq ($(TARGET_ARCH), sparc) |
225 | LIBOBJS+= op_helper.o helper.o | |
226 | endif | |
227 | ||
626df76a FB |
228 | # NOTE: the disassembler code is only needed for debugging |
229 | LIBOBJS+=disas.o | |
230 | ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386) | |
bc51c5c9 FB |
231 | USE_I386_DIS=y |
232 | endif | |
233 | ifeq ($(findstring amd64, $(TARGET_ARCH) $(ARCH)),amd64) | |
234 | USE_I386_DIS=y | |
235 | endif | |
236 | ifdef USE_I386_DIS | |
626df76a FB |
237 | LIBOBJS+=i386-dis.o |
238 | endif | |
239 | ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha) | |
240 | LIBOBJS+=alpha-dis.o | |
241 | endif | |
242 | ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc) | |
243 | LIBOBJS+=ppc-dis.o | |
244 | endif | |
245 | ifeq ($(findstring sparc, $(TARGET_ARCH) $(ARCH)),sparc) | |
246 | LIBOBJS+=sparc-dis.o | |
247 | endif | |
248 | ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm) | |
249 | LIBOBJS+=arm-dis.o | |
250 | endif | |
251 | ||
252 | ifeq ($(ARCH),ia64) | |
253 | OBJS += ia64-syscall.o | |
254 | endif | |
255 | ||
1e43adfc | 256 | all: $(PROGS) |
626df76a | 257 | |
1e43adfc | 258 | $(QEMU_USER): $(OBJS) |
626df76a FB |
259 | $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) |
260 | ifeq ($(ARCH),alpha) | |
261 | # Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of | |
262 | # the address space (31 bit so sign extending doesn't matter) | |
263 | echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc | |
264 | endif | |
265 | ||
266 | # must use static linking to avoid leaving stuff in virtual address space | |
b932caba | 267 | VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o |
3c56521b | 268 | VL_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o |
a541f297 | 269 | |
85571bc7 | 270 | SOUND_HW = sb16.o |
7372f88d | 271 | AUDIODRV = audio.o noaudio.o wavaudio.o |
fb065187 FB |
272 | ifdef CONFIG_SDL |
273 | AUDIODRV += sdlaudio.o | |
274 | endif | |
275 | ifdef CONFIG_OSS | |
276 | AUDIODRV += ossaudio.o | |
277 | endif | |
278 | ||
279 | pc.o: DEFINES := -DUSE_SB16 $(DEFINES) | |
85571bc7 | 280 | |
fb065187 | 281 | ifdef CONFIG_ADLIB |
85571bc7 | 282 | SOUND_HW += fmopl.o adlib.o |
85571bc7 FB |
283 | endif |
284 | ||
102a52e4 | 285 | ifdef CONFIG_FMOD |
85571bc7 | 286 | AUDIODRV += fmodaudio.o |
102a52e4 FB |
287 | audio.o fmodaudio.o: DEFINES := -I$(CONFIG_FMOD_INC) $(DEFINES) |
288 | LIBS += $(CONFIG_FMOD_LIB) | |
85571bc7 FB |
289 | endif |
290 | ||
a541f297 FB |
291 | ifeq ($(TARGET_ARCH), i386) |
292 | # Hardware support | |
85571bc7 FB |
293 | VL_OBJS+= ide.o ne2000.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV) |
294 | VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o | |
295 | VL_OBJS+= cirrus_vga.o mixeng.o | |
67b915a5 | 296 | endif |
728c9fd5 | 297 | ifeq ($(TARGET_ARCH), ppc) |
85571bc7 | 298 | VL_OBJS+= ppc.o ide.o ne2000.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV) |
64201201 | 299 | VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o |
85571bc7 | 300 | VL_OBJS+= ppc_prep.o ppc_chrp.o cuda.o adb.o openpic.o mixeng.o |
a541f297 | 301 | endif |
e95c8d51 | 302 | ifeq ($(TARGET_ARCH), sparc) |
8d5f07fa | 303 | VL_OBJS+= sun4m.o tcx.o lance.o iommu.o sched.o m48t08.o magic-load.o timer.o |
e95c8d51 | 304 | endif |
a541f297 FB |
305 | ifdef CONFIG_GDBSTUB |
306 | VL_OBJS+=gdbstub.o | |
728c9fd5 | 307 | endif |
626df76a FB |
308 | ifdef CONFIG_SDL |
309 | VL_OBJS+=sdl.o | |
de5eaa64 | 310 | endif |
7c1f25b4 FB |
311 | ifdef CONFIG_SLIRP |
312 | DEFINES+=-I$(SRC_PATH)/slirp | |
313 | SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \ | |
314 | slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \ | |
c7f74643 | 315 | tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o |
7c1f25b4 | 316 | VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS)) |
626df76a FB |
317 | endif |
318 | ||
c321f673 FB |
319 | VL_LDFLAGS= |
320 | # specific flags are needed for non soft mmu emulator | |
c321f673 FB |
321 | ifdef CONFIG_STATIC |
322 | VL_LDFLAGS+=-static | |
323 | endif | |
de5eaa64 FB |
324 | ifndef CONFIG_SOFTMMU |
325 | VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld | |
326 | endif | |
83fb7adf | 327 | ifndef CONFIG_DARWIN |
11d9f695 FB |
328 | ifndef CONFIG_WIN32 |
329 | VL_LIBS=-lutil | |
330 | endif | |
83fb7adf | 331 | endif |
c321f673 | 332 | |
1e43adfc | 333 | $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a |
11d9f695 | 334 | $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(VL_LIBS) |
626df76a FB |
335 | |
336 | sdl.o: sdl.c | |
337 | $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $< | |
338 | ||
9f059eca FB |
339 | sdlaudio.o: sdlaudio.c |
340 | $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $< | |
341 | ||
626df76a | 342 | depend: $(SRCS) |
16e9b7de | 343 | $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend |
626df76a FB |
344 | |
345 | # libqemu | |
346 | ||
347 | libqemu.a: $(LIBOBJS) | |
348 | rm -f $@ | |
349 | $(AR) rcs $@ $(LIBOBJS) | |
350 | ||
1e43adfc | 351 | translate.o: translate.c gen-op.h opc.h cpu.h |
626df76a | 352 | |
1e43adfc | 353 | translate-all.o: translate-all.c op.h opc.h cpu.h |
626df76a | 354 | |
1e43adfc | 355 | op.h: op.o $(DYNGEN) |
626df76a FB |
356 | $(DYNGEN) -o $@ $< |
357 | ||
1e43adfc | 358 | opc.h: op.o $(DYNGEN) |
626df76a FB |
359 | $(DYNGEN) -c -o $@ $< |
360 | ||
1e43adfc | 361 | gen-op.h: op.o $(DYNGEN) |
626df76a FB |
362 | $(DYNGEN) -g -o $@ $< |
363 | ||
1e43adfc | 364 | op.o: op.c |
626df76a FB |
365 | $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $< |
366 | ||
1e43adfc | 367 | helper.o: helper.c |
626df76a FB |
368 | $(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $< |
369 | ||
1e43adfc FB |
370 | ifeq ($(TARGET_ARCH), i386) |
371 | op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h | |
372 | endif | |
373 | ||
374 | ifeq ($(TARGET_ARCH), arm) | |
375 | op.o: op.c op_template.h | |
376 | endif | |
626df76a | 377 | |
1e43adfc | 378 | ifeq ($(TARGET_ARCH), sparc) |
e95c8d51 | 379 | op.o: op.c op_template.h op_mem.h |
1e43adfc | 380 | endif |
626df76a | 381 | |
728c9fd5 FB |
382 | ifeq ($(TARGET_ARCH), ppc) |
383 | op.o: op.c op_template.h op_mem.h | |
384 | op_helper.o: op_helper_mem.h | |
385 | endif | |
386 | ||
85571bc7 FB |
387 | mixeng.o: mixeng.c mixeng.h mixeng_template.h |
388 | ||
626df76a FB |
389 | %.o: %.c |
390 | $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $< | |
391 | ||
f72b519c FB |
392 | %.o: %.S |
393 | $(CC) $(DEFINES) -c -o $@ $< | |
394 | ||
626df76a | 395 | clean: |
7c1f25b4 | 396 | rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o |
1e43adfc FB |
397 | |
398 | install: all | |
9b14bb04 | 399 | ifneq ($(PROGS),) |
11d9f695 | 400 | install -m 755 -s $(PROGS) "$(bindir)" |
9b14bb04 | 401 | endif |
626df76a FB |
402 | |
403 | ifneq ($(wildcard .depend),) | |
404 | include .depend | |
405 | endif |