Back to home page

Linux Cross Reference

 
 

    


0001 VERSION = 3
0002 PATCHLEVEL = 13
0003 SUBLEVEL = 2
0004 EXTRAVERSION =
0005 NAME = One Giant Leap for Frogkind
0006 
0007 # *DOCUMENTATION*
0008 # To see a list of typical targets execute "make help"
0009 # More info can be located in ./README
0010 # Comments in this file are targeted only to the developer, do not
0011 # expect to learn how to build the kernel reading this file.
0012 
0013 # Do not:
0014 # o  use make's built-in rules and variables
0015 #    (this increases performance and avoids hard-to-debug behaviour);
0016 # o  print "Entering directory ...";
0017 MAKEFLAGS += -rR --no-print-directory
0018 
0019 # Avoid funny character set dependencies
0020 unexport LC_ALL
0021 LC_COLLATE=C
0022 LC_NUMERIC=C
0023 export LC_COLLATE LC_NUMERIC
0024 
0025 # Avoid interference with shell env settings
0026 unexport GREP_OPTIONS
0027 
0028 # We are using a recursive build, so we need to do a little thinking
0029 # to get the ordering right.
0030 #
0031 # Most importantly: sub-Makefiles should only ever modify files in
0032 # their own directory. If in some directory we have a dependency on
0033 # a file in another dir (which doesn't happen often, but it's often
0034 # unavoidable when linking the built-in.o targets which finally
0035 # turn into vmlinux), we will call a sub make in that other dir, and
0036 # after that we are sure that everything which is in that other dir
0037 # is now up to date.
0038 #
0039 # The only cases where we need to modify files which have global
0040 # effects are thus separated out and done before the recursive
0041 # descending is started. They are now explicitly listed as the
0042 # prepare rule.
0043 
0044 # To put more focus on warnings, be less verbose as default
0045 # Use 'make V=1' to see the full commands
0046 
0047 ifeq ("$(origin V)", "command line")
0048   KBUILD_VERBOSE = $(V)
0049 endif
0050 ifndef KBUILD_VERBOSE
0051   KBUILD_VERBOSE = 0
0052 endif
0053 
0054 # Call a source code checker (by default, "sparse") as part of the
0055 # C compilation.
0056 #
0057 # Use 'make C=1' to enable checking of only re-compiled files.
0058 # Use 'make C=2' to enable checking of *all* source files, regardless
0059 # of whether they are re-compiled or not.
0060 #
0061 # See the file "Documentation/sparse.txt" for more details, including
0062 # where to get the "sparse" utility.
0063 
0064 ifeq ("$(origin C)", "command line")
0065   KBUILD_CHECKSRC = $(C)
0066 endif
0067 ifndef KBUILD_CHECKSRC
0068   KBUILD_CHECKSRC = 0
0069 endif
0070 
0071 # Use make M=dir to specify directory of external module to build
0072 # Old syntax make ... SUBDIRS=$PWD is still supported
0073 # Setting the environment variable KBUILD_EXTMOD take precedence
0074 ifdef SUBDIRS
0075   KBUILD_EXTMOD ?= $(SUBDIRS)
0076 endif
0077 
0078 ifeq ("$(origin M)", "command line")
0079   KBUILD_EXTMOD := $(M)
0080 endif
0081 
0082 # kbuild supports saving output files in a separate directory.
0083 # To locate output files in a separate directory two syntaxes are supported.
0084 # In both cases the working directory must be the root of the kernel src.
0085 # 1) O=
0086 # Use "make O=dir/to/store/output/files/"
0087 #
0088 # 2) Set KBUILD_OUTPUT
0089 # Set the environment variable KBUILD_OUTPUT to point to the directory
0090 # where the output files shall be placed.
0091 # export KBUILD_OUTPUT=dir/to/store/output/files/
0092 # make
0093 #
0094 # The O= assignment takes precedence over the KBUILD_OUTPUT environment
0095 # variable.
0096 
0097 
0098 # KBUILD_SRC is set on invocation of make in OBJ directory
0099 # KBUILD_SRC is not intended to be used by the regular user (for now)
0100 ifeq ($(KBUILD_SRC),)
0101 
0102 # OK, Make called in directory where kernel src resides
0103 # Do we want to locate output files in a separate directory?
0104 ifeq ("$(origin O)", "command line")
0105   KBUILD_OUTPUT := $(O)
0106 endif
0107 
0108 ifeq ("$(origin W)", "command line")
0109   export KBUILD_ENABLE_EXTRA_GCC_CHECKS := $(W)
0110 endif
0111 
0112 # That's our default target when none is given on the command line
0113 PHONY := _all
0114 _all:
0115 
0116 # Cancel implicit rules on top Makefile
0117 $(CURDIR)/Makefile Makefile: ;
0118 
0119 ifneq ($(KBUILD_OUTPUT),)
0120 # Invoke a second make in the output directory, passing relevant variables
0121 # check that the output directory actually exists
0122 saved-output := $(KBUILD_OUTPUT)
0123 KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd)
0124 $(if $(KBUILD_OUTPUT),, \
0125      $(error output directory "$(saved-output)" does not exist))
0126 
0127 PHONY += $(MAKECMDGOALS) sub-make
0128 
0129 $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
0130         @:
0131 
0132 sub-make: FORCE
0133         $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
0134         KBUILD_SRC=$(CURDIR) \
0135         KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile \
0136         $(filter-out _all sub-make,$(MAKECMDGOALS))
0137 
0138 # Leave processing to above invocation of make
0139 skip-makefile := 1
0140 endif # ifneq ($(KBUILD_OUTPUT),)
0141 endif # ifeq ($(KBUILD_SRC),)
0142 
0143 # We process the rest of the Makefile if this is the final invocation of make
0144 ifeq ($(skip-makefile),)
0145 
0146 # If building an external module we do not care about the all: rule
0147 # but instead _all depend on modules
0148 PHONY += all
0149 ifeq ($(KBUILD_EXTMOD),)
0150 _all: all
0151 else
0152 _all: modules
0153 endif
0154 
0155 srctree         := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR))
0156 objtree         := $(CURDIR)
0157 src             := $(srctree)
0158 obj             := $(objtree)
0159 
0160 VPATH           := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))
0161 
0162 export srctree objtree VPATH
0163 
0164 
0165 # SUBARCH tells the usermode build what the underlying arch is.  That is set
0166 # first, and if a usermode build is happening, the "ARCH=um" on the command
0167 # line overrides the setting of ARCH below.  If a native build is happening,
0168 # then ARCH is assigned, getting whatever value it gets normally, and 
0169 # SUBARCH is subsequently ignored.
0170 
0171 SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \
0172                                   -e s/sun4u/sparc64/ \
0173                                   -e s/arm.*/arm/ -e s/sa110/arm/ \
0174                                   -e s/s390x/s390/ -e s/parisc64/parisc/ \
0175                                   -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
0176                                   -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ )
0177 
0178 # Cross compiling and selecting different set of gcc/bin-utils
0179 # ---------------------------------------------------------------------------
0180 #
0181 # When performing cross compilation for other architectures ARCH shall be set
0182 # to the target architecture. (See arch/* for the possibilities).
0183 # ARCH can be set during invocation of make:
0184 # make ARCH=ia64
0185 # Another way is to have ARCH set in the environment.
0186 # The default ARCH is the host where make is executed.
0187 
0188 # CROSS_COMPILE specify the prefix used for all executables used
0189 # during compilation. Only gcc and related bin-utils executables
0190 # are prefixed with $(CROSS_COMPILE).
0191 # CROSS_COMPILE can be set on the command line
0192 # make CROSS_COMPILE=ia64-linux-
0193 # Alternatively CROSS_COMPILE can be set in the environment.
0194 # A third alternative is to store a setting in .config so that plain
0195 # "make" in the configured kernel build directory always uses that.
0196 # Default value for CROSS_COMPILE is not to prefix executables
0197 # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
0198 ARCH            ?= $(SUBARCH)
0199 CROSS_COMPILE   ?= $(CONFIG_CROSS_COMPILE:"%"=%)
0200 
0201 # Architecture as present in compile.h
0202 UTS_MACHINE     := $(ARCH)
0203 SRCARCH         := $(ARCH)
0204 
0205 # Additional ARCH settings for x86
0206 ifeq ($(ARCH),i386)
0207         SRCARCH := x86
0208 endif
0209 ifeq ($(ARCH),x86_64)
0210         SRCARCH := x86
0211 endif
0212 
0213 # Additional ARCH settings for sparc
0214 ifeq ($(ARCH),sparc32)
0215        SRCARCH := sparc
0216 endif
0217 ifeq ($(ARCH),sparc64)
0218        SRCARCH := sparc
0219 endif
0220 
0221 # Additional ARCH settings for sh
0222 ifeq ($(ARCH),sh64)
0223        SRCARCH := sh
0224 endif
0225 
0226 # Additional ARCH settings for tile
0227 ifeq ($(ARCH),tilepro)
0228        SRCARCH := tile
0229 endif
0230 ifeq ($(ARCH),tilegx)
0231        SRCARCH := tile
0232 endif
0233 
0234 # Where to locate arch specific headers
0235 hdr-arch  := $(SRCARCH)
0236 
0237 KCONFIG_CONFIG  ?= .config
0238 export KCONFIG_CONFIG
0239 
0240 # SHELL used by kbuild
0241 CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
0242           else if [ -x /bin/bash ]; then echo /bin/bash; \
0243           else echo sh; fi ; fi)
0244 
0245 HOSTCC       = gcc
0246 HOSTCXX      = g++
0247 HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
0248 HOSTCXXFLAGS = -O2
0249 
0250 # Decide whether to build built-in, modular, or both.
0251 # Normally, just do built-in.
0252 
0253 KBUILD_MODULES :=
0254 KBUILD_BUILTIN := 1
0255 
0256 #       If we have only "make modules", don't compile built-in objects.
0257 #       When we're building modules with modversions, we need to consider
0258 #       the built-in objects during the descend as well, in order to
0259 #       make sure the checksums are up to date before we record them.
0260 
0261 ifeq ($(MAKECMDGOALS),modules)
0262   KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1)
0263 endif
0264 
0265 #       If we have "make <whatever> modules", compile modules
0266 #       in addition to whatever we do anyway.
0267 #       Just "make" or "make all" shall build modules as well
0268 
0269 ifneq ($(filter all _all modules,$(MAKECMDGOALS)),)
0270   KBUILD_MODULES := 1
0271 endif
0272 
0273 ifeq ($(MAKECMDGOALS),)
0274   KBUILD_MODULES := 1
0275 endif
0276 
0277 export KBUILD_MODULES KBUILD_BUILTIN
0278 export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD
0279 
0280 # Beautify output
0281 # ---------------------------------------------------------------------------
0282 #
0283 # Normally, we echo the whole command before executing it. By making
0284 # that echo $($(quiet)$(cmd)), we now have the possibility to set
0285 # $(quiet) to choose other forms of output instead, e.g.
0286 #
0287 #         quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
0288 #         cmd_cc_o_c       = $(CC) $(c_flags) -c -o $@ $<
0289 #
0290 # If $(quiet) is empty, the whole command will be printed.
0291 # If it is set to "quiet_", only the short version will be printed. 
0292 # If it is set to "silent_", nothing will be printed at all, since
0293 # the variable $(silent_cmd_cc_o_c) doesn't exist.
0294 #
0295 # A simple variant is to prefix commands with $(Q) - that's useful
0296 # for commands that shall be hidden in non-verbose mode.
0297 #
0298 #       $(Q)ln $@ :<
0299 #
0300 # If KBUILD_VERBOSE equals 0 then the above command will be hidden.
0301 # If KBUILD_VERBOSE equals 1 then the above command is displayed.
0302 
0303 ifeq ($(KBUILD_VERBOSE),1)
0304   quiet =
0305   Q =
0306 else
0307   quiet=quiet_
0308   Q = @
0309 endif
0310 
0311 # If the user is running make -s (silent mode), suppress echoing of
0312 # commands
0313 
0314 ifneq ($(filter s% -s%,$(MAKEFLAGS)),)
0315   quiet=silent_
0316 endif
0317 
0318 export quiet Q KBUILD_VERBOSE
0319 
0320 
0321 # Look for make include files relative to root of kernel src
0322 MAKEFLAGS += --include-dir=$(srctree)
0323 
0324 # We need some generic definitions (do not try to remake the file).
0325 $(srctree)/scripts/Kbuild.include: ;
0326 (srctree)/scripts/Kbuild. (CROSS_COMPILE)as
0327 LD              = $(CROSS_COMPILE)ld
0328 CC              = $(CROSS_COMPILE)gcc
0329 CPP             = $(CC) -E
0330 AR              = $(CROSS_COMPILE)ar
0331 NM              = $(CROSS_COMPILE)nm
0332 STRIP           = $(CROSS_COMPILE)strip
0333 OBJCOPY         = $(CROSS_COMPILE)objcopy
0334 OBJDUMP         = $(CROSS_COMPILE)objdump
0335 AWK             = awk
0336 GENKSYMS        = scripts/genksyms/genksyms
0337 INSTALLKERNEL  := installkernel
0338 DEPMOD          = /sbin/depmod
0339 PERL            = perl
0340 CHECK           = sparse
0341 
0342 CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
0343                   -Wbitwise -Wno-return-void $(CF)
0344 CFLAGS_MODULE   =
0345 AFLAGS_MODULE   =
0346 LDFLAGS_MODULE  =
0347 CFLAGS_KERNEL   =
0348 AFLAGS_KERNEL   =
0349 CFLAGS_GCOV     = -fprofile-arcs -ftest-coverage
0350 
0351 
0352 # Use USERINCLUDE when you must reference the UAPI directories only.
0353 USERINCLUDE    := \
0354                 -I$(srctree)/arch/$(hdr-arch)/include/uapi \
0355                 -Iarch/$(hdr-arch)/include/generated/uapi \
0356                 -I$(srctree)/include/uapi \
0357                 -Iinclude/generated/uapi \
0358                 (srctree)/include/linux/kconfig.h
0359 
0360 # Use LINUXINCLUDE when you must reference the include/ directory.
0361 # Needed to be compatible with the O= option
0362 LINUXINCLUDE    := \
0363                 -I$(srctree)/arch/$(hdr-arch)/                (hdr-arch)/include/generated \
0364                 $(if $(KBUILD_SRC), -I$(srctree)/include) \
0365                 -I                (USERINCLUDE)
0366 
0367 KBUILD_CPPFLAGS := -D__KERNEL__
0368 
0369 KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
0370                    -fno-strict-aliasing -fno-common \
0371                    -Werror-implicit-function-declaration \
0372                    -Wno-format-security \
0373                    -fno-delete-null-pointer-checks
0374 KBUILD_AFLAGS_KERNEL :=
0375 KBUILD_CFLAGS_KERNEL :=
0376 KBUILD_AFLAGS   := -D__ASSEMBLY__
0377 KBUILD_AFLAGS_MODULE  := -DMODULE
0378 KBUILD_CFLAGS_MODULE  := -DMODULE
0379 KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
0380 
0381 # Read KERNELRELEASE from include/config/kernel.release (if it exists)
0382 KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
0383 KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
0384 
0385 export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
0386 export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC
0387 export CPP AR NM STRIP OBJCOPY OBJDUMP
0388 export MAKE AWK GENKSYMS INSTALLKERNEL PERL UTS_MACHINE
0389 export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
0390 
0391 export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
0392 export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_GCOV
0393 export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
0394 export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
0395 export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
0396 export KBUILD_ARFLAGS
0397 
0398 # When compiling out-of-tree modules, put MODVERDIR in the module
0399 # tree rather than in the kernel tree. The kernel tree might
0400 # even be read-only.
0401 export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions
0402 
0403 # Files to ignore in find ... statements
0404 
0405 RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \
0406                    -o -name .pc -o -name .hg -o -name .git \) -prune -o
0407 export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
0408                          --exclude CVS --exclude .pc --exclude .hg --exclude .git
0409 
0410 # ===========================================================================
0411 # Rules shared between *config targets and build targets
0412 
0413 # Basic helpers built in scripts/
0414 PHONY += scripts_basic
0415 scripts_basic:
0416         $(Q)$(MAKE) $(build)=scripts/basic
0417         $(Q)rm -f .tmp_quiet_recordmcount
0418 
0419 # To avoid any implicit rule to kick in, define an empty command.
0420 scripts/basic/%: scripts_basic ;
0421 
0422 PHONY += outputmakefile
0423 # outputmakefile generates a Makefile in the output directory, if using a
0424 # separate output directory. This allows convenient use of make in the
0425 # output directory.
0426 outputmakefile:
0427 ifneq ($(KBUILD_SRC),)
0428         $(Q)ln -fsn $(srctree) source
0429         $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \
0430             $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
0431 endif
0432 
0433 # Support for using generic headers in asm-generic
0434 PHONY += asm-generic
0435 asm-generic:
0436         $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \
0437                     src=asm obj=arch/$(SRCARCH)/include/generated/asm
0438         $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \
0439                     src=uapi/asm obj=arch/$(SRCARCH)/include/generated/uapi/asm
0440 
0441 # To make sure we do not include .config for any of the *config targets
0442 # catch them early, and hand them over to scripts/kconfig/Makefile
0443 # It is allowed to specify more targets when calling make, including
0444 # mixing *config targets and build targets.
0445 # For example 'make oldconfig all'.
0446 # Detect when mixed targets is specified, and make a second invocation
0447 # of make so .config is not included in this case either (for *config).
0448 
0449 version_h := include/generated/uapi/linux/version.h
0450 
0451 no-dot-config-targets := clean mrproper distclean \
0452                          cscope gtags TAGS tags help %docs check% coccicheck \
0453                          $(version_h) headers_% archheaders archscripts \
0454                          kernelversion %src-pkg
0455 
0456 config-targets := 0
0457 mixed-targets  := 0
0458 dot-config     := 1
0459 
0460 ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
0461         ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
0462                 dot-config := 0
0463         endif
0464 endif
0465 
0466 ifeq ($(KBUILD_EXTMOD),)
0467         ifneq ($(filter config %config,$(MAKECMDGOALS)),)
0468                 config-targets := 1
0469                 ifneq ($(filter-out config %config,$(MAKECMDGOALS)),)
0470                         mixed-targets := 1
0471                 endif
0472         endif
0473 endif
0474 
0475 ifeq ($(mixed-targets),1)
0476 # ===========================================================================
0477 # We're called with mixed targets (*config and build targets).
0478 # Handle them one by one.
0479 
0480 %:: FORCE
0481         $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= $@
0482 
0483 else
0484 ifeq ($(config-targets),1)
0485 # ===========================================================================
0486 # *config targets only - make sure prerequisites are updated, and descend
0487 # in scripts/kconfig to make the *config target
0488 
0489 # Read arch specific Makefile to set KBUILD_DEFCONFIG as needed.
0490 # KBUILD_DEFCONFIG may point out an alternative default configuration
0491 # used for 'make defconfig'
0492 (srctree)/arch/$(SRCARCH)/Makefile
0493 export KBUILD_DEFCONFIG KBUILD_KCONFIG
0494 
0495 config: scripts_basic outputmakefile FORCE
0496         $(Q)mkdir -p include/linux include/config
0497         $(Q)$(MAKE) $(build)=scripts/kconfig $@
0498 
0499 %config: scripts_basic outputmakefile FORCE
0500         $(Q)mkdir -p include/linux include/config
0501         $(Q)$(MAKE) $(build)=scripts/kconfig $@
0502 
0503 else
0504 # ===========================================================================
0505 # Build targets only - this includes vmlinux, arch specific targets, clean
0506 # targets and others. In general all targets except *config targets.
0507 
0508 ifeq ($(KBUILD_EXTMOD),)
0509 # Additional helpers built in scripts/
0510 # Carefully list dependencies so we do not try to build scripts twice
0511 # in parallel
0512 PHONY += scripts
0513 scripts: scripts_basic include/config/auto.conf include/config/tristate.conf \
0514          asm-generic
0515         $(Q)$(MAKE) $(build)=$(@)
0516 
0517 # Objects we will link into vmlinux / subdirs we need to visit
0518 init-y          := init/
0519 drivers-y       := drivers/ sound/ firmware/
0520 net-y           := net/
0521 libs-y          := lib/
0522 core-y          := usr/
0523 endif # KBUILD_EXTMOD
0524 
0525 ifeq ($(dot-config),1)
0526 # Read in config
0527  (KBUILD_EXTMOD),)
0528 # Read in dependencies to all Kconfig* files, make sure to run
0529 # oldconfig if changes are detected.
0530 
0531 (KCONFIG_CONFIG) include/config/auto.conf.cmd: ;
0532 
0533 # If .config is newer than include/config/auto.conf, someone tinkered
0534 # with it and forgot to run make oldconfig.
0535 # if auto.conf.cmd is missing then we are probably in a cleaned tree so
0536 # we execute the config step to be sure to catch updated Kconfig files
0537 include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
0538         $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
0539 else
0540 # external modules needs include/generated/autoconf.h and include/config/auto.conf
0541 # but do not care if they are up-to-date. Use auto.conf to trigger the test
0542 PHONY += include/config/auto.conf
0543 
0544 include/config/auto.conf:
0545         $(Q)test -e include/generated/autoconf.h -a -e $@ || (          \
0546         echo >&2;                                                       \
0547         echo >&2 "  ERROR: Kernel configuration is invalid.";           \
0548         echo >&2 "         include/generated/autoconf.h or $@ are missing.";\
0549         echo >&2 "         Run 'make oldconfig && make prepare' on kernel src to fix it.";      \
0550         echo >&2 ;                                                      \
0551         /bin/false)
0552 
0553 endif # KBUILD_EXTMOD
0554 
0555 else
0556 # Dummy target needed, because used as prerequisite
0557 include/config/auto.conf: ;
0558 endif # $(dot-config)
0559 
0560 # The all: target is the default when no target is given on the
0561 # command line.
0562 # This allow a user to issue only 'make' to build a kernel including modules
0563 # Defaults to vmlinux, but the arch makefile usually adds further targets
0564 all: vmlinux
0565 
0566 ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
0567 KBUILD_CFLAGS   += -Os $(call cc-disable-warning,maybe-uninitialized,)
0568 else
0569 KBUILD_CFLAGS   += -O2
0570 endif
0571 
0572 (srctree)/arch/$(SRCARCH)/Makefile
0573 
0574 ifdef CONFIG_READABLE_ASM
0575 # Disable optimizations that make assembler listings hard to read.
0576 # reorder blocks reorders the control in the function
0577 # ipa clone creates specialized cloned functions
0578 # partial inlining inlines only parts of functions
0579 KBUILD_CFLAGS += $(call cc-option,-fno-reorder-blocks,) \
0580                  $(call cc-option,-fno-ipa-cp-clone,) \
0581                  $(call cc-option,-fno-partial-inlining)
0582 endif
0583 
0584 ifneq ($(CONFIG_FRAME_WARN),0)
0585 KBUILD_CFLAGS += $(call cc-option,-Wframe-larger-than=${CONFIG_FRAME_WARN})
0586 endif
0587 
0588 # Force gcc to behave correct even for buggy distributions
0589 ifndef CONFIG_CC_STACKPROTECTOR
0590 KBUILD_CFLAGS += $(call cc-option, -fno-stack-protector)
0591 endif
0592 
0593 # This warning generated too much noise in a regular build.
0594 # Use make W=1 to enable this warning (see scripts/Makefile.build)
0595 KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
0596 
0597 ifdef CONFIG_FRAME_POINTER
0598 KBUILD_CFLAGS   += -fno-omit-frame-pointer -fno-optimize-sibling-calls
0599 else
0600 # Some targets (ARM with Thumb2, for example), can't be built with frame
0601 # pointers.  For those, we don't have FUNCTION_TRACER automatically
0602 # select FRAME_POINTER.  However, FUNCTION_TRACER adds -pg, and this is
0603 # incompatible with -fomit-frame-pointer with current GCC, so we don't use
0604 # -fomit-frame-pointer with FUNCTION_TRACER.
0605 ifndef CONFIG_FUNCTION_TRACER
0606 KBUILD_CFLAGS   += -fomit-frame-pointer
0607 endif
0608 endif
0609 
0610 ifdef CONFIG_DEBUG_INFO
0611 KBUILD_CFLAGS   += -g
0612 KBUILD_AFLAGS   += -gdwarf-2
0613 endif
0614 
0615 ifdef CONFIG_DEBUG_INFO_REDUCED
0616 KBUILD_CFLAGS   += $(call cc-option, -femit-struct-debug-baseonly) \
0617                    $(call cc-option,-fno-var-tracking)
0618 endif
0619 
0620 ifdef CONFIG_FUNCTION_TRACER
0621 ifdef CONFIG_HAVE_FENTRY
0622 CC_USING_FENTRY := $(call cc-option, -mfentry -DCC_USING_FENTRY)
0623 endif
0624 KBUILD_CFLAGS   += -pg $(CC_USING_FENTRY)
0625 KBUILD_AFLAGS   += $(CC_USING_FENTRY)
0626 ifdef CONFIG_DYNAMIC_FTRACE
0627         ifdef CONFIG_HAVE_C_RECORDMCOUNT
0628                 BUILD_C_RECORDMCOUNT := y
0629                 export BUILD_C_RECORDMCOUNT
0630         endif
0631 endif
0632 endif
0633 
0634 # We trigger additional mismatches with less inlining
0635 ifdef CONFIG_DEBUG_SECTION_MISMATCH
0636 KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once)
0637 endif
0638 
0639 # arch Makefile may override CC so keep this after arch Makefile is included
0640 NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
0641 CHECKFLAGS     += $(NOSTDINC_FLAGS)
0642 
0643 # warn about C99 declaration after statement
0644 KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
0645 
0646 # disable pointer signed / unsigned warnings in gcc 4.0
0647 KBUILD_CFLAGS += $(call cc-disable-warning, pointer-sign)
0648 
0649 # disable invalid "can't wrap" optimizations for signed / pointers
0650 KBUILD_CFLAGS   += $(call cc-option,-fno-strict-overflow)
0651 
0652 # conserve stack if available
0653 KBUILD_CFLAGS   += $(call cc-option,-fconserve-stack)
0654 
0655 # disallow errors like 'EXPORT_GPL(foo);' with missing header
0656 KBUILD_CFLAGS   += $(call cc-option,-Werror=implicit-int)
0657 
0658 # require functions to have arguments in prototypes, not empty 'int foo()'
0659 KBUILD_CFLAGS   += $(call cc-option,-Werror=strict-prototypes)
0660 
0661 # use the deterministic mode of AR if available
0662 KBUILD_ARFLAGS := $(call ar-option,D)
0663 
0664 # check for 'asm goto'
0665 ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC)), y)
0666         KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO
0667 endif
0668 
0669 # Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments
0670 KBUILD_CPPFLAGS += $(KCPPFLAGS)
0671 KBUILD_AFLAGS += $(KAFLAGS)
0672 KBUILD_CFLAGS += $(KCFLAGS)
0673 
0674 # Use --build-id when available.
0675 LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\
0676                               $(call cc-ldoption, -Wl$(comma)--build-id,))
0677 KBUILD_LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID)
0678 LDFLAGS_vmlinux += $(LDFLAGS_BUILD_ID)
0679 
0680 ifeq ($(CONFIG_STRIP_ASM_SYMS),y)
0681 LDFLAGS_vmlinux += $(call ld-option, -X,)
0682 endif
0683 
0684 # Default kernel image to build when no specific target is given.
0685 # KBUILD_IMAGE may be overruled on the command line or
0686 # set in the environment
0687 # Also any assignments in arch/$(ARCH)/Makefile take precedence over
0688 # this default value
0689 export KBUILD_IMAGE ?= vmlinux
0690 
0691 #
0692 # INSTALL_PATH specifies where to place the updated kernel and system map
0693 # images. Default is /boot, but you can set it to other values
0694 export  INSTALL_PATH ?= /boot
0695 
0696 #
0697 # INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
0698 # relocations required by build roots.  This is not defined in the
0699 # makefile but the argument can be passed to make if needed.
0700 #
0701 
0702 MODLIB  = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
0703 export MODLIB
0704 
0705 #
0706 #  INSTALL_MOD_STRIP, if defined, will cause modules to be
0707 #  stripped after they are installed.  If INSTALL_MOD_STRIP is '1', then
0708 #  the default option --strip-debug will be used.  Otherwise,
0709 #  INSTALL_MOD_STRIP value will be used as the options to the strip command.
0710 
0711 ifdef INSTALL_MOD_STRIP
0712 ifeq ($(INSTALL_MOD_STRIP),1)
0713 mod_strip_cmd = $(STRIP) --strip-debug
0714 else
0715 mod_strip_cmd = $(STRIP) $(INSTALL_MOD_STRIP)
0716 endif # INSTALL_MOD_STRIP=1
0717 else
0718 mod_strip_cmd = true
0719 endif # INSTALL_MOD_STRIP
0720 export mod_strip_cmd
0721 
0722 # Select initial ramdisk compression format, default is gzip(1).
0723 # This shall be used by the dracut(8) tool while creating an initramfs image.
0724 #
0725 INITRD_COMPRESS-y                  := gzip
0726 INITRD_COMPRESS-$(CONFIG_RD_BZIP2) := bzip2
0727 INITRD_COMPRESS-$(CONFIG_RD_LZMA)  := lzma
0728 INITRD_COMPRESS-$(CONFIG_RD_XZ)    := xz
0729 INITRD_COMPRESS-$(CONFIG_RD_LZO)   := lzo
0730 INITRD_COMPRESS-$(CONFIG_RD_LZ4)   := lz4
0731 # do not export INITRD_COMPRESS, since we didn't actually
0732 # choose a sane default compression above.
0733 # export INITRD_COMPRESS := $(INITRD_COMPRESS-y)
0734 
0735 ifdef CONFIG_MODULE_SIG_ALL
0736 MODSECKEY = ./signing_key.priv
0737 MODPUBKEY = ./signing_key.x509
0738 export MODPUBKEY
0739 mod_sign_cmd = perl $(srctree)/scripts/sign-file $(CONFIG_MODULE_SIG_HASH) $(MODSECKEY) $(MODPUBKEY)
0740 else
0741 mod_sign_cmd = true
0742 endif
0743 export mod_sign_cmd
0744 
0745 
0746 ifeq ($(KBUILD_EXTMOD),)
0747 core-y          += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
0748 
0749 vmlinux-dirs    := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
0750                      $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
0751                      $(net-y) $(net-m) $(libs-y) $(libs-m)))
0752 
0753 vmlinux-alldirs := $(sort $(vmlinux-dirs) $(patsubst %/,%,$(filter %/, \
0754                      $(init-n) $(init-) \
0755                      $(core-n) $(core-) $(drivers-n) $(drivers-) \
0756                      $(net-n)  $(net-)  $(libs-n)    $(libs-))))
0757 
0758 init-y          := $(patsubst %/, %/built-in.o, $(init-y))
0759 core-y          := $(patsubst %/, %/built-in.o, $(core-y))
0760 drivers-y       := $(patsubst %/, %/built-in.o, $(drivers-y))
0761 net-y           := $(patsubst %/, %/built-in.o, $(net-y))
0762 libs-y1         := $(patsubst %/, %/lib.a, $(libs-y))
0763 libs-y2         := $(patsubst %/, %/built-in.o, $(libs-y))
0764 libs-y          := $(libs-y1) $(libs-y2)
0765 
0766 # Externally visible symbols (used by link-vmlinux.sh)
0767 export KBUILD_VMLINUX_INIT := $(head-y) $(init-y)
0768 export KBUILD_VMLINUX_MAIN := $(core-y) $(libs-y) $(drivers-y) $(net-y)
0769 export KBUILD_LDS          := arch/$(SRCARCH)/kernel/vmlinux.lds
0770 export LDFLAGS_vmlinux
0771 # used by scripts/pacmage/Makefile
0772 export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Documentation  (KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN)
0773 
0774 # Final link of vmlinux
0775       cmd_link-vmlinux = $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux)
0776 quiet_cmd_link-vmlinux = LINK    $@
0777 
0778 # Include targets which we want to
0779 # execute if the rest of the kernel build went well.
0780 vmlinux: scripts/link-vmlinux.sh $(vmlinux-deps) FORCE
0781 ifdef CONFIG_HEADERS_CHECK
0782         $(Q)$(MAKE) -f $(srctree)/Makefile headers_check
0783 endif
0784 ifdef CONFIG_SAMPLES
0785         $(Q)$(MAKE) $(build)=samples
0786 endif
0787 ifdef CONFIG_BUILD_DOCSRC
0788         $(Q)$(MAKE) $(build)=Documentation
0789 endif
0790         +$(call if_changed,link-vmlinux)
0791 
0792 # The actual objects are generated when descending, 
0793 # make sure no implicit rule kicks in
0794 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
0795 
0796 # Handle descending into subdirectories listed in $(vmlinux-dirs)
0797 # Preset locale variables to speed up the build process. Limit locale
0798 # tweaks to this spot to avoid wrong language settings when running
0799 # make menuconfig etc.
0800 # Error messages still appears in the original language
0801 
0802 PHONY += $(vmlinux-dirs)
0803 $(vmlinux-dirs): prepare scripts
0804         $(Q)$(MAKE) $(build)=$@
0805 
0806 define filechk_kernel.release
0807         echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
0808 endef
0809 
0810 # Store (new) KERNELRELEASE string in include/config/kernel.release
0811 include/config/kernel.release: include/config/auto.conf FORCE
0812         $(call filechk,kernel.release)
0813 
0814 
0815 # Things we need to do before we recursively start building the kernel
0816 # or the modules are listed in "prepare".
0817 # A multi level approach is used. prepareN is processed before prepareN-1.
0818 # archprepare is used in arch Makefiles and when processed asm symlink,
0819 # version.h and scripts_basic is processed / created.
0820 
0821 # Listed in dependency order
0822 PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
0823 
0824 # prepare3 is used to check if we are building in a separate output directory,
0825 # and if so do:
0826 # 1) Check that make has not been executed in the kernel src $(srctree)
0827 prepare3: include/config/kernel.release
0828 ifneq ($(KBUILD_SRC),)
0829         @$(kecho) '  Using $(srctree) as source for kernel'
0830         $(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \
0831                 echo >&2 "  $(srctree) is not clean, please run 'make mrproper'"; \
0832                 echo >&2 "  in the '$(srctree)' directory.";\
0833                 /bin/false; \
0834         fi;
0835 endif
0836 
0837 # prepare2 creates a makefile if using a separate output directory
0838 prepare2: prepare3 outputmakefile asm-generic
0839 
0840 prepare1: prepare2 $(version_h) include/generated/utsrelease.h \
0841                    include/config/auto.conf
0842         $(cmd_crmodverdir)
0843 
0844 archprepare: archheaders archscripts prepare1 scripts_basic
0845 
0846 prepare0: archprepare FORCE
0847         $(Q)$(MAKE) $(build)=.
0848 
0849 # All the preparing..
0850 prepare: prepare0
0851 
0852 # Generate some files
0853 # ---------------------------------------------------------------------------
0854 
0855 # KERNELRELEASE can change from a few different places, meaning version.h
0856 # needs to be updated, so this check is forced on all builds
0857 
0858 uts_len := 64
0859 define filechk_utsrelease.h
0860         if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \
0861           echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2;    \
0862           exit 1;                                                         \
0863         fi;                                                               \
0864         (echo \#define UTS_RELEASE \"$(KERNELRELEASE)\";)
0865 endef
0866 
0867 define filechk_version.h
0868         (echo \#define LINUX_VERSION_CODE $(shell                         \
0869         expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + 0$(SUBLEVEL)); \
0870         echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';)
0871 endef
0872 
0873 $(version_h): $(srctree)/Makefile FORCE
0874         $(call filechk,version.h)
0875 
0876 include/generated/utsrelease.h: include/config/kernel.release FORCE
0877         $(call filechk,utsrelease.h)
0878 
0879 PHONY += headerdep
0880 headerdep:
0881         $(Q)find $(srctree)/include/ -name '*.h' | xargs --max-args 1 \
0882         $(srctree)/scripts/headerdep.pl -I$(srctree)/ @ is unnecessary now.'
0883 
0884 # ---------------------------------------------------------------------------
0885 # Firmware install
0886 INSTALL_FW_PATH=$(INSTALL_MOD_PATH)/lib/firmware
0887 export INSTALL_FW_PATH
0888 
0889 PHONY += firmware_install
0890 firmware_install: FORCE
0891         @mkdir -p $(objtree)/firmware
0892         $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.fwinst obj=firmware __fw_install
0893 
0894 # ---------------------------------------------------------------------------
0895 # Kernel headers
0896 
0897 #Default location for installed headers
0898 export INSTALL_HDR_PATH = $(objtree)/usr
0899 
0900 hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
0901 
0902 # If we do an all arch process set dst to asm-$(hdr-arch)
0903 hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm)
0904 
0905 PHONY += archheaders
0906 archheaders:
0907 
0908 PHONY += archscripts
0909 archscripts:
0910 
0911 PHONY += __headers
0912 __headers: $(version_h) scripts_basic asm-generic archheaders archscripts FORCE
0913         $(Q)$(MAKE) $(build)=scripts build_unifdef
0914 
0915 PHONY += headers_install_all
0916 headers_install_all:
0917         $(Q)$(CONFIG_SHELL) $(srctree)/scripts/headers.sh install
0918 
0919 PHONY += headers_install
0920 headers_install: __headers
0921         $(if $(wildcard $(srctree)/arch/$(hdr-arch)/include/uapi/asm/Kbuild),, \
0922           $(error Headers not exportable for the $(SRCARCH) architecture))
0923         $(Q)$(MAKE) $(hdr-inst)=include/uapi
0924         $(Q)$(MAKE) $(hdr-inst)=arch/$(hdr-arch)/include/uapi/asm $(hdr-dst)
0925 
0926 PHONY += headers_check_all
0927 headers_check_all: headers_install_all
0928         $(Q)$(CONFIG_SHELL) $(srctree)/scripts/headers.sh check
0929 
0930 PHONY += headers_check
0931 headers_check: headers_install
0932         $(Q)$(MAKE) $(hdr-inst)=include/uapi HDRCHECK=1
0933         $(Q)$(MAKE) $(hdr-inst)=arch/$(hdr-arch)/include/uapi/asm $(hdr-dst) HDRCHECK=1
0934 
0935 # ---------------------------------------------------------------------------
0936 # Modules
0937 
0938 ifdef CONFIG_MODULES
0939 
0940 # By default, build modules as well
0941 
0942 all: modules
0943 
0944 #       Build modules
0945 #
0946 #       A module can be listed more than once in obj-m resulting in
0947 #       duplicate lines in modules.order files.  Those are removed
0948 #       using awk while concatenating to the final file.
0949 
0950 PHONY += modules
0951 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
0952         $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
0953         @$(kecho) '  Building modules, stage 2.';
0954         $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
0955         $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.fwinst obj=firmware __fw_modbuild
0956 
0957 modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
0958         $(Q)$(AWK) '!x[$$0]++' $^ > $(objtree)/modules.builtin
0959 
0960 %/modules.builtin: include/config/auto.conf
0961         $(Q)$(MAKE) $(modbuiltin)=$*
0962 
0963 
0964 # Target to prepare building external modules
0965 PHONY += modules_prepare
0966 modules_prepare: prepare scripts
0967 
0968 # Target to install modules
0969 PHONY += modules_install
0970 modules_install: _modinst_ _modinst_post
0971 
0972 PHONY += _modinst_
0973 _modinst_:
0974         @rm -rf $(MODLIB)/kernel
0975         @rm -f $(MODLIB)/source
0976         @mkdir -p $(MODLIB)/kernel
0977         @ln -s $(srctree) $(MODLIB)/source
0978         @if [ ! $(objtree) -ef  $(MODLIB)/build ]; then \
0979                 rm -f $(MODLIB)/build ; \
0980                 ln -s $(objtree) $(MODLIB)/build ; \
0981         fi
0982         @cp -f $(objtree)/modules.order $(MODLIB)/
0983         @cp -f $(objtree)/modules.builtin $(MODLIB)/
0984         $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
0985 
0986 # This depmod is only for convenience to give the initial
0987 # boot a modules.dep even before / is mounted read-write.  However the
0988 # boot script depmod is the master version.
0989 PHONY += _modinst_post
0990 _modinst_post: _modinst_
0991         $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.fwinst obj=firmware __fw_modinst
0992         $(call cmd,depmod)
0993 
0994 ifeq ($(CONFIG_MODULE_SIG), y)
0995 PHONY += modules_sign
0996 modules_sign:
0997         $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modsign
0998 endif
0999 
1000 else # CONFIG_MODULES
1001 
1002 # Modules not configured
1003 # ---------------------------------------------------------------------------
1004 
1005 modules modules_install: FORCE
1006         @echo >&2
1007         @echo >&2 "The present kernel configuration has modules disabled."
1008         @echo >&2 "Type 'make config' and enable loadable module support."
1009         @echo >&2 "Then build a kernel with module support enabled."
1010         @echo >&2
1011         @exit 1
1012 
1013 endif # CONFIG_MODULES
1014 
1015 ###
1016 # Cleaning is done on three levels.
1017 # make clean     Delete most generated files
1018 #                Leave enough to build external modules
1019 # make mrproper  Delete the current configuration, and all generated files
1020 # make distclean Remove editor backup files, patch leftover files and the like
1021 
1022 # Directories & files removed with 'make clean'
1023 CLEAN_DIRS  += $(MODVERDIR)
1024 
1025 # Directories & files removed with 'make mrproper'
1026 MRPROPER_DIRS  += include/config usr/include include/generated          \
1027                   arch/*/include/generated
1028 MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
1029                   Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
1030                   signing_key.priv signing_key.x509 x509.genkey         \
1031                   extra_certificates signing_key.x509.keyid             \
1032                   signing_key.x509.signer
1033 
1034 # clean - Delete most, but leave enough to build external modules
1035 #
1036 clean: rm-dirs  := $(CLEAN_DIRS)
1037 clean: rm-files := $(CLEAN_FILES)
1038 clean-dirs      := $(addprefix _clean_, . $(vmlinux-alldirs) Documentation samples)
1039 
1040 PHONY += $(clean-dirs) clean archclean vmlinuxclean
1041 $(clean-dirs):
1042         $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
1043 
1044 vmlinuxclean:
1045         $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean
1046 
1047 clean: archclean vmlinuxclean
1048 
1049 # mrproper - Delete all generated files, including .config
1050 #
1051 mrproper: rm-dirs  := $(wildcard $(MRPROPER_DIRS))
1052 mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
1053 mrproper-dirs      := $(addprefix _mrproper_,Documentation/DocBook scripts)
1054 
1055 PHONY += $(mrproper-dirs) mrproper archmrproper
1056 $(mrproper-dirs):
1057         $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
1058 
1059 mrproper: clean archmrproper $(mrproper-dirs)
1060         $(call cmd,rmdirs)
1061         $(call cmd,rmfiles)
1062 
1063 # distclean
1064 #
1065 PHONY += distclean
1066 
1067 distclean: mrproper
1068         @find $(srctree) $(RCS_FIND_IGNORE) \
1069                 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
1070                 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
1071                 -o -name '.*.rej' \
1072                 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
1073                 -type f -print | xargs rm -f
1074 
1075 
1076 # Packaging of the kernel to various formats
1077 # ---------------------------------------------------------------------------
1078 # rpm target kept for backward compatibility
1079 package-dir     := $(srctree)/scripts/package
1080 
1081 %src-pkg: FORCE
1082         $(Q)$(MAKE) $(build)=$(package-dir) $@
1083 %pkg: include/config/kernel.release FORCE
1084         $(Q)$(MAKE) $(build)=$(package-dir) $@
1085 rpm: include/config/kernel.release FORCE
1086         $(Q)$(MAKE) $(build)=$(package-dir) $@
1087 
1088 
1089 # Brief documentation of the typical targets used
1090 # ---------------------------------------------------------------------------
1091 
1092 boards := $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*_defconfig)
1093 boards := $(notdir $(boards))
1094 board-dirs := $(dir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*/*_defconfig))
1095 board-dirs := $(sort $(notdir $(board-dirs:/=)))
1096 
1097 help:
1098         @echo  'Cleaning targets:'
1099         @echo  '  clean           - Remove most generated files but keep the config and'
1100         @echo  '                    enough build support to build external modules'
1101         @echo  '  mrproper        - Remove all generated files + config + various backup files'
1102         @echo  '  distclean       - mrproper + remove editor backup and patch files'
1103         @echo  ''
1104         @echo  'Configuration targets:'
1105         @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
1106         @echo  ''
1107         @echo  'Other generic targets:'
1108         @echo  '  all             - Build all targets marked with [*]'
1109         @echo  '* vmlinux         - Build the bare kernel'
1110         @echo  '* modules         - Build all modules'
1111         @echo  '  modules_install - Install all modules to INSTALL_MOD_PATH (default: /)'
1112         @echo  '  firmware_install- Install all firmware to INSTALL_FW_PATH'
1113         @echo  '                    (default: $$(INSTALL_MOD_PATH)/lib/firmware)'
1114         @echo  '  dir/            - Build all files in dir and below'
1115         @echo  '  dir/file.[oisS] - Build specified target only'
1116         @echo  '  dir/file.lst    - Build specified mixed source/assembly target only'
1117         @echo  '                    (requires a recent binutils and recent build (System.map))'
1118         @echo  '  dir/file.ko     - Build module including final link'
1119         @echo  '  modules_prepare - Set up for building external modules'
1120         @echo  '  tags/TAGS       - Generate tags file for editors'
1121         @echo  '  cscope          - Generate cscope index'
1122         @echo  '  gtags           - Generate GNU GLOBAL index'
1123         @echo  '  kernelrelease   - Output the release version string'
1124         @echo  '  kernelversion   - Output the version stored in Makefile'
1125         @echo  '  image_name      - Output the image name'
1126         @echo  '  headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \
1127          echo  '                    (default: $(INSTALL_HDR_PATH))'; \
1128          echo  ''
1129         @echo  'Static analysers'
1130         @echo  '  checkstack      - Generate a list of stack hogs'
1131         @echo  '  namespacecheck  - Name space analysis on compiled kernel'
1132         @echo  '  versioncheck    - Sanity check on version.h usage'
1133         @echo  '  includecheck    - Check for duplicate included header files'
1134         @echo  '  export_report   - List the usages of all exported symbols'
1135         @echo  '  headers_check   - Sanity check on exported headers'
1136         @echo  '  headerdep       - Detect inclusion cycles in headers'
1137         @$(MAKE) -f $(srctree)/scripts/Makefile.help checker-help
1138         @echo  ''
1139         @echo  'Kernel packaging:'
1140         @$(MAKE) $(build)=$(package-dir) help
1141         @echo  ''
1142         @echo  'Documentation targets:'
1143         @$(MAKE) -f $(srctree)/Documentation/DocBook/Makefile dochelp
1144         @echo  ''
1145         @echo  'Architecture specific targets ($(SRCARCH)):'
1146         @$(if $(archhelp),$(archhelp),\
1147                 echo '  No architecture specific help defined for $(SRCARCH)')
1148         @echo  ''
1149         @$(if $(boards), \
1150                 $(foreach b, $(boards), \
1151                 printf "  %-24s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \
1152                 echo '')
1153         @$(if $(board-dirs), \
1154                 $(foreach b, $(board-dirs), \
1155                 printf "  %-16s - Show %s-specific targets\\n" help-$(b) $(b);) \
1156                 printf "  %-16s - Show all of the above\\n" help-boards; \
1157                 echo '')
1158 
1159         @echo  '  make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
1160         @echo  '  make V=2   [targets] 2 => give reason for rebuild of target'
1161         @echo  '  make O=dir [targets] Locate all output files in "dir", including .config'
1162         @echo  '  make C=1   [targets] Check all c source with $$CHECK (sparse by default)'
1163         @echo  '  make C=2   [targets] Force check of all c source with $$CHECK'
1164         @echo  '  make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections'
1165         @echo  '  make W=n   [targets] Enable extra gcc checks, n=1,2,3 where'
1166         @echo  '                1: warnings which may be relevant and do not occur too often'
1167         @echo  '                2: warnings which occur quite often but may still be relevant'
1168         @echo  '                3: more obscure warnings, can most likely be ignored'
1169         @echo  '                Multiple levels can be combined with W=12 or W=123'
1170         @echo  ''
1171         @echo  'Execute "make" or "make all" to build all targets marked with [*] '
1172         @echo  'For further info see the ./README file'
1173 
1174 
1175 help-board-dirs := $(addprefix help-,$(board-dirs))
1176 
1177 help-boards: $(help-board-dirs)
1178 
1179 boards-per-dir = $(notdir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/$*/*_defconfig))
1180 
1181 $(help-board-dirs): help-%:
1182         @echo  'Architecture specific targets ($(SRCARCH) $*):'
1183         @$(if $(boards-per-dir), \
1184                 $(foreach b, $(boards-per-dir), \
1185                 printf "  %-24s - Build for %s\\n" $*/$(b) $(subst _defconfig,,$(b));) \
1186                 echo '')
1187 
1188 
1189 # Documentation targets
1190 # ---------------------------------------------------------------------------
1191 %docs: scripts_basic FORCE
1192         $(Q)$(MAKE) $(build)=scripts build_docproc
1193         $(Q)$(MAKE) $(build)=Documentation/DocBook $@
1194 
1195 else # KBUILD_EXTMOD
1196 
1197 ###
1198 # External module support.
1199 # When building external modules the kernel used as basis is considered
1200 # read-only, and no consistency checks are made and the make
1201 # system is not used on the basis kernel. If updates are required
1202 # in the basis kernel ordinary make commands (without M=...) must
1203 # be used.
1204 #
1205 # The following are the only valid targets when building external
1206 # modules.
1207 # make M=dir clean     Delete all automatically generated files
1208 # make M=dir modules   Make all modules in specified dir
1209 # make M=dir           Same as 'make M=dir modules'
1210 # make M=dir modules_install
1211 #                      Install the modules built in the module directory
1212 #                      Assumes install directory is already created
1213 
1214 # We are always building modules
1215 KBUILD_MODULES := 1
1216 PHONY += crmodverdir
1217 crmodverdir:
1218         $(cmd_crmodverdir)
1219 
1220 PHONY += $(objtree)/Module.symvers
1221 $(objtree)/Module.symvers:
1222         @test -e $(objtree)/Module.symvers || ( \
1223         echo; \
1224         echo "  WARNING: Symbol version dump $(objtree)/Module.symvers"; \
1225         echo "           is missing; modules will have no dependencies and modversions."; \
1226         echo )
1227 
1228 module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD))
1229 PHONY += $(module-dirs) modules
1230 $(module-dirs): crmodverdir $(objtree)/Module.symvers
1231         $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
1232 
1233 modules: $(module-dirs)
1234         @$(kecho) '  Building modules, stage 2.';
1235         $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1236 
1237 PHONY += modules_install
1238 modules_install: _emodinst_ _emodinst_post
1239 
1240 install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra)
1241 PHONY += _emodinst_
1242 _emodinst_:
1243         $(Q)mkdir -p $(MODLIB)/$(install-dir)
1244         $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
1245 
1246 PHONY += _emodinst_post
1247 _emodinst_post: _emodinst_
1248         $(call cmd,depmod)
1249 
1250 clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD))
1251 
1252 PHONY += $(clean-dirs) clean
1253 $(clean-dirs):
1254         $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
1255 
1256 clean:  rm-dirs := $(MODVERDIR)
1257 clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers
1258 
1259 help:
1260         @echo  '  Building external modules.'
1261         @echo  '  Syntax: make -C path/to/kernel/src M=$$PWD target'
1262         @echo  ''
1263         @echo  '  modules         - default target, build the module(s)'
1264         @echo  '  modules_install - install the module'
1265         @echo  '  clean           - remove generated files in module directory only'
1266         @echo  ''
1267 
1268 # Dummies...
1269 PHONY += prepare scripts
1270 prepare: ;
1271 scripts: ;
1272 endif # KBUILD_EXTMOD
1273 
1274 clean: $(clean-dirs)
1275         $(call cmd,rmdirs)
1276         $(call cmd,rmfiles)
1277         @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
1278                 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
1279                 -o -name '*.ko.*' \
1280                 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
1281                 -o -name '*.symtypes' -o -name 'modules.order' \
1282                 -o -name modules.builtin -o -name '.tmp_*.o.*' \
1283                 -o -name '*.gcno' \) -type f -print | xargs rm -f
1284 
1285 # Generate tags for editors
1286 # ---------------------------------------------------------------------------
1287 quiet_cmd_tags = GEN     $@
1288       cmd_tags = $(CONFIG_SHELL) $(srctree)/scripts/tags.sh $@
1289 
1290 tags TAGS cscope gtags: FORCE
1291         $(call cmd,tags)
1292 
1293 # Scripts to check various things for consistency
1294 # ---------------------------------------------------------------------------
1295 
1296 PHONY += includecheck versioncheck coccicheck namespacecheck export_report
1297 
1298 includecheck:
1299         find $(srctree)/* $(RCS_FIND_IGNORE) \
1300                 -name '*.[hcS]' -type f -print | sort \
1301                 | xargs $(PERL) -w $(srctree)/scripts/checkincludes.pl
1302 
1303 versioncheck:
1304         find $(srctree)/* $(RCS_FIND_IGNORE) \
1305                 -name '*.[hcS]' -type f -print | sort \
1306                 | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl
1307 
1308 coccicheck:
1309         $(Q)$(CONFIG_SHELL) $(srctree)/scripts/$@
1310 
1311 namespacecheck:
1312         $(PERL) $(srctree)/scripts/namespace.pl
1313 
1314 export_report:
1315         $(PERL) $(srctree)/scripts/export_report.pl
1316 
1317 endif #ifeq ($(config-targets),1)
1318 endif #ifeq ($(mixed-targets),1)
1319 
1320 PHONY += checkstack kernelrelease kernelversion image_name
1321 
1322 # UML needs a little special treatment here.  It wants to use the host
1323 # toolchain, so needs $(SUBARCH) passed to checkstack.pl.  Everyone
1324 # else wants $(ARCH), including people doing cross-builds, which means
1325 # that $(SUBARCH) doesn't work here.
1326 ifeq ($(ARCH), um)
1327 CHECKSTACK_ARCH := $(SUBARCH)
1328 else
1329 CHECKSTACK_ARCH := $(ARCH)
1330 endif
1331 checkstack:
1332         $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
1333         $(PERL) $(src)/scripts/checkstack.pl $(CHECKSTACK_ARCH)
1334 
1335 kernelrelease:
1336         @echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
1337 
1338 kernelversion:
1339         @echo $(KERNELVERSION)
1340 
1341 image_name:
1342         @echo $(KBUILD_IMAGE)
1343 
1344 # Clear a bunch of variables before executing the submake
1345 tools/: FORCE
1346         $(Q)mkdir -p $(objtree)/tools
1347         $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(filter --j% -j,$(MAKEFLAGS))" O=$(objtree) subdir=tools -C $(src)/tools/
1348 
1349 tools/%: FORCE
1350         $(Q)mkdir -p $(objtree)/tools
1351         $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(filter --j% -j,$(MAKEFLAGS))" O=$(objtree) subdir=tools -C $(src)/tools/ $*
1352 
1353 # Single targets
1354 # ---------------------------------------------------------------------------
1355 # Single targets are compatible with:
1356 # - build with mixed source and output
1357 # - build with separate output dir 'make O=...'
1358 # - external modules
1359 #
1360 #  target-dir => where to store outputfile
1361 #  build-dir  => directory in kernel source tree to use
1362 
1363 ifeq ($(KBUILD_EXTMOD),)
1364         build-dir  = $(patsubst %/,%,$(dir $@))
1365         target-dir = $(dir $@)
1366 else
1367         zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@)))
1368         build-dir  = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash))
1369         target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
1370 endif
1371 
1372 %.s: %.c prepare scripts FORCE
1373         $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1374 %.i: %.c prepare scripts FORCE
1375         $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1376 %.o: %.c prepare scripts FORCE
1377         $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1378 %.lst: %.c prepare scripts FORCE
1379         $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1380 %.s: %.S prepare scripts FORCE
1381         $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1382 %.o: %.S prepare scripts FORCE
1383         $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1384 %.symtypes: %.c prepare scripts FORCE
1385         $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1386 
1387 # Modules
1388 /: prepare scripts FORCE
1389         $(cmd_crmodverdir)
1390         $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
1391         $(build)=$(build-dir)
1392 %/: prepare scripts FORCE
1393         $(cmd_crmodverdir)
1394         $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
1395         $(build)=$(build-dir)
1396 %.ko: prepare scripts FORCE
1397         $(cmd_crmodverdir)
1398         $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1)   \
1399         $(build)=$(build-dir) $(@:.ko=.o)
1400         $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1401 
1402 # FIXME Should go into a make.lib or something 
1403 # ===========================================================================
1404 
1405 quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN   $(wildcard $(rm-dirs)))
1406       cmd_rmdirs = rm -rf $(rm-dirs)
1407 
1408 quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN   $(wildcard $(rm-files)))
1409       cmd_rmfiles = rm -f $(rm-files)
1410 
1411 # Run depmod only if we have System.map and depmod is executable
1412 quiet_cmd_depmod = DEPMOD  $(KERNELRELEASE)
1413       cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \
1414                    $(KERNELRELEASE) "$(patsubst y,_,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX))"
1415 
1416 # Create temporary dir for module support files
1417 # clean it up only when building all modules
1418 cmd_crmodverdir = $(Q)mkdir -p $(MODVERDIR) \
1419                   $(if $(KBUILD_MODULES),; rm -f $(MODVERDIR)/*)
1420 
1421 # read all saved command lines
1422 
1423 targets := $(wildcard $(sort $(targets)))
1424 cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
1425 
1426 ifneq ($(cmd_files),)
1427   $(cmd_files): ;       # Do not try to update included dependency files
1428   (cmd_files)
1429 endif
1430 
1431 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir
1432 # Usage:
1433 # $(Q)$(MAKE) $(clean)=dir
1434 clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
1435 
1436 endif   # skip-makefile
1437 
1438 PHONY += FORCE
1439 FORCE:
1440 
1441 # Declare the contents of the .PHONY variable as phony.  We keep that
1442 # information in a variable so we can use it in if_changed and friends.
1443 .PHONY: $(PHONY)