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