qemu: refactor main_loop (Marcelo Tosatti)
[qemu] / Makefile
1 # Makefile for QEMU.
2
3 ifneq ($(wildcard config-host.mak),)
4 include config-host.mak
5 include $(SRC_PATH)/rules.mak
6 else
7 config-host.mak:
8         @echo "Please call configure before running make!"
9         @exit 1
10 endif
11
12 .PHONY: all clean cscope distclean dvi html info install install-doc \
13         recurse-all speed tar tarbin test
14
15 VPATH=$(SRC_PATH):$(SRC_PATH)/hw
16
17
18 CFLAGS += $(OS_CFLAGS) $(ARCH_CFLAGS)
19 LDFLAGS += $(OS_LDFLAGS) $(ARCH_LDFLAGS)
20
21 CPPFLAGS += -I. -I$(SRC_PATH) -MMD -MP -MT $@
22 CPPFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
23 LIBS=
24 ifdef CONFIG_STATIC
25 LDFLAGS += -static
26 endif
27 ifdef BUILD_DOCS
28 DOCS=qemu-doc.html qemu-tech.html qemu.1 qemu-img.1 qemu-nbd.8
29 else
30 DOCS=
31 endif
32
33 LIBS+=$(PTHREADLIBS)
34 LIBS+=$(CLOCKLIBS)
35
36 ifdef CONFIG_SOLARIS
37 LIBS+=-lsocket -lnsl -lresolv
38 endif
39
40 ifdef CONFIG_WIN32
41 LIBS+=-lwinmm -lws2_32 -liphlpapi
42 endif
43
44 all: $(TOOLS) $(DOCS) recurse-all
45
46 config-host.mak: configure
47 ifneq ($(wildcard config-host.mak),)
48         @echo $@ is out-of-date, running configure
49         @sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh
50 endif
51
52 SUBDIR_RULES=$(patsubst %,subdir-%, $(TARGET_DIRS))
53
54 subdir-%:
55         $(call quiet-command,$(MAKE) -C $* V="$(V)" TARGET_DIR="$*/" all,)
56
57 $(filter %-softmmu,$(SUBDIR_RULES)): libqemu_common.a
58 $(filter %-user,$(SUBDIR_RULES)): libqemu_user.a
59
60 recurse-all: $(SUBDIR_RULES)
61
62 #######################################################################
63 # BLOCK_OBJS is code used by both qemu system emulation and qemu-img
64
65 BLOCK_OBJS=cutils.o qemu-malloc.o
66 BLOCK_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o
67 BLOCK_OBJS+=block-dmg.o block-bochs.o block-vpc.o block-vvfat.o
68 BLOCK_OBJS+=block-qcow2.o block-parallels.o block-nbd.o
69 BLOCK_OBJS+=nbd.o block.o aio.o
70
71 ifdef CONFIG_WIN32
72 BLOCK_OBJS += block-raw-win32.o
73 else
74 ifdef CONFIG_AIO
75 BLOCK_OBJS += posix-aio-compat.o
76 endif
77 BLOCK_OBJS += block-raw-posix.o
78 endif
79
80 ######################################################################
81 # libqemu_common.a: Target independent part of system emulation. The
82 # long term path is to suppress *all* target specific code in case of
83 # system emulation, i.e. a single QEMU executable should support all
84 # CPUs and machines.
85
86 OBJS=$(BLOCK_OBJS)
87 OBJS+=readline.o console.o
88
89 OBJS+=irq.o ptimer.o
90 OBJS+=i2c.o smbus.o smbus_eeprom.o max7310.o max111x.o wm8750.o
91 OBJS+=ssd0303.o ssd0323.o ads7846.o stellaris_input.o twl92230.o
92 OBJS+=tmp105.o lm832x.o eeprom93xx.o tsc2005.o
93 OBJS+=scsi-disk.o cdrom.o
94 OBJS+=scsi-generic.o
95 OBJS+=usb.o usb-hub.o usb-$(HOST_USB).o usb-hid.o usb-msd.o usb-wacom.o
96 OBJS+=usb-serial.o usb-net.o
97 OBJS+=sd.o ssi-sd.o
98 OBJS+=bt.o bt-host.o bt-vhci.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o usb-bt.o
99 OBJS+=bt-hci-csr.o
100 OBJS+=buffered_file.o migration.o migration-tcp.o net.o qemu-sockets.o
101 OBJS+=qemu-char.o aio.o net-checksum.o savevm.o cache-utils.o
102 OBJS+=msmouse.o ps2.o
103
104 ifdef CONFIG_BRLAPI
105 OBJS+= baum.o
106 LIBS+=-lbrlapi
107 endif
108
109 ifdef CONFIG_WIN32
110 OBJS+=tap-win32.o
111 else
112 OBJS+=migration-exec.o
113 endif
114
115 AUDIO_OBJS = audio.o noaudio.o wavaudio.o mixeng.o
116 ifdef CONFIG_SDL
117 AUDIO_OBJS += sdlaudio.o
118 endif
119 ifdef CONFIG_OSS
120 AUDIO_OBJS += ossaudio.o
121 endif
122 ifdef CONFIG_COREAUDIO
123 AUDIO_OBJS += coreaudio.o
124 AUDIO_PT = yes
125 endif
126 ifdef CONFIG_ALSA
127 AUDIO_OBJS += alsaaudio.o
128 endif
129 ifdef CONFIG_DSOUND
130 AUDIO_OBJS += dsoundaudio.o
131 endif
132 ifdef CONFIG_FMOD
133 AUDIO_OBJS += fmodaudio.o
134 audio/audio.o audio/fmodaudio.o: CPPFLAGS := -I$(CONFIG_FMOD_INC) $(CPPFLAGS)
135 endif
136 ifdef CONFIG_ESD
137 AUDIO_PT = yes
138 AUDIO_PT_INT = yes
139 AUDIO_OBJS += esdaudio.o
140 endif
141 ifdef CONFIG_PA
142 AUDIO_PT = yes
143 AUDIO_PT_INT = yes
144 AUDIO_OBJS += paaudio.o
145 endif
146 ifdef AUDIO_PT
147 LDFLAGS += -pthread
148 endif
149 ifdef AUDIO_PT_INT
150 AUDIO_OBJS += audio_pt_int.o
151 endif
152 AUDIO_OBJS+= wavcapture.o
153 OBJS+=$(addprefix audio/, $(AUDIO_OBJS))
154
155 OBJS+=keymaps.o
156 ifdef CONFIG_SDL
157 OBJS+=sdl.o x_keymap.o
158 endif
159 ifdef CONFIG_CURSES
160 OBJS+=curses.o
161 endif
162 OBJS+=vnc.o acl.o d3des.o
163 ifdef CONFIG_VNC_TLS
164 OBJS+=vnc-tls.o vnc-auth-vencrypt.o
165 endif
166 ifdef CONFIG_VNC_SASL
167 OBJS+=vnc-auth-sasl.o
168 endif
169
170 ifdef CONFIG_COCOA
171 OBJS+=cocoa.o
172 endif
173
174 ifdef CONFIG_IOTHREAD
175 OBJS+=qemu-thread.o
176 endif
177
178 ifdef CONFIG_SLIRP
179 CPPFLAGS+=-I$(SRC_PATH)/slirp
180 SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
181 slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
182 tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o
183 OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
184 endif
185
186 LIBS+=$(VDE_LIBS)
187
188 cocoa.o: cocoa.m
189
190 keymaps.o: keymaps.c keymaps.h
191
192 sdl.o: sdl.c keymaps.h sdl_keysym.h
193
194 sdl.o audio/sdlaudio.o: CFLAGS += $(SDL_CFLAGS)
195
196 acl.o: acl.h acl.c
197
198 vnc.h: vnc-tls.h vnc-auth-vencrypt.h vnc-auth-sasl.h keymaps.h
199
200 vnc.o: vnc.c vnc.h vnc_keysym.h vnchextile.h d3des.c d3des.h acl.h
201
202 vnc.o: CFLAGS += $(CONFIG_VNC_TLS_CFLAGS)
203
204 vnc-tls.o: vnc-tls.c vnc.h
205
206 vnc-auth-vencrypt.o: vnc-auth-vencrypt.c vnc.h
207
208 vnc-auth-sasl.o: vnc-auth-sasl.c vnc.h
209
210 curses.o: curses.c keymaps.h curses_keys.h
211
212 bt-host.o: CFLAGS += $(CONFIG_BLUEZ_CFLAGS)
213
214 libqemu_common.a: $(OBJS)
215
216 #######################################################################
217 # USER_OBJS is code used by qemu userspace emulation
218 USER_OBJS=cutils.o  cache-utils.o
219
220 libqemu_user.a: $(USER_OBJS)
221
222 ######################################################################
223
224 qemu-img$(EXESUF): qemu-img.o qemu-tool.o osdep.o $(BLOCK_OBJS)
225
226 qemu-nbd$(EXESUF):  qemu-nbd.o qemu-tool.o osdep.o $(BLOCK_OBJS)
227
228 qemu-io$(EXESUF):  qemu-io.o qemu-tool.o osdep.o cmd.o $(BLOCK_OBJS)
229
230 qemu-img$(EXESUF) qemu-nbd$(EXESUF) qemu-io$(EXESUF): LIBS += -lz
231
232 clean:
233 # avoid old build problems by removing potentially incorrect old files
234         rm -f config.mak config.h op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
235         rm -f *.o *.d *.a $(TOOLS) TAGS cscope.* *.pod *~ */*~
236         rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d
237         $(MAKE) -C tests clean
238         for d in $(TARGET_DIRS); do \
239         $(MAKE) -C $$d $@ || exit 1 ; \
240         done
241
242 distclean: clean
243         rm -f config-host.mak config-host.h $(DOCS) qemu-options.texi
244         rm -f qemu-{doc,tech}.{info,aux,cp,dvi,fn,info,ky,log,pg,toc,tp,vr}
245         for d in $(TARGET_DIRS); do \
246         rm -rf $$d || exit 1 ; \
247         done
248
249 KEYMAPS=da     en-gb  et  fr     fr-ch  is  lt  modifiers  no  pt-br  sv \
250 ar      de     en-us  fi  fr-be  hr     it  lv  nl         pl  ru     th \
251 common  de-ch  es     fo  fr-ca  hu     ja  mk  nl-be      pt  sl     tr
252
253 ifdef INSTALL_BLOBS
254 BLOBS=bios.bin vgabios.bin vgabios-cirrus.bin ppc_rom.bin \
255 video.x openbios-sparc32 openbios-sparc64 openbios-ppc \
256 pxe-ne2k_pci.bin pxe-rtl8139.bin pxe-pcnet.bin pxe-e1000.bin \
257 bamboo.dtb
258 else
259 BLOBS=
260 endif
261
262 install-doc: $(DOCS)
263         $(INSTALL_DIR) "$(DESTDIR)$(docdir)"
264         $(INSTALL_DATA) qemu-doc.html  qemu-tech.html "$(DESTDIR)$(docdir)"
265 ifndef CONFIG_WIN32
266         $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
267         $(INSTALL_DATA) qemu.1 qemu-img.1 "$(DESTDIR)$(mandir)/man1"
268         $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8"
269         $(INSTALL_DATA) qemu-nbd.8 "$(DESTDIR)$(mandir)/man8"
270 endif
271
272 install: all $(if $(BUILD_DOCS),install-doc)
273         $(INSTALL_DIR) "$(DESTDIR)$(bindir)"
274 ifneq ($(TOOLS),)
275         $(INSTALL_PROG) $(STRIP_OPT) $(TOOLS) "$(DESTDIR)$(bindir)"
276 endif
277 ifneq ($(BLOBS),)
278         $(INSTALL_DIR) "$(DESTDIR)$(datadir)"
279         set -e; for x in $(BLOBS); do \
280                 $(INSTALL_DATA) $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(datadir)"; \
281         done
282 endif
283 ifndef CONFIG_WIN32
284         $(INSTALL_DIR) "$(DESTDIR)$(datadir)/keymaps"
285         set -e; for x in $(KEYMAPS); do \
286                 $(INSTALL_DATA) $(SRC_PATH)/keymaps/$$x "$(DESTDIR)$(datadir)/keymaps"; \
287         done
288 endif
289         for d in $(TARGET_DIRS); do \
290         $(MAKE) -C $$d $@ || exit 1 ; \
291         done
292
293 # various test targets
294 test speed: all
295         $(MAKE) -C tests $@
296
297 TAGS:
298         etags *.[ch] tests/*.[ch]
299
300 cscope:
301         rm -f ./cscope.*
302         find . -name "*.[ch]" -print | sed 's,^\./,,' > ./cscope.files
303         cscope -b
304
305 # documentation
306 %.html: %.texi
307         $(call quiet-command,texi2html -I=. -monolithic -number $<,"  GEN   $@")
308
309 %.info: %.texi
310         $(call quiet-command,makeinfo -I . $< -o $@,"  GEN   $@")
311
312 %.dvi: %.texi
313         $(call quiet-command,texi2dvi -I . $<,"  GEN   $@")
314
315 qemu-options.texi: $(SRC_PATH)/qemu-options.hx
316         $(call quiet-command,sh $(SRC_PATH)/hxtool -t < $< > $@,"  GEN   $@")
317
318 qemu.1: qemu-doc.texi qemu-options.texi
319         $(call quiet-command, \
320           perl -Ww -- $(SRC_PATH)/texi2pod.pl $< qemu.pod && \
321           pod2man --section=1 --center=" " --release=" " qemu.pod > $@, \
322           "  GEN   $@")
323
324 qemu-img.1: qemu-img.texi
325         $(call quiet-command, \
326           perl -Ww -- $(SRC_PATH)/texi2pod.pl $< qemu-img.pod && \
327           pod2man --section=1 --center=" " --release=" " qemu-img.pod > $@, \
328           "  GEN   $@")
329
330 qemu-nbd.8: qemu-nbd.texi
331         $(call quiet-command, \
332           perl -Ww -- $(SRC_PATH)/texi2pod.pl $< qemu-nbd.pod && \
333           pod2man --section=8 --center=" " --release=" " qemu-nbd.pod > $@, \
334           "  GEN   $@")
335
336 info: qemu-doc.info qemu-tech.info
337
338 dvi: qemu-doc.dvi qemu-tech.dvi
339
340 html: qemu-doc.html qemu-tech.html
341
342 qemu-doc.dvi qemu-doc.html qemu-doc.info: qemu-img.texi qemu-nbd.texi qemu-options.texi
343
344 VERSION ?= $(shell cat VERSION)
345 FILE = qemu-$(VERSION)
346
347 # tar release (use 'make -k tar' on a checkouted tree)
348 tar:
349         rm -rf /tmp/$(FILE)
350         cp -r . /tmp/$(FILE)
351         cd /tmp && tar zcvf ~/$(FILE).tar.gz $(FILE) --exclude CVS --exclude .git --exclude .svn
352         rm -rf /tmp/$(FILE)
353
354 # generate a binary distribution
355 tarbin:
356         cd / && tar zcvf ~/qemu-$(VERSION)-$(ARCH).tar.gz \
357         $(bindir)/qemu \
358         $(bindir)/qemu-system-x86_64 \
359         $(bindir)/qemu-system-arm \
360         $(bindir)/qemu-system-cris \
361         $(bindir)/qemu-system-m68k \
362         $(bindir)/qemu-system-mips \
363         $(bindir)/qemu-system-mipsel \
364         $(bindir)/qemu-system-mips64 \
365         $(bindir)/qemu-system-mips64el \
366         $(bindir)/qemu-system-ppc \
367         $(bindir)/qemu-system-ppcemb \
368         $(bindir)/qemu-system-ppc64 \
369         $(bindir)/qemu-system-sh4 \
370         $(bindir)/qemu-system-sh4eb \
371         $(bindir)/qemu-system-sparc \
372         $(bindir)/qemu-i386 \
373         $(bindir)/qemu-x86_64 \
374         $(bindir)/qemu-alpha \
375         $(bindir)/qemu-arm \
376         $(bindir)/qemu-armeb \
377         $(bindir)/qemu-cris \
378         $(bindir)/qemu-m68k \
379         $(bindir)/qemu-mips \
380         $(bindir)/qemu-mipsel \
381         $(bindir)/qemu-ppc \
382         $(bindir)/qemu-ppc64 \
383         $(bindir)/qemu-ppc64abi32 \
384         $(bindir)/qemu-sh4 \
385         $(bindir)/qemu-sh4eb \
386         $(bindir)/qemu-sparc \
387         $(bindir)/qemu-sparc64 \
388         $(bindir)/qemu-sparc32plus \
389         $(bindir)/qemu-img \
390         $(bindir)/qemu-nbd \
391         $(datadir)/bios.bin \
392         $(datadir)/vgabios.bin \
393         $(datadir)/vgabios-cirrus.bin \
394         $(datadir)/ppc_rom.bin \
395         $(datadir)/video.x \
396         $(datadir)/openbios-sparc32 \
397         $(datadir)/openbios-sparc64 \
398         $(datadir)/openbios-ppc \
399         $(datadir)/pxe-ne2k_pci.bin \
400         $(datadir)/pxe-rtl8139.bin \
401         $(datadir)/pxe-pcnet.bin \
402         $(datadir)/pxe-e1000.bin \
403         $(docdir)/qemu-doc.html \
404         $(docdir)/qemu-tech.html \
405         $(mandir)/man1/qemu.1 \
406         $(mandir)/man1/qemu-img.1 \
407         $(mandir)/man8/qemu-nbd.8
408
409 # Include automatically generated dependency files
410 -include $(wildcard *.d audio/*.d slirp/*.d)