]> git.ipfire.org Git - thirdparty/qemu.git/blame - Makefile
tests: do not print benchmark output to stdout
[thirdparty/qemu.git] / Makefile
CommitLineData
0cb3fb1e
PB
1# Makefile for QEMU.
2
4ace32e2
AO
3ifneq ($(words $(subst :, ,$(CURDIR))), 1)
4 $(error main directory cannot contain spaces nor colons)
5endif
6
519e1693
SW
7# Always point to the root of the build tree (needs GNU make).
8BUILD_DIR=$(CURDIR)
388d4758 9
eaa2ddbb
FZ
10# Before including a proper config-host.mak, assume we are in the source tree
11SRC_PATH=.
12
28fa2927 13UNCHECKED_GOALS := %clean TAGS cscope ctags dist \
de1da442 14 help check-help print-% \
4f2f6276 15 docker docker-% vm-help vm-test vm-build-%
eaa2ddbb 16
250b086e 17# All following code might depend on configuration variables
55d7e8f6 18ifneq ($(wildcard config-host.mak),)
1ad2134f 19# Put the all: rule here so that config-host.mak can contain dependencies.
8f67aa82 20all:
ad064840 21include config-host.mak
d1bd2423 22
aef45d51
DB
23git-submodule-update:
24
25.PHONY: git-submodule-update
26
c4b01c7c
DB
27git_module_status := $(shell \
28 cd '$(SRC_PATH)' && \
29 GIT="$(GIT)" ./scripts/git-submodule.sh status $(GIT_SUBMODULES); \
30 echo $$?; \
31)
aef45d51
DB
32
33ifeq (1,$(git_module_status))
f62bbee5
DB
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
aef45d51
DB
44git-submodule-update:
45 $(call quiet-command, \
cc84d63a 46 (cd $(SRC_PATH) && GIT="$(GIT)" ./scripts/git-submodule.sh update $(GIT_SUBMODULES)), \
aef45d51
DB
47 "GIT","$(GIT_SUBMODULES)")
48endif
49endif
50
a5665051
PB
51export NINJA=./ninjatool
52
53# Running meson regenerates both build.ninja and ninjatool, and that is
54# enough to prime the rest of the build.
55ninjatool: build.ninja
56
a5665051 57Makefile.ninja: build.ninja ninjatool
d7986405 58 ./ninjatool -t ninja2make --omit clean dist uninstall cscope TAGS ctags < $< > $@
a5665051
PB
59-include Makefile.ninja
60
61${ninja-targets-c_COMPILER} ${ninja-targets-cpp_COMPILER}: .var.command += -MP
62
245dac4a
PB
63# If MESON is empty, the rule will be re-evaluated after Makefiles are
64# reread (and MESON won't be empty anymore).
65ifneq ($(MESON),)
66Makefile.mtest: build.ninja scripts/mtest2make.py
67 $(MESON) introspect --tests | $(PYTHON) scripts/mtest2make.py > $@
68-include Makefile.mtest
69endif
70
92712822 71.git-submodule-status: git-submodule-update config-host.mak
aef45d51 72
d1bd2423
PM
73# Check that we're not trying to do an out-of-tree build from
74# a tree that's been used for an in-tree build.
75ifneq ($(realpath $(SRC_PATH)),$(realpath .))
76ifneq ($(wildcard $(SRC_PATH)/config-host.mak),)
77$(error This is an out of tree build but your source tree ($(SRC_PATH)) \
78seems to have been used for an in-tree build. You can fix this by running \
b98a3bae 79"$(MAKE) distclean && rm -rf *-linux-user *-softmmu" in your source tree)
d1bd2423
PM
80endif
81endif
82
2b1f35b9
AB
83CONFIG_SOFTMMU := $(if $(filter %-softmmu,$(TARGET_DIRS)),y)
84CONFIG_USER_ONLY := $(if $(filter %-user,$(TARGET_DIRS)),y)
6b827cca 85CONFIG_XEN := $(CONFIG_XEN_BACKEND)
f3aa844b
PB
86CONFIG_ALL=y
87-include config-all-devices.mak
88-include config-all-disas.mak
89
3a6b016d 90config-host.mak: $(SRC_PATH)/configure $(SRC_PATH)/pc-bios $(SRC_PATH)/VERSION
e5efe7f5 91 @echo $@ is out-of-date, running configure
a5665051
PB
92 @if test -f meson-private/coredata.dat; then \
93 ./config.status --skip-meson; \
94 else \
95 ./config.status; \
96 fi
26fffe29
EC
97
98# Force configure to re-run if the API symbols are updated
99ifeq ($(CONFIG_PLUGIN),y)
100config-host.mak: $(SRC_PATH)/plugins/qemu-plugins.symbols
101endif
102
55d7e8f6
AJ
103else
104config-host.mak:
eaa2ddbb 105ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
55d7e8f6
AJ
106 @echo "Please call configure before running make!"
107 @exit 1
108endif
7748b8cb 109endif
766a487a 110
9f5d9597
GK
111# Only needed in case Makefile.ninja does not exist.
112.PHONY: ninja-clean ninja-distclean clean-ctlist
113clean-ctlist:
114ninja-clean::
115ninja-distclean::
116build.ninja: config-host.mak
117
fb57c881
FZ
118include $(SRC_PATH)/rules.mak
119
c932ce31 120# lor is defined in rules.mak
29de2804
LV
121CONFIG_BLOCK := $(call lor,$(CONFIG_SOFTMMU),$(CONFIG_TOOLS))
122
3dff199c 123generated-files-y += .git-submodule-status
0ab8ed18 124
d9ace8b3
JQ
125# Don't try to regenerate Makefile or configure
126# We don't generate any of them
127Makefile: ;
128configure: ;
129
acfdaac5
PB
130.PHONY: all clean cscope distclean install \
131 recurse-all dist msi FORCE
0cb3fb1e 132
fec90ff0 133$(call set-vpath, $(SRC_PATH))
8c462f8f 134
3e2e0e6b 135LIBS+=-lz $(LIBS_TOOLS)
67c0f08d 136
8cc357b5 137SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory --quiet) BUILD_DIR=$(BUILD_DIR)
a992fe3d 138
992aeb8e
PB
139ifneq ($(wildcard config-host.mak),)
140include $(SRC_PATH)/Makefile.objs
ba1183da
FZ
141endif
142
46e7b706 143include $(SRC_PATH)/tests/Makefile.include
992aeb8e 144
484e2cc7 145all: recurse-all
859aef02 146Makefile: $(addsuffix /all, $(SUBDIRS))
b9dea4fb 147
67953a37
CF
148# LIBFDT_lib="": avoid breaking existing trees with objects requiring -fPIC
149DTC_MAKE_ARGS=-I$(SRC_PATH)/dtc VPATH=$(SRC_PATH)/dtc -C dtc V="$(V)" LIBFDT_lib=""
965f486c 150DTC_CFLAGS=$(CFLAGS) $(QEMU_CFLAGS)
67953a37 151DTC_CPPFLAGS=-I$(SRC_PATH)/dtc/libfdt
a540f158 152
3b8593ee 153.PHONY: dtc/all
67953a37
CF
154dtc/all: .git-submodule-status dtc/libfdt
155 $(call quiet-command,$(MAKE) $(DTC_MAKE_ARGS) CPPFLAGS="$(DTC_CPPFLAGS)" CFLAGS="$(DTC_CFLAGS)" LDFLAGS="$(QEMU_LDFLAGS)" ARFLAGS="$(ARFLAGS)" CC="$(CC)" AR="$(AR)" LD="$(LD)" $(SUBDIR_MAKEFLAGS) libfdt,)
a540f158 156
00525864 157dtc/%: .git-submodule-status
814e1110 158 @mkdir -p $@
a540f158 159
e219c499
RH
160# Overriding CFLAGS causes us to lose defines added in the sub-makefile.
161# Not overriding CFLAGS leads to mis-matches between compilation modes.
162# Therefore we replicate some of the logic in the sub-makefile.
163# Remove all the extra -Warning flags that QEMU uses that Capstone doesn't;
164# no need to annoy QEMU developers with such things.
165CAP_CFLAGS = $(patsubst -W%,,$(CFLAGS) $(QEMU_CFLAGS))
166CAP_CFLAGS += -DCAPSTONE_USE_SYS_DYN_MEM
167CAP_CFLAGS += -DCAPSTONE_HAS_ARM
168CAP_CFLAGS += -DCAPSTONE_HAS_ARM64
169CAP_CFLAGS += -DCAPSTONE_HAS_POWERPC
170CAP_CFLAGS += -DCAPSTONE_HAS_X86
171
3b8593ee
MA
172.PHONY: capstone/all
173capstone/all: .git-submodule-status
9f81aeb5 174 $(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))
e219c499 175
3b8593ee
MA
176.PHONY: slirp/all
177slirp/all: .git-submodule-status
daa79d9a
AB
178 $(call quiet-command,$(MAKE) -C $(SRC_PATH)/slirp \
179 BUILD_DIR="$(BUILD_DIR)/slirp" \
180 PKG_CONFIG="$(PKG_CONFIG)" \
181 CC="$(CC)" AR="$(AR)" LD="$(LD)" RANLIB="$(RANLIB)" \
db5adeaa 182 CFLAGS="$(QEMU_CFLAGS) $(CFLAGS)" LDFLAGS="$(QEMU_LDFLAGS)")
675b9b53 183
3b8593ee 184ROM_DIRS = $(addprefix pc-bios/, $(ROMS))
1338a4b7 185ROM_DIRS_RULES=$(foreach t, all clean, $(addsuffix /$(t), $(ROM_DIRS)))
a9c87304 186# Only keep -O and -g cflags
1338a4b7
MA
187.PHONY: $(ROM_DIRS_RULES)
188$(ROM_DIRS_RULES):
49b7d744 189 $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)" TARGET_DIR="$(dir $@)" $(notdir $@),)
c05ac895 190
5e6d1573 191.PHONY: recurse-all recurse-clean
49b7d744 192recurse-all: $(addsuffix /all, $(ROM_DIRS))
5e6d1573 193recurse-clean: $(addsuffix /clean, $(ROM_DIRS))
83f64091 194
44dc0ca3 195######################################################################
4fb240a4 196
a5665051 197clean: recurse-clean ninja-clean clean-ctlist
9f5d9597 198 if test -f ninjatool; then ./ninjatool $(if $(V),-v,) -t clean; fi
2d80ae89 199# avoid old build problems by removing potentially incorrect old files
25be210f 200 rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
484e2cc7 201 find . \( -name '*.so' -o -name '*.dll' -o -name '*.[oda]' \) -type f \
23858f40
LE
202 ! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-aarch64.a \
203 ! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-arm.a \
204 ! -path ./roms/edk2/BaseTools/Source/Python/UPT/Dll/sqlite3.dll \
205 -exec rm {} +
c3a0ee84 206 rm -f TAGS cscope.* *.pod *~ */*~
b855f8d1 207 rm -f fsdev/*.pod scsi/*.pod
3dff199c 208 rm -f $(foreach f,$(generated-files-y),$(f) $(f)-timestamp)
31e31b8a 209
859aef02 210VERSION = $(shell cat $(SRC_PATH)/VERSION)
34bb443e
AL
211
212dist: qemu-$(VERSION).tar.bz2
213
34bb443e
AL
214qemu-%.tar.bz2:
215 $(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst qemu-%.tar.bz2,%,$@)"
216
a5665051
PB
217distclean: clean ninja-distclean
218 -test -f ninjatool && ./ninjatool $(if $(V),-v,) -t clean -g
acfdaac5 219 rm -f config-host.mak config-host.h*
2038f8c8 220 rm -f tests/tcg/config-*.mak
2becc36a 221 rm -f config-all-disas.mak config.status
e8f3bd71 222 rm -f tests/qemu-iotests/common.env
fc8e320e 223 rm -f roms/seabios/config.mak roms/vgabios/config.mak
26fffe29 224 rm -f qemu-plugins-ld.symbols qemu-plugins-ld64.symbols
64ed6f92 225 rm -f *-config-target.h *-config-devices.mak *-config-devices.h
a5665051 226 rm -rf meson-private meson-logs meson-info compile_commands.json
245dac4a 227 rm -f Makefile.ninja ninjatool ninjatool.stamp Makefile.mtest
793553ac 228 rm -f config.log
67ed96f9 229 rm -f linux-headers/asm
d9840e25 230 rm -Rf .sdk
7d13299d 231
d7986405
GK
232.PHONY: ctags
233ctags:
234 rm -f tags
235 find "$(SRC_PATH)" -name '*.[hc]' -exec ctags --append {} +
236
237.PHONY: TAGS
238TAGS:
239 rm -f TAGS
240 find "$(SRC_PATH)" -name '*.[hc]' -exec etags --append {} +
241
242.PHONY: cscope
243cscope:
244 rm -f "$(SRC_PATH)"/cscope.*
245 find "$(SRC_PATH)/" -name "*.[chsS]" -print | sed -e 's,^\./,,' > "$(SRC_PATH)/cscope.files"
246 cscope -b -i"$(SRC_PATH)/cscope.files"
247
a5665051
PB
248# Needed by "meson install"
249export DESTDIR
612384d7 250
cb5fc67d
AL
251# Add a dependency on the generated files, so that they are always
252# rebuilt before other object files
428952cf 253ifneq ($(wildcard config-host.mak),)
eaa2ddbb 254ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
3dff199c 255Makefile: $(generated-files-y)
7748b8cb 256endif
428952cf 257endif
cb5fc67d 258
4fb240a4 259# Include automatically generated dependency files
1435ddb8
PB
260# Dependencies in Makefile.objs files come from our recursive subdir rules
261-include $(wildcard *.d tests/*.d)
324027c2
FZ
262
263include $(SRC_PATH)/tests/docker/Makefile.include
b1fb9a63 264include $(SRC_PATH)/tests/vm/Makefile.include
0d8e065f 265
c355de59
PMD
266print-help-run = printf " %-30s - %s\\n" "$1" "$2"
267print-help = $(quiet-@)$(call print-help-run,$1,$2)
268
0d8e065f
MAL
269.PHONY: help
270help:
271 @echo 'Generic targets:'
c355de59 272 $(call print-help,all,Build all)
c355de59
PMD
273 $(call print-help,dir/file.o,Build specified target only)
274 $(call print-help,install,Install QEMU, documentation and tools)
275 $(call print-help,ctags/TAGS,Generate tags file for editors)
276 $(call print-help,cscope,Generate cscope index)
968b4db3 277 $(call print-help,sparse,Run sparse on the QEMU source)
0d8e065f 278 @echo ''
0d8e065f 279 @echo 'Cleaning targets:'
c355de59 280 $(call print-help,clean,Remove most generated files but keep the config)
c355de59
PMD
281 $(call print-help,distclean,Remove all generated files)
282 $(call print-help,dist,Build a distributable tarball)
0d8e065f
MAL
283 @echo ''
284 @echo 'Test targets:'
c355de59
PMD
285 $(call print-help,check,Run all tests (check-help for details))
286 $(call print-help,docker,Help about targets running tests inside containers)
287 $(call print-help,vm-help,Help about targets running tests inside VM)
0d8e065f
MAL
288 @echo ''
289 @echo 'Documentation targets:'
acfdaac5 290 $(call print-help,html info pdf txt man,Build documentation in specified format)
0d8e065f
MAL
291 @echo ''
292ifdef CONFIG_WIN32
293 @echo 'Windows targets:'
c355de59 294 $(call print-help,installer,Build NSIS-based installer for QEMU)
0d8e065f 295ifdef QEMU_GA_MSI_ENABLED
c355de59 296 $(call print-help,msi,Build MSI-based installer for qemu-ga)
0d8e065f
MAL
297endif
298 @echo ''
299endif
c355de59
PMD
300 $(call print-help,$(MAKE) [targets],(quiet build, default))
301 $(call print-help,$(MAKE) V=1 [targets],(verbose build))