blob: 65e4f0e39b2f6709c5101a353ed4157dafc1f605 [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
balrog7e7c5e42008-04-14 21:57:44 +000054OBJS+=ssd0303.o ssd0323.o ads7846.o stellaris_input.o twl92230.o
55OBJS+=tmp105.o
pbrook87ecb682007-11-17 17:14:51 +000056OBJS+=scsi-disk.o cdrom.o
ths985a03b2007-12-24 16:10:43 +000057OBJS+=scsi-generic.o
balroga7954212008-01-14 03:41:02 +000058OBJS+=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 +000059OBJS+=sd.o ssi-sd.o
pbrook87ecb682007-11-17 17:14:51 +000060
aurel322e4d9fb2008-04-08 06:01:02 +000061ifdef CONFIG_BRLAPI
62OBJS+= baum.o
63LIBS+=-lbrlapi
64endif
65
bellard4fb240a2007-11-07 19:24:02 +000066ifdef CONFIG_WIN32
67OBJS+=tap-win32.o
68endif
69
70AUDIO_OBJS = audio.o noaudio.o wavaudio.o mixeng.o
71ifdef CONFIG_SDL
72AUDIO_OBJS += sdlaudio.o
73endif
74ifdef CONFIG_OSS
75AUDIO_OBJS += ossaudio.o
76endif
77ifdef CONFIG_COREAUDIO
78AUDIO_OBJS += coreaudio.o
balrogca9cc282008-01-14 04:24:29 +000079AUDIO_PT = yes
bellard4fb240a2007-11-07 19:24:02 +000080endif
81ifdef CONFIG_ALSA
82AUDIO_OBJS += alsaaudio.o
83endif
84ifdef CONFIG_DSOUND
85AUDIO_OBJS += dsoundaudio.o
86endif
87ifdef CONFIG_FMOD
88AUDIO_OBJS += fmodaudio.o
89audio/audio.o audio/fmodaudio.o: CPPFLAGS := -I$(CONFIG_FMOD_INC) $(CPPFLAGS)
90endif
balrogca9cc282008-01-14 04:24:29 +000091ifdef CONFIG_ESD
92AUDIO_PT = yes
93AUDIO_PT_INT = yes
94AUDIO_OBJS += esdaudio.o
95endif
96ifdef AUDIO_PT
97LDFLAGS += -pthread
98endif
99ifdef AUDIO_PT_INT
100AUDIO_OBJS += audio_pt_int.o
101endif
bellard4fb240a2007-11-07 19:24:02 +0000102AUDIO_OBJS+= wavcapture.o
103OBJS+=$(addprefix audio/, $(AUDIO_OBJS))
104
105ifdef CONFIG_SDL
106OBJS+=sdl.o x_keymap.o
107endif
balrog4d3b6f62008-02-10 16:33:14 +0000108ifdef CONFIG_CURSES
109OBJS+=curses.o
110endif
bellard4fb240a2007-11-07 19:24:02 +0000111OBJS+=vnc.o d3des.o
112
113ifdef CONFIG_COCOA
114OBJS+=cocoa.o
115endif
116
117ifdef CONFIG_SLIRP
118CPPFLAGS+=-I$(SRC_PATH)/slirp
119SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
120slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
121tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o
122OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
123endif
124
125cocoa.o: cocoa.m
bellard40293e52008-01-31 11:32:10 +0000126 $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
bellard4fb240a2007-11-07 19:24:02 +0000127
128sdl.o: sdl.c keymaps.c sdl_keysym.h
bellard40293e52008-01-31 11:32:10 +0000129 $(CC) $(CFLAGS) $(CPPFLAGS) $(SDL_CFLAGS) -c -o $@ $<
bellard4fb240a2007-11-07 19:24:02 +0000130
131vnc.o: vnc.c keymaps.c sdl_keysym.h vnchextile.h d3des.c d3des.h
bellard40293e52008-01-31 11:32:10 +0000132 $(CC) $(CFLAGS) $(CPPFLAGS) $(CONFIG_VNC_TLS_CFLAGS) -c -o $@ $<
bellard4fb240a2007-11-07 19:24:02 +0000133
balrog4d3b6f62008-02-10 16:33:14 +0000134curses.o: curses.c keymaps.c curses_keys.h
pbrookf5d28392008-03-31 23:41:24 +0000135 $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
balrog4d3b6f62008-02-10 16:33:14 +0000136
bellard4fb240a2007-11-07 19:24:02 +0000137audio/sdlaudio.o: audio/sdlaudio.c
bellard40293e52008-01-31 11:32:10 +0000138 $(CC) $(CFLAGS) $(CPPFLAGS) $(SDL_CFLAGS) -c -o $@ $<
bellard4fb240a2007-11-07 19:24:02 +0000139
140libqemu_common.a: $(OBJS)
141 rm -f $@
142 $(AR) rcs $@ $(OBJS)
143
ths223d4672007-12-15 17:28:36 +0000144QEMU_IMG_BLOCK_OBJS = $(BLOCK_OBJS)
145ifdef CONFIG_WIN32
146QEMU_IMG_BLOCK_OBJS += qemu-img-block-raw-win32.o
147else
148QEMU_IMG_BLOCK_OBJS += qemu-img-block-raw-posix.o
149endif
150
bellard4fb240a2007-11-07 19:24:02 +0000151######################################################################
152
ths223d4672007-12-15 17:28:36 +0000153qemu-img$(EXESUF): qemu-img.o qemu-img-block.o $(QEMU_IMG_BLOCK_OBJS)
bellard40293e52008-01-31 11:32:10 +0000154 $(CC) $(LDFLAGS) -o $@ $^ -lz $(LIBS)
bellard4fb240a2007-11-07 19:24:02 +0000155
pbrookfaf07962007-11-11 02:51:17 +0000156qemu-img-%.o: %.c
bellard40293e52008-01-31 11:32:10 +0000157 $(CC) $(CFLAGS) $(CPPFLAGS) -DQEMU_IMG -c -o $@ $<
pbrookfaf07962007-11-11 02:51:17 +0000158
bellard4fb240a2007-11-07 19:24:02 +0000159%.o: %.c
bellard40293e52008-01-31 11:32:10 +0000160 $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
bellard4fb240a2007-11-07 19:24:02 +0000161
162# dyngen host tool
bellard11d9f692004-04-02 20:55:59 +0000163dyngen$(EXESUF): dyngen.c
bellard40293e52008-01-31 11:32:10 +0000164 $(HOST_CC) $(CFLAGS) $(CPPFLAGS) -o $@ $^
bellard31e31b82003-02-18 22:55:36 +0000165
166clean:
bellard2d80ae82003-08-11 23:01:33 +0000167# avoid old build problems by removing potentially incorrect old files
ths5fafdf22007-09-16 21:08:06 +0000168 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 +0000169 rm -f *.o *.d *.a $(TOOLS) dyngen$(EXESUF) TAGS cscope.* *.pod *~ */*~
balrogb94ec3e2008-01-14 02:36:29 +0000170 rm -rf dyngen.dSYM
bellard4fb240a2007-11-07 19:24:02 +0000171 rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d
bellard7d3505c2004-05-12 19:32:15 +0000172 $(MAKE) -C tests clean
bellard626df762003-08-10 21:39:31 +0000173 for d in $(TARGET_DIRS); do \
bellard7d3505c2004-05-12 19:32:15 +0000174 $(MAKE) -C $$d $@ || exit 1 ; \
bellard626df762003-08-10 21:39:31 +0000175 done
bellard31e31b82003-02-18 22:55:36 +0000176
bellard7d132992003-03-06 23:23:54 +0000177distclean: clean
pbrookcc8ae6d2006-04-23 17:57:59 +0000178 rm -f config-host.mak config-host.h $(DOCS)
pbrook0cb3fb12006-05-14 12:07:53 +0000179 rm -f qemu-{doc,tech}.{info,aux,cp,dvi,fn,info,ky,log,pg,toc,tp,vr}
bellard76bc6832003-08-10 23:41:46 +0000180 for d in $(TARGET_DIRS); do \
bellardbc1b0502003-10-28 00:12:52 +0000181 rm -rf $$d || exit 1 ; \
bellard76bc6832003-08-10 23:41:46 +0000182 done
bellard7d132992003-03-06 23:23:54 +0000183
bellardfed4a9a2004-12-12 22:18:34 +0000184KEYMAPS=da en-gb et fr fr-ch is lt modifiers no pt-br sv \
185ar de en-us fi fr-be hr it lv nl pl ru th \
186common de-ch es fo fr-ca hu ja mk nl-be pt sl tr
187
pbrook38954dc2006-04-30 23:54:18 +0000188install-doc: $(DOCS)
189 mkdir -p "$(DESTDIR)$(docdir)"
190 $(INSTALL) -m 644 qemu-doc.html qemu-tech.html "$(DESTDIR)$(docdir)"
191ifndef CONFIG_WIN32
192 mkdir -p "$(DESTDIR)$(mandir)/man1"
193 $(INSTALL) qemu.1 qemu-img.1 "$(DESTDIR)$(mandir)/man1"
194endif
195
196install: all $(if $(BUILD_DOCS),install-doc)
pbrook1236cab2006-04-09 20:47:35 +0000197 mkdir -p "$(DESTDIR)$(bindir)"
ths932a79d2007-10-20 18:29:34 +0000198ifneq ($(TOOLS),)
pbrook6a882642006-04-17 13:57:12 +0000199 $(INSTALL) -m 755 -s $(TOOLS) "$(DESTDIR)$(bindir)"
ths932a79d2007-10-20 18:29:34 +0000200endif
pbrook1236cab2006-04-09 20:47:35 +0000201 mkdir -p "$(DESTDIR)$(datadir)"
blueswir118be8d72008-03-05 18:16:09 +0000202 set -e; for x in bios.bin vgabios.bin vgabios-cirrus.bin ppc_rom.bin \
blueswir1938255d2008-04-23 19:38:07 +0000203 video.x openbios-sparc32 openbios-sparc64 pxe-ne2k_pci.bin \
thseec85c22007-01-05 17:41:07 +0000204 pxe-rtl8139.bin pxe-pcnet.bin; do \
pbrook6a882642006-04-17 13:57:12 +0000205 $(INSTALL) -m 644 $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(datadir)"; \
pbrookad064842006-04-16 12:41:07 +0000206 done
bellard11d9f692004-04-02 20:55:59 +0000207ifndef CONFIG_WIN32
pbrook1236cab2006-04-09 20:47:35 +0000208 mkdir -p "$(DESTDIR)$(datadir)/keymaps"
blueswir118be8d72008-03-05 18:16:09 +0000209 set -e; for x in $(KEYMAPS); do \
pbrook6a882642006-04-17 13:57:12 +0000210 $(INSTALL) -m 644 $(SRC_PATH)/keymaps/$$x "$(DESTDIR)$(datadir)/keymaps"; \
pbrookad064842006-04-16 12:41:07 +0000211 done
bellard11d9f692004-04-02 20:55:59 +0000212endif
bellard626df762003-08-10 21:39:31 +0000213 for d in $(TARGET_DIRS); do \
bellard7d3505c2004-05-12 19:32:15 +0000214 $(MAKE) -C $$d $@ || exit 1 ; \
bellard626df762003-08-10 21:39:31 +0000215 done
bellard612384d2003-03-22 17:31:19 +0000216
bellard367e86e2003-03-01 17:13:26 +0000217# various test targets
bellard9b0b8202007-11-14 10:34:57 +0000218test speed: all
bellard7d3505c2004-05-12 19:32:15 +0000219 $(MAKE) -C tests $@
bellard31e31b82003-02-18 22:55:36 +0000220
ths5fafdf22007-09-16 21:08:06 +0000221TAGS:
bellardb9adb4a2003-04-29 20:41:16 +0000222 etags *.[ch] tests/*.[ch]
bellard31e31b82003-02-18 22:55:36 +0000223
bellard6688bc62005-08-21 09:23:39 +0000224cscope:
225 rm -f ./cscope.*
226 find . -name "*.[ch]" -print > ./cscope.files
227 cscope -b
228
bellard3ef693a2003-03-23 20:17:16 +0000229# documentation
bellard1f673132004-04-04 15:21:17 +0000230%.html: %.texi
bellard3ef693a2003-03-23 20:17:16 +0000231 texi2html -monolithic -number $<
232
bellardf3548322006-04-30 22:51:54 +0000233%.info: %.texi
234 makeinfo $< -o $@
235
236%.dvi: %.texi
237 texi2dvi $<
238
bellard5a671352003-10-01 00:13:48 +0000239qemu.1: qemu-doc.texi
pbrookad064842006-04-16 12:41:07 +0000240 $(SRC_PATH)/texi2pod.pl $< qemu.pod
bellard5a671352003-10-01 00:13:48 +0000241 pod2man --section=1 --center=" " --release=" " qemu.pod > $@
242
bellardacd935e2004-11-15 22:57:26 +0000243qemu-img.1: qemu-img.texi
pbrookad064842006-04-16 12:41:07 +0000244 $(SRC_PATH)/texi2pod.pl $< qemu-img.pod
bellardacd935e2004-11-15 22:57:26 +0000245 pod2man --section=1 --center=" " --release=" " qemu-img.pod > $@
246
pbrook0cb3fb12006-05-14 12:07:53 +0000247info: qemu-doc.info qemu-tech.info
248
249dvi: qemu-doc.dvi qemu-tech.dvi
250
251html: qemu-doc.html qemu-tech.html
252
thsdf5cf722007-01-24 22:56:36 +0000253VERSION ?= $(shell cat VERSION)
254FILE = qemu-$(VERSION)
bellard586314f2003-03-03 15:02:29 +0000255
bellard1e43adf2003-09-30 20:54:24 +0000256# tar release (use 'make -k tar' on a checkouted tree)
bellard586314f2003-03-03 15:02:29 +0000257tar:
258 rm -rf /tmp/$(FILE)
bellard1e43adf2003-09-30 20:54:24 +0000259 cp -r . /tmp/$(FILE)
aurel3299c6c082008-04-22 20:45:30 +0000260 cd /tmp && tar zcvf ~/$(FILE).tar.gz $(FILE) --exclude CVS --exclude .git --exclude .svn
bellard586314f2003-03-03 15:02:29 +0000261 rm -rf /tmp/$(FILE)
262
bellard76b62fd2003-10-28 00:47:44 +0000263# generate a binary distribution
bellardd691f662003-03-24 21:58:34 +0000264tarbin:
blueswir118be8d72008-03-05 18:16:09 +0000265 cd / && tar zcvf ~/qemu-$(VERSION)-$(ARCH).tar.gz \
bellard43095f32005-04-27 20:49:23 +0000266 $(bindir)/qemu \
bellard7efa4382004-05-12 18:54:06 +0000267 $(bindir)/qemu-system-ppc \
j_mayerd4082e92007-04-24 07:34:03 +0000268 $(bindir)/qemu-system-ppc64 \
269 $(bindir)/qemu-system-ppcemb \
bellardacd935e2004-11-15 22:57:26 +0000270 $(bindir)/qemu-system-sparc \
bellard43095f32005-04-27 20:49:23 +0000271 $(bindir)/qemu-system-x86_64 \
bellard93856aa2005-07-24 18:44:35 +0000272 $(bindir)/qemu-system-mips \
pbrook38260992006-03-11 14:51:13 +0000273 $(bindir)/qemu-system-mipsel \
thsfbe4f652007-04-01 11:16:48 +0000274 $(bindir)/qemu-system-mips64 \
275 $(bindir)/qemu-system-mips64el \
bellardea31eb52005-12-06 21:42:03 +0000276 $(bindir)/qemu-system-arm \
thsff1aaf62007-09-29 21:18:26 +0000277 $(bindir)/qemu-system-m68k \
278 $(bindir)/qemu-system-sh4 \
ths85ffbdf2007-12-09 05:10:03 +0000279 $(bindir)/qemu-system-sh4eb \
bellardf0403c02008-01-06 18:27:12 +0000280 $(bindir)/qemu-system-cris \
bellard7efa4382004-05-12 18:54:06 +0000281 $(bindir)/qemu-i386 \
bellardf0403c02008-01-06 18:27:12 +0000282 $(bindir)/qemu-x86_64 \
bellard7efa4382004-05-12 18:54:06 +0000283 $(bindir)/qemu-arm \
bellardea31eb52005-12-06 21:42:03 +0000284 $(bindir)/qemu-armeb \
bellard7efa4382004-05-12 18:54:06 +0000285 $(bindir)/qemu-sparc \
bellardf0403c02008-01-06 18:27:12 +0000286 $(bindir)/qemu-sparc32plus \
287 $(bindir)/qemu-sparc64 \
bellard7efa4382004-05-12 18:54:06 +0000288 $(bindir)/qemu-ppc \
j_mayerd4082e92007-04-24 07:34:03 +0000289 $(bindir)/qemu-ppc64 \
bellardf0403c02008-01-06 18:27:12 +0000290 $(bindir)/qemu-ppc64abi32 \
bellardea31eb52005-12-06 21:42:03 +0000291 $(bindir)/qemu-mips \
292 $(bindir)/qemu-mipsel \
j_mayercf6c1b12007-04-05 20:46:02 +0000293 $(bindir)/qemu-alpha \
thsff1aaf62007-09-29 21:18:26 +0000294 $(bindir)/qemu-m68k \
295 $(bindir)/qemu-sh4 \
ths85ffbdf2007-12-09 05:10:03 +0000296 $(bindir)/qemu-sh4eb \
bellardf0403c02008-01-06 18:27:12 +0000297 $(bindir)/qemu-cris \
bellardb932cab2004-08-01 21:46:49 +0000298 $(bindir)/qemu-img \
bellard7efa4382004-05-12 18:54:06 +0000299 $(datadir)/bios.bin \
300 $(datadir)/vgabios.bin \
bellardde9258a2004-06-06 15:50:03 +0000301 $(datadir)/vgabios-cirrus.bin \
bellard637f6cd2004-06-21 19:54:47 +0000302 $(datadir)/ppc_rom.bin \
bellardd5295252005-07-03 14:00:51 +0000303 $(datadir)/video.x \
bellard0986ac32006-06-14 12:36:32 +0000304 $(datadir)/openbios-sparc32 \
blueswir1938255d2008-04-23 19:38:07 +0000305 $(datadir)/openbios-sparc64 \
bellard19c80e52007-02-05 21:22:42 +0000306 $(datadir)/pxe-ne2k_pci.bin \
307 $(datadir)/pxe-rtl8139.bin \
308 $(datadir)/pxe-pcnet.bin \
bellard1f50f8d2004-05-08 14:44:43 +0000309 $(docdir)/qemu-doc.html \
310 $(docdir)/qemu-tech.html \
blueswir118be8d72008-03-05 18:16:09 +0000311 $(mandir)/man1/qemu.1 $(mandir)/man1/qemu-img.1
bellardd691f662003-03-24 21:58:34 +0000312
bellard4fb240a2007-11-07 19:24:02 +0000313# Include automatically generated dependency files
314-include $(wildcard *.d audio/*.d slirp/*.d)