Fix preprocessor guard condition
[qemu-kvm/fedora.git] / Makefile
blobfcf8a5820f2d16f90afba5113353a82a4e543eac
1 # Makefile for QEMU.
3 include config-host.mak
5 .PHONY: all clean distclean dvi info install install-doc tar tarbin \
6 speed test html dvi info
8 VPATH=$(SRC_PATH):$(SRC_PATH)/hw
10 CFLAGS += $(OS_CFLAGS) $(ARCH_CFLAGS)
11 LDFLAGS += $(OS_LDFLAGS) $(ARCH_LDFLAGS)
13 CPPFLAGS += -I. -I$(SRC_PATH) -MMD -MP -MT $@
14 CPPFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
15 LIBS=
16 ifdef CONFIG_STATIC
17 LDFLAGS += -static
18 endif
19 ifdef BUILD_DOCS
20 DOCS=qemu-doc.html qemu-tech.html qemu.1 qemu-img.1 qemu-nbd.8
21 else
22 DOCS=
23 endif
25 LIBS+=$(AIOLIBS)
27 all: $(TOOLS) $(DOCS) recurse-all
29 SUBDIR_RULES=$(patsubst %,subdir-%, $(TARGET_DIRS))
31 subdir-%: dyngen$(EXESUF)
32 $(MAKE) -C $(subst subdir-,,$@) all
34 $(filter %-softmmu,$(SUBDIR_RULES)): libqemu_common.a
35 $(filter %-user,$(SUBDIR_RULES)): libqemu_user.a
37 recurse-all: $(SUBDIR_RULES)
39 #######################################################################
40 # BLOCK_OBJS is code used by both qemu system emulation and qemu-img
42 BLOCK_OBJS=cutils.o qemu-malloc.o
43 BLOCK_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o
44 BLOCK_OBJS+=block-dmg.o block-bochs.o block-vpc.o block-vvfat.o
45 BLOCK_OBJS+=block-qcow2.o block-parallels.o block-nbd.o
47 ######################################################################
48 # libqemu_common.a: Target independent part of system emulation. The
49 # long term path is to suppress *all* target specific code in case of
50 # system emulation, i.e. a single QEMU executable should support all
51 # CPUs and machines.
53 OBJS=nbd.o $(BLOCK_OBJS)
54 OBJS+=readline.o console.o
55 OBJS+=block.o
57 OBJS+=irq.o
58 OBJS+=i2c.o smbus.o smbus_eeprom.o max7310.o max111x.o wm8750.o
59 OBJS+=ssd0303.o ssd0323.o ads7846.o stellaris_input.o twl92230.o
60 OBJS+=tmp105.o lm832x.o
61 OBJS+=scsi-disk.o cdrom.o
62 OBJS+=scsi-generic.o
63 OBJS+=usb.o usb-hub.o usb-linux.o usb-hid.o usb-msd.o usb-wacom.o
64 OBJS+=usb-serial.o usb-net.o
65 OBJS+=sd.o ssi-sd.o
67 ifdef CONFIG_BRLAPI
68 OBJS+= baum.o
69 LIBS+=-lbrlapi
70 endif
72 ifdef CONFIG_WIN32
73 OBJS+=tap-win32.o
74 endif
76 AUDIO_OBJS = audio.o noaudio.o wavaudio.o mixeng.o
77 ifdef CONFIG_SDL
78 AUDIO_OBJS += sdlaudio.o
79 endif
80 ifdef CONFIG_OSS
81 AUDIO_OBJS += ossaudio.o
82 endif
83 ifdef CONFIG_COREAUDIO
84 AUDIO_OBJS += coreaudio.o
85 AUDIO_PT = yes
86 endif
87 ifdef CONFIG_ALSA
88 AUDIO_OBJS += alsaaudio.o
89 endif
90 ifdef CONFIG_DSOUND
91 AUDIO_OBJS += dsoundaudio.o
92 endif
93 ifdef CONFIG_FMOD
94 AUDIO_OBJS += fmodaudio.o
95 audio/audio.o audio/fmodaudio.o: CPPFLAGS := -I$(CONFIG_FMOD_INC) $(CPPFLAGS)
96 endif
97 ifdef CONFIG_ESD
98 AUDIO_PT = yes
99 AUDIO_PT_INT = yes
100 AUDIO_OBJS += esdaudio.o
101 endif
102 ifdef CONFIG_PA
103 AUDIO_PT = yes
104 AUDIO_PT_INT = yes
105 AUDIO_OBJS += paaudio.o
106 endif
107 ifdef AUDIO_PT
108 LDFLAGS += -pthread
109 endif
110 ifdef AUDIO_PT_INT
111 AUDIO_OBJS += audio_pt_int.o
112 endif
113 AUDIO_OBJS+= wavcapture.o
114 OBJS+=$(addprefix audio/, $(AUDIO_OBJS))
116 ifdef CONFIG_SDL
117 OBJS+=sdl.o x_keymap.o
118 endif
119 ifdef CONFIG_CURSES
120 OBJS+=curses.o
121 endif
122 OBJS+=vnc.o d3des.o
124 ifdef CONFIG_COCOA
125 OBJS+=cocoa.o
126 endif
128 ifdef CONFIG_SLIRP
129 CPPFLAGS+=-I$(SRC_PATH)/slirp
130 SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
131 slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
132 tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o
133 OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
134 endif
136 LIBS+=$(VDE_LIBS)
138 cocoa.o: cocoa.m
139 $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
141 sdl.o: sdl.c keymaps.c sdl_keysym.h
142 $(CC) $(CFLAGS) $(CPPFLAGS) $(SDL_CFLAGS) -c -o $@ $<
144 vnc.o: vnc.c keymaps.c sdl_keysym.h vnchextile.h d3des.c d3des.h
145 $(CC) $(CFLAGS) $(CPPFLAGS) $(CONFIG_VNC_TLS_CFLAGS) -c -o $@ $<
147 curses.o: curses.c keymaps.c curses_keys.h
148 $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
150 audio/sdlaudio.o: audio/sdlaudio.c
151 $(CC) $(CFLAGS) $(CPPFLAGS) $(SDL_CFLAGS) -c -o $@ $<
153 libqemu_common.a: $(OBJS)
154 rm -f $@
155 $(AR) rcs $@ $(OBJS)
157 #######################################################################
158 # USER_OBJS is code used by qemu userspace emulation
159 USER_OBJS=cutils.o
161 libqemu_user.a: $(USER_OBJS)
162 rm -f $@
163 $(AR) rcs $@ $(USER_OBJS)
165 QEMU_IMG_BLOCK_OBJS = nbd.o $(BLOCK_OBJS)
166 ifdef CONFIG_WIN32
167 QEMU_IMG_BLOCK_OBJS += qemu-img-block-raw-win32.o
168 else
169 QEMU_IMG_BLOCK_OBJS += qemu-img-block-raw-posix.o
170 endif
172 ######################################################################
174 qemu-img$(EXESUF): qemu-img.o qemu-img-block.o $(QEMU_IMG_BLOCK_OBJS)
175 $(CC) $(LDFLAGS) -o $@ $^ -lz $(LIBS)
177 qemu-img-%.o: %.c
178 $(CC) $(CFLAGS) $(CPPFLAGS) -DQEMU_IMG -c -o $@ $<
180 %.o: %.c
181 $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
183 qemu-nbd-%.o: %.c
184 $(CC) $(CFLAGS) $(CPPFLAGS) -DQEMU_NBD -c -o $@ $<
186 qemu-nbd$(EXESUF): qemu-nbd.o qemu-nbd-nbd.o qemu-img-block.o \
187 osdep.o qemu-nbd-block-raw-posix.o $(BLOCK_OBJS)
188 $(CC) $(LDFLAGS) -o $@ $^ -lz $(LIBS)
190 # dyngen host tool
191 dyngen$(EXESUF): dyngen.c
192 $(HOST_CC) $(CFLAGS) $(CPPFLAGS) -o $@ $^
194 clean:
195 # avoid old build problems by removing potentially incorrect old files
196 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
197 rm -f *.o *.d *.a $(TOOLS) dyngen$(EXESUF) TAGS cscope.* *.pod *~ */*~
198 rm -rf dyngen.dSYM
199 rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d
200 $(MAKE) -C tests clean
201 for d in $(TARGET_DIRS); do \
202 $(MAKE) -C $$d $@ || exit 1 ; \
203 done
205 distclean: clean
206 rm -f config-host.mak config-host.h $(DOCS)
207 rm -f qemu-{doc,tech}.{info,aux,cp,dvi,fn,info,ky,log,pg,toc,tp,vr}
208 for d in $(TARGET_DIRS); do \
209 rm -rf $$d || exit 1 ; \
210 done
212 KEYMAPS=da en-gb et fr fr-ch is lt modifiers no pt-br sv \
213 ar de en-us fi fr-be hr it lv nl pl ru th \
214 common de-ch es fo fr-ca hu ja mk nl-be pt sl tr
216 install-doc: $(DOCS)
217 mkdir -p "$(DESTDIR)$(docdir)"
218 $(INSTALL) -m 644 qemu-doc.html qemu-tech.html "$(DESTDIR)$(docdir)"
219 ifndef CONFIG_WIN32
220 mkdir -p "$(DESTDIR)$(mandir)/man1"
221 $(INSTALL) qemu.1 qemu-img.1 "$(DESTDIR)$(mandir)/man1"
222 mkdir -p "$(DESTDIR)$(mandir)/man8"
223 $(INSTALL) qemu-nbd.8 "$(DESTDIR)$(mandir)/man8"
224 endif
226 install: all $(if $(BUILD_DOCS),install-doc)
227 mkdir -p "$(DESTDIR)$(bindir)"
228 ifneq ($(TOOLS),)
229 $(INSTALL) -m 755 -s $(TOOLS) "$(DESTDIR)$(bindir)"
230 endif
231 mkdir -p "$(DESTDIR)$(datadir)"
232 set -e; for x in bios.bin vgabios.bin vgabios-cirrus.bin ppc_rom.bin \
233 video.x openbios-sparc32 openbios-sparc64 pxe-ne2k_pci.bin \
234 pxe-rtl8139.bin pxe-pcnet.bin pxe-e1000.bin; do \
235 $(INSTALL) -m 644 $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(datadir)"; \
236 done
237 ifndef CONFIG_WIN32
238 mkdir -p "$(DESTDIR)$(datadir)/keymaps"
239 set -e; for x in $(KEYMAPS); do \
240 $(INSTALL) -m 644 $(SRC_PATH)/keymaps/$$x "$(DESTDIR)$(datadir)/keymaps"; \
241 done
242 endif
243 for d in $(TARGET_DIRS); do \
244 $(MAKE) -C $$d $@ || exit 1 ; \
245 done
247 # various test targets
248 test speed: all
249 $(MAKE) -C tests $@
251 TAGS:
252 etags *.[ch] tests/*.[ch]
254 cscope:
255 rm -f ./cscope.*
256 find . -name "*.[ch]" -print > ./cscope.files
257 cscope -b
259 # documentation
260 %.html: %.texi
261 texi2html -monolithic -number $<
263 %.info: %.texi
264 makeinfo $< -o $@
266 %.dvi: %.texi
267 texi2dvi $<
269 qemu.1: qemu-doc.texi
270 $(SRC_PATH)/texi2pod.pl $< qemu.pod
271 pod2man --section=1 --center=" " --release=" " qemu.pod > $@
273 qemu-img.1: qemu-img.texi
274 $(SRC_PATH)/texi2pod.pl $< qemu-img.pod
275 pod2man --section=1 --center=" " --release=" " qemu-img.pod > $@
277 qemu-nbd.8: qemu-nbd.texi
278 $(SRC_PATH)/texi2pod.pl $< qemu-nbd.pod
279 pod2man --section=8 --center=" " --release=" " qemu-nbd.pod > $@
281 info: qemu-doc.info qemu-tech.info
283 dvi: qemu-doc.dvi qemu-tech.dvi
285 html: qemu-doc.html qemu-tech.html
287 VERSION ?= $(shell cat VERSION)
288 FILE = qemu-$(VERSION)
290 # tar release (use 'make -k tar' on a checkouted tree)
291 tar:
292 rm -rf /tmp/$(FILE)
293 cp -r . /tmp/$(FILE)
294 cd /tmp && tar zcvf ~/$(FILE).tar.gz $(FILE) --exclude CVS --exclude .git --exclude .svn
295 rm -rf /tmp/$(FILE)
297 # generate a binary distribution
298 tarbin:
299 cd / && tar zcvf ~/qemu-$(VERSION)-$(ARCH).tar.gz \
300 $(bindir)/qemu \
301 $(bindir)/qemu-system-ppc \
302 $(bindir)/qemu-system-ppc64 \
303 $(bindir)/qemu-system-ppcemb \
304 $(bindir)/qemu-system-sparc \
305 $(bindir)/qemu-system-x86_64 \
306 $(bindir)/qemu-system-mips \
307 $(bindir)/qemu-system-mipsel \
308 $(bindir)/qemu-system-mips64 \
309 $(bindir)/qemu-system-mips64el \
310 $(bindir)/qemu-system-arm \
311 $(bindir)/qemu-system-m68k \
312 $(bindir)/qemu-system-sh4 \
313 $(bindir)/qemu-system-sh4eb \
314 $(bindir)/qemu-system-cris \
315 $(bindir)/qemu-i386 \
316 $(bindir)/qemu-x86_64 \
317 $(bindir)/qemu-arm \
318 $(bindir)/qemu-armeb \
319 $(bindir)/qemu-sparc \
320 $(bindir)/qemu-sparc32plus \
321 $(bindir)/qemu-sparc64 \
322 $(bindir)/qemu-ppc \
323 $(bindir)/qemu-ppc64 \
324 $(bindir)/qemu-ppc64abi32 \
325 $(bindir)/qemu-mips \
326 $(bindir)/qemu-mipsel \
327 $(bindir)/qemu-alpha \
328 $(bindir)/qemu-m68k \
329 $(bindir)/qemu-sh4 \
330 $(bindir)/qemu-sh4eb \
331 $(bindir)/qemu-cris \
332 $(bindir)/qemu-img \
333 $(bindir)/qemu-nbd \
334 $(datadir)/bios.bin \
335 $(datadir)/vgabios.bin \
336 $(datadir)/vgabios-cirrus.bin \
337 $(datadir)/ppc_rom.bin \
338 $(datadir)/video.x \
339 $(datadir)/openbios-sparc32 \
340 $(datadir)/openbios-sparc64 \
341 $(datadir)/pxe-ne2k_pci.bin \
342 $(datadir)/pxe-rtl8139.bin \
343 $(datadir)/pxe-pcnet.bin \
344 $(datadir)/pxe-e1000.bin \
345 $(docdir)/qemu-doc.html \
346 $(docdir)/qemu-tech.html \
347 $(mandir)/man1/qemu.1 $(mandir)/man1/qemu-img.1
348 $(mandir)/man8/qemu-nbd.8
350 # Include automatically generated dependency files
351 -include $(wildcard *.d audio/*.d slirp/*.d)