Add CDC-Ethernet usb NIC (original patch from Thomas Sailer).
[qemu] / Makefile
1 # Makefile for QEMU.
2
3 include config-host.mak
4
5 .PHONY: all clean distclean dvi info install install-doc tar tarbin \
6         speed test html dvi info
7
8 VPATH=$(SRC_PATH):$(SRC_PATH)/hw
9
10 CFLAGS += $(OS_CFLAGS) $(ARCH_CFLAGS)
11 LDFLAGS += $(OS_LDFLAGS) $(ARCH_LDFLAGS)
12
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
24
25 LIBS+=$(AIOLIBS)
26
27 all: $(TOOLS) $(DOCS) recurse-all 
28
29 SUBDIR_RULES=$(patsubst %,subdir-%, $(TARGET_DIRS))
30
31 subdir-%: dyngen$(EXESUF)
32         $(MAKE) -C $(subst subdir-,,$@) all
33
34 $(filter %-softmmu,$(SUBDIR_RULES)): libqemu_common.a
35 $(filter %-user,$(SUBDIR_RULES)): libqemu_user.a
36
37 recurse-all: $(SUBDIR_RULES)
38
39 #######################################################################
40 # BLOCK_OBJS is code used by both qemu system emulation and qemu-img
41
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
46
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.
52
53 OBJS=nbd.o $(BLOCK_OBJS)
54 OBJS+=readline.o console.o
55 OBJS+=block.o
56
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
66
67 ifdef CONFIG_BRLAPI
68 OBJS+= baum.o
69 LIBS+=-lbrlapi
70 endif
71
72 ifdef CONFIG_WIN32
73 OBJS+=tap-win32.o
74 endif
75
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))
115
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
123
124 ifdef CONFIG_COCOA
125 OBJS+=cocoa.o
126 endif
127
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
135
136 cocoa.o: cocoa.m
137         $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
138
139 sdl.o: sdl.c keymaps.c sdl_keysym.h
140         $(CC) $(CFLAGS) $(CPPFLAGS) $(SDL_CFLAGS) -c -o $@ $<
141
142 vnc.o: vnc.c keymaps.c sdl_keysym.h vnchextile.h d3des.c d3des.h
143         $(CC) $(CFLAGS) $(CPPFLAGS) $(CONFIG_VNC_TLS_CFLAGS) -c -o $@ $<
144
145 curses.o: curses.c keymaps.c curses_keys.h
146         $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
147
148 audio/sdlaudio.o: audio/sdlaudio.c
149         $(CC) $(CFLAGS) $(CPPFLAGS) $(SDL_CFLAGS) -c -o $@ $<
150
151 libqemu_common.a: $(OBJS)
152         rm -f $@ 
153         $(AR) rcs $@ $(OBJS)
154
155 #######################################################################
156 # USER_OBJS is code used by qemu userspace emulation
157 USER_OBJS=cutils.o
158
159 libqemu_user.a: $(USER_OBJS)
160         rm -f $@ 
161         $(AR) rcs $@ $(USER_OBJS)
162
163 QEMU_IMG_BLOCK_OBJS = nbd.o $(BLOCK_OBJS)
164 ifdef CONFIG_WIN32
165 QEMU_IMG_BLOCK_OBJS += qemu-img-block-raw-win32.o
166 else
167 QEMU_IMG_BLOCK_OBJS += qemu-img-block-raw-posix.o
168 endif
169
170 ######################################################################
171
172 qemu-img$(EXESUF): qemu-img.o qemu-img-block.o $(QEMU_IMG_BLOCK_OBJS)
173         $(CC) $(LDFLAGS) -o $@ $^ -lz $(LIBS)
174
175 qemu-img-%.o: %.c
176         $(CC) $(CFLAGS) $(CPPFLAGS) -DQEMU_IMG -c -o $@ $<
177
178 %.o: %.c
179         $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
180
181 qemu-nbd-%.o: %.c
182         $(CC) $(CFLAGS) $(CPPFLAGS) -DQEMU_NBD -c -o $@ $<
183
184 qemu-nbd$(EXESUF):  qemu-nbd.o qemu-nbd-nbd.o qemu-img-block.o \
185                     osdep.o qemu-nbd-block-raw-posix.o $(BLOCK_OBJS)
186         $(CC) $(LDFLAGS) -o $@ $^ -lz $(LIBS)
187
188 # dyngen host tool
189 dyngen$(EXESUF): dyngen.c
190         $(HOST_CC) $(CFLAGS) $(CPPFLAGS) -o $@ $^
191
192 clean:
193 # avoid old build problems by removing potentially incorrect old files
194         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
195         rm -f *.o *.d *.a $(TOOLS) dyngen$(EXESUF) TAGS cscope.* *.pod *~ */*~
196         rm -rf dyngen.dSYM
197         rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d
198         $(MAKE) -C tests clean
199         for d in $(TARGET_DIRS); do \
200         $(MAKE) -C $$d $@ || exit 1 ; \
201         done
202
203 distclean: clean
204         rm -f config-host.mak config-host.h $(DOCS)
205         rm -f qemu-{doc,tech}.{info,aux,cp,dvi,fn,info,ky,log,pg,toc,tp,vr}
206         for d in $(TARGET_DIRS); do \
207         rm -rf $$d || exit 1 ; \
208         done
209
210 KEYMAPS=da     en-gb  et  fr     fr-ch  is  lt  modifiers  no  pt-br  sv \
211 ar      de     en-us  fi  fr-be  hr     it  lv  nl         pl  ru     th \
212 common  de-ch  es     fo  fr-ca  hu     ja  mk  nl-be      pt  sl     tr
213
214 install-doc: $(DOCS)
215         mkdir -p "$(DESTDIR)$(docdir)"
216         $(INSTALL) -m 644 qemu-doc.html  qemu-tech.html "$(DESTDIR)$(docdir)"
217 ifndef CONFIG_WIN32
218         mkdir -p "$(DESTDIR)$(mandir)/man1"
219         $(INSTALL) qemu.1 qemu-img.1 "$(DESTDIR)$(mandir)/man1"
220         mkdir -p "$(DESTDIR)$(mandir)/man8"
221         $(INSTALL) qemu-nbd.8 "$(DESTDIR)$(mandir)/man8"
222 endif
223
224 install: all $(if $(BUILD_DOCS),install-doc)
225         mkdir -p "$(DESTDIR)$(bindir)"
226 ifneq ($(TOOLS),)
227         $(INSTALL) -m 755 -s $(TOOLS) "$(DESTDIR)$(bindir)"
228 endif
229         mkdir -p "$(DESTDIR)$(datadir)"
230         set -e; for x in bios.bin vgabios.bin vgabios-cirrus.bin ppc_rom.bin \
231                 video.x openbios-sparc32 openbios-sparc64 pxe-ne2k_pci.bin \
232                 pxe-rtl8139.bin pxe-pcnet.bin; do \
233                 $(INSTALL) -m 644 $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(datadir)"; \
234         done
235 ifndef CONFIG_WIN32
236         mkdir -p "$(DESTDIR)$(datadir)/keymaps"
237         set -e; for x in $(KEYMAPS); do \
238                 $(INSTALL) -m 644 $(SRC_PATH)/keymaps/$$x "$(DESTDIR)$(datadir)/keymaps"; \
239         done
240 endif
241         for d in $(TARGET_DIRS); do \
242         $(MAKE) -C $$d $@ || exit 1 ; \
243         done
244
245 # various test targets
246 test speed: all
247         $(MAKE) -C tests $@
248
249 TAGS:
250         etags *.[ch] tests/*.[ch]
251
252 cscope:
253         rm -f ./cscope.*
254         find . -name "*.[ch]" -print > ./cscope.files
255         cscope -b
256
257 # documentation
258 %.html: %.texi
259         texi2html -monolithic -number $<
260
261 %.info: %.texi
262         makeinfo $< -o $@
263
264 %.dvi: %.texi
265         texi2dvi $<
266
267 qemu.1: qemu-doc.texi
268         $(SRC_PATH)/texi2pod.pl $< qemu.pod
269         pod2man --section=1 --center=" " --release=" " qemu.pod > $@
270
271 qemu-img.1: qemu-img.texi
272         $(SRC_PATH)/texi2pod.pl $< qemu-img.pod
273         pod2man --section=1 --center=" " --release=" " qemu-img.pod > $@
274
275 qemu-nbd.8: qemu-nbd.texi
276         $(SRC_PATH)/texi2pod.pl $< qemu-nbd.pod
277         pod2man --section=8 --center=" " --release=" " qemu-nbd.pod > $@
278
279 info: qemu-doc.info qemu-tech.info
280
281 dvi: qemu-doc.dvi qemu-tech.dvi
282
283 html: qemu-doc.html qemu-tech.html
284
285 VERSION ?= $(shell cat VERSION)
286 FILE = qemu-$(VERSION)
287
288 # tar release (use 'make -k tar' on a checkouted tree)
289 tar:
290         rm -rf /tmp/$(FILE)
291         cp -r . /tmp/$(FILE)
292         cd /tmp && tar zcvf ~/$(FILE).tar.gz $(FILE) --exclude CVS --exclude .git --exclude .svn
293         rm -rf /tmp/$(FILE)
294
295 # generate a binary distribution
296 tarbin:
297         cd / && tar zcvf ~/qemu-$(VERSION)-$(ARCH).tar.gz \
298         $(bindir)/qemu \
299         $(bindir)/qemu-system-ppc \
300         $(bindir)/qemu-system-ppc64 \
301         $(bindir)/qemu-system-ppcemb \
302         $(bindir)/qemu-system-sparc \
303         $(bindir)/qemu-system-x86_64 \
304         $(bindir)/qemu-system-mips \
305         $(bindir)/qemu-system-mipsel \
306         $(bindir)/qemu-system-mips64 \
307         $(bindir)/qemu-system-mips64el \
308         $(bindir)/qemu-system-arm \
309         $(bindir)/qemu-system-m68k \
310         $(bindir)/qemu-system-sh4 \
311         $(bindir)/qemu-system-sh4eb \
312         $(bindir)/qemu-system-cris \
313         $(bindir)/qemu-i386 \
314         $(bindir)/qemu-x86_64 \
315         $(bindir)/qemu-arm \
316         $(bindir)/qemu-armeb \
317         $(bindir)/qemu-sparc \
318         $(bindir)/qemu-sparc32plus \
319         $(bindir)/qemu-sparc64 \
320         $(bindir)/qemu-ppc \
321         $(bindir)/qemu-ppc64 \
322         $(bindir)/qemu-ppc64abi32 \
323         $(bindir)/qemu-mips \
324         $(bindir)/qemu-mipsel \
325         $(bindir)/qemu-alpha \
326         $(bindir)/qemu-m68k \
327         $(bindir)/qemu-sh4 \
328         $(bindir)/qemu-sh4eb \
329         $(bindir)/qemu-cris \
330         $(bindir)/qemu-img \
331         $(bindir)/qemu-nbd \
332         $(datadir)/bios.bin \
333         $(datadir)/vgabios.bin \
334         $(datadir)/vgabios-cirrus.bin \
335         $(datadir)/ppc_rom.bin \
336         $(datadir)/video.x \
337         $(datadir)/openbios-sparc32 \
338         $(datadir)/openbios-sparc64 \
339         $(datadir)/pxe-ne2k_pci.bin \
340         $(datadir)/pxe-rtl8139.bin \
341         $(datadir)/pxe-pcnet.bin \
342         $(docdir)/qemu-doc.html \
343         $(docdir)/qemu-tech.html \
344         $(mandir)/man1/qemu.1 $(mandir)/man1/qemu-img.1
345         $(mandir)/man8/qemu-nbd.8
346
347 # Include automatically generated dependency files
348 -include $(wildcard *.d audio/*.d slirp/*.d)