blob: e8b28770b78da82b3322bffd59b47aa6a216ba20 [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
ths6f30fa82007-01-05 01:00:47 +00008BASE_CFLAGS=
9BASE_LDFLAGS=
10
blueswir131422552007-04-16 18:27:06 +000011BASE_CFLAGS += $(OS_CFLAGS) $(ARCH_CFLAGS)
12BASE_LDFLAGS += $(OS_LDFLAGS) $(ARCH_LDFLAGS)
13
bellard4fb240a2007-11-07 19:24:02 +000014CPPFLAGS += -I. -I$(SRC_PATH) -MMD -MP
15CPPFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
bellard766a4872003-02-18 23:35:48 +000016LIBS=
bellard1f50f8d2004-05-08 14:44:43 +000017ifdef CONFIG_STATIC
ths6f30fa82007-01-05 01:00:47 +000018BASE_LDFLAGS += -static
bellard1f50f8d2004-05-08 14:44:43 +000019endif
pbrookcc8ae6d2006-04-23 17:57:59 +000020ifdef BUILD_DOCS
bellardacd935e2004-11-15 22:57:26 +000021DOCS=qemu-doc.html qemu-tech.html qemu.1 qemu-img.1
pbrookcc8ae6d2006-04-23 17:57:59 +000022else
23DOCS=
24endif
bellard7d132992003-03-06 23:23:54 +000025
ths70956b72007-03-17 15:00:37 +000026LIBS+=$(AIOLIBS)
bellard83f64092006-08-01 16:21:11 +000027
pbrookda0b0df2007-11-10 19:30:52 +000028all: $(TOOLS) $(DOCS) recurse-all
pbrookb9dea4f2006-05-13 16:54:03 +000029
pbrookda0b0df2007-11-10 19:30:52 +000030subdir-%: dyngen$(EXESUF) libqemu_common.a
pbrook4aa42532006-05-13 13:55:08 +000031 $(MAKE) -C $(subst subdir-,,$@) all
32
33recurse-all: $(patsubst %,subdir-%, $(TARGET_DIRS))
bellard83f64092006-08-01 16:21:11 +000034
pbrookfaf07962007-11-11 02:51:17 +000035#######################################################################
36# BLOCK_OBJS is code used by both qemu system emulation and qemu-img
37
38BLOCK_OBJS=cutils.o
39BLOCK_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o
40BLOCK_OBJS+=block-dmg.o block-bochs.o block-vpc.o block-vvfat.o
41BLOCK_OBJS+=block-qcow2.o block-parallels.o
42
bellard4fb240a2007-11-07 19:24:02 +000043######################################################################
pbrookfaf07962007-11-11 02:51:17 +000044# libqemu_common.a: Target indepedent part of system emulation. The
bellard4fb240a2007-11-07 19:24:02 +000045# long term path is to suppress *all* target specific code in case of
46# system emulation, i.e. a single QEMU executable should support all
47# CPUs and machines.
bellard47cea612004-05-17 20:06:42 +000048
pbrookfaf07962007-11-11 02:51:17 +000049OBJS=$(BLOCK_OBJS)
50OBJS+=readline.o console.o
51OBJS+=block.o
bellard4fb240a2007-11-07 19:24:02 +000052
53ifdef CONFIG_WIN32
54OBJS+=tap-win32.o
55endif
56
57AUDIO_OBJS = audio.o noaudio.o wavaudio.o mixeng.o
58ifdef CONFIG_SDL
59AUDIO_OBJS += sdlaudio.o
60endif
61ifdef CONFIG_OSS
62AUDIO_OBJS += ossaudio.o
63endif
64ifdef CONFIG_COREAUDIO
65AUDIO_OBJS += coreaudio.o
66endif
67ifdef CONFIG_ALSA
68AUDIO_OBJS += alsaaudio.o
69endif
70ifdef CONFIG_DSOUND
71AUDIO_OBJS += dsoundaudio.o
72endif
73ifdef CONFIG_FMOD
74AUDIO_OBJS += fmodaudio.o
75audio/audio.o audio/fmodaudio.o: CPPFLAGS := -I$(CONFIG_FMOD_INC) $(CPPFLAGS)
76endif
77AUDIO_OBJS+= wavcapture.o
78OBJS+=$(addprefix audio/, $(AUDIO_OBJS))
79
80ifdef CONFIG_SDL
81OBJS+=sdl.o x_keymap.o
82endif
83OBJS+=vnc.o d3des.o
84
85ifdef CONFIG_COCOA
86OBJS+=cocoa.o
87endif
88
89ifdef CONFIG_SLIRP
90CPPFLAGS+=-I$(SRC_PATH)/slirp
91SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
92slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
93tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o
94OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
95endif
96
97cocoa.o: cocoa.m
98 $(CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
99
100sdl.o: sdl.c keymaps.c sdl_keysym.h
101 $(CC) $(CFLAGS) $(CPPFLAGS) $(SDL_CFLAGS) $(BASE_CFLAGS) -c -o $@ $<
102
103vnc.o: vnc.c keymaps.c sdl_keysym.h vnchextile.h d3des.c d3des.h
104 $(CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
105
106audio/sdlaudio.o: audio/sdlaudio.c
107 $(CC) $(CFLAGS) $(CPPFLAGS) $(SDL_CFLAGS) $(BASE_CFLAGS) -c -o $@ $<
108
109libqemu_common.a: $(OBJS)
110 rm -f $@
111 $(AR) rcs $@ $(OBJS)
112
113######################################################################
114
pbrookfaf07962007-11-11 02:51:17 +0000115qemu-img$(EXESUF): qemu-img.o qemu-img-block.o qemu-img-block-raw.o $(BLOCK_OBJS)
bellard4fb240a2007-11-07 19:24:02 +0000116 $(CC) $(LDFLAGS) $(BASE_LDFLAGS) -o $@ $^ -lz $(LIBS)
117
pbrookfaf07962007-11-11 02:51:17 +0000118qemu-img-%.o: %.c
119 $(CC) $(CFLAGS) $(CPPFLAGS) -DQEMU_IMG $(BASE_CFLAGS) -c -o $@ $<
120
bellard4fb240a2007-11-07 19:24:02 +0000121%.o: %.c
122 $(CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
123
124# dyngen host tool
bellard11d9f692004-04-02 20:55:59 +0000125dyngen$(EXESUF): dyngen.c
ths6f30fa82007-01-05 01:00:47 +0000126 $(HOST_CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -o $@ $^
bellard31e31b82003-02-18 22:55:36 +0000127
128clean:
bellard2d80ae82003-08-11 23:01:33 +0000129# avoid old build problems by removing potentially incorrect old files
ths5fafdf22007-09-16 21:08:06 +0000130 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 +0000131 rm -f *.o *.d *.a $(TOOLS) dyngen$(EXESUF) TAGS cscope.* *.pod *~ */*~
132 rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d
bellard7d3505c2004-05-12 19:32:15 +0000133 $(MAKE) -C tests clean
bellard626df762003-08-10 21:39:31 +0000134 for d in $(TARGET_DIRS); do \
bellard7d3505c2004-05-12 19:32:15 +0000135 $(MAKE) -C $$d $@ || exit 1 ; \
bellard626df762003-08-10 21:39:31 +0000136 done
bellard31e31b82003-02-18 22:55:36 +0000137
bellard7d132992003-03-06 23:23:54 +0000138distclean: clean
pbrookcc8ae6d2006-04-23 17:57:59 +0000139 rm -f config-host.mak config-host.h $(DOCS)
pbrook0cb3fb12006-05-14 12:07:53 +0000140 rm -f qemu-{doc,tech}.{info,aux,cp,dvi,fn,info,ky,log,pg,toc,tp,vr}
bellard76bc6832003-08-10 23:41:46 +0000141 for d in $(TARGET_DIRS); do \
bellardbc1b0502003-10-28 00:12:52 +0000142 rm -rf $$d || exit 1 ; \
bellard76bc6832003-08-10 23:41:46 +0000143 done
bellard7d132992003-03-06 23:23:54 +0000144
bellardfed4a9a2004-12-12 22:18:34 +0000145KEYMAPS=da en-gb et fr fr-ch is lt modifiers no pt-br sv \
146ar de en-us fi fr-be hr it lv nl pl ru th \
147common de-ch es fo fr-ca hu ja mk nl-be pt sl tr
148
pbrook38954dc2006-04-30 23:54:18 +0000149install-doc: $(DOCS)
150 mkdir -p "$(DESTDIR)$(docdir)"
151 $(INSTALL) -m 644 qemu-doc.html qemu-tech.html "$(DESTDIR)$(docdir)"
152ifndef CONFIG_WIN32
153 mkdir -p "$(DESTDIR)$(mandir)/man1"
154 $(INSTALL) qemu.1 qemu-img.1 "$(DESTDIR)$(mandir)/man1"
155endif
156
157install: all $(if $(BUILD_DOCS),install-doc)
pbrook1236cab2006-04-09 20:47:35 +0000158 mkdir -p "$(DESTDIR)$(bindir)"
ths932a79d2007-10-20 18:29:34 +0000159ifneq ($(TOOLS),)
pbrook6a882642006-04-17 13:57:12 +0000160 $(INSTALL) -m 755 -s $(TOOLS) "$(DESTDIR)$(bindir)"
ths932a79d2007-10-20 18:29:34 +0000161endif
pbrook1236cab2006-04-09 20:47:35 +0000162 mkdir -p "$(DESTDIR)$(datadir)"
pbrookad064842006-04-16 12:41:07 +0000163 for x in bios.bin vgabios.bin vgabios-cirrus.bin ppc_rom.bin \
ths860c6c52007-05-20 10:54:50 +0000164 video.x openbios-sparc32 pxe-ne2k_pci.bin \
thseec85c22007-01-05 17:41:07 +0000165 pxe-rtl8139.bin pxe-pcnet.bin; do \
pbrook6a882642006-04-17 13:57:12 +0000166 $(INSTALL) -m 644 $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(datadir)"; \
pbrookad064842006-04-16 12:41:07 +0000167 done
bellard11d9f692004-04-02 20:55:59 +0000168ifndef CONFIG_WIN32
pbrook1236cab2006-04-09 20:47:35 +0000169 mkdir -p "$(DESTDIR)$(datadir)/keymaps"
pbrookad064842006-04-16 12:41:07 +0000170 for x in $(KEYMAPS); do \
pbrook6a882642006-04-17 13:57:12 +0000171 $(INSTALL) -m 644 $(SRC_PATH)/keymaps/$$x "$(DESTDIR)$(datadir)/keymaps"; \
pbrookad064842006-04-16 12:41:07 +0000172 done
bellard11d9f692004-04-02 20:55:59 +0000173endif
bellard626df762003-08-10 21:39:31 +0000174 for d in $(TARGET_DIRS); do \
bellard7d3505c2004-05-12 19:32:15 +0000175 $(MAKE) -C $$d $@ || exit 1 ; \
bellard626df762003-08-10 21:39:31 +0000176 done
bellard612384d2003-03-22 17:31:19 +0000177
bellard367e86e2003-03-01 17:13:26 +0000178# various test targets
bellard9b0b8202007-11-14 10:34:57 +0000179test speed: all
bellard7d3505c2004-05-12 19:32:15 +0000180 $(MAKE) -C tests $@
bellard31e31b82003-02-18 22:55:36 +0000181
ths5fafdf22007-09-16 21:08:06 +0000182TAGS:
bellardb9adb4a2003-04-29 20:41:16 +0000183 etags *.[ch] tests/*.[ch]
bellard31e31b82003-02-18 22:55:36 +0000184
bellard6688bc62005-08-21 09:23:39 +0000185cscope:
186 rm -f ./cscope.*
187 find . -name "*.[ch]" -print > ./cscope.files
188 cscope -b
189
bellard3ef693a2003-03-23 20:17:16 +0000190# documentation
bellard1f673132004-04-04 15:21:17 +0000191%.html: %.texi
bellard3ef693a2003-03-23 20:17:16 +0000192 texi2html -monolithic -number $<
193
bellardf3548322006-04-30 22:51:54 +0000194%.info: %.texi
195 makeinfo $< -o $@
196
197%.dvi: %.texi
198 texi2dvi $<
199
bellard5a671352003-10-01 00:13:48 +0000200qemu.1: qemu-doc.texi
pbrookad064842006-04-16 12:41:07 +0000201 $(SRC_PATH)/texi2pod.pl $< qemu.pod
bellard5a671352003-10-01 00:13:48 +0000202 pod2man --section=1 --center=" " --release=" " qemu.pod > $@
203
bellardacd935e2004-11-15 22:57:26 +0000204qemu-img.1: qemu-img.texi
pbrookad064842006-04-16 12:41:07 +0000205 $(SRC_PATH)/texi2pod.pl $< qemu-img.pod
bellardacd935e2004-11-15 22:57:26 +0000206 pod2man --section=1 --center=" " --release=" " qemu-img.pod > $@
207
pbrook0cb3fb12006-05-14 12:07:53 +0000208info: qemu-doc.info qemu-tech.info
209
210dvi: qemu-doc.dvi qemu-tech.dvi
211
212html: qemu-doc.html qemu-tech.html
213
thsdf5cf722007-01-24 22:56:36 +0000214VERSION ?= $(shell cat VERSION)
215FILE = qemu-$(VERSION)
bellard586314f2003-03-03 15:02:29 +0000216
bellard1e43adf2003-09-30 20:54:24 +0000217# tar release (use 'make -k tar' on a checkouted tree)
bellard586314f2003-03-03 15:02:29 +0000218tar:
219 rm -rf /tmp/$(FILE)
bellard1e43adf2003-09-30 20:54:24 +0000220 cp -r . /tmp/$(FILE)
bellard76b62fd2003-10-28 00:47:44 +0000221 ( cd /tmp ; tar zcvf ~/$(FILE).tar.gz $(FILE) --exclude CVS )
bellard586314f2003-03-03 15:02:29 +0000222 rm -rf /tmp/$(FILE)
223
bellard76b62fd2003-10-28 00:47:44 +0000224# generate a binary distribution
bellardd691f662003-03-24 21:58:34 +0000225tarbin:
ths4887d782007-09-29 21:22:33 +0000226 ( cd / ; tar zcvf ~/qemu-$(VERSION)-$(ARCH).tar.gz \
bellard43095f32005-04-27 20:49:23 +0000227 $(bindir)/qemu \
bellard7efa4382004-05-12 18:54:06 +0000228 $(bindir)/qemu-system-ppc \
j_mayerd4082e92007-04-24 07:34:03 +0000229 $(bindir)/qemu-system-ppc64 \
230 $(bindir)/qemu-system-ppcemb \
bellardacd935e2004-11-15 22:57:26 +0000231 $(bindir)/qemu-system-sparc \
bellard43095f32005-04-27 20:49:23 +0000232 $(bindir)/qemu-system-x86_64 \
bellard93856aa2005-07-24 18:44:35 +0000233 $(bindir)/qemu-system-mips \
pbrook38260992006-03-11 14:51:13 +0000234 $(bindir)/qemu-system-mipsel \
thsfbe4f652007-04-01 11:16:48 +0000235 $(bindir)/qemu-system-mips64 \
236 $(bindir)/qemu-system-mips64el \
bellardea31eb52005-12-06 21:42:03 +0000237 $(bindir)/qemu-system-arm \
thsff1aaf62007-09-29 21:18:26 +0000238 $(bindir)/qemu-system-m68k \
239 $(bindir)/qemu-system-sh4 \
bellard7efa4382004-05-12 18:54:06 +0000240 $(bindir)/qemu-i386 \
241 $(bindir)/qemu-arm \
bellardea31eb52005-12-06 21:42:03 +0000242 $(bindir)/qemu-armeb \
bellard7efa4382004-05-12 18:54:06 +0000243 $(bindir)/qemu-sparc \
244 $(bindir)/qemu-ppc \
j_mayerd4082e92007-04-24 07:34:03 +0000245 $(bindir)/qemu-ppc64 \
bellardea31eb52005-12-06 21:42:03 +0000246 $(bindir)/qemu-mips \
247 $(bindir)/qemu-mipsel \
ths540635b2007-09-30 01:58:33 +0000248 $(bindir)/qemu-mipsn32 \
249 $(bindir)/qemu-mipsn32el \
250 $(bindir)/qemu-mips64 \
251 $(bindir)/qemu-mips64el \
j_mayercf6c1b12007-04-05 20:46:02 +0000252 $(bindir)/qemu-alpha \
thsff1aaf62007-09-29 21:18:26 +0000253 $(bindir)/qemu-m68k \
254 $(bindir)/qemu-sh4 \
bellardb932cab2004-08-01 21:46:49 +0000255 $(bindir)/qemu-img \
bellard7efa4382004-05-12 18:54:06 +0000256 $(datadir)/bios.bin \
257 $(datadir)/vgabios.bin \
bellardde9258a2004-06-06 15:50:03 +0000258 $(datadir)/vgabios-cirrus.bin \
bellard637f6cd2004-06-21 19:54:47 +0000259 $(datadir)/ppc_rom.bin \
bellardd5295252005-07-03 14:00:51 +0000260 $(datadir)/video.x \
bellard0986ac32006-06-14 12:36:32 +0000261 $(datadir)/openbios-sparc32 \
bellard19c80e52007-02-05 21:22:42 +0000262 $(datadir)/pxe-ne2k_pci.bin \
263 $(datadir)/pxe-rtl8139.bin \
264 $(datadir)/pxe-pcnet.bin \
bellard1f50f8d2004-05-08 14:44:43 +0000265 $(docdir)/qemu-doc.html \
266 $(docdir)/qemu-tech.html \
bellardacd935e2004-11-15 22:57:26 +0000267 $(mandir)/man1/qemu.1 $(mandir)/man1/qemu-img.1 )
bellardd691f662003-03-24 21:58:34 +0000268
bellard31e31b82003-02-18 22:55:36 +0000269ifneq ($(wildcard .depend),)
270include .depend
271endif
bellard4fb240a2007-11-07 19:24:02 +0000272
273# Include automatically generated dependency files
274-include $(wildcard *.d audio/*.d slirp/*.d)