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