Merge commit 'd918f23efaf486293b96418fe5deaff8a5583304' into upstream-merge
[qemu-kvm/fedora.git] / Makefile
blob4385bd8ec6d30c2bef20bb349acf5f993cff666f
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 CPPFLAGS += -U_FORTIFY_SOURCE
26 LIBS=
27 ifdef CONFIG_STATIC
28 LDFLAGS += -static
29 endif
30 ifdef BUILD_DOCS
31 DOCS=qemu-doc.html qemu-tech.html qemu.1 qemu-img.1 qemu-nbd.8
32 else
33 DOCS=
34 endif
36 LIBS+=$(PTHREADLIBS)
37 LIBS+=$(CLOCKLIBS)
39 ifdef CONFIG_SOLARIS
40 LIBS+=-lsocket -lnsl -lresolv
41 endif
43 ifdef CONFIG_WIN32
44 LIBS+=-lwinmm -lws2_32 -liphlpapi
45 endif
47 build-all: $(TOOLS) $(DOCS) recurse-all
49 config-host.mak: configure
50 ifneq ($(wildcard config-host.mak),)
51 @echo $@ is out-of-date, running configure
52 @sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh
53 endif
55 SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory)
56 SUBDIR_RULES=$(patsubst %,subdir-%, $(TARGET_DIRS))
58 ifeq ($(KVM_KMOD),yes)
60 .PHONEY: kvm-kmod
62 all: kvm-kmod
64 kvm-kmod:
65 $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C kvm/kernel V="$(V)" )
68 endif
70 subdir-%:
71 $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" TARGET_DIR="$*/" all,)
73 $(filter %-softmmu,$(SUBDIR_RULES)): libqemu_common.a
74 $(filter %-user,$(SUBDIR_RULES)): libqemu_user.a
76 recurse-all: $(SUBDIR_RULES)
78 #######################################################################
79 # BLOCK_OBJS is code used by both qemu system emulation and qemu-img
81 BLOCK_OBJS=cutils.o cache-utils.o qemu-malloc.o qemu-option.o module.o
82 BLOCK_OBJS+=block/cow.o block/qcow.o aes.o block/vmdk.o block/cloop.o
83 BLOCK_OBJS+=block/dmg.o block/bochs.o block/vpc.o block/vvfat.o
84 BLOCK_OBJS+=block/qcow2.o block/qcow2-refcount.o block/qcow2-cluster.o
85 BLOCK_OBJS+=block/qcow2-snapshot.o
86 BLOCK_OBJS+=block/parallels.o block/nbd.o
87 BLOCK_OBJS+=nbd.o block.o aio.o
89 ifdef CONFIG_WIN32
90 BLOCK_OBJS += block/raw-win32.o
91 else
92 ifdef CONFIG_AIO
93 BLOCK_OBJS += posix-aio-compat.o
94 endif
95 BLOCK_OBJS += block/raw-posix.o
96 endif
98 ifdef CONFIG_CURL
99 BLOCK_OBJS += block/curl.o
100 endif
102 ifdef CONFIG_AIO
103 BLOCK_OBJS += compatfd.o
104 endif
106 ######################################################################
107 # libqemu_common.a: Target independent part of system emulation. The
108 # long term path is to suppress *all* target specific code in case of
109 # system emulation, i.e. a single QEMU executable should support all
110 # CPUs and machines.
112 OBJS=$(BLOCK_OBJS)
113 OBJS+=readline.o console.o
115 OBJS+=irq.o ptimer.o
116 OBJS+=i2c.o smbus.o smbus_eeprom.o max7310.o max111x.o wm8750.o
117 OBJS+=ssd0303.o ssd0323.o ads7846.o stellaris_input.o twl92230.o
118 OBJS+=tmp105.o lm832x.o eeprom93xx.o tsc2005.o
119 OBJS+=scsi-disk.o cdrom.o
120 OBJS+=scsi-generic.o
121 OBJS+=usb.o usb-hub.o usb-$(HOST_USB).o usb-hid.o usb-msd.o usb-wacom.o
122 OBJS+=usb-serial.o usb-net.o
123 OBJS+=sd.o ssi-sd.o
124 OBJS+=bt.o bt-host.o bt-vhci.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o usb-bt.o
125 OBJS+=bt-hci-csr.o
126 OBJS+=buffered_file.o migration.o migration-tcp.o net.o qemu-sockets.o
127 OBJS+=qemu-char.o aio.o net-checksum.o savevm.o cache-utils.o
128 OBJS+=msmouse.o ps2.o
129 OBJS+=qdev.o ssi.o
131 ifdef CONFIG_BRLAPI
132 OBJS+= baum.o
133 LIBS+=-lbrlapi
134 endif
136 ifdef CONFIG_WIN32
137 OBJS+=tap-win32.o
138 else
139 OBJS+=migration-exec.o
140 endif
142 AUDIO_OBJS = audio.o noaudio.o wavaudio.o mixeng.o
143 ifdef CONFIG_SDL
144 AUDIO_OBJS += sdlaudio.o
145 endif
146 ifdef CONFIG_OSS
147 AUDIO_OBJS += ossaudio.o
148 endif
149 ifdef CONFIG_COREAUDIO
150 AUDIO_OBJS += coreaudio.o
151 AUDIO_PT = yes
152 endif
153 ifdef CONFIG_ALSA
154 AUDIO_OBJS += alsaaudio.o
155 endif
156 ifdef CONFIG_DSOUND
157 AUDIO_OBJS += dsoundaudio.o
158 endif
159 ifdef CONFIG_FMOD
160 AUDIO_OBJS += fmodaudio.o
161 audio/audio.o audio/fmodaudio.o: CPPFLAGS := -I$(CONFIG_FMOD_INC) $(CPPFLAGS)
162 endif
163 ifdef CONFIG_ESD
164 AUDIO_PT = yes
165 AUDIO_PT_INT = yes
166 AUDIO_OBJS += esdaudio.o
167 endif
168 ifdef CONFIG_PA
169 AUDIO_PT = yes
170 AUDIO_PT_INT = yes
171 AUDIO_OBJS += paaudio.o
172 endif
173 ifdef AUDIO_PT
174 LDFLAGS += -pthread
175 endif
176 ifdef AUDIO_PT_INT
177 AUDIO_OBJS += audio_pt_int.o
178 endif
179 AUDIO_OBJS+= wavcapture.o
180 OBJS+=$(addprefix audio/, $(AUDIO_OBJS))
182 OBJS+=keymaps.o
183 ifdef CONFIG_SDL
184 OBJS+=sdl.o sdl_zoom.o x_keymap.o
185 endif
186 ifdef CONFIG_CURSES
187 OBJS+=curses.o
188 endif
189 OBJS+=vnc.o acl.o d3des.o
190 ifdef CONFIG_VNC_TLS
191 OBJS+=vnc-tls.o vnc-auth-vencrypt.o
192 endif
193 ifdef CONFIG_VNC_SASL
194 OBJS+=vnc-auth-sasl.o
195 endif
197 ifdef CONFIG_COCOA
198 OBJS+=cocoa.o
199 endif
201 ifdef CONFIG_IOTHREAD
202 OBJS+=qemu-thread.o
203 endif
205 ifdef CONFIG_SLIRP
206 CPPFLAGS+=-I$(SRC_PATH)/slirp
207 SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
208 slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
209 tcp_subr.o tcp_timer.o udp.o bootp.o tftp.o
210 OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
211 endif
213 LIBS+=$(VDE_LIBS)
215 # xen backend driver support
216 XEN_OBJS := xen_backend.o xen_devconfig.o
217 XEN_OBJS += xen_console.o xenfb.o xen_disk.o xen_nic.o
218 ifdef CONFIG_XEN
219 OBJS += $(XEN_OBJS)
220 endif
222 LIBS+=$(CURL_LIBS)
224 cocoa.o: cocoa.m
226 keymaps.o: keymaps.c keymaps.h
228 sdl_zoom.o: sdl_zoom.c sdl_zoom.h sdl_zoom_template.h
230 sdl.o: sdl.c keymaps.h sdl_keysym.h sdl_zoom.h
232 sdl.o audio/sdlaudio.o baum.o: CFLAGS += $(SDL_CFLAGS)
234 acl.o: acl.h acl.c
236 vnc.h: vnc-tls.h vnc-auth-vencrypt.h vnc-auth-sasl.h keymaps.h
238 vnc.o: vnc.c vnc.h vnc_keysym.h vnchextile.h d3des.c d3des.h acl.h
240 vnc.o: CFLAGS += $(CONFIG_VNC_TLS_CFLAGS)
242 vnc-tls.o: vnc-tls.c vnc.h
244 vnc-auth-vencrypt.o: vnc-auth-vencrypt.c vnc.h
246 vnc-auth-sasl.o: vnc-auth-sasl.c vnc.h
248 curses.o: curses.c keymaps.h curses_keys.h
250 bt-host.o: CFLAGS += $(CONFIG_BLUEZ_CFLAGS)
252 libqemu_common.a: $(OBJS)
254 #######################################################################
255 # USER_OBJS is code used by qemu userspace emulation
256 USER_OBJS=cutils.o cache-utils.o
258 libqemu_user.a: $(USER_OBJS)
260 ######################################################################
262 qemu-img.o: qemu-img-cmds.h
264 qemu-img$(EXESUF): qemu-img.o qemu-tool.o tool-osdep.o $(BLOCK_OBJS)
266 qemu-nbd$(EXESUF): qemu-nbd.o qemu-tool.o tool-osdep.o $(BLOCK_OBJS)
268 qemu-io$(EXESUF): qemu-io.o qemu-tool.o tool-osdep.o cmd.o $(BLOCK_OBJS)
270 qemu-img$(EXESUF) qemu-nbd$(EXESUF) qemu-io$(EXESUF): LIBS += -lz
272 qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx
273 $(call quiet-command,sh $(SRC_PATH)/hxtool -h < $< > $@," GEN $@")
275 clean:
276 # avoid old build problems by removing potentially incorrect old files
277 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
278 rm -f *.o *.d *.a $(TOOLS) TAGS cscope.* *.pod *~ */*~
279 rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d block/*.o block/*.d
280 rm -f qemu-img-cmds.h
281 $(MAKE) -C tests clean
282 for d in $(TARGET_DIRS) libhw32 libhw64; do \
283 $(MAKE) -C $$d $@ || exit 1 ; \
284 done
286 distclean: clean
287 rm -f config-host.mak config-host.h $(DOCS) qemu-options.texi qemu-img-cmds.texi
288 rm -f qemu-{doc,tech}.{info,aux,cp,dvi,fn,info,ky,log,pg,toc,tp,vr}
289 for d in $(TARGET_DIRS) libhw32 libhw64; do \
290 rm -rf $$d || exit 1 ; \
291 done
293 KEYMAPS=da en-gb et fr fr-ch is lt modifiers no pt-br sv \
294 ar de en-us fi fr-be hr it lv nl pl ru th \
295 common de-ch es fo fr-ca hu ja mk nl-be pt sl tr
297 ifdef INSTALL_BLOBS
298 BLOBS=bios.bin vgabios.bin vgabios-cirrus.bin ppc_rom.bin \
299 video.x openbios-sparc32 openbios-sparc64 openbios-ppc \
300 pxe-ne2k_pci.bin pxe-rtl8139.bin pxe-pcnet.bin pxe-e1000.bin \
301 bamboo.dtb petalogix-s3adsp1800.dtb
302 BLOBS += extboot.bin
303 else
304 BLOBS=
305 endif
307 install-doc: $(DOCS)
308 $(INSTALL_DIR) "$(DESTDIR)$(docdir)"
309 $(INSTALL_DATA) qemu-doc.html qemu-tech.html "$(DESTDIR)$(docdir)"
310 ifndef CONFIG_WIN32
311 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
312 $(INSTALL_DATA) qemu.1 qemu-img.1 "$(DESTDIR)$(mandir)/man1"
313 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8"
314 $(INSTALL_DATA) qemu-nbd.8 "$(DESTDIR)$(mandir)/man8"
315 endif
317 install: all $(if $(BUILD_DOCS),install-doc)
318 $(INSTALL_DIR) "$(DESTDIR)$(bindir)"
319 ifneq ($(TOOLS),)
320 $(INSTALL_PROG) $(STRIP_OPT) $(TOOLS) "$(DESTDIR)$(bindir)"
321 endif
322 ifneq ($(BLOBS),)
323 $(INSTALL_DIR) "$(DESTDIR)$(datadir)"
324 set -e; for x in $(BLOBS); do \
325 if [ -f $(SRC_PATH)/pc-bios/$$x ];then \
326 $(INSTALL_DATA) $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(datadir)"; \
327 fi \
328 done
329 endif
330 $(INSTALL_DIR) "$(DESTDIR)$(datadir)/keymaps"
331 set -e; for x in $(KEYMAPS); do \
332 $(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x "$(DESTDIR)$(datadir)/keymaps"; \
333 done
334 for d in $(TARGET_DIRS); do \
335 $(MAKE) -C $$d $@ || exit 1 ; \
336 done
337 ifeq ($(KVM_KMOD),yes)
338 $(MAKE) -C kvm/kernel $@
339 endif
341 # various test targets
342 test speed: all
343 $(MAKE) -C tests $@
345 TAGS:
346 etags *.[ch] tests/*.[ch]
348 cscope:
349 rm -f ./cscope.*
350 find . -name "*.[ch]" -print | sed 's,^\./,,' > ./cscope.files
351 cscope -b
353 # documentation
354 %.html: %.texi
355 $(call quiet-command,texi2html -I=. -monolithic -number $<," GEN $@")
357 %.info: %.texi
358 $(call quiet-command,makeinfo -I . $< -o $@," GEN $@")
360 %.dvi: %.texi
361 $(call quiet-command,texi2dvi -I . $<," GEN $@")
363 qemu-options.texi: $(SRC_PATH)/qemu-options.hx
364 $(call quiet-command,sh $(SRC_PATH)/hxtool -t < $< > $@," GEN $@")
366 qemu-monitor.texi: $(SRC_PATH)/qemu-monitor.hx
367 $(call quiet-command,sh $(SRC_PATH)/hxtool -t < $< > $@," GEN $@")
369 qemu-img-cmds.texi: $(SRC_PATH)/qemu-img-cmds.hx
370 $(call quiet-command,sh $(SRC_PATH)/hxtool -t < $< > $@," GEN $@")
372 qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi
373 $(call quiet-command, \
374 perl -Ww -- $(SRC_PATH)/texi2pod.pl $< qemu.pod && \
375 pod2man --section=1 --center=" " --release=" " qemu.pod > $@, \
376 " GEN $@")
378 qemu-img.1: qemu-img.texi qemu-img-cmds.texi
379 $(call quiet-command, \
380 perl -Ww -- $(SRC_PATH)/texi2pod.pl $< qemu-img.pod && \
381 pod2man --section=1 --center=" " --release=" " qemu-img.pod > $@, \
382 " GEN $@")
384 qemu-nbd.8: qemu-nbd.texi
385 $(call quiet-command, \
386 perl -Ww -- $(SRC_PATH)/texi2pod.pl $< qemu-nbd.pod && \
387 pod2man --section=8 --center=" " --release=" " qemu-nbd.pod > $@, \
388 " GEN $@")
390 info: qemu-doc.info qemu-tech.info
392 dvi: qemu-doc.dvi qemu-tech.dvi
394 html: qemu-doc.html qemu-tech.html
396 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
398 VERSION ?= $(shell cat VERSION)
399 FILE = qemu-$(VERSION)
401 # tar release (use 'make -k tar' on a checkouted tree)
402 tar:
403 rm -rf /tmp/$(FILE)
404 cp -r . /tmp/$(FILE)
405 cd /tmp && tar zcvf ~/$(FILE).tar.gz $(FILE) --exclude CVS --exclude .git --exclude .svn
406 rm -rf /tmp/$(FILE)
408 # generate a binary distribution
409 tarbin:
410 cd / && tar zcvf ~/qemu-$(VERSION)-$(ARCH).tar.gz \
411 $(bindir)/qemu \
412 $(bindir)/qemu-system-x86_64 \
413 $(bindir)/qemu-system-arm \
414 $(bindir)/qemu-system-cris \
415 $(bindir)/qemu-system-m68k \
416 $(bindir)/qemu-system-mips \
417 $(bindir)/qemu-system-mipsel \
418 $(bindir)/qemu-system-mips64 \
419 $(bindir)/qemu-system-mips64el \
420 $(bindir)/qemu-system-ppc \
421 $(bindir)/qemu-system-ppcemb \
422 $(bindir)/qemu-system-ppc64 \
423 $(bindir)/qemu-system-sh4 \
424 $(bindir)/qemu-system-sh4eb \
425 $(bindir)/qemu-system-sparc \
426 $(bindir)/qemu-i386 \
427 $(bindir)/qemu-x86_64 \
428 $(bindir)/qemu-alpha \
429 $(bindir)/qemu-arm \
430 $(bindir)/qemu-armeb \
431 $(bindir)/qemu-cris \
432 $(bindir)/qemu-m68k \
433 $(bindir)/qemu-mips \
434 $(bindir)/qemu-mipsel \
435 $(bindir)/qemu-ppc \
436 $(bindir)/qemu-ppc64 \
437 $(bindir)/qemu-ppc64abi32 \
438 $(bindir)/qemu-sh4 \
439 $(bindir)/qemu-sh4eb \
440 $(bindir)/qemu-sparc \
441 $(bindir)/qemu-sparc64 \
442 $(bindir)/qemu-sparc32plus \
443 $(bindir)/qemu-img \
444 $(bindir)/qemu-nbd \
445 $(datadir)/bios.bin \
446 $(datadir)/vgabios.bin \
447 $(datadir)/vgabios-cirrus.bin \
448 $(datadir)/ppc_rom.bin \
449 $(datadir)/video.x \
450 $(datadir)/openbios-sparc32 \
451 $(datadir)/openbios-sparc64 \
452 $(datadir)/openbios-ppc \
453 $(datadir)/pxe-ne2k_pci.bin \
454 $(datadir)/pxe-rtl8139.bin \
455 $(datadir)/pxe-pcnet.bin \
456 $(datadir)/pxe-e1000.bin \
457 $(datadir)/extboot.bin \
458 $(docdir)/qemu-doc.html \
459 $(docdir)/qemu-tech.html \
460 $(mandir)/man1/qemu.1 \
461 $(mandir)/man1/qemu-img.1 \
462 $(mandir)/man8/qemu-nbd.8
464 # Include automatically generated dependency files
465 -include $(wildcard *.d audio/*.d slirp/*.d block/*.d)
467 .PHONY: kvm/extboot
469 build-targets-i386 = $(build-targets-x86)
470 build-targets-x86_64 = $(build-targets-x86)
471 build-targets-x86 = kvm/extboot
472 build-targets-ia64 =
474 all: $(build-targets-$(ARCH))
476 kvm/extboot:
477 $(MAKE) -C $@
478 if ! [ -f pc-bios/extboot.bin ] \
479 || ! cmp -s pc-bios/extboot.bin $@/extboot.bin; then \
480 cp $@/extboot.bin pc-bios/extboot.bin; \