Merge commit 'a62acdc0cc5308706e2503557a09828979b59a12' into upstream-merge
[qemu-kvm/fedora.git] / Makefile
blob5c98108be7d0050cd646c8ca3c4ade11e14650a5
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) roms 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-obj-y is code used by both qemu system emulation and qemu-img
81 block-obj-y = cutils.o cache-utils.o qemu-malloc.o qemu-option.o module.o
82 block-obj-y += block/cow.o block/qcow.o aes.o block/vmdk.o block/cloop.o
83 block-obj-y += block/dmg.o block/bochs.o block/vpc.o block/vvfat.o
84 block-obj-y += block/qcow2.o block/qcow2-refcount.o block/qcow2-cluster.o
85 block-obj-y += block/qcow2-snapshot.o
86 block-obj-y += block/parallels.o block/nbd.o
87 block-obj-y += nbd.o block.o aio.o
89 ifdef CONFIG_WIN32
90 block-obj-y += block/raw-win32.o
91 else
92 ifdef CONFIG_AIO
93 block-obj-y += posix-aio-compat.o
94 endif
95 block-obj-y += block/raw-posix.o
96 endif
98 block-obj-$(CONFIG_CURL) += block/curl.o
100 ifdef CONFIG_AIO
101 block-obj-y += compatfd.o
102 endif
104 ######################################################################
105 # libqemu_common.a: Target independent part of system emulation. The
106 # long term path is to suppress *all* target specific code in case of
107 # system emulation, i.e. a single QEMU executable should support all
108 # CPUs and machines.
110 obj-y = $(block-obj-y)
111 obj-y += readline.o console.o
113 obj-y += irq.o ptimer.o
114 obj-y += i2c.o smbus.o smbus_eeprom.o max7310.o max111x.o wm8750.o
115 obj-y += ssd0303.o ssd0323.o ads7846.o stellaris_input.o twl92230.o
116 obj-y += tmp105.o lm832x.o eeprom93xx.o tsc2005.o
117 obj-y += scsi-disk.o cdrom.o
118 obj-y += scsi-generic.o
119 obj-y += usb.o usb-hub.o usb-$(HOST_USB).o usb-hid.o usb-msd.o usb-wacom.o
120 obj-y += usb-serial.o usb-net.o
121 obj-y += sd.o ssi-sd.o
122 obj-y += bt.o bt-host.o bt-vhci.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o usb-bt.o
123 obj-y += bt-hci-csr.o
124 obj-y += buffered_file.o migration.o migration-tcp.o net.o qemu-sockets.o
125 obj-y += qemu-char.o aio.o net-checksum.o savevm.o cache-utils.o
126 obj-y += msmouse.o ps2.o
127 obj-y += qdev.o ssi.o
129 obj-$(CONFIG_BRLAPI) += baum.o
131 ifdef CONFIG_BRLAPI
132 LIBS+=-lbrlapi
133 endif
135 ifdef CONFIG_WIN32
136 obj-y += tap-win32.o
137 else
138 obj-y += migration-exec.o
139 endif
141 ifdef CONFIG_COREAUDIO
142 AUDIO_PT = yes
143 endif
144 ifdef CONFIG_FMOD
145 audio/audio.o audio/fmodaudio.o: CPPFLAGS := -I$(CONFIG_FMOD_INC) $(CPPFLAGS)
146 endif
147 ifdef CONFIG_ESD
148 AUDIO_PT = yes
149 AUDIO_PT_INT = yes
150 endif
151 ifdef CONFIG_PA
152 AUDIO_PT = yes
153 AUDIO_PT_INT = yes
154 endif
155 ifdef AUDIO_PT
156 LDFLAGS += -pthread
157 endif
159 audio-obj-y = audio.o noaudio.o wavaudio.o mixeng.o
160 audio-obj-$(CONFIG_SDL) += sdlaudio.o
161 audio-obj-$(CONFIG_OSS) += ossaudio.o
162 audio-obj-$(CONFIG_COREAUDIO) += coreaudio.o
163 audio-obj-$(CONFIG_ALSA) += alsaaudio.o
164 audio-obj-$(CONFIG_DSOUND) += dsoundaudio.o
165 audio-obj-$(CONFIG_FMOD) += fmodaudio.o
166 audio-obj-$(CONFIG_ESD) += esdaudio.o
167 audio-obj-$(CONFIG_PA) += paaudio.o
168 audio-obj-$(AUDIO_PT_INT) += audio_pt_int.o
169 audio-obj-y += wavcapture.o
170 obj-y += $(addprefix audio/, $(audio-obj-y))
172 obj-y += keymaps.o
173 obj-$(CONFIG_SDL) += sdl.o sdl_zoom.o x_keymap.o
174 obj-$(CONFIG_CURSES) += curses.o
175 obj-y += vnc.o acl.o d3des.o
176 obj-$(CONFIG_VNC_TLS) += vnc-tls.o vnc-auth-vencrypt.o
177 obj-$(CONFIG_VNC_SASL) += vnc-auth-sasl.o
178 obj-$(CONFIG_COCOA) += cocoa.o
179 obj-$(CONFIG_IOTHREAD) += qemu-thread.o
181 ifdef CONFIG_SLIRP
182 CPPFLAGS+=-I$(SRC_PATH)/slirp
183 endif
185 slirp-obj-y = cksum.o if.o ip_icmp.o ip_input.o ip_output.o
186 slirp-obj-y += slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o
187 slirp-obj-y += tcp_subr.o tcp_timer.o udp.o bootp.o tftp.o
188 obj-$(CONFIG_SLIRP) += $(addprefix slirp/, $(slirp-obj-y))
190 LIBS+=$(VDE_LIBS)
192 # xen backend driver support
193 obj-$(CONFIG_XEN) += xen_backend.o xen_devconfig.o
194 obj-$(CONFIG_XEN) += xen_console.o xenfb.o xen_disk.o xen_nic.o
196 LIBS+=$(CURL_LIBS)
198 cocoa.o: cocoa.m
200 keymaps.o: keymaps.c keymaps.h
202 sdl_zoom.o: sdl_zoom.c sdl_zoom.h sdl_zoom_template.h
204 sdl.o: sdl.c keymaps.h sdl_keysym.h sdl_zoom.h
206 sdl.o audio/sdlaudio.o baum.o: CFLAGS += $(SDL_CFLAGS)
208 acl.o: acl.h acl.c
210 vnc.h: vnc-tls.h vnc-auth-vencrypt.h vnc-auth-sasl.h keymaps.h
212 vnc.o: vnc.c vnc.h vnc_keysym.h vnchextile.h d3des.c d3des.h acl.h
214 vnc.o: CFLAGS += $(CONFIG_VNC_TLS_CFLAGS)
216 vnc-tls.o: vnc-tls.c vnc.h
218 vnc-auth-vencrypt.o: vnc-auth-vencrypt.c vnc.h
220 vnc-auth-sasl.o: vnc-auth-sasl.c vnc.h
222 curses.o: curses.c keymaps.h curses_keys.h
224 bt-host.o: CFLAGS += $(CONFIG_BLUEZ_CFLAGS)
226 libqemu_common.a: $(obj-y)
228 #######################################################################
229 # user-obj-y is code used by qemu userspace emulation
230 user-obj-y = cutils.o cache-utils.o
232 libqemu_user.a: $(user-obj-y)
234 ######################################################################
236 qemu-img.o: qemu-img-cmds.h
238 qemu-img$(EXESUF): qemu-img.o qemu-tool.o tool-osdep.o $(block-obj-y)
240 qemu-nbd$(EXESUF): qemu-nbd.o qemu-tool.o tool-osdep.o $(block-obj-y)
242 qemu-io$(EXESUF): qemu-io.o qemu-tool.o tool-osdep.o cmd.o $(block-obj-y)
244 qemu-img$(EXESUF) qemu-nbd$(EXESUF) qemu-io$(EXESUF): LIBS += -lz
246 qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx
247 $(call quiet-command,sh $(SRC_PATH)/hxtool -h < $< > $@," GEN $@")
249 clean:
250 # avoid old build problems by removing potentially incorrect old files
251 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
252 rm -f *.o *.d *.a $(TOOLS) TAGS cscope.* *.pod *~ */*~
253 rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d block/*.o block/*.d
254 rm -f qemu-img-cmds.h
255 $(MAKE) -C tests clean
256 for d in $(TARGET_DIRS) $(ROMS) libhw32 libhw64; do \
257 $(MAKE) -C $$d $@ || exit 1 ; \
258 done
260 distclean: clean
261 rm -f config-host.mak config-host.h $(DOCS) qemu-options.texi qemu-img-cmds.texi
262 rm -f qemu-{doc,tech}.{info,aux,cp,dvi,fn,info,ky,log,pg,toc,tp,vr}
263 for d in $(TARGET_DIRS) libhw32 libhw64; do \
264 rm -rf $$d || exit 1 ; \
265 done
267 KEYMAPS=da en-gb et fr fr-ch is lt modifiers no pt-br sv \
268 ar de en-us fi fr-be hr it lv nl pl ru th \
269 common de-ch es fo fr-ca hu ja mk nl-be pt sl tr
271 ifdef INSTALL_BLOBS
272 BLOBS=bios.bin vgabios.bin vgabios-cirrus.bin ppc_rom.bin \
273 video.x openbios-sparc32 openbios-sparc64 openbios-ppc \
274 pxe-ne2k_pci.bin pxe-rtl8139.bin pxe-pcnet.bin pxe-e1000.bin \
275 bamboo.dtb petalogix-s3adsp1800.dtb \
276 multiboot.bin
277 BLOBS += extboot.bin
278 else
279 BLOBS=
280 endif
282 roms:
283 for d in $(ROMS); do \
284 $(MAKE) -C $$d || exit 1 ; \
285 done
287 install-doc: $(DOCS)
288 $(INSTALL_DIR) "$(DESTDIR)$(docdir)"
289 $(INSTALL_DATA) qemu-doc.html qemu-tech.html "$(DESTDIR)$(docdir)"
290 ifndef CONFIG_WIN32
291 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
292 $(INSTALL_DATA) qemu.1 qemu-img.1 "$(DESTDIR)$(mandir)/man1"
293 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8"
294 $(INSTALL_DATA) qemu-nbd.8 "$(DESTDIR)$(mandir)/man8"
295 endif
297 install: all $(if $(BUILD_DOCS),install-doc)
298 $(INSTALL_DIR) "$(DESTDIR)$(bindir)"
299 ifneq ($(TOOLS),)
300 $(INSTALL_PROG) $(STRIP_OPT) $(TOOLS) "$(DESTDIR)$(bindir)"
301 endif
302 ifneq ($(BLOBS),)
303 $(INSTALL_DIR) "$(DESTDIR)$(datadir)"
304 set -e; for x in $(BLOBS); do \
305 if [ -f $(SRC_PATH)/pc-bios/$$x ];then \
306 $(INSTALL_DATA) $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(datadir)"; \
307 fi \
308 done
309 endif
310 $(INSTALL_DIR) "$(DESTDIR)$(datadir)/keymaps"
311 set -e; for x in $(KEYMAPS); do \
312 $(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x "$(DESTDIR)$(datadir)/keymaps"; \
313 done
314 for d in $(TARGET_DIRS); do \
315 $(MAKE) -C $$d $@ || exit 1 ; \
316 done
317 ifeq ($(KVM_KMOD),yes)
318 $(MAKE) -C kvm/kernel $@
319 endif
321 # various test targets
322 test speed: all
323 $(MAKE) -C tests $@
325 TAGS:
326 etags *.[ch] tests/*.[ch] block/*.[ch] hw/*.[ch]
328 cscope:
329 rm -f ./cscope.*
330 find . -name "*.[ch]" -print | sed 's,^\./,,' > ./cscope.files
331 cscope -b
333 # documentation
334 %.html: %.texi
335 $(call quiet-command,texi2html -I=. -monolithic -number $<," GEN $@")
337 %.info: %.texi
338 $(call quiet-command,makeinfo -I . $< -o $@," GEN $@")
340 %.dvi: %.texi
341 $(call quiet-command,texi2dvi -I . $<," GEN $@")
343 qemu-options.texi: $(SRC_PATH)/qemu-options.hx
344 $(call quiet-command,sh $(SRC_PATH)/hxtool -t < $< > $@," GEN $@")
346 qemu-monitor.texi: $(SRC_PATH)/qemu-monitor.hx
347 $(call quiet-command,sh $(SRC_PATH)/hxtool -t < $< > $@," GEN $@")
349 qemu-img-cmds.texi: $(SRC_PATH)/qemu-img-cmds.hx
350 $(call quiet-command,sh $(SRC_PATH)/hxtool -t < $< > $@," GEN $@")
352 qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi
353 $(call quiet-command, \
354 perl -Ww -- $(SRC_PATH)/texi2pod.pl $< qemu.pod && \
355 pod2man --section=1 --center=" " --release=" " qemu.pod > $@, \
356 " GEN $@")
358 qemu-img.1: qemu-img.texi qemu-img-cmds.texi
359 $(call quiet-command, \
360 perl -Ww -- $(SRC_PATH)/texi2pod.pl $< qemu-img.pod && \
361 pod2man --section=1 --center=" " --release=" " qemu-img.pod > $@, \
362 " GEN $@")
364 qemu-nbd.8: qemu-nbd.texi
365 $(call quiet-command, \
366 perl -Ww -- $(SRC_PATH)/texi2pod.pl $< qemu-nbd.pod && \
367 pod2man --section=8 --center=" " --release=" " qemu-nbd.pod > $@, \
368 " GEN $@")
370 info: qemu-doc.info qemu-tech.info
372 dvi: qemu-doc.dvi qemu-tech.dvi
374 html: qemu-doc.html qemu-tech.html
376 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
378 VERSION ?= $(shell cat VERSION)
379 FILE = qemu-$(VERSION)
381 # tar release (use 'make -k tar' on a checkouted tree)
382 tar:
383 rm -rf /tmp/$(FILE)
384 cp -r . /tmp/$(FILE)
385 cd /tmp && tar zcvf ~/$(FILE).tar.gz $(FILE) --exclude CVS --exclude .git --exclude .svn
386 rm -rf /tmp/$(FILE)
388 # generate a binary distribution
389 tarbin:
390 cd / && tar zcvf ~/qemu-$(VERSION)-$(ARCH).tar.gz \
391 $(bindir)/qemu \
392 $(bindir)/qemu-system-x86_64 \
393 $(bindir)/qemu-system-arm \
394 $(bindir)/qemu-system-cris \
395 $(bindir)/qemu-system-m68k \
396 $(bindir)/qemu-system-mips \
397 $(bindir)/qemu-system-mipsel \
398 $(bindir)/qemu-system-mips64 \
399 $(bindir)/qemu-system-mips64el \
400 $(bindir)/qemu-system-ppc \
401 $(bindir)/qemu-system-ppcemb \
402 $(bindir)/qemu-system-ppc64 \
403 $(bindir)/qemu-system-sh4 \
404 $(bindir)/qemu-system-sh4eb \
405 $(bindir)/qemu-system-sparc \
406 $(bindir)/qemu-i386 \
407 $(bindir)/qemu-x86_64 \
408 $(bindir)/qemu-alpha \
409 $(bindir)/qemu-arm \
410 $(bindir)/qemu-armeb \
411 $(bindir)/qemu-cris \
412 $(bindir)/qemu-m68k \
413 $(bindir)/qemu-mips \
414 $(bindir)/qemu-mipsel \
415 $(bindir)/qemu-ppc \
416 $(bindir)/qemu-ppc64 \
417 $(bindir)/qemu-ppc64abi32 \
418 $(bindir)/qemu-sh4 \
419 $(bindir)/qemu-sh4eb \
420 $(bindir)/qemu-sparc \
421 $(bindir)/qemu-sparc64 \
422 $(bindir)/qemu-sparc32plus \
423 $(bindir)/qemu-img \
424 $(bindir)/qemu-nbd \
425 $(datadir)/bios.bin \
426 $(datadir)/vgabios.bin \
427 $(datadir)/vgabios-cirrus.bin \
428 $(datadir)/ppc_rom.bin \
429 $(datadir)/video.x \
430 $(datadir)/openbios-sparc32 \
431 $(datadir)/openbios-sparc64 \
432 $(datadir)/openbios-ppc \
433 $(datadir)/pxe-ne2k_pci.bin \
434 $(datadir)/pxe-rtl8139.bin \
435 $(datadir)/pxe-pcnet.bin \
436 $(datadir)/pxe-e1000.bin \
437 $(datadir)/extboot.bin \
438 $(docdir)/qemu-doc.html \
439 $(docdir)/qemu-tech.html \
440 $(mandir)/man1/qemu.1 \
441 $(mandir)/man1/qemu-img.1 \
442 $(mandir)/man8/qemu-nbd.8
444 # Include automatically generated dependency files
445 -include $(wildcard *.d audio/*.d slirp/*.d block/*.d)
447 .PHONY: kvm/extboot
449 build-targets-i386 = $(build-targets-x86)
450 build-targets-x86_64 = $(build-targets-x86)
451 build-targets-x86 = kvm/extboot
452 build-targets-ia64 =
454 all: $(build-targets-$(ARCH))
456 kvm/extboot:
457 $(MAKE) -C $@
458 if ! [ -f pc-bios/extboot.bin ] \
459 || ! cmp -s pc-bios/extboot.bin $@/extboot.bin; then \
460 cp $@/extboot.bin pc-bios/extboot.bin; \