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