Merge branch 'master' of git://git.sv.gnu.org/qemu
[qemu-kvm/fedora.git] / Makefile
blob035bbbc67a68f6ed47267363774ba079ca1b8c7b
1 # Makefile for QEMU.
3 ifneq ($(wildcard config-host.mak),)
4 # Put the all: rule here so that config-host.mak can contain dependencies.
5 all: build-all
6 include config-host.mak
7 include $(SRC_PATH)/rules.mak
8 else
9 config-host.mak:
10 @echo "Please call configure before running make!"
11 @exit 1
12 endif
14 .PHONY: all clean cscope distclean dvi html info install install-doc \
15 recurse-all speed tar tarbin test
17 VPATH=$(SRC_PATH):$(SRC_PATH)/hw
20 CFLAGS += $(OS_CFLAGS) $(ARCH_CFLAGS)
21 LDFLAGS += $(OS_LDFLAGS) $(ARCH_LDFLAGS)
23 CPPFLAGS += -I. -I$(SRC_PATH) -MMD -MP -MT $@
24 CPPFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
25 LIBS=
26 ifdef CONFIG_STATIC
27 LDFLAGS += -static
28 endif
29 ifdef BUILD_DOCS
30 DOCS=qemu-doc.html qemu-tech.html qemu.1 qemu-img.1 qemu-nbd.8
31 else
32 DOCS=
33 endif
35 LIBS+=$(PTHREADLIBS)
36 LIBS+=$(CLOCKLIBS)
38 ifdef CONFIG_SOLARIS
39 LIBS+=-lsocket -lnsl -lresolv
40 endif
42 ifdef CONFIG_WIN32
43 LIBS+=-lwinmm -lws2_32 -liphlpapi
44 endif
46 build-all: $(TOOLS) $(DOCS) recurse-all
48 config-host.mak: configure
49 ifneq ($(wildcard config-host.mak),)
50 @echo $@ is out-of-date, running configure
51 @sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh
52 endif
54 SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory)
55 SUBDIR_RULES=$(patsubst %,subdir-%, $(TARGET_DIRS))
57 ifeq ($(KVM_KMOD),yes)
59 .PHONEY: kvm-kmod
61 all: kvm-kmod
63 kvm-kmod:
64 $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C kvm/kernel V="$(V)" )
67 endif
69 subdir-%:
70 $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" TARGET_DIR="$*/" all,)
72 $(filter %-softmmu,$(SUBDIR_RULES)): libqemu_common.a
73 $(filter %-user,$(SUBDIR_RULES)): libqemu_user.a
75 recurse-all: $(SUBDIR_RULES)
77 #######################################################################
78 # BLOCK_OBJS is code used by both qemu system emulation and qemu-img
80 BLOCK_OBJS=cutils.o cache-utils.o qemu-malloc.o qemu-option.o module.o
81 BLOCK_OBJS+=block/cow.o block/qcow.o aes.o block/vmdk.o block/cloop.o
82 BLOCK_OBJS+=block/dmg.o block/bochs.o block/vpc.o block/vvfat.o
83 BLOCK_OBJS+=block/qcow2.o block/qcow2-refcount.o block/qcow2-cluster.o
84 BLOCK_OBJS+=block/qcow2-snapshot.o
85 BLOCK_OBJS+=block/parallels.o block/nbd.o
86 BLOCK_OBJS+=nbd.o block.o aio.o
88 ifdef CONFIG_WIN32
89 BLOCK_OBJS += block/raw-win32.o
90 else
91 ifdef CONFIG_AIO
92 BLOCK_OBJS += posix-aio-compat.o
93 endif
94 BLOCK_OBJS += block/raw-posix.o
95 endif
97 ifdef CONFIG_CURL
98 BLOCK_OBJS += block/curl.o
99 endif
101 ifdef CONFIG_AIO
102 BLOCK_OBJS += compatfd.o
103 endif
105 ######################################################################
106 # libqemu_common.a: Target independent part of system emulation. The
107 # long term path is to suppress *all* target specific code in case of
108 # system emulation, i.e. a single QEMU executable should support all
109 # CPUs and machines.
111 OBJS=$(BLOCK_OBJS)
112 OBJS+=readline.o console.o
114 OBJS+=irq.o ptimer.o
115 OBJS+=i2c.o smbus.o smbus_eeprom.o max7310.o max111x.o wm8750.o
116 OBJS+=ssd0303.o ssd0323.o ads7846.o stellaris_input.o twl92230.o
117 OBJS+=tmp105.o lm832x.o eeprom93xx.o tsc2005.o
118 OBJS+=scsi-disk.o cdrom.o
119 OBJS+=scsi-generic.o
120 OBJS+=usb.o usb-hub.o usb-$(HOST_USB).o usb-hid.o usb-msd.o usb-wacom.o
121 OBJS+=usb-serial.o usb-net.o
122 OBJS+=sd.o ssi-sd.o
123 OBJS+=bt.o bt-host.o bt-vhci.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o usb-bt.o
124 OBJS+=bt-hci-csr.o
125 OBJS+=buffered_file.o migration.o migration-tcp.o net.o qemu-sockets.o
126 OBJS+=qemu-char.o aio.o net-checksum.o savevm.o cache-utils.o
127 OBJS+=msmouse.o ps2.o
128 OBJS+=qdev.o ssi.o
130 ifdef CONFIG_BRLAPI
131 OBJS+= baum.o
132 LIBS+=-lbrlapi
133 endif
135 ifdef CONFIG_WIN32
136 OBJS+=tap-win32.o
137 else
138 OBJS+=migration-exec.o
139 endif
141 AUDIO_OBJS = audio.o noaudio.o wavaudio.o mixeng.o
142 ifdef CONFIG_SDL
143 AUDIO_OBJS += sdlaudio.o
144 endif
145 ifdef CONFIG_OSS
146 AUDIO_OBJS += ossaudio.o
147 endif
148 ifdef CONFIG_COREAUDIO
149 AUDIO_OBJS += coreaudio.o
150 AUDIO_PT = yes
151 endif
152 ifdef CONFIG_ALSA
153 AUDIO_OBJS += alsaaudio.o
154 endif
155 ifdef CONFIG_DSOUND
156 AUDIO_OBJS += dsoundaudio.o
157 endif
158 ifdef CONFIG_FMOD
159 AUDIO_OBJS += fmodaudio.o
160 audio/audio.o audio/fmodaudio.o: CPPFLAGS := -I$(CONFIG_FMOD_INC) $(CPPFLAGS)
161 endif
162 ifdef CONFIG_ESD
163 AUDIO_PT = yes
164 AUDIO_PT_INT = yes
165 AUDIO_OBJS += esdaudio.o
166 endif
167 ifdef CONFIG_PA
168 AUDIO_PT = yes
169 AUDIO_PT_INT = yes
170 AUDIO_OBJS += paaudio.o
171 endif
172 ifdef AUDIO_PT
173 LDFLAGS += -pthread
174 endif
175 ifdef AUDIO_PT_INT
176 AUDIO_OBJS += audio_pt_int.o
177 endif
178 AUDIO_OBJS+= wavcapture.o
179 OBJS+=$(addprefix audio/, $(AUDIO_OBJS))
181 OBJS+=keymaps.o
182 ifdef CONFIG_SDL
183 OBJS+=sdl.o x_keymap.o
184 endif
185 ifdef CONFIG_CURSES
186 OBJS+=curses.o
187 endif
188 OBJS+=vnc.o acl.o d3des.o
189 ifdef CONFIG_VNC_TLS
190 OBJS+=vnc-tls.o vnc-auth-vencrypt.o
191 endif
192 ifdef CONFIG_VNC_SASL
193 OBJS+=vnc-auth-sasl.o
194 endif
196 ifdef CONFIG_COCOA
197 OBJS+=cocoa.o
198 endif
200 ifdef CONFIG_IOTHREAD
201 OBJS+=qemu-thread.o
202 endif
204 ifdef CONFIG_SLIRP
205 CPPFLAGS+=-I$(SRC_PATH)/slirp
206 SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
207 slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
208 tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o
209 OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
210 endif
212 LIBS+=$(VDE_LIBS)
214 # xen backend driver support
215 XEN_OBJS := xen_backend.o xen_devconfig.o
216 XEN_OBJS += xen_console.o xenfb.o xen_disk.o xen_nic.o
217 ifdef CONFIG_XEN
218 OBJS += $(XEN_OBJS)
219 endif
221 LIBS+=$(CURL_LIBS)
223 cocoa.o: cocoa.m
225 keymaps.o: keymaps.c keymaps.h
227 sdl.o: sdl.c keymaps.h sdl_keysym.h
229 sdl.o audio/sdlaudio.o baum.o: CFLAGS += $(SDL_CFLAGS)
231 acl.o: acl.h acl.c
233 vnc.h: vnc-tls.h vnc-auth-vencrypt.h vnc-auth-sasl.h keymaps.h
235 vnc.o: vnc.c vnc.h vnc_keysym.h vnchextile.h d3des.c d3des.h acl.h
237 vnc.o: CFLAGS += $(CONFIG_VNC_TLS_CFLAGS)
239 vnc-tls.o: vnc-tls.c vnc.h
241 vnc-auth-vencrypt.o: vnc-auth-vencrypt.c vnc.h
243 vnc-auth-sasl.o: vnc-auth-sasl.c vnc.h
245 curses.o: curses.c keymaps.h curses_keys.h
247 bt-host.o: CFLAGS += $(CONFIG_BLUEZ_CFLAGS)
249 libqemu_common.a: $(OBJS)
251 #######################################################################
252 # USER_OBJS is code used by qemu userspace emulation
253 USER_OBJS=cutils.o cache-utils.o
255 libqemu_user.a: $(USER_OBJS)
257 ######################################################################
259 qemu-img.o: qemu-img-cmds.h
261 qemu-img$(EXESUF): qemu-img.o qemu-tool.o tool-osdep.o $(BLOCK_OBJS)
263 qemu-nbd$(EXESUF): qemu-nbd.o qemu-tool.o tool-osdep.o $(BLOCK_OBJS)
265 qemu-io$(EXESUF): qemu-io.o qemu-tool.o tool-osdep.o cmd.o $(BLOCK_OBJS)
267 qemu-img$(EXESUF) qemu-nbd$(EXESUF) qemu-io$(EXESUF): LIBS += -lz
269 qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx
270 $(call quiet-command,sh $(SRC_PATH)/hxtool -h < $< > $@," GEN $@")
272 clean:
273 # avoid old build problems by removing potentially incorrect old files
274 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
275 rm -f *.o *.d *.a $(TOOLS) TAGS cscope.* *.pod *~ */*~
276 rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d block/*.o block/*.d
277 rm -f qemu-img-cmds.h
278 $(MAKE) -C tests clean
279 for d in $(TARGET_DIRS) libhw32 libhw64; do \
280 $(MAKE) -C $$d $@ || exit 1 ; \
281 done
283 distclean: clean
284 rm -f config-host.mak config-host.h $(DOCS) qemu-options.texi qemu-img-cmds.texi
285 rm -f qemu-{doc,tech}.{info,aux,cp,dvi,fn,info,ky,log,pg,toc,tp,vr}
286 for d in $(TARGET_DIRS) libhw32 libhw64; do \
287 rm -rf $$d || exit 1 ; \
288 done
290 KEYMAPS=da en-gb et fr fr-ch is lt modifiers no pt-br sv \
291 ar de en-us fi fr-be hr it lv nl pl ru th \
292 common de-ch es fo fr-ca hu ja mk nl-be pt sl tr
294 ifdef INSTALL_BLOBS
295 BLOBS=bios.bin vgabios.bin vgabios-cirrus.bin ppc_rom.bin \
296 video.x openbios-sparc32 openbios-sparc64 openbios-ppc \
297 pxe-ne2k_pci.bin pxe-rtl8139.bin pxe-pcnet.bin pxe-e1000.bin \
298 bamboo.dtb petalogix-s3adsp1800.dtb
299 BLOBS += extboot.bin
300 else
301 BLOBS=
302 endif
304 install-doc: $(DOCS)
305 $(INSTALL_DIR) "$(DESTDIR)$(docdir)"
306 $(INSTALL_DATA) qemu-doc.html qemu-tech.html "$(DESTDIR)$(docdir)"
307 ifndef CONFIG_WIN32
308 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
309 $(INSTALL_DATA) qemu.1 qemu-img.1 "$(DESTDIR)$(mandir)/man1"
310 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8"
311 $(INSTALL_DATA) qemu-nbd.8 "$(DESTDIR)$(mandir)/man8"
312 endif
314 install: all $(if $(BUILD_DOCS),install-doc)
315 $(INSTALL_DIR) "$(DESTDIR)$(bindir)"
316 ifneq ($(TOOLS),)
317 $(INSTALL_PROG) $(STRIP_OPT) $(TOOLS) "$(DESTDIR)$(bindir)"
318 endif
319 ifneq ($(BLOBS),)
320 $(INSTALL_DIR) "$(DESTDIR)$(datadir)"
321 set -e; for x in $(BLOBS); do \
322 if [ -f $(SRC_PATH)/pc-bios/$$x ];then \
323 $(INSTALL_DATA) $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(datadir)"; \
324 fi \
325 done
326 endif
327 ifndef CONFIG_WIN32
328 $(INSTALL_DIR) "$(DESTDIR)$(datadir)/keymaps"
329 set -e; for x in $(KEYMAPS); do \
330 $(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x "$(DESTDIR)$(datadir)/keymaps"; \
331 done
332 endif
333 for d in $(TARGET_DIRS); do \
334 $(MAKE) -C $$d $@ || exit 1 ; \
335 done
336 ifeq ($(KVM_KMOD),yes)
337 $(MAKE) -C kvm/kernel $@
338 endif
340 # various test targets
341 test speed: all
342 $(MAKE) -C tests $@
344 TAGS:
345 etags *.[ch] tests/*.[ch]
347 cscope:
348 rm -f ./cscope.*
349 find . -name "*.[ch]" -print | sed 's,^\./,,' > ./cscope.files
350 cscope -b
352 # documentation
353 %.html: %.texi
354 $(call quiet-command,texi2html -I=. -monolithic -number $<," GEN $@")
356 %.info: %.texi
357 $(call quiet-command,makeinfo -I . $< -o $@," GEN $@")
359 %.dvi: %.texi
360 $(call quiet-command,texi2dvi -I . $<," GEN $@")
362 qemu-options.texi: $(SRC_PATH)/qemu-options.hx
363 $(call quiet-command,sh $(SRC_PATH)/hxtool -t < $< > $@," GEN $@")
365 qemu-monitor.texi: $(SRC_PATH)/qemu-monitor.hx
366 $(call quiet-command,sh $(SRC_PATH)/hxtool -t < $< > $@," GEN $@")
368 qemu-img-cmds.texi: $(SRC_PATH)/qemu-img-cmds.hx
369 $(call quiet-command,sh $(SRC_PATH)/hxtool -t < $< > $@," GEN $@")
371 qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi
372 $(call quiet-command, \
373 perl -Ww -- $(SRC_PATH)/texi2pod.pl $< qemu.pod && \
374 pod2man --section=1 --center=" " --release=" " qemu.pod > $@, \
375 " GEN $@")
377 qemu-img.1: qemu-img.texi qemu-img-cmds.texi
378 $(call quiet-command, \
379 perl -Ww -- $(SRC_PATH)/texi2pod.pl $< qemu-img.pod && \
380 pod2man --section=1 --center=" " --release=" " qemu-img.pod > $@, \
381 " GEN $@")
383 qemu-nbd.8: qemu-nbd.texi
384 $(call quiet-command, \
385 perl -Ww -- $(SRC_PATH)/texi2pod.pl $< qemu-nbd.pod && \
386 pod2man --section=8 --center=" " --release=" " qemu-nbd.pod > $@, \
387 " GEN $@")
389 info: qemu-doc.info qemu-tech.info
391 dvi: qemu-doc.dvi qemu-tech.dvi
393 html: qemu-doc.html qemu-tech.html
395 qemu-doc.dvi qemu-doc.html qemu-doc.info: qemu-img.texi qemu-nbd.texi qemu-options.texi qemu-monitor.texi qemu-img-cmds.texi
397 VERSION ?= $(shell cat VERSION)
398 FILE = qemu-$(VERSION)
400 # tar release (use 'make -k tar' on a checkouted tree)
401 tar:
402 rm -rf /tmp/$(FILE)
403 cp -r . /tmp/$(FILE)
404 cd /tmp && tar zcvf ~/$(FILE).tar.gz $(FILE) --exclude CVS --exclude .git --exclude .svn
405 rm -rf /tmp/$(FILE)
407 # generate a binary distribution
408 tarbin:
409 cd / && tar zcvf ~/qemu-$(VERSION)-$(ARCH).tar.gz \
410 $(bindir)/qemu \
411 $(bindir)/qemu-system-x86_64 \
412 $(bindir)/qemu-system-arm \
413 $(bindir)/qemu-system-cris \
414 $(bindir)/qemu-system-m68k \
415 $(bindir)/qemu-system-mips \
416 $(bindir)/qemu-system-mipsel \
417 $(bindir)/qemu-system-mips64 \
418 $(bindir)/qemu-system-mips64el \
419 $(bindir)/qemu-system-ppc \
420 $(bindir)/qemu-system-ppcemb \
421 $(bindir)/qemu-system-ppc64 \
422 $(bindir)/qemu-system-sh4 \
423 $(bindir)/qemu-system-sh4eb \
424 $(bindir)/qemu-system-sparc \
425 $(bindir)/qemu-i386 \
426 $(bindir)/qemu-x86_64 \
427 $(bindir)/qemu-alpha \
428 $(bindir)/qemu-arm \
429 $(bindir)/qemu-armeb \
430 $(bindir)/qemu-cris \
431 $(bindir)/qemu-m68k \
432 $(bindir)/qemu-mips \
433 $(bindir)/qemu-mipsel \
434 $(bindir)/qemu-ppc \
435 $(bindir)/qemu-ppc64 \
436 $(bindir)/qemu-ppc64abi32 \
437 $(bindir)/qemu-sh4 \
438 $(bindir)/qemu-sh4eb \
439 $(bindir)/qemu-sparc \
440 $(bindir)/qemu-sparc64 \
441 $(bindir)/qemu-sparc32plus \
442 $(bindir)/qemu-img \
443 $(bindir)/qemu-nbd \
444 $(datadir)/bios.bin \
445 $(datadir)/vgabios.bin \
446 $(datadir)/vgabios-cirrus.bin \
447 $(datadir)/ppc_rom.bin \
448 $(datadir)/video.x \
449 $(datadir)/openbios-sparc32 \
450 $(datadir)/openbios-sparc64 \
451 $(datadir)/openbios-ppc \
452 $(datadir)/pxe-ne2k_pci.bin \
453 $(datadir)/pxe-rtl8139.bin \
454 $(datadir)/pxe-pcnet.bin \
455 $(datadir)/pxe-e1000.bin \
456 $(datadir)/extboot.bin \
457 $(docdir)/qemu-doc.html \
458 $(docdir)/qemu-tech.html \
459 $(mandir)/man1/qemu.1 \
460 $(mandir)/man1/qemu-img.1 \
461 $(mandir)/man8/qemu-nbd.8
463 # Include automatically generated dependency files
464 -include $(wildcard *.d audio/*.d slirp/*.d block/*.d)
466 .PHONY: kvm/extboot
468 build-targets-i386 = $(build-targets-x86)
469 build-targets-x86_64 = $(build-targets-x86)
470 build-targets-x86 = kvm/extboot
471 build-targets-ia64 =
473 all: $(build-targets-$(ARCH))
475 kvm/extboot:
476 $(MAKE) -C $@
477 if ! [ -f pc-bios/extboot.bin ] \
478 || ! cmp -s pc-bios/extboot.bin $@/extboot.bin; then \
479 cp $@/extboot.bin pc-bios/extboot.bin; \