xref: /openbmc/qemu/Makefile (revision fb37726d)
1# Makefile for QEMU.
2
3# Always point to the root of the build tree (needs GNU make).
4BUILD_DIR=$(CURDIR)
5
6# Before including a proper config-host.mak, assume we are in the source tree
7SRC_PATH=.
8
9UNCHECKED_GOALS := %clean TAGS cscope ctags
10
11# All following code might depend on configuration variables
12ifneq ($(wildcard config-host.mak),)
13# Put the all: rule here so that config-host.mak can contain dependencies.
14all:
15include config-host.mak
16
17# Check that we're not trying to do an out-of-tree build from
18# a tree that's been used for an in-tree build.
19ifneq ($(realpath $(SRC_PATH)),$(realpath .))
20ifneq ($(wildcard $(SRC_PATH)/config-host.mak),)
21$(error This is an out of tree build but your source tree ($(SRC_PATH)) \
22seems to have been used for an in-tree build. You can fix this by running \
23"make distclean && rm -rf *-linux-user *-softmmu" in your source tree)
24endif
25endif
26
27CONFIG_SOFTMMU := $(if $(filter %-softmmu,$(TARGET_DIRS)),y)
28CONFIG_USER_ONLY := $(if $(filter %-user,$(TARGET_DIRS)),y)
29CONFIG_ALL=y
30-include config-all-devices.mak
31-include config-all-disas.mak
32
33include $(SRC_PATH)/rules.mak
34config-host.mak: $(SRC_PATH)/configure
35	@echo $@ is out-of-date, running configure
36	@# TODO: The next lines include code which supports a smooth
37	@# transition from old configurations without config.status.
38	@# This code can be removed after QEMU 1.7.
39	@if test -x config.status; then \
40	    ./config.status; \
41        else \
42	    sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh; \
43	fi
44else
45config-host.mak:
46ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
47	@echo "Please call configure before running make!"
48	@exit 1
49endif
50endif
51
52GENERATED_HEADERS = config-host.h qemu-options.def
53GENERATED_HEADERS += qmp-commands.h qapi-types.h qapi-visit.h qapi-event.h
54GENERATED_SOURCES += qmp-marshal.c qapi-types.c qapi-visit.c qapi-event.c
55
56GENERATED_HEADERS += trace/generated-events.h
57GENERATED_SOURCES += trace/generated-events.c
58
59GENERATED_HEADERS += trace/generated-tracers.h
60ifeq ($(findstring dtrace,$(TRACE_BACKENDS)),dtrace)
61GENERATED_HEADERS += trace/generated-tracers-dtrace.h
62endif
63GENERATED_SOURCES += trace/generated-tracers.c
64
65GENERATED_HEADERS += trace/generated-tcg-tracers.h
66
67GENERATED_HEADERS += trace/generated-helpers-wrappers.h
68GENERATED_HEADERS += trace/generated-helpers.h
69GENERATED_SOURCES += trace/generated-helpers.c
70
71ifeq ($(findstring ust,$(TRACE_BACKENDS)),ust)
72GENERATED_HEADERS += trace/generated-ust-provider.h
73GENERATED_SOURCES += trace/generated-ust.c
74endif
75
76# Don't try to regenerate Makefile or configure
77# We don't generate any of them
78Makefile: ;
79configure: ;
80
81.PHONY: all clean cscope distclean dvi html info install install-doc \
82	pdf recurse-all speed test dist msi
83
84$(call set-vpath, $(SRC_PATH))
85
86LIBS+=-lz $(LIBS_TOOLS)
87
88HELPERS-$(CONFIG_LINUX) = qemu-bridge-helper$(EXESUF)
89
90ifdef BUILD_DOCS
91DOCS=qemu-doc.html qemu-tech.html qemu.1 qemu-img.1 qemu-nbd.8 qemu-ga.8
92DOCS+=qmp-commands.txt
93ifdef CONFIG_LINUX
94DOCS+=kvm_stat.1
95endif
96ifdef CONFIG_VIRTFS
97DOCS+=fsdev/virtfs-proxy-helper.1
98endif
99else
100DOCS=
101endif
102
103SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory) BUILD_DIR=$(BUILD_DIR)
104SUBDIR_DEVICES_MAK=$(patsubst %, %/config-devices.mak, $(TARGET_DIRS))
105SUBDIR_DEVICES_MAK_DEP=$(patsubst %, %-config-devices.mak.d, $(TARGET_DIRS))
106
107ifeq ($(SUBDIR_DEVICES_MAK),)
108config-all-devices.mak:
109	$(call quiet-command,echo '# no devices' > $@,"  GEN   $@")
110else
111config-all-devices.mak: $(SUBDIR_DEVICES_MAK)
112	$(call quiet-command, sed -n \
113             's|^\([^=]*\)=\(.*\)$$|\1:=$$(findstring y,$$(\1)\2)|p' \
114             $(SUBDIR_DEVICES_MAK) | sort -u > $@, \
115             "  GEN   $@")
116endif
117
118-include $(SUBDIR_DEVICES_MAK_DEP)
119
120%/config-devices.mak: default-configs/%.mak
121	$(call quiet-command, \
122            $(SHELL) $(SRC_PATH)/scripts/make_device_config.sh $< $*-config-devices.mak.d $@ > $@.tmp, "  GEN   $@.tmp")
123	$(call quiet-command, if test -f $@; then \
124	  if cmp -s $@.old $@; then \
125	    mv $@.tmp $@; \
126	    cp -p $@ $@.old; \
127	  else \
128	    if test -f $@.old; then \
129	      echo "WARNING: $@ (user modified) out of date.";\
130	    else \
131	      echo "WARNING: $@ out of date.";\
132	    fi; \
133	    echo "Run \"make defconfig\" to regenerate."; \
134	    rm $@.tmp; \
135	  fi; \
136	 else \
137	  mv $@.tmp $@; \
138	  cp -p $@ $@.old; \
139	 fi, "  GEN   $@");
140
141defconfig:
142	rm -f config-all-devices.mak $(SUBDIR_DEVICES_MAK)
143
144ifneq ($(wildcard config-host.mak),)
145include $(SRC_PATH)/Makefile.objs
146endif
147
148dummy := $(call unnest-vars,, \
149                stub-obj-y \
150                util-obj-y \
151                qga-obj-y \
152                qga-vss-dll-obj-y \
153                block-obj-y \
154                block-obj-m \
155                crypto-obj-y \
156                crypto-aes-obj-y \
157                common-obj-y \
158                common-obj-m)
159
160ifneq ($(wildcard config-host.mak),)
161include $(SRC_PATH)/tests/Makefile
162endif
163ifeq ($(CONFIG_SMARTCARD_NSS),y)
164include $(SRC_PATH)/libcacard/Makefile
165endif
166
167all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all modules
168
169config-host.h: config-host.h-timestamp
170config-host.h-timestamp: config-host.mak
171qemu-options.def: $(SRC_PATH)/qemu-options.hx
172	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"  GEN   $@")
173
174SUBDIR_RULES=$(patsubst %,subdir-%, $(TARGET_DIRS))
175SOFTMMU_SUBDIR_RULES=$(filter %-softmmu,$(SUBDIR_RULES))
176
177$(SOFTMMU_SUBDIR_RULES): $(block-obj-y)
178$(SOFTMMU_SUBDIR_RULES): $(crypto-obj-y)
179$(SOFTMMU_SUBDIR_RULES): config-all-devices.mak
180
181subdir-%:
182	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" TARGET_DIR="$*/" all,)
183
184subdir-pixman: pixman/Makefile
185	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C pixman V="$(V)" all,)
186
187pixman/Makefile: $(SRC_PATH)/pixman/configure
188	(cd pixman; CFLAGS="$(CFLAGS) -fPIC $(extra_cflags) $(extra_ldflags)" $(SRC_PATH)/pixman/configure $(AUTOCONF_HOST) --disable-gtk --disable-shared --enable-static)
189
190$(SRC_PATH)/pixman/configure:
191	(cd $(SRC_PATH)/pixman; autoreconf -v --install)
192
193DTC_MAKE_ARGS=-I$(SRC_PATH)/dtc VPATH=$(SRC_PATH)/dtc -C dtc V="$(V)" LIBFDT_srcdir=$(SRC_PATH)/dtc/libfdt
194DTC_CFLAGS=$(CFLAGS) $(QEMU_CFLAGS)
195DTC_CPPFLAGS=-I$(BUILD_DIR)/dtc -I$(SRC_PATH)/dtc -I$(SRC_PATH)/dtc/libfdt
196
197subdir-dtc:dtc/libfdt dtc/tests
198	$(call quiet-command,$(MAKE) $(DTC_MAKE_ARGS) CPPFLAGS="$(DTC_CPPFLAGS)" CFLAGS="$(DTC_CFLAGS)" LDFLAGS="$(LDFLAGS)" ARFLAGS="$(ARFLAGS)" CC="$(CC)" AR="$(AR)" LD="$(LD)" $(SUBDIR_MAKEFLAGS) libfdt/libfdt.a,)
199
200dtc/%:
201	mkdir -p $@
202
203$(SUBDIR_RULES): libqemuutil.a libqemustub.a $(common-obj-y)
204
205ROMSUBDIR_RULES=$(patsubst %,romsubdir-%, $(ROMS))
206romsubdir-%:
207	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C pc-bios/$* V="$(V)" TARGET_DIR="$*/",)
208
209ALL_SUBDIRS=$(TARGET_DIRS) $(patsubst %,pc-bios/%, $(ROMS))
210
211recurse-all: $(SUBDIR_RULES) $(ROMSUBDIR_RULES)
212
213$(BUILD_DIR)/version.o: $(SRC_PATH)/version.rc config-host.h | $(BUILD_DIR)/version.lo
214	$(call quiet-command,$(WINDRES) -I$(BUILD_DIR) -o $@ $<,"  RC    version.o")
215$(BUILD_DIR)/version.lo: $(SRC_PATH)/version.rc config-host.h
216	$(call quiet-command,$(WINDRES) -I$(BUILD_DIR) -o $@ $<,"  RC    version.lo")
217
218Makefile: $(version-obj-y) $(version-lobj-y)
219
220######################################################################
221# Build libraries
222
223libqemustub.a: $(stub-obj-y)
224libqemuutil.a: $(util-obj-y)
225
226block-modules = $(foreach o,$(block-obj-m),"$(basename $(subst /,-,$o))",) NULL
227util/module.o-cflags = -D'CONFIG_BLOCK_MODULES=$(block-modules)'
228
229######################################################################
230
231qemu-img.o: qemu-img-cmds.h
232
233qemu-img$(EXESUF): qemu-img.o $(block-obj-y) $(crypto-obj-y) libqemuutil.a libqemustub.a
234qemu-nbd$(EXESUF): qemu-nbd.o $(block-obj-y) $(crypto-obj-y) libqemuutil.a libqemustub.a
235qemu-io$(EXESUF): qemu-io.o $(block-obj-y) $(crypto-obj-y) libqemuutil.a libqemustub.a
236
237qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o
238
239fsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o fsdev/virtio-9p-marshal.o libqemuutil.a libqemustub.a
240fsdev/virtfs-proxy-helper$(EXESUF): LIBS += -lcap
241
242qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx
243	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"  GEN   $@")
244
245qemu-ga$(EXESUF): LIBS = $(LIBS_QGA)
246qemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated
247
248gen-out-type = $(subst .,-,$(suffix $@))
249
250qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py
251
252qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h :\
253$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
254	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \
255		$(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \
256		"  GEN   $@")
257qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h :\
258$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
259	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \
260		$(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \
261		"  GEN   $@")
262qga/qapi-generated/qga-qmp-commands.h qga/qapi-generated/qga-qmp-marshal.c :\
263$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
264	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \
265		$(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \
266		"  GEN   $@")
267
268qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \
269               $(SRC_PATH)/qapi/block.json $(SRC_PATH)/qapi/block-core.json \
270               $(SRC_PATH)/qapi/event.json
271
272qapi-types.c qapi-types.h :\
273$(qapi-modules) $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
274	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \
275		$(gen-out-type) -o "." -b $<, \
276		"  GEN   $@")
277qapi-visit.c qapi-visit.h :\
278$(qapi-modules) $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
279	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \
280		$(gen-out-type) -o "." -b $<, \
281		"  GEN   $@")
282qapi-event.c qapi-event.h :\
283$(qapi-modules) $(SRC_PATH)/scripts/qapi-event.py $(qapi-py)
284	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-event.py \
285		$(gen-out-type) -o "." $<, \
286		"  GEN   $@")
287qmp-commands.h qmp-marshal.c :\
288$(qapi-modules) $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
289	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \
290		$(gen-out-type) -o "." -m $<, \
291		"  GEN   $@")
292
293QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h)
294$(qga-obj-y) qemu-ga.o: $(QGALIB_GEN)
295
296# we require QGA_VSS_PROVIDER files to be built alongside qemu-ga
297# executable since they are shipped together, but we don't want to actually
298# link against them
299qemu-ga$(EXESUF): $(qga-obj-y) libqemuutil.a libqemustub.a $(QGA_VSS_PROVIDER)
300	$(call LINK, $(filter-out $(QGA_VSS_PROVIDER), $^))
301
302ifdef QEMU_GA_MSI_ENABLED
303QEMU_GA_MSI=qemu-ga-$(ARCH).msi
304
305msi: $(QEMU_GA_MSI)
306
307$(QEMU_GA_MSI): qemu-ga.exe
308
309$(QEMU_GA_MSI): config-host.mak
310
311$(QEMU_GA_MSI):  $(SRC_PATH)/qga/installer/qemu-ga.wxs
312	$(call quiet-command,QEMU_GA_VERSION="$(QEMU_GA_VERSION)" QEMU_GA_MANUFACTURER="$(QEMU_GA_MANUFACTURER)" QEMU_GA_DISTRO="$(QEMU_GA_DISTRO)" BUILD_DIR="$(BUILD_DIR)" \
313	wixl -o $@ $(QEMU_GA_MSI_ARCH) $(QEMU_GA_MSI_WITH_VSS) $(QEMU_GA_MSI_MINGW_DLL_PATH) $<, "  WIXL  $@")
314else
315msi:
316	@echo "MSI build not configured or dependency resolution failed (reconfigure with --enable-guest-agent-msi option)"
317endif
318
319clean:
320# avoid old build problems by removing potentially incorrect old files
321	rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
322	rm -f qemu-options.def
323	rm -f *.msi
324	find . \( -name '*.l[oa]' -o -name '*.so' -o -name '*.dll' -o -name '*.mo' -o -name '*.[oda]' \) -type f -exec rm {} +
325	rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) qemu-ga TAGS cscope.* *.pod *~ */*~
326	rm -f fsdev/*.pod
327	rm -rf .libs */.libs
328	rm -f qemu-img-cmds.h
329	rm -f ui/shader/*-vert.h ui/shader/*-frag.h
330	@# May not be present in GENERATED_HEADERS
331	rm -f trace/generated-tracers-dtrace.dtrace*
332	rm -f trace/generated-tracers-dtrace.h*
333	rm -f $(foreach f,$(GENERATED_HEADERS),$(f) $(f)-timestamp)
334	rm -f $(foreach f,$(GENERATED_SOURCES),$(f) $(f)-timestamp)
335	rm -rf qapi-generated
336	rm -rf qga/qapi-generated
337	for d in $(ALL_SUBDIRS); do \
338	if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \
339	rm -f $$d/qemu-options.def; \
340        done
341
342VERSION ?= $(shell cat VERSION)
343
344dist: qemu-$(VERSION).tar.bz2
345
346qemu-%.tar.bz2:
347	$(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst qemu-%.tar.bz2,%,$@)"
348
349distclean: clean
350	rm -f config-host.mak config-host.h* config-host.ld $(DOCS) qemu-options.texi qemu-img-cmds.texi qemu-monitor.texi
351	rm -f config-all-devices.mak config-all-disas.mak config.status
352	rm -f po/*.mo tests/qemu-iotests/common.env
353	rm -f roms/seabios/config.mak roms/vgabios/config.mak
354	rm -f qemu-doc.info qemu-doc.aux qemu-doc.cp qemu-doc.cps qemu-doc.dvi
355	rm -f qemu-doc.fn qemu-doc.fns qemu-doc.info qemu-doc.ky qemu-doc.kys
356	rm -f qemu-doc.log qemu-doc.pdf qemu-doc.pg qemu-doc.toc qemu-doc.tp
357	rm -f qemu-doc.vr
358	rm -f config.log
359	rm -f linux-headers/asm
360	rm -f qemu-tech.info qemu-tech.aux qemu-tech.cp qemu-tech.dvi qemu-tech.fn qemu-tech.info qemu-tech.ky qemu-tech.log qemu-tech.pdf qemu-tech.pg qemu-tech.toc qemu-tech.tp qemu-tech.vr
361	for d in $(TARGET_DIRS); do \
362	rm -rf $$d || exit 1 ; \
363        done
364	rm -Rf .sdk
365	if test -f pixman/config.log; then $(MAKE) -C pixman distclean; fi
366	if test -f dtc/version_gen.h; then $(MAKE) $(DTC_MAKE_ARGS) clean; fi
367
368KEYMAPS=da     en-gb  et  fr     fr-ch  is  lt  modifiers  no  pt-br  sv \
369ar      de     en-us  fi  fr-be  hr     it  lv  nl         pl  ru     th \
370common  de-ch  es     fo  fr-ca  hu     ja  mk  nl-be      pt  sl     tr \
371bepo    cz
372
373ifdef INSTALL_BLOBS
374BLOBS=bios.bin bios-256k.bin sgabios.bin vgabios.bin vgabios-cirrus.bin \
375vgabios-stdvga.bin vgabios-vmware.bin vgabios-qxl.bin vgabios-virtio.bin \
376acpi-dsdt.aml q35-acpi-dsdt.aml \
377ppc_rom.bin openbios-sparc32 openbios-sparc64 openbios-ppc QEMU,tcx.bin QEMU,cgthree.bin \
378pxe-e1000.rom pxe-eepro100.rom pxe-ne2k_pci.rom \
379pxe-pcnet.rom pxe-rtl8139.rom pxe-virtio.rom \
380efi-e1000.rom efi-eepro100.rom efi-ne2k_pci.rom \
381efi-pcnet.rom efi-rtl8139.rom efi-virtio.rom \
382qemu-icon.bmp qemu_logo_no_text.svg \
383bamboo.dtb petalogix-s3adsp1800.dtb petalogix-ml605.dtb \
384multiboot.bin linuxboot.bin kvmvapic.bin \
385s390-zipl.rom \
386s390-ccw.img \
387spapr-rtas.bin slof.bin \
388palcode-clipper \
389u-boot.e500
390else
391BLOBS=
392endif
393
394install-doc: $(DOCS)
395	$(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)"
396	$(INSTALL_DATA) qemu-doc.html  qemu-tech.html "$(DESTDIR)$(qemu_docdir)"
397	$(INSTALL_DATA) qmp-commands.txt "$(DESTDIR)$(qemu_docdir)"
398ifdef CONFIG_POSIX
399	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
400	$(INSTALL_DATA) qemu.1 "$(DESTDIR)$(mandir)/man1"
401ifneq ($(TOOLS),)
402	$(INSTALL_DATA) qemu-img.1 "$(DESTDIR)$(mandir)/man1"
403	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8"
404	$(INSTALL_DATA) qemu-nbd.8 "$(DESTDIR)$(mandir)/man8"
405endif
406ifneq (,$(findstring qemu-ga,$(TOOLS)))
407	$(INSTALL_DATA) qemu-ga.8 "$(DESTDIR)$(mandir)/man8"
408endif
409endif
410ifdef CONFIG_VIRTFS
411	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
412	$(INSTALL_DATA) fsdev/virtfs-proxy-helper.1 "$(DESTDIR)$(mandir)/man1"
413endif
414
415install-datadir:
416	$(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)"
417
418install-localstatedir:
419ifdef CONFIG_POSIX
420ifneq (,$(findstring qemu-ga,$(TOOLS)))
421	$(INSTALL_DIR) "$(DESTDIR)$(qemu_localstatedir)"/run
422endif
423endif
424
425
426install: all $(if $(BUILD_DOCS),install-doc) \
427install-datadir install-localstatedir
428ifneq ($(TOOLS),)
429	$(call install-prog,$(TOOLS),$(DESTDIR)$(bindir))
430endif
431ifneq ($(CONFIG_MODULES),)
432	$(INSTALL_DIR) "$(DESTDIR)$(qemu_moddir)"
433	for s in $(modules-m:.mo=$(DSOSUF)); do \
434		t="$(DESTDIR)$(qemu_moddir)/$$(echo $$s | tr / -)"; \
435		$(INSTALL_LIB) $$s "$$t"; \
436		test -z "$(STRIP)" || $(STRIP) "$$t"; \
437	done
438endif
439ifneq ($(HELPERS-y),)
440	$(call install-prog,$(HELPERS-y),$(DESTDIR)$(libexecdir))
441endif
442ifneq ($(BLOBS),)
443	set -e; for x in $(BLOBS); do \
444		$(INSTALL_DATA) $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(qemu_datadir)"; \
445	done
446endif
447ifeq ($(CONFIG_GTK),y)
448	$(MAKE) -C po $@
449endif
450	$(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/keymaps"
451	set -e; for x in $(KEYMAPS); do \
452		$(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x "$(DESTDIR)$(qemu_datadir)/keymaps"; \
453	done
454	$(INSTALL_DATA) $(SRC_PATH)/trace-events "$(DESTDIR)$(qemu_datadir)/trace-events"
455	for d in $(TARGET_DIRS); do \
456	$(MAKE) $(SUBDIR_MAKEFLAGS) TARGET_DIR=$$d/ -C $$d $@ || exit 1 ; \
457        done
458
459# various test targets
460test speed: all
461	$(MAKE) -C tests/tcg $@
462
463.PHONY: ctags
464ctags:
465	rm -f $@
466	find "$(SRC_PATH)" -name '*.[hc]' -exec ctags --append {} +
467
468.PHONY: TAGS
469TAGS:
470	rm -f $@
471	find "$(SRC_PATH)" -name '*.[hc]' -exec etags --append {} +
472
473cscope:
474	rm -f "$(SRC_PATH)"/cscope.*
475	find "$(SRC_PATH)/" -name "*.[chsS]" -print | sed 's,^\./,,' > "$(SRC_PATH)/cscope.files"
476	cscope -b -i"$(SRC_PATH)/cscope.files"
477
478# opengl shader programs
479ui/shader/%-vert.h: $(SRC_PATH)/ui/shader/%.vert $(SRC_PATH)/scripts/shaderinclude.pl
480	@mkdir -p $(dir $@)
481	$(call quiet-command,\
482		perl $(SRC_PATH)/scripts/shaderinclude.pl $< > $@,\
483		"  VERT  $@")
484
485ui/shader/%-frag.h: $(SRC_PATH)/ui/shader/%.frag $(SRC_PATH)/scripts/shaderinclude.pl
486	@mkdir -p $(dir $@)
487	$(call quiet-command,\
488		perl $(SRC_PATH)/scripts/shaderinclude.pl $< > $@,\
489		"  FRAG  $@")
490
491ui/console-gl.o: $(SRC_PATH)/ui/console-gl.c \
492	ui/shader/texture-blit-vert.h ui/shader/texture-blit-frag.h
493
494# documentation
495MAKEINFO=makeinfo
496MAKEINFOFLAGS=--no-headers --no-split --number-sections
497TEXIFLAG=$(if $(V),,--quiet)
498%.dvi: %.texi
499	$(call quiet-command,texi2dvi $(TEXIFLAG) -I . $<,"  GEN   $@")
500
501%.html: %.texi
502	$(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --html $< -o $@, \
503	"  GEN   $@")
504
505%.info: %.texi
506	$(call quiet-command,$(MAKEINFO) $< -o $@,"  GEN   $@")
507
508%.pdf: %.texi
509	$(call quiet-command,texi2pdf $(TEXIFLAG) -I . $<,"  GEN   $@")
510
511qemu-options.texi: $(SRC_PATH)/qemu-options.hx
512	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"  GEN   $@")
513
514qemu-monitor.texi: $(SRC_PATH)/hmp-commands.hx
515	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"  GEN   $@")
516
517qmp-commands.txt: $(SRC_PATH)/qmp-commands.hx
518	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -q < $< > $@,"  GEN   $@")
519
520qemu-img-cmds.texi: $(SRC_PATH)/qemu-img-cmds.hx
521	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"  GEN   $@")
522
523qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi
524	$(call quiet-command, \
525	  perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu.pod && \
526	  $(POD2MAN) --section=1 --center=" " --release=" " qemu.pod > $@, \
527	  "  GEN   $@")
528
529qemu-img.1: qemu-img.texi qemu-img-cmds.texi
530	$(call quiet-command, \
531	  perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu-img.pod && \
532	  $(POD2MAN) --section=1 --center=" " --release=" " qemu-img.pod > $@, \
533	  "  GEN   $@")
534
535fsdev/virtfs-proxy-helper.1: fsdev/virtfs-proxy-helper.texi
536	$(call quiet-command, \
537	  perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< fsdev/virtfs-proxy-helper.pod && \
538	  $(POD2MAN) --section=1 --center=" " --release=" " fsdev/virtfs-proxy-helper.pod > $@, \
539	  "  GEN   $@")
540
541qemu-nbd.8: qemu-nbd.texi
542	$(call quiet-command, \
543	  perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu-nbd.pod && \
544	  $(POD2MAN) --section=8 --center=" " --release=" " qemu-nbd.pod > $@, \
545	  "  GEN   $@")
546
547qemu-ga.8: qemu-ga.texi
548	$(call quiet-command, \
549	  perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu-ga.pod && \
550	  $(POD2MAN) --section=8 --center=" " --release=" " qemu-ga.pod > $@, \
551	  "  GEN   $@")
552
553kvm_stat.1: scripts/kvm/kvm_stat.texi
554	$(call quiet-command, \
555	  perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< kvm_stat.pod && \
556	  $(POD2MAN) --section=1 --center=" " --release=" " kvm_stat.pod > $@, \
557	  "  GEN   $@")
558
559dvi: qemu-doc.dvi qemu-tech.dvi
560html: qemu-doc.html qemu-tech.html
561info: qemu-doc.info qemu-tech.info
562pdf: qemu-doc.pdf qemu-tech.pdf
563
564qemu-doc.dvi qemu-doc.html qemu-doc.info qemu-doc.pdf: \
565	qemu-img.texi qemu-nbd.texi qemu-options.texi \
566	qemu-monitor.texi qemu-img-cmds.texi qemu-ga.texi
567
568ifdef CONFIG_WIN32
569
570INSTALLER = qemu-setup-$(VERSION)$(EXESUF)
571
572nsisflags = -V2 -NOCD
573
574ifneq ($(wildcard $(SRC_PATH)/dll),)
575ifeq ($(ARCH),x86_64)
576# 64 bit executables
577DLL_PATH = $(SRC_PATH)/dll/w64
578nsisflags += -DW64
579else
580# 32 bit executables
581DLL_PATH = $(SRC_PATH)/dll/w32
582endif
583endif
584
585.PHONY: installer
586installer: $(INSTALLER)
587
588INSTDIR=/tmp/qemu-nsis
589
590$(INSTALLER): $(SRC_PATH)/qemu.nsi
591	$(MAKE) install prefix=${INSTDIR}
592ifdef SIGNCODE
593	(cd ${INSTDIR}; \
594         for i in *.exe; do \
595           $(SIGNCODE) $${i}; \
596         done \
597        )
598endif # SIGNCODE
599	(cd ${INSTDIR}; \
600         for i in qemu-system-*.exe; do \
601           arch=$${i%.exe}; \
602           arch=$${arch#qemu-system-}; \
603           echo Section \"$$arch\" Section_$$arch; \
604           echo SetOutPath \"\$$INSTDIR\"; \
605           echo File \"\$${BINDIR}\\$$i\"; \
606           echo SectionEnd; \
607         done \
608        ) >${INSTDIR}/system-emulations.nsh
609	makensis $(nsisflags) \
610                $(if $(BUILD_DOCS),-DCONFIG_DOCUMENTATION="y") \
611                $(if $(CONFIG_GTK),-DCONFIG_GTK="y") \
612                -DBINDIR="${INSTDIR}" \
613                $(if $(DLL_PATH),-DDLLDIR="$(DLL_PATH)") \
614                -DSRCDIR="$(SRC_PATH)" \
615                -DOUTFILE="$(INSTALLER)" \
616                $(SRC_PATH)/qemu.nsi
617	rm -r ${INSTDIR}
618ifdef SIGNCODE
619	$(SIGNCODE) $(INSTALLER)
620endif # SIGNCODE
621endif # CONFIG_WIN
622
623# Add a dependency on the generated files, so that they are always
624# rebuilt before other object files
625ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
626Makefile: $(GENERATED_HEADERS)
627endif
628
629# Include automatically generated dependency files
630# Dependencies in Makefile.objs files come from our recursive subdir rules
631-include $(wildcard *.d tests/*.d)
632