3 ifneq ($(words $(subst :, ,$(CURDIR
))), 1)
4 $(error main directory cannot contain spaces nor colons
)
7 # Always point to the root of the build tree (needs GNU make).
10 # Before including a proper config-host.mak, assume we are in the source tree
13 # Don't use implicit rules or variables
14 # we have explicit rules for everything
17 SHELL
= /usr
/bin
/env bash
-o pipefail
19 # Usage: $(call quiet-command,command and args,"NAME","args to print")
20 # This will run "command and args", and either:
21 # if V=1 just print the whole command and args
22 # otherwise print the 'quiet' output in the format " NAME args to print"
23 # NAME should be a short name of the command, 7 letters or fewer.
24 # If called with only a single argument, will print nothing in quiet mode.
25 quiet-command-run
= $(if
$(V
),,$(if
$2,printf
" %-7s %s\n" $2 $3 && ))$1
26 quiet-@
= $(if
$(V
),,@
)
27 quiet-command
= $(quiet-@
)$(call quiet-command-run
,$1,$2,$3)
29 UNCHECKED_GOALS
:= %clean TAGS cscope ctags
dist \
30 help check-help print-
% \
31 docker docker-
% vm-help vm-test vm-build-
%
33 # All following code might depend on configuration variables
34 ifneq ($(wildcard config-host.mak
),)
35 # Put the all: rule here so that config-host.mak can contain dependencies.
37 include config-host.mak
41 .PHONY
: git-submodule-update
43 git_module_status
:= $(shell \
45 GIT
="$(GIT)" .
/scripts
/git-submodule.sh status
$(GIT_SUBMODULES
); \
49 ifeq (1,$(git_module_status
))
50 ifeq (no
,$(GIT_UPDATE
))
52 $(call quiet-command
, \
54 echo
"GIT submodule checkout is out of date. Please run" && \
55 echo
" scripts/git-submodule.sh update $(GIT_SUBMODULES)" && \
56 echo
"from the source directory checkout $(SRC_PATH)" && \
61 $(call quiet-command
, \
62 (cd
$(SRC_PATH
) && GIT
="$(GIT)" .
/scripts
/git-submodule.sh update
$(GIT_SUBMODULES
)), \
63 "GIT","$(GIT_SUBMODULES)")
67 export NINJA
=.
/ninjatool
69 # Running meson regenerates both build.ninja and ninjatool, and that is
70 # enough to prime the rest of the build.
71 ninjatool
: build.ninja
73 Makefile.ninja
: build.ninja ninjatool
74 .
/ninjatool
-t ninja2make
--omit
clean dist uninstall cscope TAGS ctags
< $< > $@
75 -include Makefile.ninja
77 ${ninja-targets-c_COMPILER
} ${ninja-targets-cpp_COMPILER
}: .var.command
+= -MP
79 # If MESON is empty, the rule will be re-evaluated after Makefiles are
80 # reread (and MESON won't be empty anymore).
82 Makefile.mtest
: build.ninja scripts
/mtest2make.py
83 $(MESON
) introspect
--targets
--tests
--benchmarks |
$(PYTHON
) scripts
/mtest2make.py
> $@
84 -include Makefile.mtest
87 Makefile
: .git-submodule-status
88 .git-submodule-status
: git-submodule-update config-host.mak
90 # Check that we're not trying to do an out-of-tree build from
91 # a tree that's been used for an in-tree build.
92 ifneq ($(realpath
$(SRC_PATH
)),$(realpath .
))
93 ifneq ($(wildcard $(SRC_PATH
)/config-host.mak
),)
94 $(error This is an out of tree build but your source tree
($(SRC_PATH
)) \
95 seems to have been used for an in-tree build. You can fix this by running \
96 "$(MAKE) distclean && rm -rf *-linux-user *-softmmu" in your source tree
)
100 config-host.mak
: $(SRC_PATH
)/configure
$(SRC_PATH
)/pc-bios
$(SRC_PATH
)/VERSION
101 @echo
$@ is out-of-date
, running configure
102 @if
test -f meson-private
/coredata.dat
; then \
103 .
/config.status
--skip-meson
; \
108 # Force configure to re-run if the API symbols are updated
109 ifeq ($(CONFIG_PLUGIN
),y
)
110 config-host.mak
: $(SRC_PATH
)/plugins
/qemu-plugins.symbols
114 $(call quiet-command
,\
115 $(MAKE
) $(SUBDIR_MAKEFLAGS
) -C contrib
/plugins V
="$(V)", \
116 "BUILD", "example plugins")
121 ifneq ($(filter-out $(UNCHECKED_GOALS
),$(MAKECMDGOALS
)),$(if
$(MAKECMDGOALS
),,fail
))
122 @echo
"Please call configure before running make!"
127 # Only needed in case Makefile.ninja does not exist.
128 .PHONY
: ninja-clean ninja-distclean clean-ctlist
132 build.ninja
: config-host.mak
134 # Don't try to regenerate Makefile or configure
135 # We don't generate any of them
139 .PHONY
: all clean distclean install \
140 recurse-all
dist msi FORCE
142 SUBDIR_MAKEFLAGS
=$(if
$(V
),,--no-print-directory
--quiet
)
144 include $(SRC_PATH
)/tests
/Makefile.
include
149 ROM_DIRS
= $(addprefix pc-bios
/, $(ROMS
))
150 ROM_DIRS_RULES
=$(foreach t
, all clean, $(addsuffix /$(t
), $(ROM_DIRS
)))
151 # Only keep -O and -g cflags
152 .PHONY
: $(ROM_DIRS_RULES
)
154 $(call quiet-command
,$(MAKE
) $(SUBDIR_MAKEFLAGS
) -C
$(dir $@
) V
="$(V)" TARGET_DIR
="$(dir $@)" $(notdir $@
),)
156 .PHONY
: recurse-all recurse-clean
157 recurse-all
: $(addsuffix /all, $(ROM_DIRS
))
158 recurse-clean
: $(addsuffix /clean, $(ROM_DIRS
))
160 ######################################################################
162 clean: recurse-clean ninja-clean clean-ctlist
163 if
test -f ninjatool
; then .
/ninjatool
$(if
$(V
),-v
,) -t
clean; fi
164 # avoid old build problems by removing potentially incorrect old files
165 rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
166 find . \
( -name
'*.so' -o
-name
'*.dll' -o
-name
'*.[oda]' \
) -type f \
167 ! -path .
/roms
/edk2
/ArmPkg
/Library
/GccLto
/liblto-aarch64.a \
168 ! -path .
/roms
/edk2
/ArmPkg
/Library
/GccLto
/liblto-arm.a \
170 rm -f TAGS cscope.
* *.pod
*~
*/*~
171 rm -f fsdev
/*.pod scsi
/*.pod
173 VERSION
= $(shell cat
$(SRC_PATH
)/VERSION
)
175 dist: qemu-
$(VERSION
).
tar.bz2
178 $(SRC_PATH
)/scripts
/make-release
"$(SRC_PATH)" "$(patsubst qemu-%.tar.bz2,%,$@)"
180 distclean: clean ninja-distclean
181 -test -f ninjatool
&& .
/ninjatool
$(if
$(V
),-v
,) -t
clean -g
182 rm -f config-host.mak config-host.h
*
183 rm -f tests
/tcg
/config-
*.mak
184 rm -f config-all-disas.mak config.status
185 rm -f tests
/qemu-iotests
/common.env
186 rm -f roms
/seabios
/config.mak roms
/vgabios
/config.mak
187 rm -f qemu-plugins-ld.symbols qemu-plugins-ld64.symbols
188 rm -f
*-config-target.h
*-config-devices.mak
*-config-devices.h
189 rm -rf meson-private meson-logs meson-info compile_commands.json
190 rm -f Makefile.ninja ninjatool ninjatool.stamp Makefile.mtest
192 rm -f linux-headers
/asm
195 find-src-path
= find
"$(SRC_PATH)/" -path
"$(SRC_PATH)/meson" -prune
-o
-name
"*.[chsS]"
199 rm -f
"$(SRC_PATH)/"tags
200 $(find-src-path
) -exec ctags
-f
"$(SRC_PATH)/"tags --append
{} +
204 rm -f
"$(SRC_PATH)/"TAGS
205 $(find-src-path
) -exec etags
-f
"$(SRC_PATH)/"TAGS
--append
{} +
209 rm -f
"$(SRC_PATH)"/cscope.
*
210 $(find-src-path
) -print | sed
-e
's,^\./,,' > "$(SRC_PATH)/cscope.files"
211 cscope
-b
-i
"$(SRC_PATH)/cscope.files" -f
"$(SRC_PATH)"/cscope.out
213 # Needed by "meson install"
216 include $(SRC_PATH
)/tests
/docker
/Makefile.
include
217 include $(SRC_PATH
)/tests
/vm
/Makefile.
include
219 print-help-run
= printf
" %-30s - %s\\n" "$1" "$2"
220 print-help
= $(quiet-@
)$(call print-help-run
,$1,$2)
224 @echo
'Generic targets:'
225 $(call print-help
,all,Build
all)
226 $(call print-help
,dir/file.o
,Build specified target only
)
227 $(call print-help
,install,Install QEMU
, documentation and tools
)
228 $(call print-help
,ctags
/TAGS
,Generate
tags file for editors
)
229 $(call print-help
,cscope
,Generate cscope index
)
230 $(call print-help
,sparse
,Run sparse on the QEMU source
)
232 ifeq ($(CONFIG_PLUGIN
),y
)
233 @echo
'Plugin targets:'
234 $(call print-help
,plugins
,Build the example TCG plugins
)
237 @echo
'Cleaning targets:'
238 $(call print-help
,clean,Remove most generated files but keep the config
)
239 $(call print-help
,distclean,Remove
all generated files
)
240 $(call print-help
,dist,Build a distributable tarball
)
242 @echo
'Test targets:'
243 $(call print-help
,check,Run
all tests
(check-help for details
))
244 $(call print-help
,bench
,Run
all benchmarks
)
245 $(call print-help
,docker
,Help about targets running tests inside containers
)
246 $(call print-help
,vm-help
,Help about targets running tests inside VM
)
248 @echo
'Documentation targets:'
249 $(call print-help
,html man
,Build documentation in specified format
)
252 @echo
'Windows targets:'
253 $(call print-help
,installer
,Build NSIS-based installer for QEMU
)
255 $(call print-help
,msi
,Build MSI-based installer for qemu-ga
)
259 $(call print-help
,$(MAKE
) [targets
],(quiet build
, default
))
260 $(call print-help
,$(MAKE
) V
=1 [targets
],(verbose build
))
262 # will delete the target of a rule if commands exit with a nonzero exit status