From nobody Mon Feb 9 17:06:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1571850722; cv=none; d=zoho.com; s=zohoarc; b=K8Nvu4JBdjey31N9Q1bSIA3PiaMCS7WCBAI030dLCkbEC6VBgCyyT1kF71UxjLxSJsz6NYgFfBYYpxrUyU4/Z8Gk2O8rL5Rscb9FqYU6HyK3YEMzfMU6xYapMPfD3KGPHN9EP3292B7umFht8L0bBegM5C2QelltOcDW05rtoVM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571850722; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jRLnyTBFbUw++1nGwKhq6MEx7bK27B7wSFcoWJ9DWEM=; b=a8Sv8XUQlzHIgbPMz51Y+TLU7OBKJ2D31yiybFckog5fEv1OqE33RHuIJKWmW947QCZZCFZRkwGKeQNvTkVOM5FNP4F1FFcEg29z1O9/po6bx4i+XA4DMCqwvNgtY8urSOnVSmG83G0xDdL70NB4DSMlvAiUQJOkaZIgRSlQscw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 157185072283572.7889534953216; Wed, 23 Oct 2019 10:12:02 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNK9n-0002eG-4X; Wed, 23 Oct 2019 17:10:47 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNK9l-0002dN-L9 for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 17:10:45 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 09156916-f5b8-11e9-9488-12813bfff9fa; Wed, 23 Oct 2019 17:10:39 +0000 (UTC) X-Inumbo-ID: 09156916-f5b8-11e9-9488-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571850639; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8lmlO/7p9GznTUOr/iZxDm/tyiPM2BM+XRXLjTUxh9M=; b=GlrFJQptSM/IrT4wGiHTtjIb6bTKz6R4hELjpmrQOul9ic/zUR0Lv921 VvBauHQu6myuCpsnUlo7oVar/dWY3dtPfNVAoXtdbHyHd05JPd+OPyDLI pKQyQjZ8wI23tgt2cl14d2yrJvkqHmf7rbPfEHmcqGxuwTe2a0+VxlEsI 0=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa2.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa2.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: H+yHm6gRSKvWRvyzgoOXTF6FHGC67Zz7ruCz1W1XZCFIhktMtHujALOnWpWyVylRxU+cxG93qo 7XJ0sTH8kpOKtMpRZSZwX9ydon8nL0fZ7LGOiPiDBCIW7dzts7FqWMnsp8JLwA7V4vSG5xNOIO Ie8VtR80dKxKKKHGVBJShTAlGXaxmbIoIBLJBOs+JZpmwb6Jfl0Id6GOcA1WWAqt7n7Wz5EA+a cpPII7+eFFWwbcnraPcU3aGAf9xF0JjTSScIxR5q2TFuRSBr6Lkd6R5lfEGOsXOm9nJgdzZi4a 3bI= X-SBRS: 2.7 X-MesageID: 7335581 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,221,1569297600"; d="scan'208";a="7335581" From: Anthony PERARD To: Date: Wed, 23 Oct 2019 17:48:35 +0100 Message-ID: <20191023164837.2700240-22-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023164837.2700240-1-anthony.perard@citrix.com> References: <20191023164837.2700240-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [RFC XEN PATCH 21/23] Import root Makefile from Linux v5.3 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Edit a lot of it out, mostly CFLAGS, build of modules. Edit in xenversion. --- xen/Makefile | 1249 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 1001 insertions(+), 248 deletions(-) diff --git a/xen/Makefile b/xen/Makefile index b1b60e679082..90645668957c 100644 --- a/xen/Makefile +++ b/xen/Makefile @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 # This is the correct place to edit the build version. # All other places this is stored (eg. compile.h) should be autogenerated. export XEN_VERSION =3D 4 @@ -11,284 +12,1036 @@ export XEN_DOMAIN ?=3D $(shell ([ -x /bin/dnsdomainn= ame ] && /bin/dnsdomainname) | export XEN_BUILD_DATE ?=3D $(shell LC_ALL=3DC date) export XEN_BUILD_TIME ?=3D $(shell LC_ALL=3DC date +%T) export XEN_BUILD_HOST ?=3D $(shell hostname) -export XEN_CONFIG_EXPERT ?=3D n =20 -export BASEDIR :=3D $(CURDIR) -export XEN_ROOT :=3D $(BASEDIR)/.. +export XEN_ROOT :=3D $(CURDIR)/.. + +# *DOCUMENTATION* +# To see a list of typical targets execute "make help" +# More info can be located in ./README +# Comments in this file are targeted only to the developer, do not +# expect to learn how to build the kernel reading this file. + +# That's our default target when none is given on the command line +PHONY :=3D _all +_all: + +# We are using a recursive build, so we need to do a little thinking +# to get the ordering right. +# +# Most importantly: sub-Makefiles should only ever modify files in +# their own directory. If in some directory we have a dependency on +# a file in another dir (which doesn't happen often, but it's often +# unavoidable when linking the built-in.a targets which finally +# turn into xen), we will call a sub make in that other dir, and +# after that we are sure that everything which is in that other dir +# is now up to date. +# +# The only cases where we need to modify files which have global +# effects are thus separated out and done before the recursive +# descending is started. They are now explicitly listed as the +# prepare rule. + +ifneq ($(sub_make_done),1) =20 # Do not use make's built-in rules and variables +# (this increases performance and avoids hard-to-debug behaviour) MAKEFLAGS +=3D -rR =20 -EFI_MOUNTPOINT ?=3D $(BOOT_DIR)/efi +# Avoid funny character set dependencies +unexport LC_ALL +LC_COLLATE=3DC +LC_NUMERIC=3DC +export LC_COLLATE LC_NUMERIC =20 -ARCH=3D$(XEN_TARGET_ARCH) -SRCARCH=3D$(shell echo $(ARCH) | sed -e 's/x86.*/x86/' -e s'/arm\(32\|64\)= /arm/g') +# Avoid interference with shell env settings +unexport GREP_OPTIONS =20 -# Don't break if the build process wasn't called from the top level -# we need XEN_TARGET_ARCH to generate the proper config -include $(XEN_ROOT)/Config.mk +# Beautify output +# ------------------------------------------------------------------------= --- +# +# Normally, we echo the whole command before executing it. By making +# that echo $($(quiet)$(cmd)), we now have the possibility to set +# $(quiet) to choose other forms of output instead, e.g. +# +# quiet_cmd_cc_o_c =3D Compiling $(RELDIR)/$@ +# cmd_cc_o_c =3D $(CC) $(c_flags) -c -o $@ $< +# +# If $(quiet) is empty, the whole command will be printed. +# If it is set to "quiet_", only the short version will be printed. +# If it is set to "silent_", nothing will be printed at all, since +# the variable $(silent_cmd_cc_o_c) doesn't exist. +# +# A simple variant is to prefix commands with $(Q) - that's useful +# for commands that shall be hidden in non-verbose mode. +# +# $(Q)ln $@ :< +# +# If KBUILD_VERBOSE equals 0 then the above command will be hidden. +# If KBUILD_VERBOSE equals 1 then the above command is displayed. +# +# To put more focus on warnings, be less verbose as default +# Use 'make V=3D1' to see the full commands =20 -# Allow someone to change their config file -export KCONFIG_CONFIG ?=3D .config +ifeq ("$(origin V)", "command line") + KBUILD_VERBOSE =3D $(V) +endif +ifndef KBUILD_VERBOSE + KBUILD_VERBOSE =3D 0 +endif =20 -.PHONY: default -default: build +ifeq ($(KBUILD_VERBOSE),1) + quiet =3D + Q =3D +else + quiet=3Dquiet_ + Q =3D @ +endif + +# If the user is running make -s (silent mode), suppress echoing of +# commands + +ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),) + quiet=3Dsilent_ +endif + +export quiet Q KBUILD_VERBOSE =20 -.PHONY: dist -dist: install +# Kbuild will save output files in the current working directory. +# This does not need to match to the root of the kernel source tree. +# +# For example, you can do this: +# +# cd /dir/to/store/output/files; make -f /dir/to/kernel/source/Makefile +# +# If you want to save output files in a different location, there are +# two syntaxes to specify it. +# +# 1) O=3D +# Use "make O=3Ddir/to/store/output/files/" +# +# 2) Set KBUILD_OUTPUT +# Set the environment variable KBUILD_OUTPUT to point to the output direct= ory. +# export KBUILD_OUTPUT=3Ddir/to/store/output/files/; make +# +# The O=3D assignment takes precedence over the KBUILD_OUTPUT environment +# variable. =20 -build install:: include/config/auto.conf +# Do we want to change the working directory? +ifeq ("$(origin O)", "command line") + KBUILD_OUTPUT :=3D $(O) +endif =20 -.PHONY: build install uninstall clean distclean cscope TAGS tags MAP gtags= tests -build install uninstall debug clean distclean cscope TAGS tags MAP gtags t= ests:: -ifneq ($(XEN_TARGET_ARCH),x86_32) - $(MAKE) -f Rules.mk _$@ +ifneq ($(KBUILD_OUTPUT),) +# Make's built-in functions such as $(abspath ...), $(realpath ...) cannot +# expand a shell special character '~'. We use a somewhat tedious way here. +abs_objtree :=3D $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) = && pwd) +$(if $(abs_objtree),, \ + $(error failed to create output directory "$(KBUILD_OUTPUT)")) + +# $(realpath ...) resolves symlinks +abs_objtree :=3D $(realpath $(abs_objtree)) +else +abs_objtree :=3D $(CURDIR) +endif # ifneq ($(KBUILD_OUTPUT),) + +ifeq ($(abs_objtree),$(CURDIR)) +# Suppress "Entering directory ..." unless we are changing the work direct= ory. +MAKEFLAGS +=3D --no-print-directory else - echo "*** Xen x86/32 target no longer supported!" +need-sub-make :=3D 1 +endif + +abs_srctree :=3D $(realpath $(dir $(lastword $(MAKEFILE_LIST)))) + +ifneq ($(words $(subst :, ,$(abs_srctree))), 1) +$(error source directory cannot contain spaces or colons) +endif + +ifneq ($(abs_srctree),$(abs_objtree)) +# Look for make include files relative to root of kernel src +# +# This does not become effective immediately because MAKEFLAGS is re-parsed +# once after the Makefile is read. We need to invoke sub-make. +MAKEFLAGS +=3D --include-dir=3D$(abs_srctree) +need-sub-make :=3D 1 +endif + +ifneq ($(filter 3.%,$(MAKE_VERSION)),) +# 'MAKEFLAGS +=3D -rR' does not immediately become effective for GNU Make = 3.x +# We need to invoke sub-make to avoid implicit rules in the top Makefile. +need-sub-make :=3D 1 +# Cancel implicit rules for this Makefile. +$(lastword $(MAKEFILE_LIST)): ; +endif + +export abs_srctree abs_objtree +export sub_make_done :=3D 1 + +ifeq ($(need-sub-make),1) + +PHONY +=3D $(MAKECMDGOALS) sub-make + +$(filter-out _all sub-make $(lastword $(MAKEFILE_LIST)), $(MAKECMDGOALS)) = _all: sub-make + @: + +# Invoke a second make in the output directory, passing relevant variables +sub-make: + $(Q)$(MAKE) -C $(abs_objtree) -f $(abs_srctree)/Makefile $(MAKECMDGOALS) + +endif # need-sub-make +endif # sub_make_done + +# We process the rest of the Makefile if this is the final invocation of m= ake +ifeq ($(need-sub-make),) + +# Do not print "Entering directory ...", +# but we want to display it when entering to the output directory +# so that IDEs/editors are able to understand relative filenames. +MAKEFLAGS +=3D --no-print-directory + +# Call a source code checker (by default, "sparse") as part of the +# C compilation. +# +# Use 'make C=3D1' to enable checking of only re-compiled files. +# Use 'make C=3D2' to enable checking of *all* source files, regardless +# of whether they are re-compiled or not. +# +# See the file "Documentation/dev-tools/sparse.rst" for more details, +# including where to get the "sparse" utility. + +ifeq ("$(origin C)", "command line") + KBUILD_CHECKSRC =3D $(C) +endif +ifndef KBUILD_CHECKSRC + KBUILD_CHECKSRC =3D 0 +endif + +export KBUILD_CHECKSRC + +ifeq ($(abs_srctree),$(abs_objtree)) + # building in the source tree + srctree :=3D . + building_out_of_srctree :=3D +else + ifeq ($(abs_srctree)/,$(dir $(abs_objtree))) + # building in a subdirectory of the source tree + srctree :=3D .. + else + srctree :=3D $(abs_srctree) + endif + building_out_of_srctree :=3D 1 +endif + +ifneq ($(KBUILD_ABS_SRCTREE),) +srctree :=3D $(abs_srctree) +endif + +objtree :=3D . +VPATH :=3D $(srctree) + +export building_out_of_srctree srctree objtree VPATH + +# To make sure we do not include .config for any of the *config targets +# catch them early, and hand them over to scripts/kconfig/Makefile +# It is allowed to specify more targets when calling make, including +# mixing *config targets and build targets. +# For example 'make oldconfig all'. +# Detect when mixed targets is specified, and make a second invocation +# of make so .config is not included in this case either (for *config). + +version_h :=3D include/xen/compile.h + +clean-targets :=3D %clean mrproper cleandocs +no-dot-config-targets :=3D $(clean-targets) \ + cscope gtags TAGS tags help% %docs check% \ + $(version_h) headers headers_% archheaders \ + xenversion +no-sync-config-targets :=3D $(no-dot-config-targets) install %install + +config-targets :=3D 0 +mixed-targets :=3D 0 +dot-config :=3D 1 +may-sync-config :=3D 1 + +ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) + ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),) + dot-config :=3D 0 + endif endif =20 -.PHONY: _build -_build: $(TARGET)$(CONFIG_XEN_INSTALL_SUFFIX) - -.PHONY: _install -_install: D=3D$(DESTDIR) -_install: T=3D$(notdir $(TARGET)) -_install: Z=3D$(CONFIG_XEN_INSTALL_SUFFIX) -_install: $(TARGET)$(CONFIG_XEN_INSTALL_SUFFIX) - [ -d $(D)$(BOOT_DIR) ] || $(INSTALL_DIR) $(D)$(BOOT_DIR) - $(INSTALL_DATA) $(TARGET)$(Z) $(D)$(BOOT_DIR)/$(T)-$(XEN_FULLVERSION)$(Z) - ln -f -s $(T)-$(XEN_FULLVERSION)$(Z) $(D)$(BOOT_DIR)/$(T)-$(XEN_VERSION).= $(XEN_SUBVERSION)$(Z) - ln -f -s $(T)-$(XEN_FULLVERSION)$(Z) $(D)$(BOOT_DIR)/$(T)-$(XEN_VERSION)$= (Z) - ln -f -s $(T)-$(XEN_FULLVERSION)$(Z) $(D)$(BOOT_DIR)/$(T)$(Z) - [ -d "$(D)$(DEBUG_DIR)" ] || $(INSTALL_DIR) $(D)$(DEBUG_DIR) - $(INSTALL_DATA) $(TARGET)-syms $(D)$(DEBUG_DIR)/$(T)-syms-$(XEN_FULLVERSI= ON) - $(INSTALL_DATA) $(TARGET)-syms.map $(D)$(DEBUG_DIR)/$(T)-syms-$(XEN_FULLV= ERSION).map - $(INSTALL_DATA) $(KCONFIG_CONFIG) $(D)$(BOOT_DIR)/$(T)-$(XEN_FULLVERSION)= .config - if [ -r $(TARGET).efi -a -n '$(EFI_DIR)' ]; then \ - [ -d $(D)$(EFI_DIR) ] || $(INSTALL_DIR) $(D)$(EFI_DIR); \ - $(INSTALL_DATA) $(TARGET).efi $(D)$(EFI_DIR)/$(T)-$(XEN_FULLVERSION).efi= ; \ - if [ -e $(TARGET).efi.map ]; then \ - $(INSTALL_DATA) $(TARGET).efi.map $(D)$(DEBUG_DIR)/$(T)-$(XEN_FULLVERSI= ON).efi.map; \ - fi; \ - ln -sf $(T)-$(XEN_FULLVERSION).efi $(D)$(EFI_DIR)/$(T)-$(XEN_VERSION).$(= XEN_SUBVERSION).efi; \ - ln -sf $(T)-$(XEN_FULLVERSION).efi $(D)$(EFI_DIR)/$(T)-$(XEN_VERSION).ef= i; \ - ln -sf $(T)-$(XEN_FULLVERSION).efi $(D)$(EFI_DIR)/$(T).efi; \ - if [ -n '$(EFI_MOUNTPOINT)' -a -n '$(EFI_VENDOR)' ]; then \ - $(INSTALL_DATA) $(TARGET).efi $(D)$(EFI_MOUNTPOINT)/efi/$(EFI_VENDOR)/$= (T)-$(XEN_FULLVERSION).efi; \ - elif [ "$(D)" =3D "$(patsubst $(shell cd $(XEN_ROOT) && pwd)/%,%,$(D))" = ]; then \ - echo 'EFI installation only partially done (EFI_VENDOR not set)' >&2; \ - fi; \ - fi - -.PHONY: _tests -_tests: - $(MAKE) -f $(BASEDIR)/Rules.mk -C test tests - -.PHONY: _uninstall -_uninstall: D=3D$(DESTDIR) -_uninstall: T=3D$(notdir $(TARGET)) -_uninstall: Z=3D$(CONFIG_XEN_INSTALL_SUFFIX) -_uninstall: - rm -f $(D)$(BOOT_DIR)/$(T)-$(XEN_FULLVERSION).config - rm -f $(D)$(BOOT_DIR)/$(T)-$(XEN_FULLVERSION)$(Z) - rm -f $(D)$(BOOT_DIR)/$(T)-$(XEN_VERSION).$(XEN_SUBVERSION)$(Z) - rm -f $(D)$(BOOT_DIR)/$(T)-$(XEN_VERSION)$(Z) - rm -f $(D)$(BOOT_DIR)/$(T)$(Z) - rm -f $(D)$(DEBUG_DIR)/$(T)-syms-$(XEN_FULLVERSION) - rm -f $(D)$(DEBUG_DIR)/$(T)-syms-$(XEN_FULLVERSION).map - rm -f $(D)$(EFI_DIR)/$(T)-$(XEN_FULLVERSION).efi - rm -f $(D)$(EFI_DIR)/$(T)-$(XEN_VERSION).$(XEN_SUBVERSION).efi - rm -f $(D)$(DEBUG_DIR)/$(T)-$(XEN_FULLVERSION).efi.map - rm -f $(D)$(EFI_DIR)/$(T)-$(XEN_VERSION).efi - rm -f $(D)$(EFI_DIR)/$(T).efi - rm -f $(D)$(EFI_MOUNTPOINT)/efi/$(EFI_VENDOR)/$(T)-$(XEN_FULLVERSION).efi - -.PHONY: _debug -_debug: - $(OBJDUMP) -D -S $(TARGET)-syms > $(TARGET).s - -.PHONY: _clean -_clean: delete-unfresh-files - $(MAKE) -C tools clean - $(MAKE) -f $(BASEDIR)/Rules.mk -C include clean - $(MAKE) -f $(BASEDIR)/Rules.mk -C common clean - $(MAKE) -f $(BASEDIR)/Rules.mk -C drivers clean - $(MAKE) -f $(BASEDIR)/Rules.mk -C xsm clean - $(MAKE) -f $(BASEDIR)/Rules.mk -C crypto clean - $(MAKE) -f $(BASEDIR)/Rules.mk -C arch/arm clean - $(MAKE) -f $(BASEDIR)/Rules.mk -C arch/x86 clean - $(MAKE) -f $(BASEDIR)/Rules.mk -C test clean - $(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig ARCH=3D$(ARCH) SRCAR= CH=3D$(SRCARCH) clean - find . \( -name "*.o" -o -name ".*.d" -o -name ".*.d2" -o -name "*.gcno" = \) -exec rm -f {} \; - rm -f include/asm $(TARGET) $(TARGET).gz $(TARGET).efi $(TARGET).efi.map = $(TARGET)-syms $(TARGET)-syms.map *~ core - rm -f include/asm-*/asm-offsets.h - rm -f .banner - -.PHONY: _distclean -_distclean: clean - rm -f tags TAGS cscope.files cscope.in.out cscope.out cscope.po.out GTAGS= GPATH GRTAGS GSYMS .config - -$(TARGET).gz: $(TARGET) - gzip -n -f -9 < $< > $@.new - mv $@.new $@ - -$(TARGET): delete-unfresh-files - $(MAKE) -C tools - $(MAKE) -f $(BASEDIR)/Rules.mk include/xen/compile.h - [ -e include/asm ] || ln -sf asm-$(TARGET_ARCH) include/asm - [ -e arch/$(TARGET_ARCH)/efi ] && for f in boot.c runtime.c compat.c efi.= h;\ - do test -r arch/$(TARGET_ARCH)/efi/$$f || \ - ln -nsf ../../../common/efi/$$f arch/$(TARGET_ARCH)/efi/; \ - done; \ - true - $(MAKE) -f $(BASEDIR)/Rules.mk -C include - $(MAKE) -f $(BASEDIR)/Rules.mk -C arch/$(TARGET_ARCH) asm-offsets.s - $(MAKE) -f $(BASEDIR)/Rules.mk include/asm-$(TARGET_ARCH)/asm-offsets.h - $(MAKE) -f $(BASEDIR)/Rules.mk -C arch/$(TARGET_ARCH) $@ - -# drivers/char/console.o contains static banner/compile info. Blow it away. -# Don't refresh these files during e.g., 'sudo make install' -.PHONY: delete-unfresh-files -delete-unfresh-files: - @if [ ! -r include/xen/compile.h -o -O include/xen/compile.h ]; then \ - rm -f include/xen/compile.h; \ - fi - -.banner: Makefile - @if which figlet >/dev/null 2>&1 ; then \ - echo " Xen $(XEN_FULLVERSION)" | figlet -f tools/xen.flf > $@.tmp; \ - else \ - echo " Xen $(XEN_FULLVERSION)" > $@.tmp; \ - fi - @mv -f $@.tmp $@ - -# compile.h contains dynamic build info. Rebuilt on every 'make' invocatio= n. -include/xen/compile.h: include/xen/compile.h.in .banner - @sed -e 's/@@date@@/$(XEN_BUILD_DATE)/g' \ - -e 's/@@time@@/$(XEN_BUILD_TIME)/g' \ - -e 's/@@whoami@@/$(XEN_WHOAMI)/g' \ - -e 's/@@domain@@/$(XEN_DOMAIN)/g' \ - -e 's/@@hostname@@/$(XEN_BUILD_HOST)/g' \ - -e 's!@@compiler@@!$(shell $(CC) $(CFLAGS) --version 2>&1 | head -1)!= g' \ - -e 's/@@version@@/$(XEN_VERSION)/g' \ - -e 's/@@subversion@@/$(XEN_SUBVERSION)/g' \ - -e 's/@@extraversion@@/$(XEN_EXTRAVERSION)/g' \ - -e 's!@@changeset@@!$(shell tools/scmversion $(XEN_ROOT) || echo "una= vailable")!g' \ - < include/xen/compile.h.in > $@.new - @cat .banner - @$(PYTHON) tools/fig-to-oct.py < .banner >> $@.new - @mv -f $@.new $@ - -include/asm-$(TARGET_ARCH)/asm-offsets.h: arch/$(TARGET_ARCH)/asm-offsets.s - @(set -e; \ - echo "/*"; \ - echo " * DO NOT MODIFY."; \ - echo " *"; \ - echo " * This file was auto-generated from $<"; \ - echo " *"; \ - echo " */"; \ - echo ""; \ - echo "#ifndef __ASM_OFFSETS_H__"; \ - echo "#define __ASM_OFFSETS_H__"; \ - echo ""; \ - sed -rne "/^[^#].*=3D=3D>/{s:.*=3D=3D>(.*)<=3D=3D.*:\1:; s: [\$$#]: :; = p;}"; \ - echo ""; \ - echo "#endif") <$< >$@ - -SUBDIRS =3D xsm arch/$(TARGET_ARCH) common drivers test -define all_sources - ( find include/asm-$(TARGET_ARCH) -name '*.h' -print; \ - find include -name 'asm-*' -prune -o -name '*.h' -print; \ - find $(SUBDIRS) -name '*.[chS]' -print ) +ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),) + ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),) + may-sync-config :=3D 0 + endif +endif + +ifneq ($(filter config %config,$(MAKECMDGOALS)),) + config-targets :=3D 1 + ifneq ($(words $(MAKECMDGOALS)),1) + mixed-targets :=3D 1 + endif +endif + +# For "make -j clean all", "make -j mrproper defconfig all", etc. +ifneq ($(filter $(clean-targets),$(MAKECMDGOALS)),) + ifneq ($(filter-out $(clean-targets),$(MAKECMDGOALS)),) + mixed-targets :=3D 1 + endif +endif + +# install and modules_install need also be processed one by one +ifneq ($(filter install,$(MAKECMDGOALS)),) + ifneq ($(filter modules_install,$(MAKECMDGOALS)),) + mixed-targets :=3D 1 + endif +endif + +ifeq ($(mixed-targets),1) +# =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D +# We're called with mixed targets (*config and build targets). +# Handle them one by one. + +PHONY +=3D $(MAKECMDGOALS) __build_one_by_one + +$(filter-out __build_one_by_one, $(MAKECMDGOALS)): __build_one_by_one + @: + +__build_one_by_one: + $(Q)set -e; \ + for i in $(MAKECMDGOALS); do \ + $(MAKE) -f $(srctree)/Makefile $$i; \ + done + +else + +include scripts/Kbuild.include + +# Cross compiling and selecting different set of gcc/bin-utils +# ------------------------------------------------------------------------= --- +# +# When performing cross compilation for other architectures ARCH shall be = set +# to the target architecture. (See arch/* for the possibilities). +# ARCH can be set during invocation of make: +# make ARCH=3Dia64 +# Another way is to have ARCH set in the environment. +# The default ARCH is the host where make is executed. + +# CROSS_COMPILE specify the prefix used for all executables used +# during compilation. Only gcc and related bin-utils executables +# are prefixed with $(CROSS_COMPILE). +# CROSS_COMPILE can be set on the command line +# make CROSS_COMPILE=3Dia64-linux- +# Alternatively CROSS_COMPILE can be set in the environment. +# Default value for CROSS_COMPILE is not to prefix executables +# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile +ARCH ?=3D $(SUBARCH) +SRCARCH :=3D $(shell echo $(XEN_TARGET_ARCH) | \ + sed -e 's/x86.*/x86/' -e s'/arm\(32\|64\)/ar= m/g') + +KCONFIG_CONFIG ?=3D .config +export KCONFIG_CONFIG + +# SHELL used by kbuild +CONFIG_SHELL :=3D $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ + else if [ -x /bin/bash ]; then echo /bin/bash; \ + else echo sh; fi ; fi) + +HOST_LFS_CFLAGS :=3D $(shell getconf LFS_CFLAGS 2>/dev/null) +HOST_LFS_LDFLAGS :=3D $(shell getconf LFS_LDFLAGS 2>/dev/null) +HOST_LFS_LIBS :=3D $(shell getconf LFS_LIBS 2>/dev/null) + +HOSTCC =3D gcc +HOSTCXX =3D g++ +KBUILD_HOSTCFLAGS :=3D -Wall -Wmissing-prototypes -Wstrict-prototypes -O= 2 \ + -fomit-frame-pointer -std=3Dgnu89 $(HOST_LFS_CFLAGS) \ + $(HOSTCFLAGS) +KBUILD_HOSTCXXFLAGS :=3D -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS) +KBUILD_HOSTLDFLAGS :=3D $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS) +KBUILD_HOSTLDLIBS :=3D $(HOST_LFS_LIBS) $(HOSTLDLIBS) + +# Make variables (CC, etc...) +AS =3D $(CROSS_COMPILE)as +LD =3D $(CROSS_COMPILE)ld +CC =3D $(CROSS_COMPILE)gcc +CPP =3D $(CC) -E +AR =3D $(CROSS_COMPILE)ar +NM =3D $(CROSS_COMPILE)nm +STRIP =3D $(CROSS_COMPILE)strip +OBJCOPY =3D $(CROSS_COMPILE)objcopy +OBJDUMP =3D $(CROSS_COMPILE)objdump +OBJSIZE =3D $(CROSS_COMPILE)size +PAHOLE =3D pahole +LEX =3D flex +YACC =3D bison +AWK =3D awk +PERL =3D perl +PYTHON =3D python +PYTHON2 =3D python2 +PYTHON3 =3D python3 +CHECK =3D sparse + +CHECKFLAGS :=3D -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ + -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF) +NOSTDINC_FLAGS :=3D +CFLAGS_KERNEL =3D +AFLAGS_KERNEL =3D +LDFLAGS_vmlinux =3D + +# Use LINUXINCLUDE when you must reference the include/ directory. +# Needed to be compatible with the O=3D option +LINUXINCLUDE :=3D \ + $(if $(building_out_of_srctree),-I$(srctree)/include) \ + -I$(objtree)/include + +KBUILD_AFLAGS :=3D -D__ASSEMBLY__ -fno-PIE +KBUILD_CFLAGS :=3D +KBUILD_CPPFLAGS :=3D +KBUILD_LDFLAGS :=3D +GCC_PLUGINS_CFLAGS :=3D +CLANG_FLAGS :=3D + +export ARCH SRCARCH CONFIG_SHELL HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS= LD CC +export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE PAHOLE LEX YACC AWK +export PERL PYTHON PYTHON2 PYTHON3 CHECK CHECKFLAGS MAKE HOSTCXX +export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS + +export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDF= LAGS +export KBUILD_CFLAGS CFLAGS_KERNEL +export CFLAGS_KASAN CFLAGS_KASAN_NOSANITIZE CFLAGS_UBSAN +export KBUILD_AFLAGS AFLAGS_KERNEL +export KBUILD_ARFLAGS + +# Files to ignore in find ... statements + +export RCS_FIND_IGNORE :=3D \( -name SCCS -o -name BitKeeper -o -name .svn= -o \ + -name CVS -o -name .pc -o -name .hg -o -name .git \) \ + -prune -o +export RCS_TAR_IGNORE :=3D --exclude SCCS --exclude BitKeeper --exclude .s= vn \ + --exclude CVS --exclude .pc --exclude .hg --exclude .git + +# =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D +# Rules shared between *config targets and build targets + +# Basic helpers built in scripts/basic/ +PHONY +=3D scripts_basic +scripts_basic: + $(Q)$(MAKE) $(build)=3Dscripts/basic + +PHONY +=3D outputmakefile +# outputmakefile generates a Makefile in the output directory, if using a +# separate output directory. This allows convenient use of make in the +# output directory. +# At the same time when output Makefile generated, generate .gitignore to +# ignore whole output directory +outputmakefile: +ifdef building_out_of_srctree + $(Q)ln -fsn $(srctree) source + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree) + $(Q)test -e .gitignore || \ + { echo "# this is build directory, ignore it"; echo "*"; } > .gitignore +endif + +ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),) +ifneq ($(CROSS_COMPILE),) +CLANG_FLAGS +=3D --target=3D$(notdir $(CROSS_COMPILE:%-=3D%)) +GCC_TOOLCHAIN_DIR :=3D $(dir $(shell which $(CROSS_COMPILE)elfedit)) +CLANG_FLAGS +=3D --prefix=3D$(GCC_TOOLCHAIN_DIR) +GCC_TOOLCHAIN :=3D $(realpath $(GCC_TOOLCHAIN_DIR)/..) +endif +ifneq ($(GCC_TOOLCHAIN),) +CLANG_FLAGS +=3D --gcc-toolchain=3D$(GCC_TOOLCHAIN) +endif +ifeq ($(shell $(AS) --version 2>&1 | head -n 1 | grep clang),) +CLANG_FLAGS +=3D -no-integrated-as +endif +CLANG_FLAGS +=3D -Werror=3Dunknown-warning-option +KBUILD_CFLAGS +=3D $(CLANG_FLAGS) +KBUILD_AFLAGS +=3D $(CLANG_FLAGS) +export CLANG_FLAGS +endif + +# The expansion should be delayed until arch/$(SRCARCH)/Makefile is includ= ed. +# Some architectures define CROSS_COMPILE in arch/$(SRCARCH)/Makefile. +# CC_VERSION_TEXT is referenced from Kconfig (so it needs export), +# and from include/config/auto.conf.cmd to detect the compiler upgrade. +CC_VERSION_TEXT =3D $(shell $(CC) --version 2>/dev/null | head -n 1) + +ifeq ($(config-targets),1) +# =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D +# *config targets only - make sure prerequisites are updated, and descend +# in scripts/kconfig to make the *config target + +# Read arch specific Makefile to set KBUILD_DEFCONFIG as needed. +# KBUILD_DEFCONFIG may point out an alternative default configuration +# used for 'make defconfig' +include arch/$(SRCARCH)/Makefile +export KBUILD_DEFCONFIG KBUILD_KCONFIG CC_VERSION_TEXT + +config: scripts_basic outputmakefile FORCE + $(Q)$(MAKE) $(build)=3Dscripts/kconfig $@ + +%config: scripts_basic outputmakefile FORCE + $(Q)$(MAKE) $(build)=3Dscripts/kconfig $@ + +else +# =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D +# Build targets only - this includes vmlinux, arch specific targets, clean +# targets and others. In general all targets except *config targets. + +PHONY +=3D all +_all: all + +# Just do built-in. + +KBUILD_BUILTIN :=3D 1 + +export KBUILD_BUILTIN + +ifeq ($(dot-config),1) +include include/config/auto.conf +endif + +ifeq ($(KBUILD_EXTMOD),) +# Objects we will link into vmlinux / subdirs we need to visit +init-y :=3D init/ +drivers-y :=3D drivers/ sound/ +drivers-$(CONFIG_SAMPLES) +=3D samples/ +drivers-$(CONFIG_KERNEL_HEADER_TEST) +=3D include/ +net-y :=3D net/ +libs-y :=3D lib/ +core-y :=3D usr/ +virt-y :=3D virt/ +endif # KBUILD_EXTMOD + +# The all: target is the default when no target is given on the +# command line. +# This allow a user to issue only 'make' to build a kernel including modul= es +# Defaults to vmlinux, but the arch makefile usually adds further targets +all: vmlinux + +CFLAGS_GCOV :=3D -fprofile-arcs -ftest-coverage \ + $(call cc-option,-fno-tree-loop-im) \ + $(call cc-disable-warning,maybe-uninitialized,) +export CFLAGS_GCOV + +# The arch Makefiles can override CC_FLAGS_FTRACE. We may also append it l= ater. +ifdef CONFIG_FUNCTION_TRACER + CC_FLAGS_FTRACE :=3D -pg +endif + +RETPOLINE_CFLAGS_GCC :=3D -mindirect-branch=3Dthunk-extern -mindirect-bran= ch-register +RETPOLINE_VDSO_CFLAGS_GCC :=3D -mindirect-branch=3Dthunk-inline -mindirect= -branch-register +RETPOLINE_CFLAGS_CLANG :=3D -mretpoline-external-thunk +RETPOLINE_VDSO_CFLAGS_CLANG :=3D -mretpoline +RETPOLINE_CFLAGS :=3D $(call cc-option,$(RETPOLINE_CFLAGS_GCC),$(call cc-o= ption,$(RETPOLINE_CFLAGS_CLANG))) +RETPOLINE_VDSO_CFLAGS :=3D $(call cc-option,$(RETPOLINE_VDSO_CFLAGS_GCC),$= (call cc-option,$(RETPOLINE_VDSO_CFLAGS_CLANG))) +export RETPOLINE_CFLAGS +export RETPOLINE_VDSO_CFLAGS + +# The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default +# values of the respective KBUILD_* variables +ARCH_CPPFLAGS :=3D +ARCH_AFLAGS :=3D +ARCH_CFLAGS :=3D +include arch/$(SRCARCH)/Makefile + +ifeq ($(dot-config),1) +ifeq ($(may-sync-config),1) +# Read in dependencies to all Kconfig* files, make sure to run syncconfig = if +# changes are detected. This should be included after arch/$(SRCARCH)/Make= file +# because some architectures define CROSS_COMPILE there. +include include/config/auto.conf.cmd + +$(KCONFIG_CONFIG): + @echo >&2 '***' + @echo >&2 '*** Configuration file "$@" not found!' + @echo >&2 '***' + @echo >&2 '*** Please run some configurator (e.g. "make oldconfig" or' + @echo >&2 '*** "make menuconfig" or "make xconfig").' + @echo >&2 '***' + @/bin/false + +# The actual configuration files used during the build are stored in +# include/generated/ and include/config/. Update them if .config is newer = than +# include/config/auto.conf (which mirrors .config). +# +# This exploits the 'multi-target pattern rule' trick. +# The syncconfig should be executed only once to make all the targets. +%/auto.conf %/auto.conf.cmd %/tristate.conf: $(KCONFIG_CONFIG) + $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig +else +# External modules and some install targets need include/generated/autocon= f.h +# and include/config/auto.conf but do not care if they are up-to-date. +# Use auto.conf to trigger the test +PHONY +=3D include/config/auto.conf + +include/config/auto.conf: + $(Q)test -e include/generated/autoconf.h -a -e $@ || ( \ + echo >&2; \ + echo >&2 " ERROR: Kernel configuration is invalid."; \ + echo >&2 " include/generated/autoconf.h or $@ are missing.";\ + echo >&2 " Run 'make oldconfig && make prepare' on kernel src to = fix it."; \ + echo >&2 ; \ + /bin/false) + +endif # may-sync-config +endif # $(dot-config) + + +# arch Makefile may override CC so keep this after arch Makefile is includ= ed +NOSTDINC_FLAGS +=3D -nostdinc -isystem $(shell $(CC) -print-file-name=3Din= clude) + + + +# use the deterministic mode of AR if available +KBUILD_ARFLAGS :=3D $(call ar-option,D) + +include scripts/Makefile.kasan +include scripts/Makefile.ubsan + +# Add any arch overrides and user supplied CPPFLAGS, AFLAGS and CFLAGS as = the +# last assignments +KBUILD_CPPFLAGS +=3D $(ARCH_CPPFLAGS) $(KCPPFLAGS) +KBUILD_AFLAGS +=3D $(ARCH_AFLAGS) $(KAFLAGS) +KBUILD_CFLAGS +=3D $(ARCH_CFLAGS) $(KCFLAGS) + +# insure the checker run with the right endianness +CHECKFLAGS +=3D $(if $(CONFIG_CPU_BIG_ENDIAN),-mbig-endian,-mlittle-endian) + +# the checker needs the correct machine size +CHECKFLAGS +=3D $(if $(CONFIG_64BIT),-m64,-m32) + +# Default kernel image to build when no specific target is given. +# KBUILD_IMAGE may be overruled on the command line or +# set in the environment +# Also any assignments in arch/$(ARCH)/Makefile take precedence over +# this default value +export KBUILD_IMAGE ?=3D vmlinux + +# +# INSTALL_PATH specifies where to place the updated kernel and system map +# images. Default is /boot, but you can set it to other values +export INSTALL_PATH ?=3D /boot + +HOST_LIBELF_LIBS =3D $(shell pkg-config libelf --libs 2>/dev/null || echo = -lelf) + +PHONY +=3D prepare0 + +core-y +=3D kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/ + +vmlinux-dirs :=3D $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \ + $(core-y) $(core-m) $(drivers-y) $(drivers-m) \ + $(net-y) $(net-m) $(libs-y) $(libs-m) $(virt-y))) + +vmlinux-alldirs :=3D $(sort $(vmlinux-dirs) Documentation \ + $(patsubst %/,%,$(filter %/, $(init-) $(core-) \ + $(drivers-) $(net-) $(libs-) $(virt-)))) + +init-y :=3D $(patsubst %/, %/built-in.a, $(init-y)) +core-y :=3D $(patsubst %/, %/built-in.a, $(core-y)) +drivers-y :=3D $(patsubst %/, %/built-in.a, $(drivers-y)) +net-y :=3D $(patsubst %/, %/built-in.a, $(net-y)) +libs-y1 :=3D $(patsubst %/, %/lib.a, $(libs-y)) +libs-y2 :=3D $(patsubst %/, %/built-in.a, $(filter-out %.a, $(libs-y))) +virt-y :=3D $(patsubst %/, %/built-in.a, $(virt-y)) + +# Externally visible symbols (used by link-vmlinux.sh) +export KBUILD_VMLINUX_OBJS :=3D $(head-y) $(init-y) $(core-y) $(libs-y2) \ + $(drivers-y) $(net-y) $(virt-y) +export KBUILD_VMLINUX_LIBS :=3D $(libs-y1) +export KBUILD_LDS :=3D arch/$(SRCARCH)/kernel/vmlinux.lds +export LDFLAGS_vmlinux +# used by scripts/package/Makefile +export KBUILD_ALLDIRS :=3D $(sort $(filter-out arch/%,$(vmlinux-alldirs)) = LICENSES arch include scripts tools) + +vmlinux-deps :=3D $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LI= BS) + +ARCH_POSTLINK :=3D $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink) + +# Final link of vmlinux with optional arch pass after final link +cmd_link-vmlinux =3D \ + $(CONFIG_SHELL) $< $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_vmlinux) ; \ + $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) + +vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE + +$(call if_changed,link-vmlinux) + +targets :=3D vmlinux + +# The actual objects are generated when descending, +# make sure no implicit rule kicks in +$(sort $(vmlinux-deps)): $(vmlinux-dirs) ; + +# Handle descending into subdirectories listed in $(vmlinux-dirs) +# Preset locale variables to speed up the build process. Limit locale +# tweaks to this spot to avoid wrong language settings when running +# make menuconfig etc. +# Error messages still appears in the original language + +PHONY +=3D $(vmlinux-dirs) +$(vmlinux-dirs): prepare + $(Q)$(MAKE) $(build)=3D$@ need-builtin=3D1 need-modorder=3D1 + +filechk_kernel.release =3D \ + echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversi= on $(srctree))" + +# Store (new) KERNELRELEASE string in include/config/kernel.release +include/config/kernel.release: FORCE + $(call filechk,kernel.release) + +# Additional helpers built in scripts/ +# Carefully list dependencies so we do not try to build scripts twice +# in parallel +PHONY +=3D scripts +scripts: scripts_basic scripts_dtc + $(Q)$(MAKE) $(build)=3D$(@) + +# Things we need to do before we recursively start building the kernel +# or the modules are listed in "prepare". +# A multi level approach is used. prepareN is processed before prepareN-1. +# archprepare is used in arch Makefiles and when processed asm symlink, +# version.h and scripts_basic is processed / created. + +PHONY +=3D prepare archprepare prepare3 + +# prepare3 is used to check if we are building in a separate output direct= ory, +# and if so do: +# 1) Check that make has not been executed in the kernel src $(srctree) +prepare3: include/config/kernel.release +ifdef building_out_of_srctree + @$(kecho) ' Using $(srctree) as source for kernel' + $(Q)if [ -f $(srctree)/.config -o \ + -d $(srctree)/include/config -o \ + -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \ + echo >&2 " $(srctree) is not clean, please run 'make ARCH=3D$(ARCH) mrp= roper'"; \ + echo >&2 " in the '$(srctree)' directory.";\ + /bin/false; \ + fi; +endif + +archprepare: archheaders archscripts scripts prepare3 outputmakefile \ + asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h + +prepare0: archprepare + $(Q)$(MAKE) $(build)=3Dscripts/mod + $(Q)$(MAKE) $(build)=3D. + +# All the preparing.. +prepare: prepare0 + +# Generate some files +# ------------------------------------------------------------------------= --- + +# KERNELRELEASE can change from a few different places, meaning version.h +# needs to be updated, so this check is forced on all builds + +uts_len :=3D 64 +define filechk_utsrelease.h + if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \ + echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \ + exit 1; \ + fi; \ + echo \#define UTS_RELEASE \"$(KERNELRELEASE)\" endef =20 -define set_exuberant_flags - exuberant_flags=3D`$1 --version 2>/dev/null | (grep -iq exuberant && \ - echo "-I __initdata,__exitdata,__acquires,__releases \ - -I EXPORT_SYMBOL \ - --extra=3D+f --c-kinds=3D+px") || true`=20 +define filechk_version.h + echo \#define LINUX_VERSION_CODE $(shell \ + expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + 0$(SUBLEVEL)); \ + echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))' endef =20 -.PHONY: xenversion +$(version_h): FORCE + $(call filechk,version.h) + $(Q)rm -f $(old_version_h) + +### +# Cleaning is done on three levels. +# make clean Delete most generated files +# Leave enough to build external modules +# make mrproper Delete the current configuration, and all generated files +# make distclean Remove editor backup files, patch leftover files and the = like + +# Directories & files removed with 'make clean' +CLEAN_DIRS +=3D include/ksym +CLEAN_FILES +=3D modules.builtin.modinfo + +# Directories & files removed with 'make mrproper' +MRPROPER_DIRS +=3D include/config include/generated \ + arch/$(SRCARCH)/include/generated .tmp_objdiff +MRPROPER_FILES +=3D .config .config.old .version \ + Module.symvers \ + signing_key.pem signing_key.priv signing_key.x509 \ + x509.genkey extra_certificates signing_key.x509.keyid \ + signing_key.x509.signer vmlinux-gdb.py + +# Directories & files removed with 'make distclean' +DISTCLEAN_DIRS +=3D +DISTCLEAN_FILES +=3D tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS + +# clean - Delete most, but leave enough to build external modules +# +clean: rm-dirs :=3D $(CLEAN_DIRS) +clean: rm-files :=3D $(CLEAN_FILES) +clean-dirs :=3D $(addprefix _clean_, . $(vmlinux-alldirs)) + +PHONY +=3D $(clean-dirs) clean archclean vmlinuxclean +$(clean-dirs): + $(Q)$(MAKE) $(clean)=3D$(patsubst _clean_%,%,$@) + +vmlinuxclean: + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean + $(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean) + +clean: archclean vmlinuxclean + +# mrproper - Delete all generated files, including .config +# +mrproper: rm-dirs :=3D $(wildcard $(MRPROPER_DIRS)) +mrproper: rm-files :=3D $(wildcard $(MRPROPER_FILES)) +mrproper-dirs :=3D $(addprefix _mrproper_,scripts) + +PHONY +=3D $(mrproper-dirs) mrproper +$(mrproper-dirs): + $(Q)$(MAKE) $(clean)=3D$(patsubst _mrproper_%,%,$@) + +mrproper: clean $(mrproper-dirs) + $(call cmd,rmdirs) + $(call cmd,rmfiles) + +# distclean +# +distclean: rm-dirs :=3D $(wildcard $(DISTCLEAN_DIRS)) +distclean: rm-files :=3D $(wildcard $(DISTCLEAN_FILES)) + +PHONY +=3D distclean + +distclean: mrproper + $(call cmd,rmdirs) + $(call cmd,rmfiles) + @find $(srctree) $(RCS_FIND_IGNORE) \ + \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ + -o -name '*.bak' -o -name '#*#' -o -name '*%' \ + -o -name 'core' \) \ + -type f -print | xargs rm -f + + +# Brief documentation of the typical targets used +# ------------------------------------------------------------------------= --- + +boards :=3D $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*_defconfig) +boards :=3D $(sort $(notdir $(boards))) +board-dirs :=3D $(dir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*/*_de= fconfig)) +board-dirs :=3D $(sort $(notdir $(board-dirs:/=3D))) + +PHONY +=3D help +help: + @echo 'Cleaning targets:' + @echo ' clean - Remove most generated files but keep the config and' + @echo ' enough build support to build external module= s' + @echo ' mrproper - Remove all generated files + config + various back= up files' + @echo ' distclean - mrproper + remove editor backup and patch files' + @echo '' + @echo 'Configuration targets:' + @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help + @echo '' + @echo 'Other generic targets:' + @echo ' all - Build all targets marked with [*]' + @echo '* vmlinux - Build the bare kernel' + @echo '* modules - Build all modules' + @echo ' modules_install - Install all modules to INSTALL_MOD_PATH (defa= ult: /)' + @echo ' dir/ - Build all files in dir and below' + @echo ' dir/file.[ois] - Build specified target only' + @echo ' dir/file.ll - Build the LLVM assembly file' + @echo ' (requires compiler support for LLVM assembly = generation)' + @echo ' dir/file.lst - Build specified mixed source/assembly target = only' + @echo ' (requires a recent binutils and recent build = (System.map))' + @echo ' dir/file.ko - Build module including final link' + @echo ' modules_prepare - Set up for building external modules' + @echo ' tags/TAGS - Generate tags file for editors' + @echo ' cscope - Generate cscope index' + @echo ' gtags - Generate GNU GLOBAL index' + @echo ' kernelrelease - Output the release version string (use with m= ake -s)' + @echo ' kernelversion - Output the version stored in Makefile (use wi= th make -s)' + @echo ' image_name - Output the image name (use with make -s)' + @echo ' headers_install - Install sanitised kernel headers to INSTALL_H= DR_PATH'; \ + echo ' (default: $(INSTALL_HDR_PATH))'; \ + echo '' + @echo 'Static analysers:' + @echo ' checkstack - Generate a list of stack hogs' + @echo ' namespacecheck - Name space analysis on compiled kernel' + @echo ' versioncheck - Sanity check on version.h usage' + @echo ' includecheck - Check for duplicate included header files' + @echo ' export_report - List the usages of all exported symbols' + @echo ' headers_check - Sanity check on exported headers' + @echo ' headerdep - Detect inclusion cycles in headers' + @echo ' coccicheck - Check with Coccinelle' + @echo '' + @echo 'Kernel selftest:' + @echo ' kselftest - Build and run kernel selftest (run as root)' + @echo ' Build, install, and boot kernel before' + @echo ' running kselftest on it' + @echo ' kselftest-clean - Remove all generated kselftest files' + @echo ' kselftest-merge - Merge all the config dependencies of kselftes= t to existing' + @echo ' .config.' + @echo '' + @$(if $(dtstree), \ + echo 'Devicetree:'; \ + echo '* dtbs - Build device tree blobs for enabled boards'; \ + echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'; \ + echo '') + + @echo 'Userspace tools targets:' + @echo ' use "make tools/help"' + @echo ' or "cd tools; make help"' + @echo '' + @echo 'Kernel packaging:' + @$(MAKE) $(build)=3D$(package-dir) help + @echo '' + @echo 'Documentation targets:' + @$(MAKE) -f $(srctree)/Documentation/Makefile dochelp + @echo '' + @echo 'Architecture specific targets ($(SRCARCH)):' + @$(if $(archhelp),$(archhelp),\ + echo ' No architecture specific help defined for $(SRCARCH)') + @echo '' + @$(if $(boards), \ + $(foreach b, $(boards), \ + printf " %-24s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \ + echo '') + @$(if $(board-dirs), \ + $(foreach b, $(board-dirs), \ + printf " %-16s - Show %s-specific targets\\n" help-$(b) $(b);) \ + printf " %-16s - Show all of the above\\n" help-boards; \ + echo '') + + @echo ' make V=3D0|1 [targets] 0 =3D> quiet build (default), 1 =3D> ver= bose build' + @echo ' make V=3D2 [targets] 2 =3D> give reason for rebuild of target' + @echo ' make O=3Ddir [targets] Locate all output files in "dir", includ= ing .config' + @echo ' make C=3D1 [targets] Check re-compiled c source with $$CHECK = (sparse by default)' + @echo ' make C=3D2 [targets] Force check of all c source with $$CHECK' + @echo ' make RECORDMCOUNT_WARN=3D1 [targets] Warn about ignored mcount = sections' + @echo ' make W=3Dn [targets] Enable extra gcc checks, n=3D1,2,3 where' + @echo ' 1: warnings which may be relevant and do not occur too often' + @echo ' 2: warnings which occur quite often but may still be relevant' + @echo ' 3: more obscure warnings, can most likely be ignored' + @echo ' Multiple levels can be combined with W=3D12 or W=3D123' + @echo '' + @echo 'Execute "make" or "make all" to build all targets marked with [*]= ' + @echo 'For further info see the ./README file' + + +help-board-dirs :=3D $(addprefix help-,$(board-dirs)) + +help-boards: $(help-board-dirs) + +boards-per-dir =3D $(sort $(notdir $(wildcard $(srctree)/arch/$(SRCARCH)/c= onfigs/$*/*_defconfig))) + +$(help-board-dirs): help-%: + @echo 'Architecture specific targets ($(SRCARCH) $*):' + @$(if $(boards-per-dir), \ + $(foreach b, $(boards-per-dir), \ + printf " %-24s - Build for %s\\n" $*/$(b) $(subst _defconfig,,$(b));) \ + echo '') + + +# Misc +# ------------------------------------------------------------------------= --- + +clean: $(clean-dirs) + $(call cmd,rmdirs) + $(call cmd,rmfiles) + @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \ + \( -name '*.[aios]' -o -name '*.ko' -o -name '.*.cmd' \ + -o -name '*.ko.*' \ + -o -name '*.dtb' -o -name '*.dtb.S' -o -name '*.dt.yaml' \ + -o -name '*.dwo' -o -name '*.lst' \ + -o -name '*.su' -o -name '*.mod' \ + -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ + -o -name '*.lex.c' -o -name '*.tab.[ch]' \ + -o -name '*.asn1.[ch]' \ + -o -name '*.symtypes' -o -name 'modules.order' \ + -o -name modules.builtin -o -name '.tmp_*.o.*' \ + -o -name '*.c.[012]*.*' \ + -o -name '*.ll' \ + -o -name '*.gcno' \) -type f -print | xargs rm -f + +# Generate tags for editors +# ------------------------------------------------------------------------= --- +quiet_cmd_tags =3D GEN $@ + cmd_tags =3D $(CONFIG_SHELL) $(srctree)/scripts/tags.sh $@ + +tags TAGS cscope gtags: FORCE + $(call cmd,tags) + +# Scripts to check various things for consistency +# ------------------------------------------------------------------------= --- + +PHONY +=3D includecheck versioncheck + +includecheck: + find $(srctree)/* $(RCS_FIND_IGNORE) \ + -name '*.[hcS]' -type f -print | sort \ + | xargs $(PERL) -w $(srctree)/scripts/checkincludes.pl + +versioncheck: + find $(srctree)/* $(RCS_FIND_IGNORE) \ + -name '*.[hcS]' -type f -print | sort \ + | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl + +PHONY +=3D xenversion image_name + xenversion: @echo $(XEN_FULLVERSION) =20 -.PHONY: _TAGS -_TAGS:=20 - set -e; rm -f TAGS; \ - $(call set_exuberant_flags,etags); \ - $(all_sources) | xargs etags $$exuberant_flags -a - -.PHONY: _tags -_tags:=20 - set -e; rm -f tags; \ - $(call set_exuberant_flags,ctags); \ - $(all_sources) | xargs ctags $$exuberant_flags -a - -.PHONY: _gtags -_gtags: - set -e; rm -f GTAGS GSYMS GPATH GRTAGS - $(all_sources) | gtags -f - - -.PHONY: _cscope -_cscope: - $(all_sources) > cscope.files - cscope -k -b -q - -.PHONY: _MAP -_MAP: - $(NM) -n $(TARGET)-syms | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|= \(\.\.ng$$\)\|\(LASH[RL]DI\)' > System.map - -.PHONY: FORCE -FORCE: - -%.o %.i %.s: %.c FORCE - $(MAKE) -f $(BASEDIR)/Rules.mk -C $(*D) $(@F) +image_name: + @echo $(KBUILD_IMAGE) =20 -%.o %.s: %.S FORCE - $(MAKE) -f $(BASEDIR)/Rules.mk -C $(*D) $(@F) +# Single targets +# ------------------------------------------------------------------------= --- +# Single targets are compatible with: +# - build with mixed source and output +# - build with separate output dir 'make O=3D...' +# +# target-dir =3D> where to store outputfile +# build-dir =3D> directory in kernel source tree to use =20 -%/: FORCE - $(MAKE) -f $(BASEDIR)/Rules.mk -C $* built_in.o built_in_bin.o +build-target =3D $@ +build-dir =3D $(patsubst %/,%,$(dir $(build-target))) =20 -build-intermediate =3D $(eval $(call build-intermediate-closure,$(1))) -define build-intermediate-closure -$(1): FORCE - $(MAKE) -f $(BASEDIR)/Rules.mk -C $$(@D) $$(@F) -endef +%.i: prepare FORCE + $(Q)$(MAKE) $(build)=3D$(build-dir) $(build-target) +%.ll: prepare FORCE + $(Q)$(MAKE) $(build)=3D$(build-dir) $(build-target) +%.lst: prepare FORCE + $(Q)$(MAKE) $(build)=3D$(build-dir) $(build-target) +%.o: prepare FORCE + $(Q)$(MAKE) $(build)=3D$(build-dir) $(build-target) +%.s: prepare FORCE + $(Q)$(MAKE) $(build)=3D$(build-dir) $(build-target) +%.symtypes: prepare FORCE + $(Q)$(MAKE) $(build)=3D$(build-dir) $(build-target) =20 -$(foreach base,arch/x86/mm/guest_walk_% \ - arch/x86/mm/hap/guest_walk_%level \ - arch/x86/mm/shadow/guest_%, \ - $(foreach ext,o i s,$(call build-intermediate,$(base).$(ext)))) +# FIXME Should go into a make.lib or something +# =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D =20 -kconfig :=3D oldconfig config menuconfig defconfig \ - nconfig xconfig gconfig savedefconfig listnewconfig olddefconfig \ - randconfig $(notdir $(wildcard arch/$(SRCARCH)/configs/*_defconfig)) -.PHONY: $(kconfig) -$(kconfig): - $(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig ARCH=3D$(ARCH) SRCAR= CH=3D$(SRCARCH) HOSTCC=3D"$(HOSTCC)" HOSTCXX=3D"$(HOSTCXX)" $@ +quiet_cmd_rmdirs =3D $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-d= irs))) + cmd_rmdirs =3D rm -rf $(rm-dirs) =20 -include/config/%.conf: include/config/auto.conf.cmd $(KCONFIG_CONFIG) - $(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig ARCH=3D$(ARCH) SRCAR= CH=3D$(SRCARCH) HOSTCC=3D"$(HOSTCC)" HOSTCXX=3D"$(HOSTCXX)" syncconfig +quiet_cmd_rmfiles =3D $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm= -files))) + cmd_rmfiles =3D rm -f $(rm-files) =20 -# Allow people to just run `make` as before and not force them to configure -$(KCONFIG_CONFIG): - $(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig ARCH=3D$(ARCH) SRCAR= CH=3D$(SRCARCH) HOSTCC=3D"$(HOSTCC)" HOSTCXX=3D"$(HOSTCXX)" defconfig +# read saved command lines for existing targets +existing-targets :=3D $(wildcard $(sort $(targets))) =20 -# Break the dependency chain for the first run -include/config/auto.conf.cmd: ; +-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) =20 --include $(BASEDIR)/include/config/auto.conf.cmd +endif # ifeq ($(config-targets),1) +endif # ifeq ($(mixed-targets),1) +endif # need-sub-make =20 -.PHONY: cloc -cloc: - $(eval tmpfile :=3D $(shell mktemp)) - $(foreach f, $(shell find $(BASEDIR) -name *.o.d), \ - $(eval path :=3D $(dir $(f))) \ - $(eval names :=3D $(shell grep -o "[a-zA-Z0-9_/-]*\.[cS]" $(f))) \ - $(foreach sf, $(names), \ - $(shell if test -f $(path)/$(sf) ; then echo $(path)/$(sf) >> $(tmpfile= ); fi;))) - cloc --list-file=3D$(tmpfile) - rm $(tmpfile) +PHONY +=3D FORCE +FORCE: =20 +# Declare the contents of the PHONY variable as phony. We keep that +# information in a variable so we can use it in if_changed and friends. +.PHONY: $(PHONY) --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel