1VERSION = 3 2PATCHLEVEL = 10 3SUBLEVEL = 0 4EXTRAVERSION = 5NAME = Unicycling Gorilla 6RHEL_MAJOR = 7 7RHEL_MINOR = 4 8RHEL_RELEASE = 693 9 10# 11# DRM backport version 12# 13RHEL_DRM_VERSION = 4 14RHEL_DRM_PATCHLEVEL = 10 15RHEL_DRM_SUBLEVEL = 13 16 17# *DOCUMENTATION* 18# To see a list of typical targets execute "make help" 19# More info can be located in ./README 20# Comments in this file are targeted only to the developer, do not 21# expect to learn how to build the kernel reading this file. 22 23# Do not: 24# o use make's built-in rules and variables 25# (this increases performance and avoids hard-to-debug behaviour); 26# o print "Entering directory ..."; 27MAKEFLAGS += -rR --no-print-directory 28 29# Avoid funny character set dependencies 30unexport LC_ALL 31LC_COLLATE=C 32LC_NUMERIC=C 33export LC_COLLATE LC_NUMERIC 34 35# We are using a recursive build, so we need to do a little thinking 36# to get the ordering right. 37# 38# Most importantly: sub-Makefiles should only ever modify files in 39# their own directory. If in some directory we have a dependency on 40# a file in another dir (which doesn't happen often, but it's often 41# unavoidable when linking the built-in.o targets which finally 42# turn into vmlinux), we will call a sub make in that other dir, and 43# after that we are sure that everything which is in that other dir 44# is now up to date. 45# 46# The only cases where we need to modify files which have global 47# effects are thus separated out and done before the recursive 48# descending is started. They are now explicitly listed as the 49# prepare rule. 50 51# To put more focus on warnings, be less verbose as default 52# Use 'make V=1' to see the full commands 53 54ifeq ("$(origin V)", "command line") 55 KBUILD_VERBOSE = $(V) 56endif 57ifndef KBUILD_VERBOSE 58 KBUILD_VERBOSE = 0 59endif 60 61# Call a source code checker (by default, "sparse") as part of the 62# C compilation. 63# 64# Use 'make C=1' to enable checking of only re-compiled files. 65# Use 'make C=2' to enable checking of *all* source files, regardless 66# of whether they are re-compiled or not. 67# 68# See the file "Documentation/sparse.txt" for more details, including 69# where to get the "sparse" utility. 70 71ifeq ("$(origin C)", "command line") 72 KBUILD_CHECKSRC = $(C) 73endif 74ifndef KBUILD_CHECKSRC 75 KBUILD_CHECKSRC = 0 76endif 77 78# Use make M=dir to specify directory of external module to build 79# Old syntax make ... SUBDIRS=$PWD is still supported 80# Setting the environment variable KBUILD_EXTMOD take precedence 81ifdef SUBDIRS 82 KBUILD_EXTMOD ?= $(SUBDIRS) 83endif 84 85ifeq ("$(origin M)", "command line") 86 KBUILD_EXTMOD := $(M) 87endif 88 89# kbuild supports saving output files in a separate directory. 90# To locate output files in a separate directory two syntaxes are supported. 91# In both cases the working directory must be the root of the kernel src. 92# 1) O= 93# Use "make O=dir/to/store/output/files/" 94# 95# 2) Set KBUILD_OUTPUT 96# Set the environment variable KBUILD_OUTPUT to point to the directory 97# where the output files shall be placed. 98# export KBUILD_OUTPUT=dir/to/store/output/files/ 99# make 100# 101# The O= assignment takes precedence over the KBUILD_OUTPUT environment 102# variable. 103 104 105# KBUILD_SRC is set on invocation of make in OBJ directory 106# KBUILD_SRC is not intended to be used by the regular user (for now) 107ifeq ($(KBUILD_SRC),) 108 109# OK, Make called in directory where kernel src resides 110# Do we want to locate output files in a separate directory? 111ifeq ("$(origin O)", "command line") 112 KBUILD_OUTPUT := $(O) 113endif 114 115ifeq ("$(origin W)", "command line") 116 export KBUILD_ENABLE_EXTRA_GCC_CHECKS := $(W) 117endif 118 119# That's our default target when none is given on the command line 120PHONY := _all 121_all: 122 123# Cancel implicit rules on top Makefile 124$(CURDIR)/Makefile Makefile: ; 125 126ifneq ($(KBUILD_OUTPUT),) 127# Invoke a second make in the output directory, passing relevant variables 128# check that the output directory actually exists 129saved-output := $(KBUILD_OUTPUT) 130KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd) 131$(if $(KBUILD_OUTPUT),, \ 132 $(error output directory "$(saved-output)" does not exist)) 133 134PHONY += $(MAKECMDGOALS) sub-make 135 136$(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make 137 @: 138 139sub-make: FORCE 140 $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \ 141 KBUILD_SRC=$(CURDIR) \ 142 KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile \ 143 $(filter-out _all sub-make,$(MAKECMDGOALS)) 144 145# Leave processing to above invocation of make 146skip-makefile := 1 147endif # ifneq ($(KBUILD_OUTPUT),) 148endif # ifeq ($(KBUILD_SRC),) 149 150# We process the rest of the Makefile if this is the final invocation of make 151ifeq ($(skip-makefile),) 152 153# If building an external module we do not care about the all: rule 154# but instead _all depend on modules 155PHONY += all 156ifeq ($(KBUILD_EXTMOD),) 157_all: all 158else 159_all: modules 160endif 161 162ifeq ($(KBUILD_SRC),) 163 # building in the source tree 164 srctree := . 165else 166 ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR))) 167 # building in a subdirectory of the source tree 168 srctree := .. 169 else 170 srctree := $(KBUILD_SRC) 171 endif 172endif 173objtree := . 174src := $(srctree) 175obj := $(objtree) 176 177VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD)) 178 179export srctree objtree VPATH 180 181# SUBARCH tells the usermode build what the underlying arch is. That is set 182# first, and if a usermode build is happening, the "ARCH=um" on the command 183# line overrides the setting of ARCH below. If a native build is happening, 184# then ARCH is assigned, getting whatever value it gets normally, and 185# SUBARCH is subsequently ignored. 186 187SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ 188 -e s/sun4u/sparc64/ \ 189 -e s/arm.*/arm/ -e s/sa110/arm/ \ 190 -e s/s390x/s390/ -e s/parisc64/parisc/ \ 191 -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ 192 -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ ) 193 194# Cross compiling and selecting different set of gcc/bin-utils 195# --------------------------------------------------------------------------- 196# 197# When performing cross compilation for other architectures ARCH shall be set 198# to the target architecture. (See arch/* for the possibilities). 199# ARCH can be set during invocation of make: 200# make ARCH=ia64 201# Another way is to have ARCH set in the environment. 202# The default ARCH is the host where make is executed. 203 204# CROSS_COMPILE specify the prefix used for all executables used 205# during compilation. Only gcc and related bin-utils executables 206# are prefixed with $(CROSS_COMPILE). 207# CROSS_COMPILE can be set on the command line 208# make CROSS_COMPILE=ia64-linux- 209# Alternatively CROSS_COMPILE can be set in the environment. 210# A third alternative is to store a setting in .config so that plain 211# "make" in the configured kernel build directory always uses that. 212# Default value for CROSS_COMPILE is not to prefix executables 213# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile 214ARCH ?= $(SUBARCH) 215CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%) 216 217# Architecture as present in compile.h 218UTS_MACHINE := $(ARCH) 219SRCARCH := $(ARCH) 220 221# Additional ARCH settings for x86 222ifeq ($(ARCH),i386) 223 SRCARCH := x86 224endif 225ifeq ($(ARCH),x86_64) 226 SRCARCH := x86 227endif 228 229# Additional ARCH settings for sparc 230ifeq ($(ARCH),sparc32) 231 SRCARCH := sparc 232endif 233ifeq ($(ARCH),sparc64) 234 SRCARCH := sparc 235endif 236 237# Additional ARCH settings for sh 238ifeq ($(ARCH),sh64) 239 SRCARCH := sh 240endif 241 242# Additional ARCH settings for tile 243ifeq ($(ARCH),tilepro) 244 SRCARCH := tile 245endif 246ifeq ($(ARCH),tilegx) 247 SRCARCH := tile 248endif 249 250# Where to locate arch specific headers 251hdr-arch := $(SRCARCH) 252 253KCONFIG_CONFIG ?= .config 254export KCONFIG_CONFIG 255 256# SHELL used by kbuild 257CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ 258 else if [ -x /bin/bash ]; then echo /bin/bash; \ 259 else echo sh; fi ; fi) 260 261HOSTCC = gcc 262HOSTCXX = g++ 263HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89 -g 264HOSTCXXFLAGS = -O2 265 266# Decide whether to build built-in, modular, or both. 267# Normally, just do built-in. 268 269KBUILD_MODULES := 270KBUILD_BUILTIN := 1 271 272# If we have only "make modules", don't compile built-in objects. 273# When we're building modules with modversions, we need to consider 274# the built-in objects during the descend as well, in order to 275# make sure the checksums are up to date before we record them. 276 277ifeq ($(MAKECMDGOALS),modules) 278 KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1) 279endif 280 281# If we have "make <whatever> modules", compile modules 282# in addition to whatever we do anyway. 283# Just "make" or "make all" shall build modules as well 284 285ifneq ($(filter all _all modules,$(MAKECMDGOALS)),) 286 KBUILD_MODULES := 1 287endif 288 289ifeq ($(MAKECMDGOALS),) 290 KBUILD_MODULES := 1 291endif 292 293export KBUILD_MODULES KBUILD_BUILTIN 294export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD 295 296# Beautify output 297# --------------------------------------------------------------------------- 298# 299# Normally, we echo the whole command before executing it. By making 300# that echo $($(quiet)$(cmd)), we now have the possibility to set 301# $(quiet) to choose other forms of output instead, e.g. 302# 303# quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@ 304# cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< 305# 306# If $(quiet) is empty, the whole command will be printed. 307# If it is set to "quiet_", only the short version will be printed. 308# If it is set to "silent_", nothing will be printed at all, since 309# the variable $(silent_cmd_cc_o_c) doesn't exist. 310# 311# A simple variant is to prefix commands with $(Q) - that's useful 312# for commands that shall be hidden in non-verbose mode. 313# 314# $(Q)ln $@ :< 315# 316# If KBUILD_VERBOSE equals 0 then the above command will be hidden. 317# If KBUILD_VERBOSE equals 1 then the above command is displayed. 318 319ifeq ($(KBUILD_VERBOSE),1) 320 quiet = 321 Q = 322else 323 quiet=quiet_ 324 Q = @ 325endif 326 327# If the user is running make -s (silent mode), suppress echoing of 328# commands 329 330ifneq ($(filter s% -s%,$(MAKEFLAGS)),) 331 quiet=silent_ 332endif 333 334export quiet Q KBUILD_VERBOSE 335 336 337# Look for make include files relative to root of kernel src 338MAKEFLAGS += --include-dir=$(srctree) 339 340# We need some generic definitions (do not try to remake the file). 341$(srctree)/scripts/Kbuild.include: ; 342include $(srctree)/scripts/Kbuild.include 343 344# Make variables (CC, etc...) 345 346AS = $(CROSS_COMPILE)as 347LD = $(CROSS_COMPILE)ld 348CC = $(CROSS_COMPILE)gcc 349CPP = $(CC) -E 350AR = $(CROSS_COMPILE)ar 351NM = $(CROSS_COMPILE)nm 352STRIP = $(CROSS_COMPILE)strip 353OBJCOPY = $(CROSS_COMPILE)objcopy 354OBJDUMP = $(CROSS_COMPILE)objdump 355AWK = awk 356GENKSYMS = scripts/genksyms/genksyms 357INSTALLKERNEL := installkernel 358DEPMOD = /sbin/depmod 359PERL = perl 360CHECK = sparse 361 362CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ 363 -Wbitwise -Wno-return-void $(CF) 364CFLAGS_MODULE = 365AFLAGS_MODULE = 366LDFLAGS_MODULE = 367CFLAGS_KERNEL = 368AFLAGS_KERNEL = 369CFLAGS_GCOV = -fprofile-arcs -ftest-coverage 370 371 372# Use USERINCLUDE when you must reference the UAPI directories only. 373USERINCLUDE := \ 374 -I$(srctree)/arch/$(hdr-arch)/include/uapi \ 375 -Iarch/$(hdr-arch)/include/generated/uapi \ 376 -I$(srctree)/include/uapi \ 377 -Iinclude/generated/uapi \ 378 -include $(srctree)/include/linux/kconfig.h 379 380# Use LINUXINCLUDE when you must reference the include/ directory. 381# Needed to be compatible with the O= option 382LINUXINCLUDE := \ 383 -I$(srctree)/arch/$(hdr-arch)/include \ 384 -Iarch/$(hdr-arch)/include/generated \ 385 $(if $(KBUILD_SRC), -I$(srctree)/include) \ 386 -Iinclude \ 387 $(USERINCLUDE) 388 389KBUILD_CPPFLAGS := -D__KERNEL__ 390 391KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ 392 -fno-strict-aliasing -fno-common \ 393 -Werror-implicit-function-declaration \ 394 -Wno-format-security \ 395 -fno-delete-null-pointer-checks \ 396 -std=gnu89 397 398ifneq ($(WITH_GCOV),1) 399ifeq ($(KBUILD_EXTMOD),) 400ifneq (,$(filter $(ARCH), x86 x86_64 powerpc)) 401KBUILD_CFLAGS += $(call cc-ifversion, -eq, 0408, -Werror) 402endif 403# powerpc is compiled with -O3 and gcc 4.8 has some known problems 404# with compiler warnings when using -O3, so let's disable them: 405ifeq ($(ARCH)-$(call cc-version),powerpc-0408) 406KBUILD_CFLAGS += -Wno-error=maybe-uninitialized -Wno-error=array-bounds 407endif 408endif 409endif 410 411KBUILD_AFLAGS_KERNEL := 412KBUILD_CFLAGS_KERNEL := 413KBUILD_AFLAGS := -D__ASSEMBLY__ 414KBUILD_AFLAGS_MODULE := -DMODULE 415KBUILD_CFLAGS_MODULE := -DMODULE 416KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds 417 418# Read KERNELRELEASE from include/config/kernel.release (if it exists) 419KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) 420KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) 421 422export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION 423export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC 424export CPP AR NM STRIP OBJCOPY OBJDUMP 425export MAKE AWK GENKSYMS INSTALLKERNEL PERL UTS_MACHINE 426export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS 427 428export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS 429export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_GCOV 430export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE 431export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE 432export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL 433export KBUILD_ARFLAGS 434 435# When compiling out-of-tree modules, put MODVERDIR in the module 436# tree rather than in the kernel tree. The kernel tree might 437# even be read-only. 438export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions 439 440# Files to ignore in find ... statements 441 442export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o \ 443 -name CVS -o -name .pc -o -name .hg -o -name .git \) \ 444 -prune -o 445export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \ 446 --exclude CVS --exclude .pc --exclude .hg --exclude .git 447 448# =========================================================================== 449# Rules shared between *config targets and build targets 450 451# Basic helpers built in scripts/ 452PHONY += scripts_basic 453scripts_basic: 454 $(Q)$(MAKE) $(build)=scripts/basic 455 $(Q)rm -f .tmp_quiet_recordmcount 456 457# To avoid any implicit rule to kick in, define an empty command. 458scripts/basic/%: scripts_basic ; 459 460PHONY += outputmakefile 461# outputmakefile generates a Makefile in the output directory, if using a 462# separate output directory. This allows convenient use of make in the 463# output directory. 464outputmakefile: 465ifneq ($(KBUILD_SRC),) 466 $(Q)ln -fsn $(srctree) source 467 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \ 468 $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL) 469endif 470 471# Support for using generic headers in asm-generic 472PHONY += asm-generic 473asm-generic: 474 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \ 475 src=asm obj=arch/$(SRCARCH)/include/generated/asm 476 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \ 477 src=uapi/asm obj=arch/$(SRCARCH)/include/generated/uapi/asm 478 479# To make sure we do not include .config for any of the *config targets 480# catch them early, and hand them over to scripts/kconfig/Makefile 481# It is allowed to specify more targets when calling make, including 482# mixing *config targets and build targets. 483# For example 'make oldconfig all'. 484# Detect when mixed targets is specified, and make a second invocation 485# of make so .config is not included in this case either (for *config). 486 487version_h := include/generated/uapi/linux/version.h 488 489no-dot-config-targets := clean mrproper distclean \ 490 cscope gtags TAGS tags help %docs check% coccicheck \ 491 $(version_h) headers_% archheaders archscripts \ 492 kernelversion %src-pkg 493 494config-targets := 0 495mixed-targets := 0 496dot-config := 1 497 498ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) 499 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),) 500 dot-config := 0 501 endif 502endif 503 504ifeq ($(KBUILD_EXTMOD),) 505 ifneq ($(filter config %config,$(MAKECMDGOALS)),) 506 config-targets := 1 507 ifneq ($(filter-out config %config,$(MAKECMDGOALS)),) 508 mixed-targets := 1 509 endif 510 endif 511endif 512 513ifeq ($(mixed-targets),1) 514# =========================================================================== 515# We're called with mixed targets (*config and build targets). 516# Handle them one by one. 517 518%:: FORCE 519 $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= $@ 520 521else 522ifeq ($(config-targets),1) 523# =========================================================================== 524# *config targets only - make sure prerequisites are updated, and descend 525# in scripts/kconfig to make the *config target 526 527# Read arch specific Makefile to set KBUILD_DEFCONFIG as needed. 528# KBUILD_DEFCONFIG may point out an alternative default configuration 529# used for 'make defconfig' 530include $(srctree)/arch/$(SRCARCH)/Makefile 531export KBUILD_DEFCONFIG KBUILD_KCONFIG 532 533config: scripts_basic outputmakefile FORCE 534 $(Q)mkdir -p include/linux include/config 535 $(Q)$(MAKE) $(build)=scripts/kconfig $@ 536 537%config: scripts_basic outputmakefile FORCE 538 $(Q)mkdir -p include/linux include/config 539 $(Q)$(MAKE) $(build)=scripts/kconfig $@ 540 541else 542# =========================================================================== 543# Build targets only - this includes vmlinux, arch specific targets, clean 544# targets and others. In general all targets except *config targets. 545 546ifeq ($(KBUILD_EXTMOD),) 547# Additional helpers built in scripts/ 548# Carefully list dependencies so we do not try to build scripts twice 549# in parallel 550PHONY += scripts 551scripts: scripts_basic include/config/auto.conf include/config/tristate.conf \ 552 asm-generic $(version_h) 553 $(Q)$(MAKE) $(build)=$(@) 554 555# Objects we will link into vmlinux / subdirs we need to visit 556init-y := init/ 557drivers-y := drivers/ sound/ firmware/ 558net-y := net/ 559libs-y := lib/ 560core-y := usr/ 561virt-y := virt/ 562endif # KBUILD_EXTMOD 563 564ifeq ($(dot-config),1) 565# Read in config 566-include include/config/auto.conf 567 568ifeq ($(KBUILD_EXTMOD),) 569# Read in dependencies to all Kconfig* files, make sure to run 570# oldconfig if changes are detected. 571-include include/config/auto.conf.cmd 572 573# To avoid any implicit rule to kick in, define an empty command 574$(KCONFIG_CONFIG) include/config/auto.conf.cmd: ; 575 576# If .config is newer than include/config/auto.conf, someone tinkered 577# with it and forgot to run make oldconfig. 578# if auto.conf.cmd is missing then we are probably in a cleaned tree so 579# we execute the config step to be sure to catch updated Kconfig files 580include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd 581 $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig 582else 583# external modules needs include/generated/autoconf.h and include/config/auto.conf 584# but do not care if they are up-to-date. Use auto.conf to trigger the test 585PHONY += include/config/auto.conf 586 587include/config/auto.conf: 588 $(Q)test -e include/generated/autoconf.h -a -e $@ || ( \ 589 echo >&2; \ 590 echo >&2 " ERROR: Kernel configuration is invalid."; \ 591 echo >&2 " include/generated/autoconf.h or $@ are missing.";\ 592 echo >&2 " Run 'make oldconfig && make prepare' on kernel src to fix it."; \ 593 echo >&2 ; \ 594 /bin/false) 595 596endif # KBUILD_EXTMOD 597 598else 599# Dummy target needed, because used as prerequisite 600include/config/auto.conf: ; 601endif # $(dot-config) 602 603# The all: target is the default when no target is given on the 604# command line. 605# This allow a user to issue only 'make' to build a kernel including modules 606# Defaults to vmlinux, but the arch makefile usually adds further targets 607all: vmlinux 608 609ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE 610KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,) 611else 612KBUILD_CFLAGS += -O2 613endif 614 615include $(srctree)/arch/$(SRCARCH)/Makefile 616 617ifdef CONFIG_READABLE_ASM 618# Disable optimizations that make assembler listings hard to read. 619# reorder blocks reorders the control in the function 620# ipa clone creates specialized cloned functions 621# partial inlining inlines only parts of functions 622KBUILD_CFLAGS += $(call cc-option,-fno-reorder-blocks,) \ 623 $(call cc-option,-fno-ipa-cp-clone,) \ 624 $(call cc-option,-fno-partial-inlining) 625endif 626 627ifneq ($(CONFIG_FRAME_WARN),0) 628KBUILD_CFLAGS += $(call cc-option,-Wframe-larger-than=${CONFIG_FRAME_WARN}) 629endif 630 631# Handle stack protector mode. 632ifdef CONFIG_CC_STACKPROTECTOR_REGULAR 633 stackp-flag := -fstack-protector 634 ifeq ($(call cc-option, $(stackp-flag)),) 635 $(warning Cannot use CONFIG_CC_STACKPROTECTOR: \ 636 -fstack-protector not supported by compiler)) 637 endif 638else ifdef CONFIG_CC_STACKPROTECTOR_STRONG 639 stackp-flag := -fstack-protector-strong 640 ifeq ($(call cc-option, $(stackp-flag)),) 641 $(warning Cannot use CONFIG_CC_STACKPROTECTOR_STRONG: \ 642 -fstack-protector-strong not supported by compiler) 643 endif 644else 645 # Force off for distro compilers that enable stack protector by default. 646 stackp-flag := $(call cc-option, -fno-stack-protector) 647endif 648KBUILD_CFLAGS += $(stackp-flag) 649 650# This warning generated too much noise in a regular build. 651# Use make W=1 to enable this warning (see scripts/Makefile.build) 652KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) 653 654ifdef CONFIG_FRAME_POINTER 655KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls 656else 657# Some targets (ARM with Thumb2, for example), can't be built with frame 658# pointers. For those, we don't have FUNCTION_TRACER automatically 659# select FRAME_POINTER. However, FUNCTION_TRACER adds -pg, and this is 660# incompatible with -fomit-frame-pointer with current GCC, so we don't use 661# -fomit-frame-pointer with FUNCTION_TRACER. 662ifndef CONFIG_FUNCTION_TRACER 663KBUILD_CFLAGS += -fomit-frame-pointer 664endif 665endif 666 667ifdef CONFIG_DEBUG_INFO 668KBUILD_CFLAGS += -g 669KBUILD_AFLAGS += -gdwarf-2 670endif 671 672ifdef CONFIG_DEBUG_INFO_REDUCED 673KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ 674 $(call cc-option,-fno-var-tracking) 675endif 676 677ifdef CONFIG_FUNCTION_TRACER 678ifdef CONFIG_HAVE_FENTRY 679CC_USING_FENTRY := $(call cc-option, -mfentry -DCC_USING_FENTRY) 680endif 681KBUILD_CFLAGS += -pg $(CC_USING_FENTRY) 682KBUILD_AFLAGS += $(CC_USING_FENTRY) 683ifdef CONFIG_DYNAMIC_FTRACE 684 ifdef CONFIG_HAVE_C_RECORDMCOUNT 685 BUILD_C_RECORDMCOUNT := y 686 export BUILD_C_RECORDMCOUNT 687 endif 688endif 689endif 690 691# We trigger additional mismatches with less inlining 692ifdef CONFIG_DEBUG_SECTION_MISMATCH 693KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once) 694endif 695 696# arch Makefile may override CC so keep this after arch Makefile is included 697NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) 698CHECKFLAGS += $(NOSTDINC_FLAGS) 699 700# warn about C99 declaration after statement 701KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,) 702 703# disable pointer signed / unsigned warnings in gcc 4.0 704KBUILD_CFLAGS += $(call cc-disable-warning, pointer-sign) 705 706# disable invalid "can't wrap" optimizations for signed / pointers 707KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow) 708 709# conserve stack if available 710KBUILD_CFLAGS += $(call cc-option,-fconserve-stack) 711 712# use the deterministic mode of AR if available 713KBUILD_ARFLAGS := $(call ar-option,D) 714 715# check for 'asm goto' 716ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC)), y) 717 KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO 718endif 719 720# Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments 721KBUILD_CPPFLAGS += $(KCPPFLAGS) 722KBUILD_AFLAGS += $(KAFLAGS) 723KBUILD_CFLAGS += $(KCFLAGS) 724 725# Use --build-id when available. 726LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\ 727 $(call cc-ldoption, -Wl$(comma)--build-id,)) 728KBUILD_LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID) 729LDFLAGS_vmlinux += $(LDFLAGS_BUILD_ID) 730 731ifeq ($(CONFIG_STRIP_ASM_SYMS),y) 732LDFLAGS_vmlinux += $(call ld-option, -X,) 733endif 734 735# Default kernel image to build when no specific target is given. 736# KBUILD_IMAGE may be overruled on the command line or 737# set in the environment 738# Also any assignments in arch/$(ARCH)/Makefile take precedence over 739# this default value 740export KBUILD_IMAGE ?= vmlinux 741 742# 743# INSTALL_PATH specifies where to place the updated kernel and system map 744# images. Default is /boot, but you can set it to other values 745export INSTALL_PATH ?= /boot 746 747# 748# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory 749# relocations required by build roots. This is not defined in the 750# makefile but the argument can be passed to make if needed. 751# 752 753MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE) 754export MODLIB 755 756# 757# INSTALL_MOD_STRIP, if defined, will cause modules to be 758# stripped after they are installed. If INSTALL_MOD_STRIP is '1', then 759# the default option --strip-debug will be used. Otherwise, 760# INSTALL_MOD_STRIP value will be used as the options to the strip command. 761 762ifdef INSTALL_MOD_STRIP 763ifeq ($(INSTALL_MOD_STRIP),1) 764mod_strip_cmd = $(STRIP) --strip-debug 765else 766mod_strip_cmd = $(STRIP) $(INSTALL_MOD_STRIP) 767endif # INSTALL_MOD_STRIP=1 768else 769mod_strip_cmd = true 770endif # INSTALL_MOD_STRIP 771export mod_strip_cmd 772 773 774ifdef CONFIG_MODULE_SIG_ALL 775MODSECKEY = ./signing_key.priv 776MODPUBKEY = ./signing_key.x509 777export MODPUBKEY 778mod_sign_cmd = perl $(srctree)/scripts/sign-file $(CONFIG_MODULE_SIG_HASH) $(MODSECKEY) $(MODPUBKEY) 779else 780mod_sign_cmd = true 781endif 782export mod_sign_cmd 783 784 785ifeq ($(KBUILD_EXTMOD),) 786core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ 787 788vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \ 789 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \ 790 $(net-y) $(net-m) $(libs-y) $(libs-m) $(virt-y))) 791 792vmlinux-alldirs := $(sort $(vmlinux-dirs) $(patsubst %/,%,$(filter %/, \ 793 $(init-n) $(init-) \ 794 $(core-n) $(core-) $(drivers-n) $(drivers-) \ 795 $(net-n) $(net-) $(libs-n) $(libs-) \ 796 $(virt-n) $(virt-)))) 797 798init-y := $(patsubst %/, %/built-in.o, $(init-y)) 799core-y := $(patsubst %/, %/built-in.o, $(core-y)) 800drivers-y := $(patsubst %/, %/built-in.o, $(drivers-y)) 801net-y := $(patsubst %/, %/built-in.o, $(net-y)) 802libs-y1 := $(patsubst %/, %/lib.a, $(libs-y)) 803libs-y2 := $(patsubst %/, %/built-in.o, $(libs-y)) 804libs-y := $(libs-y1) $(libs-y2) 805virt-y := $(patsubst %/, %/built-in.o, $(virt-y)) 806 807# Externally visible symbols (used by link-vmlinux.sh) 808export KBUILD_VMLINUX_INIT := $(head-y) $(init-y) 809export KBUILD_VMLINUX_MAIN := $(core-y) $(libs-y) $(drivers-y) $(net-y) $(virt-y) 810export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds 811export LDFLAGS_vmlinux 812# used by scripts/pacmage/Makefile 813export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Documentation include samples scripts tools) 814 815vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) 816 817# Final link of vmlinux 818 cmd_link-vmlinux = $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) 819quiet_cmd_link-vmlinux = LINK $@ 820 821ifdef AFTER_LINK 822 cmd_link-vmlinux += ; $(AFTER_LINK) 823endif 824 825# Include targets which we want to 826# execute if the rest of the kernel build went well. 827vmlinux: scripts/link-vmlinux.sh $(vmlinux-deps) FORCE 828ifdef CONFIG_HEADERS_CHECK 829 $(Q)$(MAKE) -f $(srctree)/Makefile headers_check 830endif 831ifdef CONFIG_SAMPLES 832 $(Q)$(MAKE) $(build)=samples 833endif 834ifdef CONFIG_BUILD_DOCSRC 835 $(Q)$(MAKE) $(build)=Documentation 836endif 837 +$(call if_changed,link-vmlinux) 838 839# The actual objects are generated when descending, 840# make sure no implicit rule kicks in 841$(sort $(vmlinux-deps)): $(vmlinux-dirs) ; 842 843# Handle descending into subdirectories listed in $(vmlinux-dirs) 844# Preset locale variables to speed up the build process. Limit locale 845# tweaks to this spot to avoid wrong language settings when running 846# make menuconfig etc. 847# Error messages still appears in the original language 848 849PHONY += $(vmlinux-dirs) 850$(vmlinux-dirs): prepare scripts 851 $(Q)$(MAKE) $(build)=$@ 852 853# Store (new) KERNELRELASE string in include/config/kernel.release 854include/config/kernel.release: include/config/auto.conf FORCE 855 $(Q)rm -f $@ 856 $(Q)echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" > $@ 857 858 859# Things we need to do before we recursively start building the kernel 860# or the modules are listed in "prepare". 861# A multi level approach is used. prepareN is processed before prepareN-1. 862# archprepare is used in arch Makefiles and when processed asm symlink, 863# version.h and scripts_basic is processed / created. 864 865# Listed in dependency order 866PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3 867 868# 869# Generate qrwlock specific files 870# 871include $(srctree)/Makefile.qlock 872 873# prepare3 is used to check if we are building in a separate output directory, 874# and if so do: 875# 1) Check that make has not been executed in the kernel src $(srctree) 876prepare3: include/config/kernel.release 877ifneq ($(KBUILD_SRC),) 878 @$(kecho) ' Using $(srctree) as source for kernel' 879 $(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \ 880 echo >&2 " $(srctree) is not clean, please run 'make mrproper'"; \ 881 echo >&2 " in the '$(srctree)' directory.";\ 882 /bin/false; \ 883 fi; 884endif 885 886# prepare2 creates a makefile if using a separate output directory 887prepare2: prepare3 outputmakefile asm-generic 888 889prepare1: prepare2 $(version_h) include/generated/utsrelease.h \ 890 include/config/auto.conf 891 $(cmd_crmodverdir) 892 893archprepare: archheaders archscripts prepare1 scripts_basic 894 895prepare0: archprepare $(qlock_files) FORCE 896 $(Q)$(MAKE) $(build)=. 897 898# All the preparing.. 899prepare: prepare0 prepare-objtool 900 901ifdef CONFIG_STACK_VALIDATION 902 has_libelf := $(shell echo "int main() {}" | $(HOSTCC) -xc -o /dev/null -lelf - &> /dev/null && echo 1 || echo 0) 903 ifeq ($(has_libelf),1) 904 objtool_target := tools/objtool FORCE 905 else 906 $(warning "Cannot use CONFIG_STACK_VALIDATION, please install libelf-dev or elfutils-libelf-devel") 907 SKIP_STACK_VALIDATION := 1 908 export SKIP_STACK_VALIDATION 909 endif 910endif 911 912PHONY += prepare-objtool 913prepare-objtool: $(objtool_target) 914 915# Generate some files 916# --------------------------------------------------------------------------- 917 918# KERNELRELEASE can change from a few different places, meaning version.h 919# needs to be updated, so this check is forced on all builds 920 921uts_len := 64 922define filechk_utsrelease.h 923 if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \ 924 echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \ 925 exit 1; \ 926 fi; \ 927 (echo \#define UTS_RELEASE \"$(KERNELRELEASE)\";) 928endef 929 930define filechk_version.h 931 (echo \#define LINUX_VERSION_CODE $(shell \ 932 expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + 0$(SUBLEVEL)); \ 933 echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))'; \ 934 echo '#define RHEL_MAJOR $(RHEL_MAJOR)'; \ 935 echo '#define RHEL_MINOR $(RHEL_MINOR)'; \ 936 echo '#define RHEL_RELEASE_VERSION(a,b) (((a) << 8) + (b))'; \ 937 echo '#define RHEL_RELEASE_CODE \ 938 $(shell expr $(RHEL_MAJOR) \* 256 + $(RHEL_MINOR))'; \ 939 echo '#define RHEL_RELEASE "$(RHEL_RELEASE)"';) 940endef 941 942$(version_h): $(srctree)/Makefile FORCE 943 $(call filechk,version.h) 944 945include/generated/utsrelease.h: include/config/kernel.release FORCE 946 $(call filechk,utsrelease.h) 947 948PHONY += headerdep 949headerdep: 950 $(Q)find $(srctree)/include/ -name '*.h' | xargs --max-args 1 \ 951 $(srctree)/scripts/headerdep.pl -I$(srctree)/include 952 953# --------------------------------------------------------------------------- 954 955PHONY += depend dep 956depend dep: 957 @echo '*** Warning: make $@ is unnecessary now.' 958 959# --------------------------------------------------------------------------- 960# Firmware install 961INSTALL_FW_PATH=$(INSTALL_MOD_PATH)/lib/firmware 962export INSTALL_FW_PATH 963 964PHONY += firmware_install 965firmware_install: FORCE 966 @mkdir -p $(objtree)/firmware 967 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.fwinst obj=firmware __fw_install 968 969# --------------------------------------------------------------------------- 970# Kernel headers 971 972#Default location for installed headers 973export INSTALL_HDR_PATH = $(objtree)/usr 974 975hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj 976 977# If we do an all arch process set dst to asm-$(hdr-arch) 978hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm) 979 980PHONY += archheaders 981archheaders: 982 983PHONY += archscripts 984archscripts: 985 986PHONY += __headers 987__headers: $(version_h) scripts_basic asm-generic archheaders archscripts FORCE 988 $(Q)$(MAKE) $(build)=scripts build_unifdef 989 990PHONY += headers_install_all 991headers_install_all: 992 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/headers.sh install 993 994PHONY += headers_install 995headers_install: __headers 996 $(if $(wildcard $(srctree)/arch/$(hdr-arch)/include/uapi/asm/Kbuild),, \ 997 $(error Headers not exportable for the $(SRCARCH) architecture)) 998 $(Q)$(MAKE) $(hdr-inst)=include/uapi 999 $(Q)$(MAKE) $(hdr-inst)=arch/$(hdr-arch)/include/uapi/asm $(hdr-dst) 1000
1001PHONY += headers_check_all 1002headers_check_all: headers_install_all 1003 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/headers.sh check 1004 1005PHONY += headers_check 1006headers_check: headers_install 1007 $(Q)$(MAKE) $(hdr-inst)=include/uapi HDRCHECK=1 1008 $(Q)$(MAKE) $(hdr-inst)=arch/$(hdr-arch)/include/uapi/asm $(hdr-dst) HDRCHECK=1 1009 1010# --------------------------------------------------------------------------- 1011# Modules 1012 1013ifdef CONFIG_MODULES 1014 1015# By default, build modules as well 1016 1017all: modules 1018 1019# Build modules 1020# 1021# A module can be listed more than once in obj-m resulting in 1022# duplicate lines in modules.order files. Those are removed 1023# using awk while concatenating to the final file. 1024 1025PHONY += modules 1026modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin 1027 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order 1028 @$(kecho) ' Building modules, stage 2.'; 1029 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost 1030 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.fwinst obj=firmware __fw_modbuild 1031 1032modules.builtin: $(vmlinux-dirs:%=%/modules.builtin) 1033 $(Q)$(AWK) '!x[$$0]++' $^ > $(objtree)/modules.builtin 1034 1035%/modules.builtin: include/config/auto.conf 1036 $(Q)$(MAKE) $(modbuiltin)=$* 1037 1038 1039# Target to prepare building external modules 1040PHONY += modules_prepare 1041modules_prepare: prepare scripts 1042 1043# Target to install modules 1044PHONY += modules_install 1045modules_install: _modinst_ _modinst_post 1046 1047PHONY += _modinst_ 1048_modinst_: 1049 @rm -rf $(MODLIB)/kernel 1050 @rm -f $(MODLIB)/source 1051 @mkdir -p $(MODLIB)/kernel 1052 @ln -s `cd $(srctree) && /bin/pwd` $(MODLIB)/source 1053 @if [ ! $(objtree) -ef $(MODLIB)/build ]; then \ 1054 rm -f $(MODLIB)/build ; \ 1055 ln -s $(CURDIR) $(MODLIB)/build ; \ 1056 fi 1057 @cp -f $(objtree)/modules.order $(MODLIB)/ 1058 @cp -f $(objtree)/modules.builtin $(MODLIB)/ 1059 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst 1060 1061# This depmod is only for convenience to give the initial 1062# boot a modules.dep even before / is mounted read-write. However the 1063# boot script depmod is the master version. 1064PHONY += _modinst_post 1065_modinst_post: _modinst_ 1066 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.fwinst obj=firmware __fw_modinst 1067 $(call cmd,depmod) 1068 1069ifeq ($(CONFIG_MODULE_SIG), y) 1070PHONY += modules_sign 1071modules_sign: 1072 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modsign 1073endif 1074 1075else # CONFIG_MODULES 1076 1077# Modules not configured 1078# --------------------------------------------------------------------------- 1079 1080modules modules_install: FORCE 1081 @echo >&2 1082 @echo >&2 "The present kernel configuration has modules disabled." 1083 @echo >&2 "Type 'make config' and enable loadable module support." 1084 @echo >&2 "Then build a kernel with module support enabled." 1085 @echo >&2 1086 @exit 1 1087 1088endif # CONFIG_MODULES 1089 1090### 1091# Cleaning is done on three levels. 1092# make clean Delete most generated files 1093# Leave enough to build external modules 1094# make mrproper Delete the current configuration, and all generated files 1095# make distclean Remove editor backup files, patch leftover files and the like 1096 1097# Directories & files removed with 'make clean' 1098CLEAN_DIRS += $(MODVERDIR) 1099 1100# Directories & files removed with 'make mrproper' 1101MRPROPER_DIRS += include/config usr/include include/generated \ 1102 arch/*/include/generated 1103MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \ 1104 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \ 1105 signing_key.priv signing_key.x509 x509.genkey \ 1106 extra_certificates signing_key.x509.keyid \ 1107 signing_key.x509.signer 1108 1109# clean - Delete most, but leave enough to build external modules 1110# 1111clean: rm-dirs := $(CLEAN_DIRS) 1112clean: rm-files := $(CLEAN_FILES) 1113clean-dirs := $(addprefix _clean_, . $(vmlinux-alldirs) Documentation samples) 1114 1115PHONY += $(clean-dirs) clean archclean vmlinuxclean 1116$(clean-dirs): 1117 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) 1118 1119vmlinuxclean: 1120 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean 1121 1122clean: archclean vmlinuxclean 1123 1124# mrproper - Delete all generated files, including .config 1125# 1126mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS)) 1127mrproper: rm-files := $(wildcard $(MRPROPER_FILES)) 1128mrproper-dirs := $(addprefix _mrproper_,Documentation/DocBook scripts) 1129 1130PHONY += $(mrproper-dirs) mrproper archmrproper 1131$(mrproper-dirs): 1132 $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@) 1133 1134mrproper: clean archmrproper $(mrproper-dirs) 1135 $(call cmd,rmdirs) 1136 $(call cmd,rmfiles) 1137 1138# distclean 1139# 1140PHONY += distclean 1141 1142distclean: mrproper 1143 @find $(srctree) $(RCS_FIND_IGNORE) \ 1144 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ 1145 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ 1146 -o -name '.*.rej' \ 1147 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \ 1148 -type f -print | xargs rm -f 1149 1150 1151# Packaging of the kernel to various formats 1152# --------------------------------------------------------------------------- 1153# rpm target kept for backward compatibility 1154package-dir := $(srctree)/scripts/package 1155 1156%src-pkg: FORCE 1157 $(Q)$(MAKE) $(build)=$(package-dir) $@ 1158%pkg: include/config/kernel.release FORCE 1159 $(Q)$(MAKE) $(build)=$(package-dir) $@ 1160rpm: include/config/kernel.release FORCE 1161 $(Q)$(MAKE) $(build)=$(package-dir) $@ 1162 1163 1164# Brief documentation of the typical targets used 1165# --------------------------------------------------------------------------- 1166 1167boards := $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*_defconfig) 1168boards := $(notdir $(boards)) 1169board-dirs := $(dir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*/*_defconfig)) 1170board-dirs := $(sort $(notdir $(board-dirs:/=))) 1171 1172help: 1173 @echo 'Cleaning targets:' 1174 @echo ' clean - Remove most generated files but keep the config and' 1175 @echo ' enough build support to build external modules' 1176 @echo ' mrproper - Remove all generated files + config + various backup files' 1177 @echo ' distclean - mrproper + remove editor backup and patch files' 1178 @echo '' 1179 @echo 'Configuration targets:' 1180 @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help 1181 @echo '' 1182 @echo 'Other generic targets:' 1183 @echo ' all - Build all targets marked with [*]' 1184 @echo '* vmlinux - Build the bare kernel' 1185 @echo '* modules - Build all modules' 1186 @echo ' modules_install - Install all modules to INSTALL_MOD_PATH (default: /)' 1187 @echo ' firmware_install- Install all firmware to INSTALL_FW_PATH' 1188 @echo ' (default: $$(INSTALL_MOD_PATH)/lib/firmware)' 1189 @echo ' dir/ - Build all files in dir and below' 1190 @echo ' dir/file.[oisS] - Build specified target only' 1191 @echo ' dir/file.lst - Build specified mixed source/assembly target only' 1192 @echo ' (requires a recent binutils and recent build (System.map))' 1193 @echo ' dir/file.ko - Build module including final link' 1194 @echo ' modules_prepare - Set up for building external modules' 1195 @echo ' tags/TAGS - Generate tags file for editors' 1196 @echo ' cscope - Generate cscope index' 1197 @echo ' gtags - Generate GNU GLOBAL index' 1198 @echo ' kernelrelease - Output the release version string' 1199 @echo ' kernelversion - Output the version stored in Makefile' 1200 @echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \ 1201 echo ' (default: $(INSTALL_HDR_PATH))'; \ 1202 echo '' 1203 @echo 'Static analysers' 1204 @echo ' checkstack - Generate a list of stack hogs' 1205 @echo ' namespacecheck - Name space analysis on compiled kernel' 1206 @echo ' versioncheck - Sanity check on version.h usage' 1207 @echo ' includecheck - Check for duplicate included header files' 1208 @echo ' export_report - List the usages of all exported symbols' 1209 @echo ' headers_check - Sanity check on exported headers' 1210 @echo ' headerdep - Detect inclusion cycles in headers' 1211 @$(MAKE) -f $(srctree)/scripts/Makefile.help checker-help 1212 @echo '' 1213 @echo 'Kernel packaging:' 1214 @$(MAKE) $(build)=$(package-dir) help 1215 @echo '' 1216 @echo 'Documentation targets:' 1217 @$(MAKE) -f $(srctree)/Documentation/DocBook/Makefile dochelp 1218 @echo '' 1219 @echo 'Architecture specific targets ($(SRCARCH)):' 1220 @$(if $(archhelp),$(archhelp),\ 1221 echo ' No architecture specific help defined for $(SRCARCH)') 1222 @echo '' 1223 @$(if $(boards), \ 1224 $(foreach b, $(boards), \ 1225 printf " %-24s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \ 1226 echo '') 1227 @$(if $(board-dirs), \ 1228 $(foreach b, $(board-dirs), \ 1229 printf " %-16s - Show %s-specific targets\\n" help-$(b) $(b);) \ 1230 printf " %-16s - Show all of the above\\n" help-boards; \ 1231 echo '') 1232 1233 @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build' 1234 @echo ' make V=2 [targets] 2 => give reason for rebuild of target' 1235 @echo ' make O=dir [targets] Locate all output files in "dir", including .config' 1236 @echo ' make C=1 [targets] Check all c source with $$CHECK (sparse by default)' 1237 @echo ' make C=2 [targets] Force check of all c source with $$CHECK' 1238 @echo ' make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections' 1239 @echo ' make W=n [targets] Enable extra gcc checks, n=1,2,3 where' 1240 @echo ' 1: warnings which may be relevant and do not occur too often' 1241 @echo ' 2: warnings which occur quite often but may still be relevant' 1242 @echo ' 3: more obscure warnings, can most likely be ignored' 1243 @echo ' Multiple levels can be combined with W=12 or W=123' 1244 @echo '' 1245 @echo 'Execute "make" or "make all" to build all targets marked with [*] ' 1246 @echo 'For further info see the ./README file' 1247 1248 1249help-board-dirs := $(addprefix help-,$(board-dirs)) 1250 1251help-boards: $(help-board-dirs) 1252 1253boards-per-dir = $(notdir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/$*/*_defconfig)) 1254 1255$(help-board-dirs): help-%: 1256 @echo 'Architecture specific targets ($(SRCARCH) $*):' 1257 @$(if $(boards-per-dir), \ 1258 $(foreach b, $(boards-per-dir), \ 1259 printf " %-24s - Build for %s\\n" $*/$(b) $(subst _defconfig,,$(b));) \ 1260 echo '') 1261 1262 1263# Documentation targets 1264# --------------------------------------------------------------------------- 1265%docs: scripts_basic FORCE 1266 $(Q)$(MAKE) $(build)=scripts build_docproc 1267 $(Q)$(MAKE) $(build)=Documentation/DocBook $@ 1268 1269else # KBUILD_EXTMOD 1270 1271### 1272# External module support. 1273# When building external modules the kernel used as basis is considered 1274# read-only, and no consistency checks are made and the make 1275# system is not used on the basis kernel. If updates are required 1276# in the basis kernel ordinary make commands (without M=...) must 1277# be used. 1278# 1279# The following are the only valid targets when building external 1280# modules. 1281# make M=dir clean Delete all automatically generated files 1282# make M=dir modules Make all modules in specified dir 1283# make M=dir Same as 'make M=dir modules' 1284# make M=dir modules_install 1285# Install the modules built in the module directory 1286# Assumes install directory is already created 1287 1288# We are always building modules 1289KBUILD_MODULES := 1 1290PHONY += crmodverdir 1291crmodverdir: 1292 $(cmd_crmodverdir) 1293 1294PHONY += $(objtree)/Module.symvers 1295$(objtree)/Module.symvers: 1296 @test -e $(objtree)/Module.symvers || ( \ 1297 echo; \ 1298 echo " WARNING: Symbol version dump $(objtree)/Module.symvers"; \ 1299 echo " is missing; modules will have no dependencies and modversions."; \ 1300 echo ) 1301 1302module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD)) 1303PHONY += $(module-dirs) modules 1304$(module-dirs): crmodverdir $(objtree)/Module.symvers 1305 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@) 1306 1307modules: $(module-dirs) 1308 @$(kecho) ' Building modules, stage 2.'; 1309 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost 1310 1311PHONY += modules_install 1312modules_install: _emodinst_ _emodinst_post 1313 1314install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra) 1315PHONY += _emodinst_ 1316_emodinst_: 1317 $(Q)mkdir -p $(MODLIB)/$(install-dir) 1318 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst 1319 1320PHONY += _emodinst_post 1321_emodinst_post: _emodinst_ 1322 $(call cmd,depmod) 1323 1324clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD)) 1325 1326PHONY += $(clean-dirs) clean 1327$(clean-dirs): 1328 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) 1329 1330clean: rm-dirs := $(MODVERDIR) 1331clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers 1332 1333help: 1334 @echo ' Building external modules.' 1335 @echo ' Syntax: make -C path/to/kernel/src M=$$PWD target' 1336 @echo '' 1337 @echo ' modules - default target, build the module(s)' 1338 @echo ' modules_install - install the module' 1339 @echo ' clean - remove generated files in module directory only' 1340 @echo '' 1341 1342# Dummies... 1343PHONY += prepare scripts 1344prepare: ; 1345scripts: ; 1346endif # KBUILD_EXTMOD 1347 1348clean: $(clean-dirs) 1349 $(call cmd,rmdirs) 1350 $(call cmd,rmfiles) 1351 @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \ 1352 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ 1353 -o -name '*.ko.*' \ 1354 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ 1355 -o -name '*.symtypes' -o -name 'modules.order' \ 1356 -o -name modules.builtin -o -name '.tmp_*.o.*' \ 1357 -o -name '*.gcno' \) -type f -print | xargs rm -f 1358 1359# Generate tags for editors 1360# --------------------------------------------------------------------------- 1361quiet_cmd_tags = GEN $@ 1362 cmd_tags = $(CONFIG_SHELL) $(srctree)/scripts/tags.sh $@ 1363 1364tags TAGS cscope gtags: FORCE 1365 $(call cmd,tags) 1366 1367# Scripts to check various things for consistency 1368# --------------------------------------------------------------------------- 1369 1370PHONY += includecheck versioncheck coccicheck namespacecheck export_report 1371 1372includecheck: 1373 find $(srctree)/* $(RCS_FIND_IGNORE) \ 1374 -name '*.[hcS]' -type f -print | sort \ 1375 | xargs $(PERL) -w $(srctree)/scripts/checkincludes.pl 1376 1377versioncheck: 1378 find $(srctree)/* $(RCS_FIND_IGNORE) \ 1379 -name '*.[hcS]' -type f -print | sort \ 1380 | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl 1381 1382coccicheck: 1383 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/$@ 1384 1385namespacecheck: 1386 $(PERL) $(srctree)/scripts/namespace.pl 1387 1388export_report: 1389 $(PERL) $(srctree)/scripts/export_report.pl 1390 1391endif #ifeq ($(config-targets),1) 1392endif #ifeq ($(mixed-targets),1) 1393 1394PHONY += checkstack kernelrelease kernelversion 1395 1396# UML needs a little special treatment here. It wants to use the host 1397# toolchain, so needs $(SUBARCH) passed to checkstack.pl. Everyone 1398# else wants $(ARCH), including people doing cross-builds, which means 1399# that $(SUBARCH) doesn't work here. 1400ifeq ($(ARCH), um) 1401CHECKSTACK_ARCH := $(SUBARCH) 1402else 1403CHECKSTACK_ARCH := $(ARCH) 1404endif 1405checkstack: 1406 $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \ 1407 $(PERL) $(src)/scripts/checkstack.pl $(CHECKSTACK_ARCH) 1408 1409kernelrelease: 1410 @echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" 1411 1412kernelversion: 1413 @echo $(KERNELVERSION) 1414 1415# Clear a bunch of variables before executing the submake 1416tools/: FORCE 1417 $(Q)mkdir -p $(objtree)/tools 1418 $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(filter --j% -j,$(MAKEFLAGS))" O=$(shell cd $(objtree) && /bin/pwd) subdir=tools -C $(src)/tools/ 1419 1420tools/%: FORCE 1421 $(Q)mkdir -p $(objtree)/tools 1422 $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(filter --j% -j,$(MAKEFLAGS))" O=$(shell cd $(objtree) && /bin/pwd) subdir=tools -C $(src)/tools/ $* 1423 1424# Single targets 1425# --------------------------------------------------------------------------- 1426# Single targets are compatible with: 1427# - build with mixed source and output 1428# - build with separate output dir 'make O=...' 1429# - external modules 1430# 1431# target-dir => where to store outputfile 1432# build-dir => directory in kernel source tree to use 1433 1434ifeq ($(KBUILD_EXTMOD),) 1435 build-dir = $(patsubst %/,%,$(dir $@)) 1436 target-dir = $(dir $@) 1437else 1438 zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@))) 1439 build-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash)) 1440 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@)) 1441endif 1442 1443%.s: %.c prepare scripts FORCE 1444 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1445%.i: %.c prepare scripts FORCE 1446 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1447%.o: %.c prepare scripts FORCE 1448 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1449%.lst: %.c prepare scripts FORCE 1450 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1451%.s: %.S prepare scripts FORCE 1452 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1453%.o: %.S prepare scripts FORCE 1454 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1455%.symtypes: %.c prepare scripts FORCE 1456 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1457 1458# Modules 1459/: prepare scripts FORCE 1460 $(cmd_crmodverdir) 1461 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ 1462 $(build)=$(build-dir) 1463%/: prepare scripts FORCE 1464 $(cmd_crmodverdir) 1465 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ 1466 $(build)=$(build-dir) 1467%.ko: prepare scripts FORCE 1468 $(cmd_crmodverdir) 1469 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ 1470 $(build)=$(build-dir) $(@:.ko=.o) 1471 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost 1472 1473# FIXME Should go into a make.lib or something 1474# =========================================================================== 1475 1476quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-dirs))) 1477 cmd_rmdirs = rm -rf $(rm-dirs) 1478 1479quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))) 1480 cmd_rmfiles = rm -f $(rm-files) 1481 1482# Run depmod only if we have System.map and depmod is executable 1483quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) 1484 cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \ 1485 $(KERNELRELEASE) "$(patsubst y,_,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX))" 1486 1487# Create temporary dir for module support files 1488# clean it up only when building all modules 1489cmd_crmodverdir = $(Q)mkdir -p $(MODVERDIR) \ 1490 $(if $(KBUILD_MODULES),; rm -f $(MODVERDIR)/*) 1491 1492# read all saved command lines 1493 1494targets := $(wildcard $(sort $(targets))) 1495cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) 1496 1497ifneq ($(cmd_files),) 1498 $(cmd_files): ; # Do not try to update included dependency files 1499 include $(cmd_files) 1500endif 1501 1502# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir 1503# Usage: 1504# $(Q)$(MAKE) $(clean)=dir 1505clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj 1506 1507endif # skip-makefile 1508 1509PHONY += FORCE 1510FORCE: 1511 1512# Declare the contents of the .PHONY variable as phony. We keep that 1513# information in a variable so we can use it in if_changed and friends. 1514.PHONY: $(PHONY) 1515