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