blob: c36a97812a6d94cf383c60a17ae69539dc0f1f18 [file] [log] [blame]
pbrook0cb3fb12006-05-14 12:07:53 +00001# Makefile for QEMU.
2
pbrookad064842006-04-16 12:41:07 +00003include config-host.mak
bellard766a4872003-02-18 23:35:48 +00004
pbrook0cb3fb12006-05-14 12:07:53 +00005.PHONY: all clean distclean dvi info install install-doc tar tarbin \
bellard9b0b8202007-11-14 10:34:57 +00006 speed test html dvi info
pbrook0cb3fb12006-05-14 12:07:53 +00007
pbrook8c462f82007-11-18 21:12:37 +00008VPATH=$(SRC_PATH):$(SRC_PATH)/hw
9
bellard40293e52008-01-31 11:32:10 +000010CFLAGS += $(OS_CFLAGS) $(ARCH_CFLAGS)
11LDFLAGS += $(OS_LDFLAGS) $(ARCH_LDFLAGS)
blueswir131422552007-04-16 18:27:06 +000012
bellard4fb240a2007-11-07 19:24:02 +000013CPPFLAGS += -I. -I$(SRC_PATH) -MMD -MP
14CPPFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
bellard766a4872003-02-18 23:35:48 +000015LIBS=
bellard1f50f8d2004-05-08 14:44:43 +000016ifdef CONFIG_STATIC
bellard40293e52008-01-31 11:32:10 +000017LDFLAGS += -static
bellard1f50f8d2004-05-08 14:44:43 +000018endif
pbrookcc8ae6d2006-04-23 17:57:59 +000019ifdef BUILD_DOCS
bellardacd935e2004-11-15 22:57:26 +000020DOCS=qemu-doc.html qemu-tech.html qemu.1 qemu-img.1
pbrookcc8ae6d2006-04-23 17:57:59 +000021else
22DOCS=
23endif
bellard7d132992003-03-06 23:23:54 +000024
ths70956b72007-03-17 15:00:37 +000025LIBS+=$(AIOLIBS)
bellard83f64092006-08-01 16:21:11 +000026
pbrookda0b0df2007-11-10 19:30:52 +000027all: $(TOOLS) $(DOCS) recurse-all
pbrookb9dea4f2006-05-13 16:54:03 +000028
pbrookda0b0df2007-11-10 19:30:52 +000029subdir-%: dyngen$(EXESUF) libqemu_common.a
pbrook4aa42532006-05-13 13:55:08 +000030 $(MAKE) -C $(subst subdir-,,$@) all
31
32recurse-all: $(patsubst %,subdir-%, $(TARGET_DIRS))
bellard83f64092006-08-01 16:21:11 +000033
pbrookfaf07962007-11-11 02:51:17 +000034#######################################################################
35# BLOCK_OBJS is code used by both qemu system emulation and qemu-img
36
37BLOCK_OBJS=cutils.o
38BLOCK_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o
39BLOCK_OBJS+=block-dmg.o block-bochs.o block-vpc.o block-vvfat.o
40BLOCK_OBJS+=block-qcow2.o block-parallels.o
41
bellard4fb240a2007-11-07 19:24:02 +000042######################################################################
bellard2e2ea902008-02-01 10:02:52 +000043# libqemu_common.a: Target independent part of system emulation. The
bellard4fb240a2007-11-07 19:24:02 +000044# long term path is to suppress *all* target specific code in case of
45# system emulation, i.e. a single QEMU executable should support all
46# CPUs and machines.
bellard47cea612004-05-17 20:06:42 +000047
pbrookfaf07962007-11-11 02:51:17 +000048OBJS=$(BLOCK_OBJS)
pbrook87ecb682007-11-17 17:14:51 +000049OBJS+=readline.o console.o
pbrookfaf07962007-11-11 02:51:17 +000050OBJS+=block.o
bellard4fb240a2007-11-07 19:24:02 +000051
pbrook87ecb682007-11-17 17:14:51 +000052OBJS+=irq.o
53OBJS+=i2c.o smbus.o smbus_eeprom.o max7310.o max111x.o wm8750.o
pbrookcf0dbb22007-11-18 14:36:08 +000054OBJS+=ssd0303.o ssd0323.o ads7846.o stellaris_input.o
pbrook87ecb682007-11-17 17:14:51 +000055OBJS+=scsi-disk.o cdrom.o
ths985a03b2007-12-24 16:10:43 +000056OBJS+=scsi-generic.o
balroga7954212008-01-14 03:41:02 +000057OBJS+=usb.o usb-hub.o usb-linux.o usb-hid.o usb-msd.o usb-wacom.o usb-serial.o
pbrook775616c2007-11-24 23:35:08 +000058OBJS+=sd.o ssi-sd.o
pbrook87ecb682007-11-17 17:14:51 +000059
bellard4fb240a2007-11-07 19:24:02 +000060ifdef CONFIG_WIN32
61OBJS+=tap-win32.o
62endif
63
64AUDIO_OBJS = audio.o noaudio.o wavaudio.o mixeng.o
65ifdef CONFIG_SDL
66AUDIO_OBJS += sdlaudio.o
67endif
68ifdef CONFIG_OSS
69AUDIO_OBJS += ossaudio.o
70endif
71ifdef CONFIG_COREAUDIO
72AUDIO_OBJS += coreaudio.o
balrogca9cc282008-01-14 04:24:29 +000073AUDIO_PT = yes
bellard4fb240a2007-11-07 19:24:02 +000074endif
75ifdef CONFIG_ALSA
76AUDIO_OBJS += alsaaudio.o
77endif
78ifdef CONFIG_DSOUND
79AUDIO_OBJS += dsoundaudio.o
80endif
81ifdef CONFIG_FMOD
82AUDIO_OBJS += fmodaudio.o
83audio/audio.o audio/fmodaudio.o: CPPFLAGS := -I$(CONFIG_FMOD_INC) $(CPPFLAGS)
84endif
balrogca9cc282008-01-14 04:24:29 +000085ifdef CONFIG_ESD
86AUDIO_PT = yes
87AUDIO_PT_INT = yes
88AUDIO_OBJS += esdaudio.o
89endif
90ifdef AUDIO_PT
91LDFLAGS += -pthread
92endif
93ifdef AUDIO_PT_INT
94AUDIO_OBJS += audio_pt_int.o
95endif
bellard4fb240a2007-11-07 19:24:02 +000096AUDIO_OBJS+= wavcapture.o
97OBJS+=$(addprefix audio/, $(AUDIO_OBJS))
98
99ifdef CONFIG_SDL
100OBJS+=sdl.o x_keymap.o
101endif
balrog4d3b6f62008-02-10 16:33:14 +0000102ifdef CONFIG_CURSES
103OBJS+=curses.o
104endif
bellard4fb240a2007-11-07 19:24:02 +0000105OBJS+=vnc.o d3des.o
106
107ifdef CONFIG_COCOA
108OBJS+=cocoa.o
109endif
110
111ifdef CONFIG_SLIRP
112CPPFLAGS+=-I$(SRC_PATH)/slirp
113SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
114slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
115tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o
116OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
117endif
118
119cocoa.o: cocoa.m
bellard40293e52008-01-31 11:32:10 +0000120 $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
bellard4fb240a2007-11-07 19:24:02 +0000121
122sdl.o: sdl.c keymaps.c sdl_keysym.h
bellard40293e52008-01-31 11:32:10 +0000123 $(CC) $(CFLAGS) $(CPPFLAGS) $(SDL_CFLAGS) -c -o $@ $<
bellard4fb240a2007-11-07 19:24:02 +0000124
125vnc.o: vnc.c keymaps.c sdl_keysym.h vnchextile.h d3des.c d3des.h
bellard40293e52008-01-31 11:32:10 +0000126 $(CC) $(CFLAGS) $(CPPFLAGS) $(CONFIG_VNC_TLS_CFLAGS) -c -o $@ $<
bellard4fb240a2007-11-07 19:24:02 +0000127
balrog4d3b6f62008-02-10 16:33:14 +0000128curses.o: curses.c keymaps.c curses_keys.h
129 $(CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
130
bellard4fb240a2007-11-07 19:24:02 +0000131audio/sdlaudio.o: audio/sdlaudio.c
bellard40293e52008-01-31 11:32:10 +0000132 $(CC) $(CFLAGS) $(CPPFLAGS) $(SDL_CFLAGS) -c -o $@ $<
bellard4fb240a2007-11-07 19:24:02 +0000133
134libqemu_common.a: $(OBJS)
135 rm -f $@
136 $(AR) rcs $@ $(OBJS)
137
ths223d4672007-12-15 17:28:36 +0000138QEMU_IMG_BLOCK_OBJS = $(BLOCK_OBJS)
139ifdef CONFIG_WIN32
140QEMU_IMG_BLOCK_OBJS += qemu-img-block-raw-win32.o
141else
142QEMU_IMG_BLOCK_OBJS += qemu-img-block-raw-posix.o
143endif
144
bellard4fb240a2007-11-07 19:24:02 +0000145######################################################################
146
ths223d4672007-12-15 17:28:36 +0000147qemu-img$(EXESUF): qemu-img.o qemu-img-block.o $(QEMU_IMG_BLOCK_OBJS)
bellard40293e52008-01-31 11:32:10 +0000148 $(CC) $(LDFLAGS) -o $@ $^ -lz $(LIBS)
bellard4fb240a2007-11-07 19:24:02 +0000149
pbrookfaf07962007-11-11 02:51:17 +0000150qemu-img-%.o: %.c
bellard40293e52008-01-31 11:32:10 +0000151 $(CC) $(CFLAGS) $(CPPFLAGS) -DQEMU_IMG -c -o $@ $<
pbrookfaf07962007-11-11 02:51:17 +0000152
bellard4fb240a2007-11-07 19:24:02 +0000153%.o: %.c
bellard40293e52008-01-31 11:32:10 +0000154 $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
bellard4fb240a2007-11-07 19:24:02 +0000155
156# dyngen host tool
bellard11d9f692004-04-02 20:55:59 +0000157dyngen$(EXESUF): dyngen.c
bellard40293e52008-01-31 11:32:10 +0000158 $(HOST_CC) $(CFLAGS) $(CPPFLAGS) -o $@ $^
bellard31e31b82003-02-18 22:55:36 +0000159
160clean:
bellard2d80ae82003-08-11 23:01:33 +0000161# avoid old build problems by removing potentially incorrect old files
ths5fafdf22007-09-16 21:08:06 +0000162 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
bellard4fb240a2007-11-07 19:24:02 +0000163 rm -f *.o *.d *.a $(TOOLS) dyngen$(EXESUF) TAGS cscope.* *.pod *~ */*~
balrogb94ec3e2008-01-14 02:36:29 +0000164 rm -rf dyngen.dSYM
bellard4fb240a2007-11-07 19:24:02 +0000165 rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d
bellard7d3505c2004-05-12 19:32:15 +0000166 $(MAKE) -C tests clean
bellard626df762003-08-10 21:39:31 +0000167 for d in $(TARGET_DIRS); do \
bellard7d3505c2004-05-12 19:32:15 +0000168 $(MAKE) -C $$d $@ || exit 1 ; \
bellard626df762003-08-10 21:39:31 +0000169 done
bellard31e31b82003-02-18 22:55:36 +0000170
bellard7d132992003-03-06 23:23:54 +0000171distclean: clean
pbrookcc8ae6d2006-04-23 17:57:59 +0000172 rm -f config-host.mak config-host.h $(DOCS)
pbrook0cb3fb12006-05-14 12:07:53 +0000173 rm -f qemu-{doc,tech}.{info,aux,cp,dvi,fn,info,ky,log,pg,toc,tp,vr}
bellard76bc6832003-08-10 23:41:46 +0000174 for d in $(TARGET_DIRS); do \
bellardbc1b0502003-10-28 00:12:52 +0000175 rm -rf $$d || exit 1 ; \
bellard76bc6832003-08-10 23:41:46 +0000176 done
bellard7d132992003-03-06 23:23:54 +0000177
bellardfed4a9a2004-12-12 22:18:34 +0000178KEYMAPS=da en-gb et fr fr-ch is lt modifiers no pt-br sv \
179ar de en-us fi fr-be hr it lv nl pl ru th \
180common de-ch es fo fr-ca hu ja mk nl-be pt sl tr
181
pbrook38954dc2006-04-30 23:54:18 +0000182install-doc: $(DOCS)
183 mkdir -p "$(DESTDIR)$(docdir)"
184 $(INSTALL) -m 644 qemu-doc.html qemu-tech.html "$(DESTDIR)$(docdir)"
185ifndef CONFIG_WIN32
186 mkdir -p "$(DESTDIR)$(mandir)/man1"
187 $(INSTALL) qemu.1 qemu-img.1 "$(DESTDIR)$(mandir)/man1"
188endif
189
190install: all $(if $(BUILD_DOCS),install-doc)
pbrook1236cab2006-04-09 20:47:35 +0000191 mkdir -p "$(DESTDIR)$(bindir)"
ths932a79d2007-10-20 18:29:34 +0000192ifneq ($(TOOLS),)
pbrook6a882642006-04-17 13:57:12 +0000193 $(INSTALL) -m 755 -s $(TOOLS) "$(DESTDIR)$(bindir)"
ths932a79d2007-10-20 18:29:34 +0000194endif
pbrook1236cab2006-04-09 20:47:35 +0000195 mkdir -p "$(DESTDIR)$(datadir)"
blueswir118be8d72008-03-05 18:16:09 +0000196 set -e; for x in bios.bin vgabios.bin vgabios-cirrus.bin ppc_rom.bin \
ths860c6c52007-05-20 10:54:50 +0000197 video.x openbios-sparc32 pxe-ne2k_pci.bin \
thseec85c22007-01-05 17:41:07 +0000198 pxe-rtl8139.bin pxe-pcnet.bin; do \
pbrook6a882642006-04-17 13:57:12 +0000199 $(INSTALL) -m 644 $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(datadir)"; \
pbrookad064842006-04-16 12:41:07 +0000200 done
bellard11d9f692004-04-02 20:55:59 +0000201ifndef CONFIG_WIN32
pbrook1236cab2006-04-09 20:47:35 +0000202 mkdir -p "$(DESTDIR)$(datadir)/keymaps"
blueswir118be8d72008-03-05 18:16:09 +0000203 set -e; for x in $(KEYMAPS); do \
pbrook6a882642006-04-17 13:57:12 +0000204 $(INSTALL) -m 644 $(SRC_PATH)/keymaps/$$x "$(DESTDIR)$(datadir)/keymaps"; \
pbrookad064842006-04-16 12:41:07 +0000205 done
bellard11d9f692004-04-02 20:55:59 +0000206endif
bellard626df762003-08-10 21:39:31 +0000207 for d in $(TARGET_DIRS); do \
bellard7d3505c2004-05-12 19:32:15 +0000208 $(MAKE) -C $$d $@ || exit 1 ; \
bellard626df762003-08-10 21:39:31 +0000209 done
bellard612384d2003-03-22 17:31:19 +0000210
bellard367e86e2003-03-01 17:13:26 +0000211# various test targets
bellard9b0b8202007-11-14 10:34:57 +0000212test speed: all
bellard7d3505c2004-05-12 19:32:15 +0000213 $(MAKE) -C tests $@
bellard31e31b82003-02-18 22:55:36 +0000214
ths5fafdf22007-09-16 21:08:06 +0000215TAGS:
bellardb9adb4a2003-04-29 20:41:16 +0000216 etags *.[ch] tests/*.[ch]
bellard31e31b82003-02-18 22:55:36 +0000217
bellard6688bc62005-08-21 09:23:39 +0000218cscope:
219 rm -f ./cscope.*
220 find . -name "*.[ch]" -print > ./cscope.files
221 cscope -b
222
bellard3ef693a2003-03-23 20:17:16 +0000223# documentation
bellard1f673132004-04-04 15:21:17 +0000224%.html: %.texi
bellard3ef693a2003-03-23 20:17:16 +0000225 texi2html -monolithic -number $<
226
bellardf3548322006-04-30 22:51:54 +0000227%.info: %.texi
228 makeinfo $< -o $@
229
230%.dvi: %.texi
231 texi2dvi $<
232
bellard5a671352003-10-01 00:13:48 +0000233qemu.1: qemu-doc.texi
pbrookad064842006-04-16 12:41:07 +0000234 $(SRC_PATH)/texi2pod.pl $< qemu.pod
bellard5a671352003-10-01 00:13:48 +0000235 pod2man --section=1 --center=" " --release=" " qemu.pod > $@
236
bellardacd935e2004-11-15 22:57:26 +0000237qemu-img.1: qemu-img.texi
pbrookad064842006-04-16 12:41:07 +0000238 $(SRC_PATH)/texi2pod.pl $< qemu-img.pod
bellardacd935e2004-11-15 22:57:26 +0000239 pod2man --section=1 --center=" " --release=" " qemu-img.pod > $@
240
pbrook0cb3fb12006-05-14 12:07:53 +0000241info: qemu-doc.info qemu-tech.info
242
243dvi: qemu-doc.dvi qemu-tech.dvi
244
245html: qemu-doc.html qemu-tech.html
246
thsdf5cf722007-01-24 22:56:36 +0000247VERSION ?= $(shell cat VERSION)
248FILE = qemu-$(VERSION)
bellard586314f2003-03-03 15:02:29 +0000249
bellard1e43adf2003-09-30 20:54:24 +0000250# tar release (use 'make -k tar' on a checkouted tree)
bellard586314f2003-03-03 15:02:29 +0000251tar:
252 rm -rf /tmp/$(FILE)
bellard1e43adf2003-09-30 20:54:24 +0000253 cp -r . /tmp/$(FILE)
blueswir118be8d72008-03-05 18:16:09 +0000254 cd /tmp && tar zcvf ~/$(FILE).tar.gz $(FILE) --exclude CVS
bellard586314f2003-03-03 15:02:29 +0000255 rm -rf /tmp/$(FILE)
256
bellard76b62fd2003-10-28 00:47:44 +0000257# generate a binary distribution
bellardd691f662003-03-24 21:58:34 +0000258tarbin:
blueswir118be8d72008-03-05 18:16:09 +0000259 cd / && tar zcvf ~/qemu-$(VERSION)-$(ARCH).tar.gz \
bellard43095f32005-04-27 20:49:23 +0000260 $(bindir)/qemu \
bellard7efa4382004-05-12 18:54:06 +0000261 $(bindir)/qemu-system-ppc \
j_mayerd4082e92007-04-24 07:34:03 +0000262 $(bindir)/qemu-system-ppc64 \
263 $(bindir)/qemu-system-ppcemb \
bellardacd935e2004-11-15 22:57:26 +0000264 $(bindir)/qemu-system-sparc \
bellard43095f32005-04-27 20:49:23 +0000265 $(bindir)/qemu-system-x86_64 \
bellard93856aa2005-07-24 18:44:35 +0000266 $(bindir)/qemu-system-mips \
pbrook38260992006-03-11 14:51:13 +0000267 $(bindir)/qemu-system-mipsel \
thsfbe4f652007-04-01 11:16:48 +0000268 $(bindir)/qemu-system-mips64 \
269 $(bindir)/qemu-system-mips64el \
bellardea31eb52005-12-06 21:42:03 +0000270 $(bindir)/qemu-system-arm \
thsff1aaf62007-09-29 21:18:26 +0000271 $(bindir)/qemu-system-m68k \
272 $(bindir)/qemu-system-sh4 \
ths85ffbdf2007-12-09 05:10:03 +0000273 $(bindir)/qemu-system-sh4eb \
bellardf0403c02008-01-06 18:27:12 +0000274 $(bindir)/qemu-system-cris \
bellard7efa4382004-05-12 18:54:06 +0000275 $(bindir)/qemu-i386 \
bellardf0403c02008-01-06 18:27:12 +0000276 $(bindir)/qemu-x86_64 \
bellard7efa4382004-05-12 18:54:06 +0000277 $(bindir)/qemu-arm \
bellardea31eb52005-12-06 21:42:03 +0000278 $(bindir)/qemu-armeb \
bellard7efa4382004-05-12 18:54:06 +0000279 $(bindir)/qemu-sparc \
bellardf0403c02008-01-06 18:27:12 +0000280 $(bindir)/qemu-sparc32plus \
281 $(bindir)/qemu-sparc64 \
bellard7efa4382004-05-12 18:54:06 +0000282 $(bindir)/qemu-ppc \
j_mayerd4082e92007-04-24 07:34:03 +0000283 $(bindir)/qemu-ppc64 \
bellardf0403c02008-01-06 18:27:12 +0000284 $(bindir)/qemu-ppc64abi32 \
bellardea31eb52005-12-06 21:42:03 +0000285 $(bindir)/qemu-mips \
286 $(bindir)/qemu-mipsel \
j_mayercf6c1b12007-04-05 20:46:02 +0000287 $(bindir)/qemu-alpha \
thsff1aaf62007-09-29 21:18:26 +0000288 $(bindir)/qemu-m68k \
289 $(bindir)/qemu-sh4 \
ths85ffbdf2007-12-09 05:10:03 +0000290 $(bindir)/qemu-sh4eb \
bellardf0403c02008-01-06 18:27:12 +0000291 $(bindir)/qemu-cris \
bellardb932cab2004-08-01 21:46:49 +0000292 $(bindir)/qemu-img \
bellard7efa4382004-05-12 18:54:06 +0000293 $(datadir)/bios.bin \
294 $(datadir)/vgabios.bin \
bellardde9258a2004-06-06 15:50:03 +0000295 $(datadir)/vgabios-cirrus.bin \
bellard637f6cd2004-06-21 19:54:47 +0000296 $(datadir)/ppc_rom.bin \
bellardd5295252005-07-03 14:00:51 +0000297 $(datadir)/video.x \
bellard0986ac32006-06-14 12:36:32 +0000298 $(datadir)/openbios-sparc32 \
bellard19c80e52007-02-05 21:22:42 +0000299 $(datadir)/pxe-ne2k_pci.bin \
300 $(datadir)/pxe-rtl8139.bin \
301 $(datadir)/pxe-pcnet.bin \
bellard1f50f8d2004-05-08 14:44:43 +0000302 $(docdir)/qemu-doc.html \
303 $(docdir)/qemu-tech.html \
blueswir118be8d72008-03-05 18:16:09 +0000304 $(mandir)/man1/qemu.1 $(mandir)/man1/qemu-img.1
bellardd691f662003-03-24 21:58:34 +0000305
bellard4fb240a2007-11-07 19:24:02 +0000306# Include automatically generated dependency files
307-include $(wildcard *.d audio/*.d slirp/*.d)