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