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