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