capstone: Update to upstream "next" branch
[qemu/ar7.git] / Makefile
blobf27bd4b2eb47b8835410fa525293ebf02bd6178c
1 # Makefile for QEMU.
3 ifneq ($(words $(subst :, ,$(CURDIR))), 1)
4 $(error main directory cannot contain spaces nor colons)
5 endif
7 # Always point to the root of the build tree (needs GNU make).
8 BUILD_DIR=$(CURDIR)
10 # Before including a proper config-host.mak, assume we are in the source tree
11 SRC_PATH=.
13 # Don't use implicit rules or variables
14 # we have explicit rules for everything
15 MAKEFLAGS += -rR
17 # Usage: $(call quiet-command,command and args,"NAME","args to print")
18 # This will run "command and args", and either:
19 # if V=1 just print the whole command and args
20 # otherwise print the 'quiet' output in the format " NAME args to print"
21 # NAME should be a short name of the command, 7 letters or fewer.
22 # If called with only a single argument, will print nothing in quiet mode.
23 quiet-command-run = $(if $(V),,$(if $2,printf " %-7s %s\n" $2 $3 && ))$1
24 quiet-@ = $(if $(V),,@)
25 quiet-command = $(quiet-@)$(call quiet-command-run,$1,$2,$3)
27 UNCHECKED_GOALS := %clean TAGS cscope ctags dist \
28 help check-help print-% \
29 docker docker-% vm-help vm-test vm-build-%
31 # All following code might depend on configuration variables
32 ifneq ($(wildcard config-host.mak),)
33 # Put the all: rule here so that config-host.mak can contain dependencies.
34 all:
35 include config-host.mak
37 git-submodule-update:
39 .PHONY: git-submodule-update
41 git_module_status := $(shell \
42 cd '$(SRC_PATH)' && \
43 GIT="$(GIT)" ./scripts/git-submodule.sh status $(GIT_SUBMODULES); \
44 echo $$?; \
47 ifeq (1,$(git_module_status))
48 ifeq (no,$(GIT_UPDATE))
49 git-submodule-update:
50 $(call quiet-command, \
51 echo && \
52 echo "GIT submodule checkout is out of date. Please run" && \
53 echo " scripts/git-submodule.sh update $(GIT_SUBMODULES)" && \
54 echo "from the source directory checkout $(SRC_PATH)" && \
55 echo && \
56 exit 1)
57 else
58 git-submodule-update:
59 $(call quiet-command, \
60 (cd $(SRC_PATH) && GIT="$(GIT)" ./scripts/git-submodule.sh update $(GIT_SUBMODULES)), \
61 "GIT","$(GIT_SUBMODULES)")
62 endif
63 endif
65 export NINJA=./ninjatool
67 # Running meson regenerates both build.ninja and ninjatool, and that is
68 # enough to prime the rest of the build.
69 ninjatool: build.ninja
71 Makefile.ninja: build.ninja ninjatool
72 ./ninjatool -t ninja2make --omit clean dist uninstall cscope TAGS ctags < $< > $@
73 -include Makefile.ninja
75 ${ninja-targets-c_COMPILER} ${ninja-targets-cpp_COMPILER}: .var.command += -MP
77 # If MESON is empty, the rule will be re-evaluated after Makefiles are
78 # reread (and MESON won't be empty anymore).
79 ifneq ($(MESON),)
80 Makefile.mtest: build.ninja scripts/mtest2make.py
81 $(MESON) introspect --targets --tests --benchmarks | $(PYTHON) scripts/mtest2make.py > $@
82 -include Makefile.mtest
83 endif
85 Makefile: .git-submodule-status
86 .git-submodule-status: git-submodule-update config-host.mak
88 # Check that we're not trying to do an out-of-tree build from
89 # a tree that's been used for an in-tree build.
90 ifneq ($(realpath $(SRC_PATH)),$(realpath .))
91 ifneq ($(wildcard $(SRC_PATH)/config-host.mak),)
92 $(error This is an out of tree build but your source tree ($(SRC_PATH)) \
93 seems to have been used for an in-tree build. You can fix this by running \
94 "$(MAKE) distclean && rm -rf *-linux-user *-softmmu" in your source tree)
95 endif
96 endif
98 config-host.mak: $(SRC_PATH)/configure $(SRC_PATH)/pc-bios $(SRC_PATH)/VERSION
99 @echo $@ is out-of-date, running configure
100 @if test -f meson-private/coredata.dat; then \
101 ./config.status --skip-meson; \
102 else \
103 ./config.status; \
106 # Force configure to re-run if the API symbols are updated
107 ifeq ($(CONFIG_PLUGIN),y)
108 config-host.mak: $(SRC_PATH)/plugins/qemu-plugins.symbols
110 .PHONY: plugins
111 plugins:
112 $(call quiet-command,\
113 $(MAKE) $(SUBDIR_MAKEFLAGS) -C contrib/plugins V="$(V)", \
114 "BUILD", "example plugins")
115 endif
117 else
118 config-host.mak:
119 ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
120 @echo "Please call configure before running make!"
121 @exit 1
122 endif
123 endif
125 # Only needed in case Makefile.ninja does not exist.
126 .PHONY: ninja-clean ninja-distclean clean-ctlist
127 clean-ctlist:
128 ninja-clean::
129 ninja-distclean::
130 build.ninja: config-host.mak
132 # Don't try to regenerate Makefile or configure
133 # We don't generate any of them
134 Makefile: ;
135 configure: ;
137 .PHONY: all clean distclean install \
138 recurse-all dist msi FORCE
140 SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory --quiet)
142 include $(SRC_PATH)/tests/Makefile.include
144 all: recurse-all
145 Makefile: $(addsuffix /all, $(SUBDIRS))
147 # LIBFDT_lib="": avoid breaking existing trees with objects requiring -fPIC
148 DTC_MAKE_ARGS=-I$(SRC_PATH)/dtc VPATH=$(SRC_PATH)/dtc -C dtc V="$(V)" LIBFDT_lib=""
149 DTC_CFLAGS=$(CFLAGS) $(QEMU_CFLAGS)
150 DTC_CPPFLAGS=-I$(SRC_PATH)/dtc/libfdt
152 .PHONY: dtc/all
153 dtc/all: .git-submodule-status dtc/libfdt
154 $(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,)
156 dtc/%: .git-submodule-status
157 @mkdir -p $@
159 # Retain for a while so that incremental build across this patch
160 # does not raise an error for missing target "capstone/all", which
161 # comes from the saved SUBDIRS value.
162 .PHONY: capstone/all
163 capstone/all:
165 .PHONY: slirp/all
166 slirp/all: .git-submodule-status
167 $(call quiet-command,$(MAKE) -C $(SRC_PATH)/slirp \
168 BUILD_DIR="$(BUILD_DIR)/slirp" \
169 PKG_CONFIG="$(PKG_CONFIG)" \
170 CC="$(CC)" AR="$(AR)" LD="$(LD)" RANLIB="$(RANLIB)" \
171 CFLAGS="$(QEMU_CFLAGS) $(CFLAGS)" LDFLAGS="$(QEMU_LDFLAGS)")
173 ROM_DIRS = $(addprefix pc-bios/, $(ROMS))
174 ROM_DIRS_RULES=$(foreach t, all clean, $(addsuffix /$(t), $(ROM_DIRS)))
175 # Only keep -O and -g cflags
176 .PHONY: $(ROM_DIRS_RULES)
177 $(ROM_DIRS_RULES):
178 $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)" TARGET_DIR="$(dir $@)" $(notdir $@),)
180 .PHONY: recurse-all recurse-clean
181 recurse-all: $(addsuffix /all, $(ROM_DIRS))
182 recurse-clean: $(addsuffix /clean, $(ROM_DIRS))
184 ######################################################################
186 clean: recurse-clean ninja-clean clean-ctlist
187 if test -f ninjatool; then ./ninjatool $(if $(V),-v,) -t clean; fi
188 # avoid old build problems by removing potentially incorrect old files
189 rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
190 find . \( -name '*.so' -o -name '*.dll' -o -name '*.[oda]' \) -type f \
191 ! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-aarch64.a \
192 ! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-arm.a \
193 -exec rm {} +
194 rm -f TAGS cscope.* *.pod *~ */*~
195 rm -f fsdev/*.pod scsi/*.pod
197 VERSION = $(shell cat $(SRC_PATH)/VERSION)
199 dist: qemu-$(VERSION).tar.bz2
201 qemu-%.tar.bz2:
202 $(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst qemu-%.tar.bz2,%,$@)"
204 distclean: clean ninja-distclean
205 -test -f ninjatool && ./ninjatool $(if $(V),-v,) -t clean -g
206 rm -f config-host.mak config-host.h*
207 rm -f tests/tcg/config-*.mak
208 rm -f config-all-disas.mak config.status
209 rm -f tests/qemu-iotests/common.env
210 rm -f roms/seabios/config.mak roms/vgabios/config.mak
211 rm -f qemu-plugins-ld.symbols qemu-plugins-ld64.symbols
212 rm -f *-config-target.h *-config-devices.mak *-config-devices.h
213 rm -rf meson-private meson-logs meson-info compile_commands.json
214 rm -f Makefile.ninja ninjatool ninjatool.stamp Makefile.mtest
215 rm -f config.log
216 rm -f linux-headers/asm
217 rm -Rf .sdk
219 find-src-path = find "$(SRC_PATH)/" -path "$(SRC_PATH)/meson" -prune -o -name "*.[chsS]"
221 .PHONY: ctags
222 ctags:
223 rm -f tags
224 $(find-src-path) -exec ctags --append {} +
226 .PHONY: TAGS
227 TAGS:
228 rm -f TAGS
229 $(find-src-path) -exec etags --append {} +
231 .PHONY: cscope
232 cscope:
233 rm -f "$(SRC_PATH)"/cscope.*
234 $(find-src-path) -print | sed -e 's,^\./,,' > "$(SRC_PATH)/cscope.files"
235 cscope -b -i"$(SRC_PATH)/cscope.files"
237 # Needed by "meson install"
238 export DESTDIR
240 include $(SRC_PATH)/tests/docker/Makefile.include
241 include $(SRC_PATH)/tests/vm/Makefile.include
243 print-help-run = printf " %-30s - %s\\n" "$1" "$2"
244 print-help = $(quiet-@)$(call print-help-run,$1,$2)
246 .PHONY: help
247 help:
248 @echo 'Generic targets:'
249 $(call print-help,all,Build all)
250 $(call print-help,dir/file.o,Build specified target only)
251 $(call print-help,install,Install QEMU, documentation and tools)
252 $(call print-help,ctags/TAGS,Generate tags file for editors)
253 $(call print-help,cscope,Generate cscope index)
254 $(call print-help,sparse,Run sparse on the QEMU source)
255 @echo ''
256 ifeq ($(CONFIG_PLUGIN),y)
257 @echo 'Plugin targets:'
258 $(call print-help,plugins,Build the example TCG plugins)
259 @echo ''
260 endif
261 @echo 'Cleaning targets:'
262 $(call print-help,clean,Remove most generated files but keep the config)
263 $(call print-help,distclean,Remove all generated files)
264 $(call print-help,dist,Build a distributable tarball)
265 @echo ''
266 @echo 'Test targets:'
267 $(call print-help,check,Run all tests (check-help for details))
268 $(call print-help,bench,Run all benchmarks)
269 $(call print-help,docker,Help about targets running tests inside containers)
270 $(call print-help,vm-help,Help about targets running tests inside VM)
271 @echo ''
272 @echo 'Documentation targets:'
273 $(call print-help,html man,Build documentation in specified format)
274 @echo ''
275 ifdef CONFIG_WIN32
276 @echo 'Windows targets:'
277 $(call print-help,installer,Build NSIS-based installer for QEMU)
278 ifdef CONFIG_QGA_MSI
279 $(call print-help,msi,Build MSI-based installer for qemu-ga)
280 endif
281 @echo ''
282 endif
283 $(call print-help,$(MAKE) [targets],(quiet build, default))
284 $(call print-help,$(MAKE) V=1 [targets],(verbose build))
286 # will delete the target of a rule if commands exit with a nonzero exit status
287 .DELETE_ON_ERROR:
289 print-%:
290 @echo '$*=$($*)'