xref: /openbmc/qemu/Makefile (revision db432672)
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 dist \
10    html info pdf txt \
11    help check-help print-% \
12    docker docker-% vm-test vm-build-%
13
14print-%:
15	@echo '$*=$($*)'
16
17# All following code might depend on configuration variables
18ifneq ($(wildcard config-host.mak),)
19# Put the all: rule here so that config-host.mak can contain dependencies.
20all:
21include config-host.mak
22
23PYTHON_UTF8 = LC_ALL= LANG=C LC_CTYPE=en_US.UTF-8 $(PYTHON)
24
25git-submodule-update:
26
27.PHONY: git-submodule-update
28
29git_module_status := $(shell \
30  cd '$(SRC_PATH)' && \
31  GIT="$(GIT)" ./scripts/git-submodule.sh status $(GIT_SUBMODULES); \
32  echo $$?; \
33)
34
35ifeq (1,$(git_module_status))
36ifeq (no,$(GIT_UPDATE))
37git-submodule-update:
38	$(call quiet-command, \
39            echo && \
40            echo "GIT submodule checkout is out of date. Please run" && \
41            echo "  scripts/git-submodule.sh update $(GIT_SUBMODULES)" && \
42            echo "from the source directory checkout $(SRC_PATH)" && \
43            echo && \
44            exit 1)
45else
46git-submodule-update:
47	$(call quiet-command, \
48          (cd $(SRC_PATH) && GIT="$(GIT)" ./scripts/git-submodule.sh update $(GIT_SUBMODULES)), \
49          "GIT","$(GIT_SUBMODULES)")
50endif
51endif
52
53.git-submodule-status: git-submodule-update config-host.mak
54
55# Check that we're not trying to do an out-of-tree build from
56# a tree that's been used for an in-tree build.
57ifneq ($(realpath $(SRC_PATH)),$(realpath .))
58ifneq ($(wildcard $(SRC_PATH)/config-host.mak),)
59$(error This is an out of tree build but your source tree ($(SRC_PATH)) \
60seems to have been used for an in-tree build. You can fix this by running \
61"$(MAKE) distclean && rm -rf *-linux-user *-softmmu" in your source tree)
62endif
63endif
64
65CONFIG_SOFTMMU := $(if $(filter %-softmmu,$(TARGET_DIRS)),y)
66CONFIG_USER_ONLY := $(if $(filter %-user,$(TARGET_DIRS)),y)
67CONFIG_XEN := $(CONFIG_XEN_BACKEND)
68CONFIG_ALL=y
69-include config-all-devices.mak
70-include config-all-disas.mak
71
72config-host.mak: $(SRC_PATH)/configure $(SRC_PATH)/pc-bios
73	@echo $@ is out-of-date, running configure
74	@# TODO: The next lines include code which supports a smooth
75	@# transition from old configurations without config.status.
76	@# This code can be removed after QEMU 1.7.
77	@if test -x config.status; then \
78	    ./config.status; \
79        else \
80	    sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh; \
81	fi
82else
83config-host.mak:
84ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
85	@echo "Please call configure before running make!"
86	@exit 1
87endif
88endif
89
90include $(SRC_PATH)/rules.mak
91
92GENERATED_FILES = qemu-version.h config-host.h qemu-options.def
93GENERATED_FILES += qmp-commands.h qapi-types.h qapi-visit.h qapi-event.h
94GENERATED_FILES += qmp-marshal.c qapi-types.c qapi-visit.c qapi-event.c
95GENERATED_FILES += qmp-introspect.h
96GENERATED_FILES += qmp-introspect.c
97
98GENERATED_FILES += trace/generated-tcg-tracers.h
99
100GENERATED_FILES += trace/generated-helpers-wrappers.h
101GENERATED_FILES += trace/generated-helpers.h
102GENERATED_FILES += trace/generated-helpers.c
103
104ifdef CONFIG_TRACE_UST
105GENERATED_FILES += trace-ust-all.h
106GENERATED_FILES += trace-ust-all.c
107endif
108
109GENERATED_FILES += module_block.h
110
111TRACE_HEADERS = trace-root.h $(trace-events-subdirs:%=%/trace.h)
112TRACE_SOURCES = trace-root.c $(trace-events-subdirs:%=%/trace.c)
113TRACE_DTRACE =
114ifdef CONFIG_TRACE_DTRACE
115TRACE_HEADERS += trace-dtrace-root.h $(trace-events-subdirs:%=%/trace-dtrace.h)
116TRACE_DTRACE += trace-dtrace-root.dtrace $(trace-events-subdirs:%=%/trace-dtrace.dtrace)
117endif
118ifdef CONFIG_TRACE_UST
119TRACE_HEADERS += trace-ust-root.h $(trace-events-subdirs:%=%/trace-ust.h)
120endif
121
122GENERATED_FILES += $(TRACE_HEADERS)
123GENERATED_FILES += $(TRACE_SOURCES)
124GENERATED_FILES += $(BUILD_DIR)/trace-events-all
125GENERATED_FILES += .git-submodule-status
126
127trace-group-name = $(shell dirname $1 | sed -e 's/[^a-zA-Z0-9]/_/g')
128
129tracetool-y = $(SRC_PATH)/scripts/tracetool.py
130tracetool-y += $(shell find $(SRC_PATH)/scripts/tracetool -name "*.py")
131
132%/trace.h: %/trace.h-timestamp
133	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
134%/trace.h-timestamp: $(SRC_PATH)/%/trace-events $(tracetool-y)
135	$(call quiet-command,$(TRACETOOL) \
136		--group=$(call trace-group-name,$@) \
137		--format=h \
138		--backends=$(TRACE_BACKENDS) \
139		$< > $@,"GEN","$(@:%-timestamp=%)")
140
141%/trace.c: %/trace.c-timestamp
142	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
143%/trace.c-timestamp: $(SRC_PATH)/%/trace-events $(tracetool-y)
144	$(call quiet-command,$(TRACETOOL) \
145		--group=$(call trace-group-name,$@) \
146		--format=c \
147		--backends=$(TRACE_BACKENDS) \
148		$< > $@,"GEN","$(@:%-timestamp=%)")
149
150%/trace-ust.h: %/trace-ust.h-timestamp
151	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
152%/trace-ust.h-timestamp: $(SRC_PATH)/%/trace-events $(tracetool-y)
153	$(call quiet-command,$(TRACETOOL) \
154		--group=$(call trace-group-name,$@) \
155		--format=ust-events-h \
156		--backends=$(TRACE_BACKENDS) \
157		$< > $@,"GEN","$(@:%-timestamp=%)")
158
159%/trace-dtrace.dtrace: %/trace-dtrace.dtrace-timestamp
160	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
161%/trace-dtrace.dtrace-timestamp: $(SRC_PATH)/%/trace-events $(BUILD_DIR)/config-host.mak $(tracetool-y)
162	$(call quiet-command,$(TRACETOOL) \
163		--group=$(call trace-group-name,$@) \
164		--format=d \
165		--backends=$(TRACE_BACKENDS) \
166		$< > $@,"GEN","$(@:%-timestamp=%)")
167
168%/trace-dtrace.h: %/trace-dtrace.dtrace $(tracetool-y)
169	$(call quiet-command,dtrace -o $@ -h -s $<, "GEN","$@")
170
171%/trace-dtrace.o: %/trace-dtrace.dtrace $(tracetool-y)
172
173
174trace-root.h: trace-root.h-timestamp
175	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
176trace-root.h-timestamp: $(SRC_PATH)/trace-events $(tracetool-y)
177	$(call quiet-command,$(TRACETOOL) \
178		--group=root \
179		--format=h \
180		--backends=$(TRACE_BACKENDS) \
181		$< > $@,"GEN","$(@:%-timestamp=%)")
182
183trace-root.c: trace-root.c-timestamp
184	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
185trace-root.c-timestamp: $(SRC_PATH)/trace-events $(tracetool-y)
186	$(call quiet-command,$(TRACETOOL) \
187		--group=root \
188		--format=c \
189		--backends=$(TRACE_BACKENDS) \
190		$< > $@,"GEN","$(@:%-timestamp=%)")
191
192trace-ust-root.h: trace-ust-root.h-timestamp
193	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
194trace-ust-root.h-timestamp: $(SRC_PATH)/trace-events $(tracetool-y)
195	$(call quiet-command,$(TRACETOOL) \
196		--group=root \
197		--format=ust-events-h \
198		--backends=$(TRACE_BACKENDS) \
199		$< > $@,"GEN","$(@:%-timestamp=%)")
200
201trace-ust-all.h: trace-ust-all.h-timestamp
202	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
203trace-ust-all.h-timestamp: $(trace-events-files) $(tracetool-y)
204	$(call quiet-command,$(TRACETOOL) \
205		--group=all \
206		--format=ust-events-h \
207		--backends=$(TRACE_BACKENDS) \
208		$(trace-events-files) > $@,"GEN","$(@:%-timestamp=%)")
209
210trace-ust-all.c: trace-ust-all.c-timestamp
211	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
212trace-ust-all.c-timestamp: $(trace-events-files) $(tracetool-y)
213	$(call quiet-command,$(TRACETOOL) \
214		--group=all \
215		--format=ust-events-c \
216		--backends=$(TRACE_BACKENDS) \
217		$(trace-events-files) > $@,"GEN","$(@:%-timestamp=%)")
218
219trace-dtrace-root.dtrace: trace-dtrace-root.dtrace-timestamp
220	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
221trace-dtrace-root.dtrace-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak $(tracetool-y)
222	$(call quiet-command,$(TRACETOOL) \
223		--group=root \
224		--format=d \
225		--backends=$(TRACE_BACKENDS) \
226		$< > $@,"GEN","$(@:%-timestamp=%)")
227
228trace-dtrace-root.h: trace-dtrace-root.dtrace
229	$(call quiet-command,dtrace -o $@ -h -s $<, "GEN","$@")
230
231trace-dtrace-root.o: trace-dtrace-root.dtrace
232
233KEYCODEMAP_GEN = $(SRC_PATH)/ui/keycodemapdb/tools/keymap-gen
234KEYCODEMAP_CSV = $(SRC_PATH)/ui/keycodemapdb/data/keymaps.csv
235
236KEYCODEMAP_FILES = \
237		 ui/input-keymap-atset1-to-qcode.c \
238		 ui/input-keymap-linux-to-qcode.c \
239		 ui/input-keymap-qcode-to-atset1.c \
240		 ui/input-keymap-qcode-to-atset2.c \
241		 ui/input-keymap-qcode-to-atset3.c \
242		 ui/input-keymap-qcode-to-linux.c \
243		 ui/input-keymap-qcode-to-qnum.c \
244		 ui/input-keymap-qcode-to-sun.c \
245		 ui/input-keymap-qnum-to-qcode.c \
246		 ui/input-keymap-usb-to-qcode.c \
247		 ui/input-keymap-win32-to-qcode.c \
248		 ui/input-keymap-x11-to-qcode.c \
249		 ui/input-keymap-xorgevdev-to-qcode.c \
250		 ui/input-keymap-xorgkbd-to-qcode.c \
251		 ui/input-keymap-xorgxquartz-to-qcode.c \
252		 ui/input-keymap-xorgxwin-to-qcode.c \
253		 $(NULL)
254
255GENERATED_FILES += $(KEYCODEMAP_FILES)
256
257ui/input-keymap-%.c: $(KEYCODEMAP_GEN) $(KEYCODEMAP_CSV) $(SRC_PATH)/ui/Makefile.objs
258	$(call quiet-command,\
259	    src=$$(echo $@ | sed -E -e "s,^ui/input-keymap-(.+)-to-(.+)\.c$$,\1,") && \
260	    dst=$$(echo $@ | sed -E -e "s,^ui/input-keymap-(.+)-to-(.+)\.c$$,\2,") && \
261	    test -e $(KEYCODEMAP_GEN) && \
262	    $(PYTHON) $(KEYCODEMAP_GEN) \
263	          --lang glib2 \
264	          --varname qemu_input_map_$${src}_to_$${dst} \
265	          code-map $(KEYCODEMAP_CSV) $${src} $${dst} \
266	        > $@ || rm -f $@, "GEN", "$@")
267
268$(KEYCODEMAP_GEN): .git-submodule-status
269$(KEYCODEMAP_CSV): .git-submodule-status
270
271# Don't try to regenerate Makefile or configure
272# We don't generate any of them
273Makefile: ;
274configure: ;
275
276.PHONY: all clean cscope distclean html info install install-doc \
277	pdf txt recurse-all dist msi FORCE
278
279$(call set-vpath, $(SRC_PATH))
280
281LIBS+=-lz $(LIBS_TOOLS)
282
283HELPERS-$(CONFIG_LINUX) = qemu-bridge-helper$(EXESUF)
284
285ifdef BUILD_DOCS
286DOCS=qemu-doc.html qemu-doc.txt qemu.1 qemu-img.1 qemu-nbd.8 qemu-ga.8
287DOCS+=docs/interop/qemu-qmp-ref.html docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7
288DOCS+=docs/interop/qemu-ga-ref.html docs/interop/qemu-ga-ref.txt docs/interop/qemu-ga-ref.7
289DOCS+=docs/qemu-block-drivers.7
290ifdef CONFIG_VIRTFS
291DOCS+=fsdev/virtfs-proxy-helper.1
292endif
293else
294DOCS=
295endif
296
297SUBDIR_MAKEFLAGS=BUILD_DIR=$(BUILD_DIR)
298SUBDIR_DEVICES_MAK=$(patsubst %, %/config-devices.mak, $(TARGET_DIRS))
299SUBDIR_DEVICES_MAK_DEP=$(patsubst %, %-config-devices.mak.d, $(TARGET_DIRS))
300
301ifeq ($(SUBDIR_DEVICES_MAK),)
302config-all-devices.mak:
303	$(call quiet-command,echo '# no devices' > $@,"GEN","$@")
304else
305config-all-devices.mak: $(SUBDIR_DEVICES_MAK)
306	$(call quiet-command, sed -n \
307             's|^\([^=]*\)=\(.*\)$$|\1:=$$(findstring y,$$(\1)\2)|p' \
308             $(SUBDIR_DEVICES_MAK) | sort -u > $@, \
309             "GEN","$@")
310endif
311
312-include $(SUBDIR_DEVICES_MAK_DEP)
313
314%/config-devices.mak: default-configs/%.mak $(SRC_PATH)/scripts/make_device_config.sh
315	$(call quiet-command, \
316            $(SHELL) $(SRC_PATH)/scripts/make_device_config.sh $< $*-config-devices.mak.d $@ > $@.tmp,"GEN","$@.tmp")
317	$(call quiet-command, if test -f $@; then \
318	  if cmp -s $@.old $@; then \
319	    mv $@.tmp $@; \
320	    cp -p $@ $@.old; \
321	  else \
322	    if test -f $@.old; then \
323	      echo "WARNING: $@ (user modified) out of date.";\
324	    else \
325	      echo "WARNING: $@ out of date.";\
326	    fi; \
327	    echo "Run \"$(MAKE) defconfig\" to regenerate."; \
328	    rm $@.tmp; \
329	  fi; \
330	 else \
331	  mv $@.tmp $@; \
332	  cp -p $@ $@.old; \
333	 fi,"GEN","$@");
334
335defconfig:
336	rm -f config-all-devices.mak $(SUBDIR_DEVICES_MAK)
337
338ifneq ($(wildcard config-host.mak),)
339include $(SRC_PATH)/Makefile.objs
340endif
341
342dummy := $(call unnest-vars,, \
343                stub-obj-y \
344                chardev-obj-y \
345                util-obj-y \
346                qga-obj-y \
347                ivshmem-client-obj-y \
348                ivshmem-server-obj-y \
349                libvhost-user-obj-y \
350                vhost-user-scsi-obj-y \
351                vhost-user-blk-obj-y \
352                qga-vss-dll-obj-y \
353                block-obj-y \
354                block-obj-m \
355                crypto-obj-y \
356                crypto-aes-obj-y \
357                qom-obj-y \
358                io-obj-y \
359                common-obj-y \
360                common-obj-m \
361                trace-obj-y)
362
363include $(SRC_PATH)/tests/Makefile.include
364
365all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all modules
366
367qemu-version.h: FORCE
368	$(call quiet-command, \
369		(cd $(SRC_PATH); \
370		printf '#define QEMU_PKGVERSION '; \
371		if test -n "$(PKGVERSION)"; then \
372			printf '"$(PKGVERSION)"\n'; \
373		else \
374			if test -d .git; then \
375				printf '" ('; \
376				git describe --match 'v*' 2>/dev/null | tr -d '\n'; \
377				if ! git diff-index --quiet HEAD &>/dev/null; then \
378					printf -- '-dirty'; \
379				fi; \
380				printf ')"\n'; \
381			else \
382				printf '""\n'; \
383			fi; \
384		fi) > $@.tmp)
385	$(call quiet-command, if ! cmp -s $@ $@.tmp; then \
386	  mv $@.tmp $@; \
387	 else \
388	  rm $@.tmp; \
389	 fi)
390
391config-host.h: config-host.h-timestamp
392config-host.h-timestamp: config-host.mak
393qemu-options.def: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool
394	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$@")
395
396SUBDIR_RULES=$(patsubst %,subdir-%, $(TARGET_DIRS))
397SOFTMMU_SUBDIR_RULES=$(filter %-softmmu,$(SUBDIR_RULES))
398
399$(SOFTMMU_SUBDIR_RULES): $(block-obj-y)
400$(SOFTMMU_SUBDIR_RULES): $(crypto-obj-y)
401$(SOFTMMU_SUBDIR_RULES): $(io-obj-y)
402$(SOFTMMU_SUBDIR_RULES): config-all-devices.mak
403
404subdir-%:
405	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" TARGET_DIR="$*/" all,)
406
407DTC_MAKE_ARGS=-I$(SRC_PATH)/dtc VPATH=$(SRC_PATH)/dtc -C dtc V="$(V)" LIBFDT_srcdir=$(SRC_PATH)/dtc/libfdt
408DTC_CFLAGS=$(CFLAGS) $(QEMU_CFLAGS)
409DTC_CPPFLAGS=-I$(BUILD_DIR)/dtc -I$(SRC_PATH)/dtc -I$(SRC_PATH)/dtc/libfdt
410
411subdir-dtc: .git-submodule-status dtc/libfdt dtc/tests
412	$(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,)
413
414dtc/%: .git-submodule-status
415	mkdir -p $@
416
417# Overriding CFLAGS causes us to lose defines added in the sub-makefile.
418# Not overriding CFLAGS leads to mis-matches between compilation modes.
419# Therefore we replicate some of the logic in the sub-makefile.
420# Remove all the extra -Warning flags that QEMU uses that Capstone doesn't;
421# no need to annoy QEMU developers with such things.
422CAP_CFLAGS = $(patsubst -W%,,$(CFLAGS) $(QEMU_CFLAGS))
423CAP_CFLAGS += -DCAPSTONE_USE_SYS_DYN_MEM
424CAP_CFLAGS += -DCAPSTONE_HAS_ARM
425CAP_CFLAGS += -DCAPSTONE_HAS_ARM64
426CAP_CFLAGS += -DCAPSTONE_HAS_POWERPC
427CAP_CFLAGS += -DCAPSTONE_HAS_X86
428
429subdir-capstone: .git-submodule-status
430	$(call quiet-command,$(MAKE) -C $(SRC_PATH)/capstone CAPSTONE_SHARED=no BUILDDIR="$(BUILD_DIR)/capstone" CC="$(CC)" AR="$(AR)" LD="$(LD)" RANLIB="$(RANLIB)" CFLAGS="$(CAP_CFLAGS)" $(SUBDIR_MAKEFLAGS) $(BUILD_DIR)/capstone/$(LIBCAPSTONE))
431
432$(SUBDIR_RULES): libqemuutil.a $(common-obj-y) $(chardev-obj-y) \
433	$(qom-obj-y) $(crypto-aes-obj-$(CONFIG_USER_ONLY))
434
435ROMSUBDIR_RULES=$(patsubst %,romsubdir-%, $(ROMS))
436# Only keep -O and -g cflags
437romsubdir-%:
438	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C pc-bios/$* V="$(V)" TARGET_DIR="$*/" CFLAGS="$(filter -O% -g%,$(CFLAGS))",)
439
440ALL_SUBDIRS=$(TARGET_DIRS) $(patsubst %,pc-bios/%, $(ROMS))
441
442recurse-all: $(SUBDIR_RULES) $(ROMSUBDIR_RULES)
443
444$(BUILD_DIR)/version.o: $(SRC_PATH)/version.rc config-host.h
445	$(call quiet-command,$(WINDRES) -I$(BUILD_DIR) -o $@ $<,"RC","version.o")
446
447Makefile: $(version-obj-y)
448
449######################################################################
450# Build libraries
451
452libqemuutil.a: $(util-obj-y) $(trace-obj-y) $(stub-obj-y)
453libvhost-user.a: $(libvhost-user-obj-y)
454
455######################################################################
456
457COMMON_LDADDS = libqemuutil.a
458
459qemu-img.o: qemu-img-cmds.h
460
461qemu-img$(EXESUF): qemu-img.o $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
462qemu-nbd$(EXESUF): qemu-nbd.o $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
463qemu-io$(EXESUF): qemu-io.o $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
464
465qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o $(COMMON_LDADDS)
466
467qemu-keymap$(EXESUF): qemu-keymap.o ui/input-keymap.o $(COMMON_LDADDS)
468
469fsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o fsdev/9p-marshal.o fsdev/9p-iov-marshal.o $(COMMON_LDADDS)
470fsdev/virtfs-proxy-helper$(EXESUF): LIBS += -lcap
471
472scsi/qemu-pr-helper$(EXESUF): scsi/qemu-pr-helper.o scsi/utils.o $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
473ifdef CONFIG_MPATH
474scsi/qemu-pr-helper$(EXESUF): LIBS += -ludev -lmultipath -lmpathpersist
475endif
476
477qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool
478	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$@")
479
480qemu-ga$(EXESUF): LIBS = $(LIBS_QGA)
481qemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated
482
483qemu-keymap$(EXESUF): LIBS += $(XKBCOMMON_LIBS)
484qemu-keymap$(EXESUF): QEMU_CFLAGS += $(XKBCOMMON_CFLAGS)
485
486gen-out-type = $(subst .,-,$(suffix $@))
487
488qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py
489
490qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h :\
491$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
492	$(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi-types.py \
493		$(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \
494		"GEN","$@")
495qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h :\
496$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
497	$(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi-visit.py \
498		$(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \
499		"GEN","$@")
500qga/qapi-generated/qga-qmp-commands.h qga/qapi-generated/qga-qmp-marshal.c :\
501$(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
502	$(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi-commands.py \
503		$(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \
504		"GEN","$@")
505
506qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \
507               $(SRC_PATH)/qapi/block.json $(SRC_PATH)/qapi/block-core.json \
508               $(SRC_PATH)/qapi/char.json \
509               $(SRC_PATH)/qapi/crypto.json \
510               $(SRC_PATH)/qapi/introspect.json \
511               $(SRC_PATH)/qapi/migration.json \
512               $(SRC_PATH)/qapi/net.json \
513               $(SRC_PATH)/qapi/rocker.json \
514               $(SRC_PATH)/qapi/run-state.json \
515               $(SRC_PATH)/qapi/sockets.json \
516               $(SRC_PATH)/qapi/tpm.json \
517               $(SRC_PATH)/qapi/trace.json \
518               $(SRC_PATH)/qapi/transaction.json \
519               $(SRC_PATH)/qapi/ui.json
520
521qapi-types.c qapi-types.h :\
522$(qapi-modules) $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
523	$(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi-types.py \
524		$(gen-out-type) -o "." -b $<, \
525		"GEN","$@")
526qapi-visit.c qapi-visit.h :\
527$(qapi-modules) $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
528	$(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi-visit.py \
529		$(gen-out-type) -o "." -b $<, \
530		"GEN","$@")
531qapi-event.c qapi-event.h :\
532$(qapi-modules) $(SRC_PATH)/scripts/qapi-event.py $(qapi-py)
533	$(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi-event.py \
534		$(gen-out-type) -o "." $<, \
535		"GEN","$@")
536qmp-commands.h qmp-marshal.c :\
537$(qapi-modules) $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
538	$(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi-commands.py \
539		$(gen-out-type) -o "." $<, \
540		"GEN","$@")
541qmp-introspect.h qmp-introspect.c :\
542$(qapi-modules) $(SRC_PATH)/scripts/qapi-introspect.py $(qapi-py)
543	$(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi-introspect.py \
544		$(gen-out-type) -o "." $<, \
545		"GEN","$@")
546
547QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h)
548$(qga-obj-y): $(QGALIB_GEN)
549
550qemu-ga$(EXESUF): $(qga-obj-y) $(COMMON_LDADDS)
551	$(call LINK, $^)
552
553ifdef QEMU_GA_MSI_ENABLED
554QEMU_GA_MSI=qemu-ga-$(ARCH).msi
555
556msi: $(QEMU_GA_MSI)
557
558$(QEMU_GA_MSI): qemu-ga.exe $(QGA_VSS_PROVIDER)
559
560$(QEMU_GA_MSI): config-host.mak
561
562$(QEMU_GA_MSI):  $(SRC_PATH)/qga/installer/qemu-ga.wxs
563	$(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)" \
564	wixl -o $@ $(QEMU_GA_MSI_ARCH) $(QEMU_GA_MSI_WITH_VSS) $(QEMU_GA_MSI_MINGW_DLL_PATH) $<,"WIXL","$@")
565else
566msi:
567	@echo "MSI build not configured or dependency resolution failed (reconfigure with --enable-guest-agent-msi option)"
568endif
569
570ifneq ($(EXESUF),)
571.PHONY: qemu-ga
572qemu-ga: qemu-ga$(EXESUF) $(QGA_VSS_PROVIDER) $(QEMU_GA_MSI)
573endif
574
575ifdef CONFIG_IVSHMEM
576ivshmem-client$(EXESUF): $(ivshmem-client-obj-y) $(COMMON_LDADDS)
577	$(call LINK, $^)
578ivshmem-server$(EXESUF): $(ivshmem-server-obj-y) $(COMMON_LDADDS)
579	$(call LINK, $^)
580endif
581vhost-user-scsi$(EXESUF): $(vhost-user-scsi-obj-y) libvhost-user.a
582	$(call LINK, $^)
583vhost-user-blk$(EXESUF): $(vhost-user-blk-obj-y) libvhost-user.a
584	$(call LINK, $^)
585
586module_block.h: $(SRC_PATH)/scripts/modules/module_block.py config-host.mak
587	$(call quiet-command,$(PYTHON) $< $@ \
588	$(addprefix $(SRC_PATH)/,$(patsubst %.mo,%.c,$(block-obj-m))), \
589	"GEN","$@")
590
591clean:
592# avoid old build problems by removing potentially incorrect old files
593	rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
594	rm -f qemu-options.def
595	rm -f *.msi
596	find . \( -name '*.so' -o -name '*.dll' -o -name '*.mo' -o -name '*.[oda]' \) -type f -exec rm {} +
597	rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) qemu-ga TAGS cscope.* *.pod *~ */*~
598	rm -f fsdev/*.pod scsi/*.pod
599	rm -f qemu-img-cmds.h
600	rm -f ui/shader/*-vert.h ui/shader/*-frag.h
601	@# May not be present in GENERATED_FILES
602	rm -f trace/generated-tracers-dtrace.dtrace*
603	rm -f trace/generated-tracers-dtrace.h*
604	rm -f $(foreach f,$(GENERATED_FILES),$(f) $(f)-timestamp)
605	rm -rf qapi-generated
606	rm -rf qga/qapi-generated
607	for d in $(ALL_SUBDIRS); do \
608	if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \
609	rm -f $$d/qemu-options.def; \
610        done
611	rm -f $(SUBDIR_DEVICES_MAK) config-all-devices.mak
612
613VERSION ?= $(shell cat VERSION)
614
615dist: qemu-$(VERSION).tar.bz2
616
617qemu-%.tar.bz2:
618	$(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst qemu-%.tar.bz2,%,$@)"
619
620distclean: clean
621	rm -f config-host.mak config-host.h* config-host.ld $(DOCS) qemu-options.texi qemu-img-cmds.texi qemu-monitor.texi qemu-monitor-info.texi
622	rm -f config-all-devices.mak config-all-disas.mak config.status
623	rm -f po/*.mo tests/qemu-iotests/common.env
624	rm -f roms/seabios/config.mak roms/vgabios/config.mak
625	rm -f qemu-doc.info qemu-doc.aux qemu-doc.cp qemu-doc.cps
626	rm -f qemu-doc.fn qemu-doc.fns qemu-doc.info qemu-doc.ky qemu-doc.kys
627	rm -f qemu-doc.log qemu-doc.pdf qemu-doc.pg qemu-doc.toc qemu-doc.tp
628	rm -f qemu-doc.vr qemu-doc.txt
629	rm -f config.log
630	rm -f linux-headers/asm
631	rm -f docs/version.texi
632	rm -f docs/interop/qemu-ga-qapi.texi docs/interop/qemu-qmp-qapi.texi
633	rm -f docs/interop/qemu-qmp-ref.7 docs/interop/qemu-ga-ref.7
634	rm -f docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
635	rm -f docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
636	rm -f docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html
637	rm -f docs/qemu-block-drivers.7
638	for d in $(TARGET_DIRS); do \
639	rm -rf $$d || exit 1 ; \
640        done
641	rm -Rf .sdk
642	if test -f dtc/version_gen.h; then $(MAKE) $(DTC_MAKE_ARGS) clean; fi
643
644KEYMAPS=da     en-gb  et  fr     fr-ch  is  lt  modifiers  no  pt-br  sv \
645ar      de     en-us  fi  fr-be  hr     it  lv  nl         pl  ru     th \
646common  de-ch  es     fo  fr-ca  hu     ja  mk  nl-be      pt  sl     tr \
647bepo    cz
648
649ifdef INSTALL_BLOBS
650BLOBS=bios.bin bios-256k.bin sgabios.bin vgabios.bin vgabios-cirrus.bin \
651vgabios-stdvga.bin vgabios-vmware.bin vgabios-qxl.bin vgabios-virtio.bin \
652acpi-dsdt.aml \
653ppc_rom.bin openbios-sparc32 openbios-sparc64 openbios-ppc QEMU,tcx.bin QEMU,cgthree.bin \
654pxe-e1000.rom pxe-eepro100.rom pxe-ne2k_pci.rom \
655pxe-pcnet.rom pxe-rtl8139.rom pxe-virtio.rom \
656efi-e1000.rom efi-eepro100.rom efi-ne2k_pci.rom \
657efi-pcnet.rom efi-rtl8139.rom efi-virtio.rom \
658efi-e1000e.rom efi-vmxnet3.rom \
659qemu-icon.bmp qemu_logo_no_text.svg \
660bamboo.dtb petalogix-s3adsp1800.dtb petalogix-ml605.dtb \
661multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin \
662s390-ccw.img s390-netboot.img \
663spapr-rtas.bin slof.bin skiboot.lid \
664palcode-clipper \
665u-boot.e500 \
666qemu_vga.ndrv \
667hppa-firmware.img
668else
669BLOBS=
670endif
671
672install-doc: $(DOCS)
673	$(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)"
674	$(INSTALL_DATA) qemu-doc.html "$(DESTDIR)$(qemu_docdir)"
675	$(INSTALL_DATA) qemu-doc.txt "$(DESTDIR)$(qemu_docdir)"
676	$(INSTALL_DATA) docs/interop/qemu-qmp-ref.html "$(DESTDIR)$(qemu_docdir)"
677	$(INSTALL_DATA) docs/interop/qemu-qmp-ref.txt "$(DESTDIR)$(qemu_docdir)"
678ifdef CONFIG_POSIX
679	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
680	$(INSTALL_DATA) qemu.1 "$(DESTDIR)$(mandir)/man1"
681	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man7"
682	$(INSTALL_DATA) docs/interop/qemu-qmp-ref.7 "$(DESTDIR)$(mandir)/man7"
683	$(INSTALL_DATA) docs/qemu-block-drivers.7 "$(DESTDIR)$(mandir)/man7"
684ifneq ($(TOOLS),)
685	$(INSTALL_DATA) qemu-img.1 "$(DESTDIR)$(mandir)/man1"
686	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8"
687	$(INSTALL_DATA) qemu-nbd.8 "$(DESTDIR)$(mandir)/man8"
688endif
689ifneq (,$(findstring qemu-ga,$(TOOLS)))
690	$(INSTALL_DATA) qemu-ga.8 "$(DESTDIR)$(mandir)/man8"
691	$(INSTALL_DATA) docs/interop/qemu-ga-ref.html "$(DESTDIR)$(qemu_docdir)"
692	$(INSTALL_DATA) docs/interop/qemu-ga-ref.txt "$(DESTDIR)$(qemu_docdir)"
693	$(INSTALL_DATA) docs/interop/qemu-ga-ref.7 "$(DESTDIR)$(mandir)/man7"
694endif
695endif
696ifdef CONFIG_VIRTFS
697	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
698	$(INSTALL_DATA) fsdev/virtfs-proxy-helper.1 "$(DESTDIR)$(mandir)/man1"
699endif
700
701install-datadir:
702	$(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)"
703
704install-localstatedir:
705ifdef CONFIG_POSIX
706ifneq (,$(findstring qemu-ga,$(TOOLS)))
707	$(INSTALL_DIR) "$(DESTDIR)$(qemu_localstatedir)"/run
708endif
709endif
710
711
712install: all $(if $(BUILD_DOCS),install-doc) install-datadir install-localstatedir
713ifneq ($(TOOLS),)
714	$(call install-prog,$(subst qemu-ga,qemu-ga$(EXESUF),$(TOOLS)),$(DESTDIR)$(bindir))
715endif
716ifneq ($(CONFIG_MODULES),)
717	$(INSTALL_DIR) "$(DESTDIR)$(qemu_moddir)"
718	for s in $(modules-m:.mo=$(DSOSUF)); do \
719		t="$(DESTDIR)$(qemu_moddir)/$$(echo $$s | tr / -)"; \
720		$(INSTALL_LIB) $$s "$$t"; \
721		test -z "$(STRIP)" || $(STRIP) "$$t"; \
722	done
723endif
724ifneq ($(HELPERS-y),)
725	$(call install-prog,$(HELPERS-y),$(DESTDIR)$(libexecdir))
726endif
727ifneq ($(BLOBS),)
728	set -e; for x in $(BLOBS); do \
729		$(INSTALL_DATA) $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(qemu_datadir)"; \
730	done
731endif
732ifeq ($(CONFIG_GTK),y)
733	$(MAKE) -C po $@
734endif
735	$(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/keymaps"
736	set -e; for x in $(KEYMAPS); do \
737		$(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x "$(DESTDIR)$(qemu_datadir)/keymaps"; \
738	done
739	$(INSTALL_DATA) $(BUILD_DIR)/trace-events-all "$(DESTDIR)$(qemu_datadir)/trace-events-all"
740	for d in $(TARGET_DIRS); do \
741	$(MAKE) $(SUBDIR_MAKEFLAGS) TARGET_DIR=$$d/ -C $$d $@ || exit 1 ; \
742        done
743
744.PHONY: ctags
745ctags:
746	rm -f tags
747	find "$(SRC_PATH)" -name '*.[hc]' -exec ctags --append {} +
748
749.PHONY: TAGS
750TAGS:
751	rm -f TAGS
752	find "$(SRC_PATH)" -name '*.[hc]' -exec etags --append {} +
753
754cscope:
755	rm -f "$(SRC_PATH)"/cscope.*
756	find "$(SRC_PATH)/" -name "*.[chsS]" -print | sed 's,^\./,,' > "$(SRC_PATH)/cscope.files"
757	cscope -b -i"$(SRC_PATH)/cscope.files"
758
759# opengl shader programs
760ui/shader/%-vert.h: $(SRC_PATH)/ui/shader/%.vert $(SRC_PATH)/scripts/shaderinclude.pl
761	@mkdir -p $(dir $@)
762	$(call quiet-command,\
763		perl $(SRC_PATH)/scripts/shaderinclude.pl $< > $@,\
764		"VERT","$@")
765
766ui/shader/%-frag.h: $(SRC_PATH)/ui/shader/%.frag $(SRC_PATH)/scripts/shaderinclude.pl
767	@mkdir -p $(dir $@)
768	$(call quiet-command,\
769		perl $(SRC_PATH)/scripts/shaderinclude.pl $< > $@,\
770		"FRAG","$@")
771
772ui/shader.o: $(SRC_PATH)/ui/shader.c \
773	ui/shader/texture-blit-vert.h \
774	ui/shader/texture-blit-flip-vert.h \
775	ui/shader/texture-blit-frag.h
776
777# documentation
778MAKEINFO=makeinfo
779MAKEINFOINCLUDES= -I docs -I $(<D) -I $(@D)
780MAKEINFOFLAGS=--no-split --number-sections $(MAKEINFOINCLUDES)
781TEXI2PODFLAGS=$(MAKEINFOINCLUDES) "-DVERSION=$(VERSION)"
782TEXI2PDFFLAGS=$(if $(V),,--quiet) -I $(SRC_PATH) $(MAKEINFOINCLUDES)
783
784docs/version.texi: $(SRC_PATH)/VERSION
785	$(call quiet-command,echo "@set VERSION $(VERSION)" > $@,"GEN","$@")
786
787%.html: %.texi docs/version.texi
788	$(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \
789	--html $< -o $@,"GEN","$@")
790
791%.info: %.texi docs/version.texi
792	$(call quiet-command,$(MAKEINFO) $(MAKEINFOFLAGS) $< -o $@,"GEN","$@")
793
794%.txt: %.texi docs/version.texi
795	$(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \
796	--plaintext $< -o $@,"GEN","$@")
797
798%.pdf: %.texi docs/version.texi
799	$(call quiet-command,texi2pdf $(TEXI2PDFFLAGS) $< -o $@,"GEN","$@")
800
801qemu-options.texi: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool
802	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@")
803
804qemu-monitor.texi: $(SRC_PATH)/hmp-commands.hx $(SRC_PATH)/scripts/hxtool
805	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@")
806
807qemu-monitor-info.texi: $(SRC_PATH)/hmp-commands-info.hx $(SRC_PATH)/scripts/hxtool
808	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@")
809
810qemu-img-cmds.texi: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool
811	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@")
812
813docs/interop/qemu-qmp-qapi.texi docs/interop/qemu-ga-qapi.texi: $(SRC_PATH)/scripts/qapi2texi.py $(qapi-py)
814
815docs/interop/qemu-qmp-qapi.texi: $(qapi-modules)
816	$(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi2texi.py $< > $@,"GEN","$@")
817
818docs/interop/qemu-ga-qapi.texi: $(SRC_PATH)/qga/qapi-schema.json
819	$(call quiet-command,$(PYTHON_UTF8) $(SRC_PATH)/scripts/qapi2texi.py $< > $@,"GEN","$@")
820
821qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi qemu-monitor-info.texi
822qemu.1: qemu-option-trace.texi
823qemu-img.1: qemu-img.texi qemu-option-trace.texi qemu-img-cmds.texi
824fsdev/virtfs-proxy-helper.1: fsdev/virtfs-proxy-helper.texi
825qemu-nbd.8: qemu-nbd.texi qemu-option-trace.texi
826qemu-ga.8: qemu-ga.texi
827docs/qemu-block-drivers.7: docs/qemu-block-drivers.texi
828
829html: qemu-doc.html docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html
830info: qemu-doc.info docs/interop/qemu-qmp-ref.info docs/interop/qemu-ga-ref.info
831pdf: qemu-doc.pdf docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
832txt: qemu-doc.txt docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
833
834qemu-doc.html qemu-doc.info qemu-doc.pdf qemu-doc.txt: \
835	qemu-img.texi qemu-nbd.texi qemu-options.texi qemu-option-trace.texi \
836	qemu-monitor.texi qemu-img-cmds.texi qemu-ga.texi \
837	qemu-monitor-info.texi docs/qemu-block-drivers.texi
838
839docs/interop/qemu-ga-ref.dvi docs/interop/qemu-ga-ref.html \
840    docs/interop/qemu-ga-ref.info docs/interop/qemu-ga-ref.pdf \
841    docs/interop/qemu-ga-ref.txt docs/interop/qemu-ga-ref.7: \
842	docs/interop/qemu-ga-ref.texi docs/interop/qemu-ga-qapi.texi
843
844docs/interop/qemu-qmp-ref.dvi docs/interop/qemu-qmp-ref.html \
845    docs/interop/qemu-qmp-ref.info docs/interop/qemu-qmp-ref.pdf \
846    docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7: \
847	docs/interop/qemu-qmp-ref.texi docs/interop/qemu-qmp-qapi.texi
848
849
850ifdef CONFIG_WIN32
851
852INSTALLER = qemu-setup-$(VERSION)$(EXESUF)
853
854nsisflags = -V2 -NOCD
855
856ifneq ($(wildcard $(SRC_PATH)/dll),)
857ifeq ($(ARCH),x86_64)
858# 64 bit executables
859DLL_PATH = $(SRC_PATH)/dll/w64
860nsisflags += -DW64
861else
862# 32 bit executables
863DLL_PATH = $(SRC_PATH)/dll/w32
864endif
865endif
866
867.PHONY: installer
868installer: $(INSTALLER)
869
870INSTDIR=/tmp/qemu-nsis
871
872$(INSTALLER): $(SRC_PATH)/qemu.nsi
873	$(MAKE) install prefix=${INSTDIR}
874ifdef SIGNCODE
875	(cd ${INSTDIR}; \
876         for i in *.exe; do \
877           $(SIGNCODE) $${i}; \
878         done \
879        )
880endif # SIGNCODE
881	(cd ${INSTDIR}; \
882         for i in qemu-system-*.exe; do \
883           arch=$${i%.exe}; \
884           arch=$${arch#qemu-system-}; \
885           echo Section \"$$arch\" Section_$$arch; \
886           echo SetOutPath \"\$$INSTDIR\"; \
887           echo File \"\$${BINDIR}\\$$i\"; \
888           echo SectionEnd; \
889         done \
890        ) >${INSTDIR}/system-emulations.nsh
891	makensis $(nsisflags) \
892                $(if $(BUILD_DOCS),-DCONFIG_DOCUMENTATION="y") \
893                $(if $(CONFIG_GTK),-DCONFIG_GTK="y") \
894                -DBINDIR="${INSTDIR}" \
895                $(if $(DLL_PATH),-DDLLDIR="$(DLL_PATH)") \
896                -DSRCDIR="$(SRC_PATH)" \
897                -DOUTFILE="$(INSTALLER)" \
898                -DDISPLAYVERSION="$(VERSION)" \
899                $(SRC_PATH)/qemu.nsi
900	rm -r ${INSTDIR}
901ifdef SIGNCODE
902	$(SIGNCODE) $(INSTALLER)
903endif # SIGNCODE
904endif # CONFIG_WIN
905
906# Add a dependency on the generated files, so that they are always
907# rebuilt before other object files
908ifneq ($(wildcard config-host.mak),)
909ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
910Makefile: $(GENERATED_FILES)
911endif
912endif
913
914.SECONDARY: $(TRACE_HEADERS) $(TRACE_HEADERS:%=%-timestamp) \
915	$(TRACE_SOURCES) $(TRACE_SOURCES:%=%-timestamp) \
916	$(TRACE_DTRACE) $(TRACE_DTRACE:%=%-timestamp)
917
918# Include automatically generated dependency files
919# Dependencies in Makefile.objs files come from our recursive subdir rules
920-include $(wildcard *.d tests/*.d)
921
922include $(SRC_PATH)/tests/docker/Makefile.include
923include $(SRC_PATH)/tests/vm/Makefile.include
924
925.PHONY: help
926help:
927	@echo  'Generic targets:'
928	@echo  '  all             - Build all'
929	@echo  '  dir/file.o      - Build specified target only'
930	@echo  '  install         - Install QEMU, documentation and tools'
931	@echo  '  ctags/TAGS      - Generate tags file for editors'
932	@echo  '  cscope          - Generate cscope index'
933	@echo  ''
934	@$(if $(TARGET_DIRS), \
935		echo 'Architecture specific targets:'; \
936		$(foreach t, $(TARGET_DIRS), \
937		printf "  %-30s - Build for %s\\n" $(patsubst %,subdir-%,$(t)) $(t);) \
938		echo '')
939	@echo  'Cleaning targets:'
940	@echo  '  clean           - Remove most generated files but keep the config'
941	@echo  '  distclean       - Remove all generated files'
942	@echo  '  dist            - Build a distributable tarball'
943	@echo  ''
944	@echo  'Test targets:'
945	@echo  '  check           - Run all tests (check-help for details)'
946	@echo  '  docker          - Help about targets running tests inside Docker containers'
947	@echo  '  vm-test         - Help about targets running tests inside VM'
948	@echo  ''
949	@echo  'Documentation targets:'
950	@echo  '  html info pdf txt'
951	@echo  '                  - Build documentation in specified format'
952	@echo  ''
953ifdef CONFIG_WIN32
954	@echo  'Windows targets:'
955	@echo  '  installer       - Build NSIS-based installer for QEMU'
956ifdef QEMU_GA_MSI_ENABLED
957	@echo  '  msi             - Build MSI-based installer for qemu-ga'
958endif
959	@echo  ''
960endif
961	@echo  '  $(MAKE) V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
962