1# $(lastword,) for GNU Make older than 3.81 2lastword = $(word $(words $(1)),$(1)) 3this-makefile := $(call lastword,$(MAKEFILE_LIST)) 4 5# This is the correct place to edit the build version. 6# All other places this is stored (eg. compile.h) should be autogenerated. 7export XEN_VERSION = 4 8export XEN_SUBVERSION = 19 9export XEN_EXTRAVERSION ?= .0$(XEN_VENDORVERSION) 10export XEN_FULLVERSION = $(XEN_VERSION).$(XEN_SUBVERSION)$(XEN_EXTRAVERSION) 11-include xen-version 12 13export XEN_WHOAMI ?= $(USER) 14ifeq ($(origin XEN_DOMAIN), undefined) 15export XEN_DOMAIN := $(shell ([ -x /bin/dnsdomainname ] && /bin/dnsdomainname) || ([ -x /bin/domainname ] && /bin/domainname || echo [unknown])) 16endif 17ifeq ($(origin XEN_BUILD_DATE), undefined) 18export XEN_BUILD_DATE := $(shell LC_ALL=C date) 19endif 20ifeq ($(origin XEN_BUILD_TIME), undefined) 21export XEN_BUILD_TIME := $(shell LC_ALL=C date +%T) 22endif 23ifeq ($(origin XEN_BUILD_HOST), undefined) 24export XEN_BUILD_HOST := $(shell hostname) 25endif 26 27# Best effort attempt to find a python interpreter, defaulting to Python 3 if 28# available. Fall back to just `python`. 29PYTHON_INTERPRETER := $(word 1,$(shell command -v python3 || command -v python || command -v python2) python) 30export PYTHON ?= $(PYTHON_INTERPRETER) 31 32export CHECKPOLICY ?= checkpolicy 33 34$(if $(filter __%, $(MAKECMDGOALS)), \ 35 $(error targets prefixed with '__' are only for internal use)) 36 37# That's our default target when none is given on the command line 38PHONY := __all 39__all: 40 41# Do not use make's built-in rules and variables 42MAKEFLAGS += -rR 43 44EFI_MOUNTPOINT ?= $(BOOT_DIR)/efi 45 46# Allow someone to change their config file 47export KCONFIG_CONFIG ?= .config 48 49export TARGET := xen 50 51.PHONY: dist 52dist: install 53 54ifneq ($(root-make-done),y) 55# section to run before calling Rules.mk, but only once. 56 57ifneq ($(origin crash_debug),undefined) 58$(error "You must use e.g. 'make menuconfig' to enable/disable crash_debug now.") 59endif 60ifeq ($(origin debug),command line) 61$(warning "You must use e.g. 'make menuconfig' to enable/disable debug now.") 62endif 63ifneq ($(origin frame_pointer),undefined) 64$(error "You must use e.g. 'make menuconfig' to enable/disable frame_pointer now.") 65endif 66ifneq ($(origin kexec),undefined) 67$(error "You must use e.g. 'make menuconfig' to enable/disable kexec now.") 68endif 69ifneq ($(origin lock_profile),undefined) 70$(error "You must use e.g. 'make menuconfig' to enable/disable lock_profile now.") 71endif 72ifneq ($(origin perfc),undefined) 73$(error "You must use e.g. 'make menuconfig' to enable/disable perfc now.") 74endif 75ifneq ($(origin verbose),undefined) 76$(error "You must use e.g. 'make menuconfig' to enable/disable verbose now.") 77endif 78 79# Beautify output 80# --------------------------------------------------------------------------- 81# 82# Normally, we echo the whole command before executing it. By making 83# that echo $($(quiet)$(cmd)), we now have the possibility to set 84# $(quiet) to choose other forms of output instead, e.g. 85# 86# quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@ 87# cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< 88# 89# If $(quiet) is empty, the whole command will be printed. 90# If it is set to "quiet_", only the short version will be printed. 91# If it is set to "silent_", nothing will be printed at all, since 92# the variable $(silent_cmd_cc_o_c) doesn't exist. 93# 94# A simple variant is to prefix commands with $(Q) - that's useful 95# for commands that shall be hidden in non-verbose mode. 96# 97# $(Q)ln $@ :< 98# 99# If KBUILD_VERBOSE equals 0 then the above command will be hidden. 100# If KBUILD_VERBOSE equals 1 then the above command is displayed. 101# 102# To put more focus on warnings, be less verbose as default 103# Use 'make V=1' to see the full commands 104 105ifeq ("$(origin V)", "command line") 106 KBUILD_VERBOSE := $(V) 107endif 108ifndef KBUILD_VERBOSE 109 KBUILD_VERBOSE := 0 110endif 111 112ifeq ($(KBUILD_VERBOSE),1) 113 quiet := 114 Q := 115else 116 quiet := quiet_ 117 Q := @ 118endif 119 120# If the user is running make -s (silent mode), suppress echoing of 121# commands 122 123ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),) 124 quiet := silent_ 125endif 126 127export quiet Q KBUILD_VERBOSE 128 129# $(realpath,) for GNU Make older than 3.81 130realpath = $(wildcard $(foreach file,$(1),$(shell cd -P $(dir $(file)) && echo "$$PWD/$(notdir $(file))"))) 131 132ifeq ("$(origin O)", "command line") 133 KBUILD_OUTPUT := $(O) 134endif 135 136ifneq ($(KBUILD_OUTPUT),) 137# Make's built-in functions such as $(abspath ...), $(realpath ...) cannot 138# expand a shell special character '~'. We use a somewhat tedious way here. 139abs_objtree := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) && pwd) 140$(if $(abs_objtree),, \ 141 $(error failed to create output directory "$(KBUILD_OUTPUT)")) 142 143# $(realpath ...) resolves symlinks 144abs_objtree := $(call realpath,$(abs_objtree)) 145else 146abs_objtree := $(CURDIR) 147endif 148 149ifeq ($(abs_objtree),$(CURDIR)) 150# Suppress "Entering directory ..." unless we are changing the work directory. 151MAKEFLAGS += --no-print-directory 152else 153need-sub-make := 1 154endif 155 156abs_srctree := $(call realpath,$(dir $(this-makefile))) 157 158ifneq ($(words $(subst :, ,$(abs_srctree))), 1) 159$(error source directory cannot contain spaces or colons) 160endif 161 162ifneq ($(abs_srctree),$(abs_objtree)) 163# Look for make include files relative to root of kernel src 164# 165# This does not become effective immediately because MAKEFLAGS is re-parsed 166# once after the Makefile is read. We need to invoke sub-make. 167MAKEFLAGS += --include-dir=$(abs_srctree) 168need-sub-make := 1 169endif 170 171export abs_srctree abs_objtree 172export root-make-done := y 173 174ifeq ($(need-sub-make),1) 175 176PHONY += $(MAKECMDGOALS) __sub-make 177 178$(filter-out $(this-makefile), $(MAKECMDGOALS)) __all: __sub-make 179 @: 180 181# Invoke a second make in the output directory, passing relevant variables 182__sub-make: 183 $(Q)$(MAKE) -C $(abs_objtree) -f $(abs_srctree)/Makefile $(MAKECMDGOALS) 184 185endif # need-sub-make 186endif # root-make-done 187 188# We process the rest of the Makefile if this is the final invocation of make 189ifeq ($(need-sub-make),) 190 191# Do not print "Entering directory ...", 192# but we want to display it when entering to the output directory 193# so that IDEs/editors are able to understand relative filenames. 194MAKEFLAGS += --no-print-directory 195 196ifeq ($(abs_srctree),$(abs_objtree)) 197 # building in the source tree 198 srctree := . 199 building_out_of_srctree := 200else 201 ifeq ($(abs_srctree)/,$(dir $(abs_objtree))) 202 # building in a subdirectory of the source tree 203 srctree := .. 204 else 205 srctree := $(abs_srctree) 206 endif 207 building_out_of_srctree := 1 208endif 209 210objtree := . 211VPATH := $(srctree) 212 213export srctree objtree VPATH 214 215export XEN_ROOT := $(abs_srctree)/.. 216 217# To make sure we do not include .config for any of the *config targets 218# catch them early, and hand them over to tools/kconfig/Makefile 219 220clean-targets := %clean 221no-dot-config-targets := $(clean-targets) \ 222 uninstall debug cloc \ 223 cscope TAGS tags gtags \ 224 xenversion 225 226config-build := n 227need-config := y 228 229ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) 230 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),) 231 need-config := n 232 endif 233endif 234 235ifneq ($(filter %config,$(MAKECMDGOALS)),) 236 config-build := y 237endif 238 239include scripts/Kbuild.include 240 241# Don't break if the build process wasn't called from the top level 242# we need XEN_TARGET_ARCH to generate the proper config 243include $(XEN_ROOT)/Config.mk 244 245# Set ARCH/SRCARCH appropriately. 246 247ARCH := $(XEN_TARGET_ARCH) 248SRCARCH := $(shell echo $(ARCH) | \ 249 sed -e 's/x86.*/x86/' -e 's/arm\(32\|64\)/arm/g' \ 250 -e 's/riscv.*/riscv/g' -e 's/ppc.*/ppc/g') 251export ARCH SRCARCH 252 253export CONFIG_SHELL := $(SHELL) 254export CC CXX LD NM OBJCOPY OBJDUMP ADDR2LINE 255export YACC = $(if $(BISON),$(BISON),bison) 256export LEX = $(if $(FLEX),$(FLEX),flex) 257 258# Default file for 'make defconfig'. 259# May be overruled on the command line or set in the environment. 260export KBUILD_DEFCONFIG ?= $(ARCH)_defconfig 261 262# Copy CFLAGS generated by "Config.mk" so they can be reused later without 263# reparsing Config.mk by e.g. arch/x86/boot/. 264export XEN_TREEWIDE_CFLAGS := $(CFLAGS) 265 266# CLANG_FLAGS needs to be calculated before calling Kconfig 267ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),) 268CLANG_FLAGS := 269 270ifeq ($(SRCARCH),x86) 271# The tests to select whether the integrated assembler is usable need to happen 272# before testing any assembler features, or else the result of the tests would 273# be stale if the integrated assembler is not used. 274 275# Older clang's built-in assembler doesn't understand .skip with labels: 276# https://bugs.llvm.org/show_bug.cgi?id=27369 277t1 = $(call as-insn,$(CC),".L0: .L1: .skip (.L1 - .L0)",,-no-integrated-as) 278 279# Check whether clang asm()-s support .include. 280t2 = $(call as-insn,$(CC) -I$(srctree)/arch/x86/include,".include \"asm/asm-defns.h\"",,-no-integrated-as) 281 282# Check whether clang keeps .macro-s between asm()-s: 283# https://bugs.llvm.org/show_bug.cgi?id=36110 284t3 = $(call as-insn,$(CC),".macro FOO;.endm"$(close); asm volatile $(open)".macro FOO;.endm",-no-integrated-as) 285 286CLANG_FLAGS += $(call or,$(t1),$(t2),$(t3)) 287endif 288 289CLANG_FLAGS += -Werror=unknown-warning-option 290CFLAGS += $(CLANG_FLAGS) 291export CLANG_FLAGS 292endif 293 294export XEN_HAS_CHECKPOLICY := $(call success,$(CHECKPOLICY) -h 2>&1 | grep -q xen) 295 296# =========================================================================== 297# Rules shared between *config targets and build targets 298 299PHONY += tools_fixdep 300tools_fixdep: 301 $(Q)$(MAKE) $(build)=tools tools/fixdep 302 303PHONY += outputmakefile 304# Before starting out-of-tree build, make sure the source tree is clean. 305# outputmakefile generates a Makefile in the output directory, if using a 306# separate output directory. This allows convenient use of make in the 307# output directory. 308# At the same time when output Makefile generated, generate .gitignore to 309# ignore whole output directory 310 311quiet_cmd_makefile = GEN Makefile 312cmd_makefile = { \ 313 echo "\# Automatically generated by $(srctree)/Makefile: don't edit"; \ 314 echo "include $(srctree)/Makefile"; \ 315 } > Makefile 316 317outputmakefile: 318ifdef building_out_of_srctree 319 $(Q)if [ -f $(srctree)/.config -o \ 320 -d $(srctree)/include/config -o \ 321 -d $(srctree)/include/generated ]; then \ 322 echo >&2 "***"; \ 323 echo >&2 "*** The source tree is not clean, please run 'make$(if $(findstring command line, $(origin XEN_TARGET_ARCH)), XEN_TARGET_ARCH=$(XEN_TARGET_ARCH)) distclean'"; \ 324 echo >&2 "*** in $(abs_srctree)";\ 325 echo >&2 "***"; \ 326 false; \ 327 fi 328 $(Q)ln -fsn $(srctree) source 329 $(call cmd,makefile) 330 $(Q)test -e .gitignore || \ 331 { echo "# this is build directory, ignore it"; echo "*"; } > .gitignore 332endif 333 334ifeq ($(config-build),y) 335# =========================================================================== 336# *config targets only - make sure prerequisites are updated, and descend 337# in tools/kconfig to make the *config target 338 339# Create a file for KCONFIG_ALLCONFIG which depends on the environment. 340# This will be use by kconfig targets allyesconfig/allmodconfig/allnoconfig/randconfig 341filechk_kconfig_allconfig = \ 342 $(if $(findstring n,$(XEN_HAS_CHECKPOLICY)), echo 'CONFIG_XSM_FLASK_POLICY=n';) \ 343 $(if $(KCONFIG_ALLCONFIG), cat $(KCONFIG_ALLCONFIG);) \ 344 : 345 346.allconfig.tmp: FORCE 347 set -e; { $(call filechk_kconfig_allconfig); } > $@ 348 349config: tools_fixdep outputmakefile FORCE 350 $(Q)$(MAKE) $(build)=tools/kconfig $@ 351 352# Config.mk tries to include .config file, don't try to remake it 353%/.config: ; 354 355%config: .allconfig.tmp tools_fixdep outputmakefile FORCE 356 $(Q)$(MAKE) $(build)=tools/kconfig KCONFIG_ALLCONFIG=$< $@ 357 358else # !config-build 359 360ifeq ($(need-config),y) 361-include include/config/auto.conf 362# Read in dependencies to all Kconfig* files, make sure to run syncconfig if 363# changes are detected. 364-include include/config/auto.conf.cmd 365 366# Allow people to just run `make` as before and not force them to configure 367# Only run defconfig if $(KCONFIG_CONFIG) is missing 368$(KCONFIG_CONFIG): tools_fixdep 369 $(if $(wildcard $@), , $(Q)$(MAKE) $(build)=tools/kconfig defconfig) 370 371# The actual configuration files used during the build are stored in 372# include/generated/ and include/config/. Update them if .config is newer than 373# include/config/auto.conf (which mirrors .config). 374# 375# This exploits the 'multi-target pattern rule' trick. 376# The syncconfig should be executed only once to make all the targets. 377include/config/%.conf include/config/%.conf.cmd: $(KCONFIG_CONFIG) 378 $(Q)rm -f include/config/auto.conf 379 $(Q)$(MAKE) $(build)=tools/kconfig syncconfig 380 381ifeq ($(CONFIG_DEBUG),y) 382CFLAGS += -O1 383else 384CFLAGS += -O2 385endif 386 387ifeq ($(CONFIG_FRAME_POINTER),y) 388CFLAGS += -fno-omit-frame-pointer 389else 390CFLAGS += -fomit-frame-pointer 391endif 392 393CFLAGS-$(CONFIG_CC_SPLIT_SECTIONS) += -ffunction-sections -fdata-sections 394 395CFLAGS += -nostdinc -fno-builtin -fno-common 396CFLAGS += -Werror -Wredundant-decls -Wwrite-strings -Wno-pointer-arith 397CFLAGS += -Wdeclaration-after-statement -Wuninitialized 398$(call cc-option-add,CFLAGS,CC,-Wvla) 399$(call cc-option-add,CFLAGS,CC,-Wflex-array-member-not-at-end) 400$(call cc-option-add,CFLAGS,CC,-Winit-self) 401CFLAGS += -pipe -D__XEN__ -include $(srctree)/include/xen/config.h 402CFLAGS-$(CONFIG_DEBUG_INFO) += -g 403 404ifneq ($(CONFIG_CC_IS_CLANG),y) 405# Clang doesn't understand this command line argument, and doesn't appear to 406# have a suitable alternative. The resulting compiled binary does function, 407# but has an excessively large symbol table. 408CFLAGS += -Wa,--strip-local-absolute 409endif 410 411AFLAGS += -D__ASSEMBLY__ 412 413$(call cc-option-add,AFLAGS,CC,-Wa$$(comma)--noexecstack) 414 415LDFLAGS-$(call ld-option,--warn-rwx-segments) += --no-warn-rwx-segments 416 417CFLAGS += $(CFLAGS-y) 418# allow extra CFLAGS externally via EXTRA_CFLAGS_XEN_CORE 419CFLAGS += $(EXTRA_CFLAGS_XEN_CORE) 420 421# Most CFLAGS are safe for assembly files: 422# -std=gnu{89,99} gets confused by #-prefixed end-of-line comments 423# -flto makes no sense and annoys clang 424AFLAGS += $(filter-out -std=gnu% -flto,$(CFLAGS)) $(AFLAGS-y) 425 426# LDFLAGS are only passed directly to $(LD) 427LDFLAGS += $(LDFLAGS_DIRECT) $(LDFLAGS-y) 428 429ifeq ($(CONFIG_UBSAN),y) 430CFLAGS_UBSAN := -fsanitize=undefined 431else 432CFLAGS_UBSAN := 433endif 434 435ifeq ($(CONFIG_LTO),y) 436CFLAGS += -flto 437LDFLAGS-$(CONFIG_CC_IS_CLANG) += -plugin LLVMgold.so 438endif 439 440ifdef building_out_of_srctree 441 CFLAGS += -I$(objtree)/include 442 CFLAGS += -I$(objtree)/arch/$(SRCARCH)/include 443endif 444CFLAGS += -I$(srctree)/include 445CFLAGS += -I$(srctree)/arch/$(SRCARCH)/include 446CFLAGS += -I$(objtree)/arch/$(SRCARCH)/include/generated 447 448# Note that link order matters! 449ALL_OBJS-y := common/built_in.o 450ALL_OBJS-y += drivers/built_in.o 451ALL_OBJS-y += lib/built_in.o 452ALL_OBJS-y += xsm/built_in.o 453ALL_OBJS-y += arch/$(SRCARCH)/built_in.o 454ALL_OBJS-$(CONFIG_CRYPTO) += crypto/built_in.o 455 456ALL_LIBS-y := lib/lib.a 457 458include $(srctree)/arch/$(SRCARCH)/arch.mk 459 460# define new variables to avoid the ones defined in Config.mk 461export XEN_CFLAGS := $(CFLAGS) 462export XEN_AFLAGS := $(AFLAGS) 463export XEN_LDFLAGS := $(LDFLAGS) 464export CFLAGS_UBSAN 465 466endif # need-config 467 468__all: build 469 470main-targets := build install uninstall clean distclean MAP 471.PHONY: $(main-targets) 472ifneq ($(XEN_TARGET_ARCH),x86_32) 473$(main-targets): %: _% ; 474else 475$(main-targets): 476 echo "*** Xen x86/32 target no longer supported!" 477endif 478 479.PHONY: _build 480_build: $(TARGET)$(CONFIG_XEN_INSTALL_SUFFIX) 481 482# Strip 483# 484# INSTALL_EFI_STRIP, if defined, will cause xen.efi to be stripped before it 485# is installed. If INSTALL_EFI_STRIP is '1', then the default option(s) below 486# will be used. Otherwise, INSTALL_EFI_STRIP value will be used as the 487# option(s) to the strip command. 488ifdef INSTALL_EFI_STRIP 489 490ifeq ($(INSTALL_EFI_STRIP),1) 491efi-strip-opt := --strip-debug --keep-file-symbols 492else 493efi-strip-opt := $(INSTALL_EFI_STRIP) 494endif 495 496endif 497 498.PHONY: _install 499_install: D=$(DESTDIR) 500_install: T=$(notdir $(TARGET)) 501_install: Z=$(CONFIG_XEN_INSTALL_SUFFIX) 502_install: $(TARGET)$(CONFIG_XEN_INSTALL_SUFFIX) 503 [ -d $(D)$(BOOT_DIR) ] || $(INSTALL_DIR) $(D)$(BOOT_DIR) 504 $(INSTALL_DATA) $(TARGET)$(Z) $(D)$(BOOT_DIR)/$(T)-$(XEN_FULLVERSION)$(Z) 505 ln -f -s $(T)-$(XEN_FULLVERSION)$(Z) $(D)$(BOOT_DIR)/$(T)-$(XEN_VERSION).$(XEN_SUBVERSION)$(Z) 506 ln -f -s $(T)-$(XEN_FULLVERSION)$(Z) $(D)$(BOOT_DIR)/$(T)-$(XEN_VERSION)$(Z) 507 ln -f -s $(T)-$(XEN_FULLVERSION)$(Z) $(D)$(BOOT_DIR)/$(T)$(Z) 508 [ -d "$(D)$(DEBUG_DIR)" ] || $(INSTALL_DIR) $(D)$(DEBUG_DIR) 509 $(INSTALL_DATA) $(TARGET)-syms $(D)$(DEBUG_DIR)/$(T)-syms-$(XEN_FULLVERSION) 510 $(INSTALL_DATA) $(TARGET)-syms.map $(D)$(DEBUG_DIR)/$(T)-syms-$(XEN_FULLVERSION).map 511 $(INSTALL_DATA) $(KCONFIG_CONFIG) $(D)$(BOOT_DIR)/$(T)-$(XEN_FULLVERSION).config 512 if [ -r $(TARGET).efi -a -n '$(EFI_DIR)' ]; then \ 513 [ -d $(D)$(EFI_DIR) ] || $(INSTALL_DIR) $(D)$(EFI_DIR); \ 514 $(INSTALL_DATA) $(TARGET).efi $(D)$(EFI_DIR)/$(T)-$(XEN_FULLVERSION).efi; \ 515 for x in map elf; do \ 516 if [ -e $(TARGET).efi.$$x ]; then \ 517 $(INSTALL_DATA) $(TARGET).efi.$$x $(D)$(DEBUG_DIR)/$(T)-$(XEN_FULLVERSION).efi.$$x; \ 518 fi; \ 519 done; \ 520 ln -sf $(T)-$(XEN_FULLVERSION).efi $(D)$(EFI_DIR)/$(T)-$(XEN_VERSION).$(XEN_SUBVERSION).efi; \ 521 ln -sf $(T)-$(XEN_FULLVERSION).efi $(D)$(EFI_DIR)/$(T)-$(XEN_VERSION).efi; \ 522 ln -sf $(T)-$(XEN_FULLVERSION).efi $(D)$(EFI_DIR)/$(T).efi; \ 523 if [ -n '$(EFI_MOUNTPOINT)' -a -n '$(EFI_VENDOR)' ]; then \ 524 $(if $(efi-strip-opt), \ 525 $(STRIP) $(efi-strip-opt) -p -o $(TARGET).efi.stripped $(TARGET).efi && \ 526 $(INSTALL_DATA) $(TARGET).efi.stripped $(D)$(EFI_MOUNTPOINT)/efi/$(EFI_VENDOR)/$(T)-$(XEN_FULLVERSION).efi ||) \ 527 $(INSTALL_DATA) $(TARGET).efi $(D)$(EFI_MOUNTPOINT)/efi/$(EFI_VENDOR)/$(T)-$(XEN_FULLVERSION).efi; \ 528 elif [ "$(D)" = "$(patsubst $(shell cd $(XEN_ROOT) && pwd)/%,%,$(D))" ]; then \ 529 echo 'EFI installation only partially done (EFI_VENDOR not set)' >&2; \ 530 fi; \ 531 fi 532 533.PHONY: tests 534tests: 535 $(Q)$(MAKE) $(build)=test 536.PHONY: install-tests 537install-tests: 538 $(Q)$(MAKE) $(build)=test install 539 540.PHONY: _uninstall 541_uninstall: D=$(DESTDIR) 542_uninstall: T=$(notdir $(TARGET)) 543_uninstall: Z=$(CONFIG_XEN_INSTALL_SUFFIX) 544_uninstall: 545 rm -f $(D)$(BOOT_DIR)/$(T)-$(XEN_FULLVERSION).config 546 rm -f $(D)$(BOOT_DIR)/$(T)-$(XEN_FULLVERSION)$(Z) 547 rm -f $(D)$(BOOT_DIR)/$(T)-$(XEN_VERSION).$(XEN_SUBVERSION)$(Z) 548 rm -f $(D)$(BOOT_DIR)/$(T)-$(XEN_VERSION)$(Z) 549 rm -f $(D)$(BOOT_DIR)/$(T)$(Z) 550 rm -f $(D)$(DEBUG_DIR)/$(T)-syms-$(XEN_FULLVERSION) 551 rm -f $(D)$(DEBUG_DIR)/$(T)-syms-$(XEN_FULLVERSION).map 552 rm -f $(D)$(EFI_DIR)/$(T)-$(XEN_FULLVERSION).efi 553 rm -f $(D)$(EFI_DIR)/$(T)-$(XEN_VERSION).$(XEN_SUBVERSION).efi 554 rm -f $(D)$(DEBUG_DIR)/$(T)-$(XEN_FULLVERSION).efi.elf 555 rm -f $(D)$(DEBUG_DIR)/$(T)-$(XEN_FULLVERSION).efi.map 556 rm -f $(D)$(EFI_DIR)/$(T)-$(XEN_VERSION).efi 557 rm -f $(D)$(EFI_DIR)/$(T).efi 558 if [ -n '$(EFI_MOUNTPOINT)' -a -n '$(EFI_VENDOR)' ]; then \ 559 rm -f $(D)$(EFI_MOUNTPOINT)/efi/$(EFI_VENDOR)/$(T)-$(XEN_FULLVERSION).efi; \ 560 fi 561 562.PHONY: _debug 563_debug: 564 $(OBJDUMP) -D -S $(TARGET)-syms > $(TARGET).s 565 566.PHONY: _clean 567_clean: 568 $(Q)$(MAKE) $(clean)=tools 569 $(Q)$(MAKE) $(clean)=include 570 $(Q)$(MAKE) $(clean)=common 571 $(Q)$(MAKE) $(clean)=drivers 572 $(Q)$(MAKE) $(clean)=lib 573 $(Q)$(MAKE) $(clean)=xsm 574 $(Q)$(MAKE) $(clean)=crypto 575 $(Q)$(MAKE) $(clean)=arch/arm 576 $(Q)$(MAKE) $(clean)=arch/ppc 577 $(Q)$(MAKE) $(clean)=arch/riscv 578 $(Q)$(MAKE) $(clean)=arch/x86 579 $(Q)$(MAKE) $(clean)=test 580 $(Q)$(MAKE) $(clean)=tools/kconfig 581 find . \( -name "*.o" -o -name ".*.d" -o -name ".*.d2" \ 582 -o -name ".*.o.tmp" -o -name "*~" -o -name "core" \ 583 -o -name '*.lex.c' -o -name '*.tab.[ch]' -o -name "*.gcno" \ 584 -o -name ".*.cmd" -o -name "lib.a" \) -exec rm -f {} \; 585 rm -f include/asm $(TARGET) $(TARGET).gz $(TARGET)-syms $(TARGET)-syms.map 586 rm -f $(TARGET).efi $(TARGET).efi.map $(TARGET).efi.elf $(TARGET).efi.stripped 587 rm -f asm-offsets.s arch/*/include/asm/asm-offsets.h 588 rm -f .banner .allconfig.tmp include/xen/compile.h 589 rm -rf $(objtree)/arch/*/include/generated 590 591.PHONY: _distclean 592_distclean: clean 593 rm -f tags TAGS cscope.files cscope.in.out cscope.out cscope.po.out GTAGS GPATH GRTAGS GSYMS .config source 594 595# Support for using generic headers in asm-generic 596PHONY += asm-generic 597asm-generic: 598 $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/asm 599 600$(TARGET).gz: $(TARGET) 601 gzip -n -f -9 < $< > $@.new 602 mv $@.new $@ 603 604$(TARGET): outputmakefile asm-generic FORCE 605 $(Q)$(MAKE) $(build)=tools 606 $(Q)$(MAKE) $(build)=. include/xen/compile.h 607 $(Q)$(MAKE) $(build)=include all 608 $(Q)$(MAKE) $(build)=arch/$(SRCARCH) include 609 $(Q)$(MAKE) $(build)=. arch/$(SRCARCH)/include/asm/asm-offsets.h 610 $(Q)$(MAKE) $(build)=. MKRELOC=$(MKRELOC) 'ALL_OBJS=$(ALL_OBJS-y)' 'ALL_LIBS=$(ALL_LIBS-y)' $@ 611 612SUBDIRS = xsm arch common crypto drivers lib test 613define all_sources 614 ( find include -type f -name '*.h' -print; \ 615 find $(SUBDIRS) -type f -name '*.[chS]' -print ) 616endef 617 618define set_exuberant_flags 619 exuberant_flags=`$1 --version 2>/dev/null | (grep -iq exuberant && \ 620 echo "-I __initdata,__exitdata,__acquires,__releases \ 621 -I EXPORT_SYMBOL \ 622 --extra=+f --c-kinds=+px") || true` 623endef 624 625.PHONY: xenversion 626xenversion: 627 @echo $(XEN_FULLVERSION) 628 629.PHONY: TAGS 630TAGS: 631 set -e; rm -f TAGS; \ 632 $(call set_exuberant_flags,etags); \ 633 $(all_sources) | xargs etags $$exuberant_flags -a 634 635.PHONY: tags 636tags: 637 set -e; rm -f tags; \ 638 $(call set_exuberant_flags,ctags); \ 639 $(all_sources) | xargs ctags $$exuberant_flags -a 640 641.PHONY: gtags 642gtags: 643 set -e; rm -f GTAGS GSYMS GPATH GRTAGS 644 $(all_sources) | gtags -f - 645 646.PHONY: cscope 647cscope: 648 $(all_sources) > cscope.files 649 cscope -k -b -q 650 651.PHONY: _MAP 652_MAP: $(TARGET) 653 $(NM) -n $(TARGET)-syms | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' > System.map 654 655%.o %.i %.s: %.c tools_fixdep FORCE 656 $(Q)$(MAKE) $(build)=$(*D) $(*D)/$(@F) 657 658%.o %.s: %.S tools_fixdep FORCE 659 $(Q)$(MAKE) $(build)=$(*D) $(*D)/$(@F) 660 661%/: tools_fixdep FORCE 662 $(Q)$(MAKE) $(build)=$* need-builtin=1 663 664.PHONY: cloc 665cloc: 666 find . -name tools -prune -o -name '*.o.cmd' -print | while read f; do \ 667 for sf in $$(grep -o "[a-zA-Z0-9_/-]*\.[cS]" $$f); do \ 668 test -f "$$sf" && echo "$$sf"; \ 669 done; \ 670 done | cloc --list-file=- 671 672# Target used by xen-analysis.sh script to retrieve Xen build system variables 673export-variable-%: 674 $(info $*=$($*)) 675 676endif #config-build 677endif # need-sub-make 678 679PHONY += FORCE 680FORCE: 681 682# Declare the contents of the PHONY variable as phony. We keep that 683# information in a variable so we can use it in if_changed and friends. 684.PHONY: $(PHONY) 685