aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile224
1 files changed, 127 insertions, 97 deletions
diff --git a/Makefile b/Makefile
index 1700d3f6ea22..4dcf25d43fa6 100644
--- a/Makefile
+++ b/Makefile
@@ -41,8 +41,9 @@ ifndef KBUILD_VERBOSE
41 KBUILD_VERBOSE = 0 41 KBUILD_VERBOSE = 0
42endif 42endif
43 43
44# Call sparse as part of compilation of C files 44# Call checker as part of compilation of C files
45# Use 'make C=1' to enable sparse checking 45# Use 'make C=1' to enable checking (sparse, by default)
46# Override with 'make C=1 CHECK=checker_executable CHECKFLAGS=....'
46 47
47ifdef C 48ifdef C
48 ifeq ("$(origin C)", "command line") 49 ifeq ("$(origin C)", "command line")
@@ -71,7 +72,7 @@ endif
71# In both cases the working directory must be the root of the kernel src. 72# In both cases the working directory must be the root of the kernel src.
72# 1) O= 73# 1) O=
73# Use "make O=dir/to/store/output/files/" 74# Use "make O=dir/to/store/output/files/"
74# 75#
75# 2) Set KBUILD_OUTPUT 76# 2) Set KBUILD_OUTPUT
76# Set the environment variable KBUILD_OUTPUT to point to the directory 77# Set the environment variable KBUILD_OUTPUT to point to the directory
77# where the output files shall be placed. 78# where the output files shall be placed.
@@ -178,18 +179,20 @@ CROSS_COMPILE ?=
178# Architecture as present in compile.h 179# Architecture as present in compile.h
179UTS_MACHINE := $(ARCH) 180UTS_MACHINE := $(ARCH)
180 181
182KCONFIG_CONFIG ?= .config
183
181# SHELL used by kbuild 184# SHELL used by kbuild
182CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ 185CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
183 else if [ -x /bin/bash ]; then echo /bin/bash; \ 186 else if [ -x /bin/bash ]; then echo /bin/bash; \
184 else echo sh; fi ; fi) 187 else echo sh; fi ; fi)
185 188
186HOSTCC = gcc 189HOSTCC = gcc
187HOSTCXX = g++ 190HOSTCXX = g++
188HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer 191HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
189HOSTCXXFLAGS = -O2 192HOSTCXXFLAGS = -O2
190 193
191# Decide whether to build built-in, modular, or both. 194# Decide whether to build built-in, modular, or both.
192# Normally, just do built-in. 195# Normally, just do built-in.
193 196
194KBUILD_MODULES := 197KBUILD_MODULES :=
195KBUILD_BUILTIN := 1 198KBUILD_BUILTIN := 1
@@ -197,7 +200,7 @@ KBUILD_BUILTIN := 1
197# If we have only "make modules", don't compile built-in objects. 200# If we have only "make modules", don't compile built-in objects.
198# When we're building modules with modversions, we need to consider 201# When we're building modules with modversions, we need to consider
199# the built-in objects during the descend as well, in order to 202# the built-in objects during the descend as well, in order to
200# make sure the checksums are uptodate before we record them. 203# make sure the checksums are up to date before we record them.
201 204
202ifeq ($(MAKECMDGOALS),modules) 205ifeq ($(MAKECMDGOALS),modules)
203 KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1) 206 KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1)
@@ -230,7 +233,7 @@ export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD
230# 233#
231# If $(quiet) is empty, the whole command will be printed. 234# If $(quiet) is empty, the whole command will be printed.
232# If it is set to "quiet_", only the short version will be printed. 235# If it is set to "quiet_", only the short version will be printed.
233# If it is set to "silent_", nothing wil be printed at all, since 236# If it is set to "silent_", nothing will be printed at all, since
234# the variable $(silent_cmd_cc_o_c) doesn't exist. 237# the variable $(silent_cmd_cc_o_c) doesn't exist.
235# 238#
236# A simple variant is to prefix commands with $(Q) - that's useful 239# A simple variant is to prefix commands with $(Q) - that's useful
@@ -265,10 +268,9 @@ MAKEFLAGS += --include-dir=$(srctree)
265# We need some generic definitions 268# We need some generic definitions
266include $(srctree)/scripts/Kbuild.include 269include $(srctree)/scripts/Kbuild.include
267 270
268# For maximum performance (+ possibly random breakage, uncomment 271# Do not use make's built-in rules and variables
269# the following) 272# This increases performance and avoid hard-to-debug behavour
270 273MAKEFLAGS += -rR
271#MAKEFLAGS += -rR
272 274
273# Make variables (CC, etc...) 275# Make variables (CC, etc...)
274 276
@@ -305,21 +307,21 @@ LINUXINCLUDE := -Iinclude \
305 307
306CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE) 308CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE)
307 309
308CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ 310CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
309 -fno-strict-aliasing -fno-common 311 -fno-strict-aliasing -fno-common
310AFLAGS := -D__ASSEMBLY__ 312AFLAGS := -D__ASSEMBLY__
311 313
312# Read KERNELRELEASE from .kernelrelease (if it exists) 314# Read KERNELRELEASE from include/config/kernel.release (if it exists)
313KERNELRELEASE = $(shell cat .kernelrelease 2> /dev/null) 315KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
314KERNELVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) 316KERNELVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
315 317
316export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION \ 318export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
317 ARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \ 319export ARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC
318 CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE \ 320export CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE
319 HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS 321export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
320 322
321export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS 323export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
322export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE 324export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
323export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE 325export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
324 326
325# When compiling out-of-tree modules, put MODVERDIR in the module 327# When compiling out-of-tree modules, put MODVERDIR in the module
@@ -357,12 +359,13 @@ endif
357# catch them early, and hand them over to scripts/kconfig/Makefile 359# catch them early, and hand them over to scripts/kconfig/Makefile
358# It is allowed to specify more targets when calling make, including 360# It is allowed to specify more targets when calling make, including
359# mixing *config targets and build targets. 361# mixing *config targets and build targets.
360# For example 'make oldconfig all'. 362# For example 'make oldconfig all'.
361# Detect when mixed targets is specified, and make a second invocation 363# Detect when mixed targets is specified, and make a second invocation
362# of make so .config is not included in this case either (for *config). 364# of make so .config is not included in this case either (for *config).
363 365
364no-dot-config-targets := clean mrproper distclean \ 366no-dot-config-targets := clean mrproper distclean \
365 cscope TAGS tags help %docs check% 367 cscope TAGS tags help %docs check% \
368 kernelrelease kernelversion
366 369
367config-targets := 0 370config-targets := 0
368mixed-targets := 0 371mixed-targets := 0
@@ -404,9 +407,8 @@ include $(srctree)/arch/$(ARCH)/Makefile
404export KBUILD_DEFCONFIG 407export KBUILD_DEFCONFIG
405 408
406config %config: scripts_basic outputmakefile FORCE 409config %config: scripts_basic outputmakefile FORCE
407 $(Q)mkdir -p include/linux 410 $(Q)mkdir -p include/linux include/config
408 $(Q)$(MAKE) $(build)=scripts/kconfig $@ 411 $(Q)$(MAKE) $(build)=scripts/kconfig $@
409 $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= .kernelrelease
410 412
411else 413else
412# =========================================================================== 414# ===========================================================================
@@ -416,13 +418,11 @@ else
416ifeq ($(KBUILD_EXTMOD),) 418ifeq ($(KBUILD_EXTMOD),)
417# Additional helpers built in scripts/ 419# Additional helpers built in scripts/
418# Carefully list dependencies so we do not try to build scripts twice 420# Carefully list dependencies so we do not try to build scripts twice
419# in parrallel 421# in parallel
420PHONY += scripts 422PHONY += scripts
421scripts: scripts_basic include/config/MARKER 423scripts: scripts_basic include/config/auto.conf
422 $(Q)$(MAKE) $(build)=$(@) 424 $(Q)$(MAKE) $(build)=$(@)
423 425
424scripts_basic: include/linux/autoconf.h
425
426# Objects we will link into vmlinux / subdirs we need to visit 426# Objects we will link into vmlinux / subdirs we need to visit
427init-y := init/ 427init-y := init/
428drivers-y := drivers/ sound/ 428drivers-y := drivers/ sound/
@@ -436,31 +436,32 @@ ifeq ($(dot-config),1)
436 436
437# Read in dependencies to all Kconfig* files, make sure to run 437# Read in dependencies to all Kconfig* files, make sure to run
438# oldconfig if changes are detected. 438# oldconfig if changes are detected.
439-include .kconfig.d 439-include include/config/auto.conf.cmd
440-include include/config/auto.conf
440 441
441include .config
442
443# If .config needs to be updated, it will be done via the dependency
444# that autoconf has on .config.
445# To avoid any implicit rule to kick in, define an empty command 442# To avoid any implicit rule to kick in, define an empty command
446.config .kconfig.d: ; 443$(KCONFIG_CONFIG) include/config/auto.conf.cmd: ;
447 444
448# If .config is newer than include/linux/autoconf.h, someone tinkered 445# If .config is newer than include/config/auto.conf, someone tinkered
449# with it and forgot to run make oldconfig. 446# with it and forgot to run make oldconfig.
450# If kconfig.d is missing then we are probarly in a cleaned tree so 447# if auto.conf.cmd is missing then we are probably in a cleaned tree so
451# we execute the config step to be sure to catch updated Kconfig files 448# we execute the config step to be sure to catch updated Kconfig files
452include/linux/autoconf.h: .kconfig.d .config 449include/config/auto.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
453 $(Q)mkdir -p include/linux 450ifeq ($(KBUILD_EXTMOD),)
454 $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig 451 $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
455else 452else
453 $(error kernel configuration not valid - run 'make prepare' in $(srctree) to update it)
454endif
455
456else
456# Dummy target needed, because used as prerequisite 457# Dummy target needed, because used as prerequisite
457include/linux/autoconf.h: ; 458include/config/auto.conf: ;
458endif 459endif
459 460
460# The all: target is the default when no target is given on the 461# The all: target is the default when no target is given on the
461# command line. 462# command line.
462# This allow a user to issue only 'make' to build a kernel including modules 463# This allow a user to issue only 'make' to build a kernel including modules
463# Defaults vmlinux but it is usually overriden in the arch makefile 464# Defaults vmlinux but it is usually overridden in the arch makefile
464all: vmlinux 465all: vmlinux
465 466
466ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE 467ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
@@ -492,11 +493,11 @@ CHECKFLAGS += $(NOSTDINC_FLAGS)
492# warn about C99 declaration after statement 493# warn about C99 declaration after statement
493CFLAGS += $(call cc-option,-Wdeclaration-after-statement,) 494CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
494 495
495# disable pointer signedness warnings in gcc 4.0 496# disable pointer signed / unsigned warnings in gcc 4.0
496CFLAGS += $(call cc-option,-Wno-pointer-sign,) 497CFLAGS += $(call cc-option,-Wno-pointer-sign,)
497 498
498# Default kernel image to build when no specific target is given. 499# Default kernel image to build when no specific target is given.
499# KBUILD_IMAGE may be overruled on the commandline or 500# KBUILD_IMAGE may be overruled on the command line or
500# set in the environment 501# set in the environment
501# Also any assignments in arch/$(ARCH)/Makefile take precedence over 502# Also any assignments in arch/$(ARCH)/Makefile take precedence over
502# this default value 503# this default value
@@ -510,12 +511,29 @@ export INSTALL_PATH ?= /boot
510# 511#
511# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory 512# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
512# relocations required by build roots. This is not defined in the 513# relocations required by build roots. This is not defined in the
513# makefile but the arguement can be passed to make if needed. 514# makefile but the argument can be passed to make if needed.
514# 515#
515 516
516MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE) 517MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
517export MODLIB 518export MODLIB
518 519
520#
521# INSTALL_MOD_STRIP, if defined, will cause modules to be
522# stripped after they are installed. If INSTALL_MOD_STRIP is '1', then
523# the default option --strip-debug will be used. Otherwise,
524# INSTALL_MOD_STRIP will used as the options to the strip command.
525
526ifdef INSTALL_MOD_STRIP
527ifeq ($(INSTALL_MOD_STRIP),1)
528mod_strip_cmd = $STRIP) --strip-debug
529else
530mod_strip_cmd = $(STRIP) $(INSTALL_MOD_STRIP)
531endif # INSTALL_MOD_STRIP=1
532else
533mod_strip_cmd = true
534endif # INSTALL_MOD_STRIP
535export mod_strip_cmd
536
519 537
520ifeq ($(KBUILD_EXTMOD),) 538ifeq ($(KBUILD_EXTMOD),)
521core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ 539core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
@@ -539,7 +557,7 @@ libs-y := $(libs-y1) $(libs-y2)
539 557
540# Build vmlinux 558# Build vmlinux
541# --------------------------------------------------------------------------- 559# ---------------------------------------------------------------------------
542# vmlinux is build from the objects selected by $(vmlinux-init) and 560# vmlinux is built from the objects selected by $(vmlinux-init) and
543# $(vmlinux-main). Most are built-in.o files from top-level directories 561# $(vmlinux-main). Most are built-in.o files from top-level directories
544# in the kernel tree, others are specified in arch/$(ARCH)Makefile. 562# in the kernel tree, others are specified in arch/$(ARCH)Makefile.
545# Ordering when linking is important, and $(vmlinux-init) must be first. 563# Ordering when linking is important, and $(vmlinux-init) must be first.
@@ -590,7 +608,7 @@ quiet_cmd_vmlinux_version = GEN .version
590 $(MAKE) $(build)=init 608 $(MAKE) $(build)=init
591 609
592# Generate System.map 610# Generate System.map
593quiet_cmd_sysmap = SYSMAP 611quiet_cmd_sysmap = SYSMAP
594 cmd_sysmap = $(CONFIG_SHELL) $(srctree)/scripts/mksysmap 612 cmd_sysmap = $(CONFIG_SHELL) $(srctree)/scripts/mksysmap
595 613
596# Link of vmlinux 614# Link of vmlinux
@@ -719,7 +737,7 @@ $(vmlinux-dirs): prepare scripts
719 $(Q)$(MAKE) $(build)=$@ 737 $(Q)$(MAKE) $(build)=$@
720 738
721# Build the kernel release string 739# Build the kernel release string
722# The KERNELRELEASE is stored in a file named .kernelrelease 740# The KERNELRELEASE is stored in a file named include/config/kernel.release
723# to be used when executing for example make install or make modules_install 741# to be used when executing for example make install or make modules_install
724# 742#
725# Take the contents of any files called localversion* and the config 743# Take the contents of any files called localversion* and the config
@@ -737,10 +755,10 @@ _localver = $(foreach f, $(__localver), $(if $(findstring ~, $(f)),,$(f)))
737localver = $(subst $(space),, \ 755localver = $(subst $(space),, \
738 $(shell cat /dev/null $(_localver)) \ 756 $(shell cat /dev/null $(_localver)) \
739 $(patsubst "%",%,$(CONFIG_LOCALVERSION))) 757 $(patsubst "%",%,$(CONFIG_LOCALVERSION)))
740 758
741# If CONFIG_LOCALVERSION_AUTO is set scripts/setlocalversion is called 759# If CONFIG_LOCALVERSION_AUTO is set scripts/setlocalversion is called
742# and if the SCM is know a tag from the SCM is appended. 760# and if the SCM is know a tag from the SCM is appended.
743# The appended tag is determinded by the SCM used. 761# The appended tag is determined by the SCM used.
744# 762#
745# Currently, only git is supported. 763# Currently, only git is supported.
746# Other SCMs can edit scripts/setlocalversion and add the appropriate 764# Other SCMs can edit scripts/setlocalversion and add the appropriate
@@ -753,9 +771,9 @@ endif
753 771
754localver-full = $(localver)$(localver-auto) 772localver-full = $(localver)$(localver-auto)
755 773
756# Store (new) KERNELRELASE string in .kernelrelease 774# Store (new) KERNELRELASE string in include/config/kernel.release
757kernelrelease = $(KERNELVERSION)$(localver-full) 775kernelrelease = $(KERNELVERSION)$(localver-full)
758.kernelrelease: FORCE 776include/config/kernel.release: include/config/auto.conf FORCE
759 $(Q)rm -f $@ 777 $(Q)rm -f $@
760 $(Q)echo $(kernelrelease) > $@ 778 $(Q)echo $(kernelrelease) > $@
761 779
@@ -776,10 +794,10 @@ PHONY += prepare-all
776# and if so do: 794# and if so do:
777# 1) Check that make has not been executed in the kernel src $(srctree) 795# 1) Check that make has not been executed in the kernel src $(srctree)
778# 2) Create the include2 directory, used for the second asm symlink 796# 2) Create the include2 directory, used for the second asm symlink
779prepare3: .kernelrelease 797prepare3: include/config/kernel.release
780ifneq ($(KBUILD_SRC),) 798ifneq ($(KBUILD_SRC),)
781 @echo ' Using $(srctree) as source for kernel' 799 @echo ' Using $(srctree) as source for kernel'
782 $(Q)if [ -f $(srctree)/.config ]; then \ 800 $(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \
783 echo " $(srctree) is not clean, please run 'make mrproper'";\ 801 echo " $(srctree) is not clean, please run 'make mrproper'";\
784 echo " in the '$(srctree)' directory.";\ 802 echo " in the '$(srctree)' directory.";\
785 /bin/false; \ 803 /bin/false; \
@@ -792,7 +810,7 @@ endif
792prepare2: prepare3 outputmakefile 810prepare2: prepare3 outputmakefile
793 811
794prepare1: prepare2 include/linux/version.h include/asm \ 812prepare1: prepare2 include/linux/version.h include/asm \
795 include/config/MARKER 813 include/config/auto.conf
796ifneq ($(KBUILD_MODULES),) 814ifneq ($(KBUILD_MODULES),)
797 $(Q)mkdir -p $(MODVERDIR) 815 $(Q)mkdir -p $(MODVERDIR)
798 $(Q)rm -f $(MODVERDIR)/* 816 $(Q)rm -f $(MODVERDIR)/*
@@ -806,27 +824,20 @@ prepare0: archprepare FORCE
806# All the preparing.. 824# All the preparing..
807prepare prepare-all: prepare0 825prepare prepare-all: prepare0
808 826
809# Leave this as default for preprocessing vmlinux.lds.S, which is now 827# Leave this as default for preprocessing vmlinux.lds.S, which is now
810# done in arch/$(ARCH)/kernel/Makefile 828# done in arch/$(ARCH)/kernel/Makefile
811 829
812export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH) 830export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH)
813 831
814# FIXME: The asm symlink changes when $(ARCH) changes. That's 832# FIXME: The asm symlink changes when $(ARCH) changes. That's
815# hard to detect, but I suppose "make mrproper" is a good idea 833# hard to detect, but I suppose "make mrproper" is a good idea
816# before switching between archs anyway. 834# before switching between archs anyway.
817 835
818include/asm: 836include/asm:
819 @echo ' SYMLINK $@ -> include/asm-$(ARCH)' 837 @echo ' SYMLINK $@ -> include/asm-$(ARCH)'
820 $(Q)if [ ! -d include ]; then mkdir -p include; fi; 838 $(Q)if [ ! -d include ]; then mkdir -p include; fi;
821 @ln -fsn asm-$(ARCH) $@ 839 @ln -fsn asm-$(ARCH) $@
822 840
823# Split autoconf.h into include/linux/config/*
824
825include/config/MARKER: scripts/basic/split-include include/linux/autoconf.h
826 @echo ' SPLIT include/linux/autoconf.h -> include/config/*'
827 @scripts/basic/split-include include/linux/autoconf.h include/config
828 @touch $@
829
830# Generate some files 841# Generate some files
831# --------------------------------------------------------------------------- 842# ---------------------------------------------------------------------------
832 843
@@ -846,7 +857,7 @@ define filechk_version.h
846 ) 857 )
847endef 858endef
848 859
849include/linux/version.h: $(srctree)/Makefile .config .kernelrelease FORCE 860include/linux/version.h: $(srctree)/Makefile include/config/kernel.release FORCE
850 $(call filechk,version.h) 861 $(call filechk,version.h)
851 862
852# --------------------------------------------------------------------------- 863# ---------------------------------------------------------------------------
@@ -860,7 +871,7 @@ depend dep:
860 871
861ifdef CONFIG_MODULES 872ifdef CONFIG_MODULES
862 873
863# By default, build modules as well 874# By default, build modules as well
864 875
865all: modules 876all: modules
866 877
@@ -942,7 +953,7 @@ CLEAN_FILES += vmlinux System.map \
942MRPROPER_DIRS += include/config include2 953MRPROPER_DIRS += include/config include2
943MRPROPER_FILES += .config .config.old include/asm .version .old_version \ 954MRPROPER_FILES += .config .config.old include/asm .version .old_version \
944 include/linux/autoconf.h include/linux/version.h \ 955 include/linux/autoconf.h include/linux/version.h \
945 .kernelrelease Module.symvers tags TAGS cscope* 956 Module.symvers tags TAGS cscope*
946 957
947# clean - Delete most, but leave enough to build external modules 958# clean - Delete most, but leave enough to build external modules
948# 959#
@@ -958,8 +969,9 @@ clean: archclean $(clean-dirs)
958 $(call cmd,rmdirs) 969 $(call cmd,rmdirs)
959 $(call cmd,rmfiles) 970 $(call cmd,rmfiles)
960 @find . $(RCS_FIND_IGNORE) \ 971 @find . $(RCS_FIND_IGNORE) \
961 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ 972 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
962 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \ 973 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
974 -o -name '*.symtypes' \) \
963 -type f -print | xargs rm -f 975 -type f -print | xargs rm -f
964 976
965# mrproper - Delete all generated files, including .config 977# mrproper - Delete all generated files, including .config
@@ -982,9 +994,9 @@ PHONY += distclean
982 994
983distclean: mrproper 995distclean: mrproper
984 @find $(srctree) $(RCS_FIND_IGNORE) \ 996 @find $(srctree) $(RCS_FIND_IGNORE) \
985 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ 997 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
986 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ 998 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
987 -o -name '.*.rej' -o -size 0 \ 999 -o -name '.*.rej' -o -size 0 \
988 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \ 1000 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
989 -type f -print | xargs rm -f 1001 -type f -print | xargs rm -f
990 1002
@@ -994,9 +1006,9 @@ distclean: mrproper
994# rpm target kept for backward compatibility 1006# rpm target kept for backward compatibility
995package-dir := $(srctree)/scripts/package 1007package-dir := $(srctree)/scripts/package
996 1008
997%pkg: FORCE 1009%pkg: include/config/kernel.release FORCE
998 $(Q)$(MAKE) $(build)=$(package-dir) $@ 1010 $(Q)$(MAKE) $(build)=$(package-dir) $@
999rpm: FORCE 1011rpm: include/config/kernel.release FORCE
1000 $(Q)$(MAKE) $(build)=$(package-dir) $@ 1012 $(Q)$(MAKE) $(build)=$(package-dir) $@
1001 1013
1002 1014
@@ -1049,8 +1061,8 @@ help:
1049 1061
1050 @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build' 1062 @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
1051 @echo ' make O=dir [targets] Locate all output files in "dir", including .config' 1063 @echo ' make O=dir [targets] Locate all output files in "dir", including .config'
1052 @echo ' make C=1 [targets] Check all c source with $$CHECK (sparse)' 1064 @echo ' make C=1 [targets] Check all c source with $$CHECK (sparse by default)'
1053 @echo ' make C=2 [targets] Force check of all c source with $$CHECK (sparse)' 1065 @echo ' make C=2 [targets] Force check of all c source with $$CHECK'
1054 @echo '' 1066 @echo ''
1055 @echo 'Execute "make" or "make all" to build all targets marked with [*] ' 1067 @echo 'Execute "make" or "make all" to build all targets marked with [*] '
1056 @echo 'For further info see the ./README file' 1068 @echo 'For further info see the ./README file'
@@ -1077,7 +1089,7 @@ else # KBUILD_EXTMOD
1077# make M=dir modules Make all modules in specified dir 1089# make M=dir modules Make all modules in specified dir
1078# make M=dir Same as 'make M=dir modules' 1090# make M=dir Same as 'make M=dir modules'
1079# make M=dir modules_install 1091# make M=dir modules_install
1080# Install the modules build in the module directory 1092# Install the modules built in the module directory
1081# Assumes install directory is already created 1093# Assumes install directory is already created
1082 1094
1083# We are always building modules 1095# We are always building modules
@@ -1136,7 +1148,7 @@ clean: rm-dirs := $(MODVERDIR)
1136clean: $(clean-dirs) 1148clean: $(clean-dirs)
1137 $(call cmd,rmdirs) 1149 $(call cmd,rmdirs)
1138 @find $(KBUILD_EXTMOD) $(RCS_FIND_IGNORE) \ 1150 @find $(KBUILD_EXTMOD) $(RCS_FIND_IGNORE) \
1139 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ 1151 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
1140 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \ 1152 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \
1141 -type f -print | xargs rm -f 1153 -type f -print | xargs rm -f
1142 1154
@@ -1175,31 +1187,41 @@ else
1175ALLINCLUDE_ARCHS := $(ARCH) 1187ALLINCLUDE_ARCHS := $(ARCH)
1176endif 1188endif
1177else 1189else
1178#Allow user to specify only ALLSOURCE_PATHS on the command line, keeping existing behaviour. 1190#Allow user to specify only ALLSOURCE_PATHS on the command line, keeping existing behavour.
1179ALLINCLUDE_ARCHS := $(ALLSOURCE_ARCHS) 1191ALLINCLUDE_ARCHS := $(ALLSOURCE_ARCHS)
1180endif 1192endif
1181 1193
1182ALLSOURCE_ARCHS := $(ARCH) 1194ALLSOURCE_ARCHS := $(ARCH)
1183 1195
1184define all-sources 1196define find-sources
1185 ( find $(__srctree) $(RCS_FIND_IGNORE) \ 1197 ( find $(__srctree) $(RCS_FIND_IGNORE) \
1186 \( -name include -o -name arch \) -prune -o \ 1198 \( -name include -o -name arch \) -prune -o \
1187 -name '*.[chS]' -print; \ 1199 -name $1 -print; \
1188 for ARCH in $(ALLSOURCE_ARCHS) ; do \ 1200 for ARCH in $(ALLSOURCE_ARCHS) ; do \
1189 find $(__srctree)arch/$${ARCH} $(RCS_FIND_IGNORE) \ 1201 find $(__srctree)arch/$${ARCH} $(RCS_FIND_IGNORE) \
1190 -name '*.[chS]' -print; \ 1202 -name $1 -print; \
1191 done ; \ 1203 done ; \
1192 find $(__srctree)security/selinux/include $(RCS_FIND_IGNORE) \ 1204 find $(__srctree)security/selinux/include $(RCS_FIND_IGNORE) \
1193 -name '*.[chS]' -print; \ 1205 -name $1 -print; \
1194 find $(__srctree)include $(RCS_FIND_IGNORE) \ 1206 find $(__srctree)include $(RCS_FIND_IGNORE) \
1195 \( -name config -o -name 'asm-*' \) -prune \ 1207 \( -name config -o -name 'asm-*' \) -prune \
1196 -o -name '*.[chS]' -print; \ 1208 -o -name $1 -print; \
1197 for ARCH in $(ALLINCLUDE_ARCHS) ; do \ 1209 for ARCH in $(ALLINCLUDE_ARCHS) ; do \
1198 find $(__srctree)include/asm-$${ARCH} $(RCS_FIND_IGNORE) \ 1210 find $(__srctree)include/asm-$${ARCH} $(RCS_FIND_IGNORE) \
1199 -name '*.[chS]' -print; \ 1211 -name $1 -print; \
1200 done ; \ 1212 done ; \
1201 find $(__srctree)include/asm-generic $(RCS_FIND_IGNORE) \ 1213 find $(__srctree)include/asm-generic $(RCS_FIND_IGNORE) \
1202 -name '*.[chS]' -print ) 1214 -name $1 -print )
1215endef
1216
1217define all-sources
1218 $(call find-sources,'*.[chS]')
1219endef
1220define all-kconfigs
1221 $(call find-sources,'Kconfig*')
1222endef
1223define all-defconfigs
1224 $(call find-sources,'defconfig')
1203endef 1225endef
1204 1226
1205quiet_cmd_cscope-file = FILELST cscope.files 1227quiet_cmd_cscope-file = FILELST cscope.files
@@ -1219,7 +1241,13 @@ define cmd_TAGS
1219 echo "-I __initdata,__exitdata,__acquires,__releases \ 1241 echo "-I __initdata,__exitdata,__acquires,__releases \
1220 -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ 1242 -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \
1221 --extra=+f --c-kinds=+px"`; \ 1243 --extra=+f --c-kinds=+px"`; \
1222 $(all-sources) | xargs etags $$ETAGSF -a 1244 $(all-sources) | xargs etags $$ETAGSF -a; \
1245 if test "x$$ETAGSF" = x; then \
1246 $(all-kconfigs) | xargs etags -a \
1247 --regex='/^config[ \t]+\([a-zA-Z0-9_]+\)/\1/'; \
1248 $(all-defconfigs) | xargs etags -a \
1249 --regex='/^#?[ \t]?\(CONFIG_[a-zA-Z0-9_]+\)/\1/'; \
1250 fi
1223endef 1251endef
1224 1252
1225TAGS: FORCE 1253TAGS: FORCE
@@ -1259,14 +1287,14 @@ namespacecheck:
1259endif #ifeq ($(config-targets),1) 1287endif #ifeq ($(config-targets),1)
1260endif #ifeq ($(mixed-targets),1) 1288endif #ifeq ($(mixed-targets),1)
1261 1289
1262PHONY += checkstack 1290PHONY += checkstack kernelrelease kernelversion
1263checkstack: 1291checkstack:
1264 $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \ 1292 $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
1265 $(PERL) $(src)/scripts/checkstack.pl $(ARCH) 1293 $(PERL) $(src)/scripts/checkstack.pl $(ARCH)
1266 1294
1267kernelrelease: 1295kernelrelease:
1268 $(if $(wildcard .kernelrelease), $(Q)echo $(KERNELRELEASE), \ 1296 $(if $(wildcard include/config/kernel.release), $(Q)echo $(KERNELRELEASE), \
1269 $(error kernelrelease not valid - run 'make *config' to update it)) 1297 $(error kernelrelease not valid - run 'make prepare' to update it))
1270kernelversion: 1298kernelversion:
1271 @echo $(KERNELVERSION) 1299 @echo $(KERNELVERSION)
1272 1300
@@ -1301,6 +1329,8 @@ endif
1301 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1329 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1302%.o: %.S prepare scripts FORCE 1330%.o: %.S prepare scripts FORCE
1303 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1331 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1332%.symtypes: %.c prepare scripts FORCE
1333 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1304 1334
1305# Modules 1335# Modules
1306/ %/: prepare scripts FORCE 1336/ %/: prepare scripts FORCE
@@ -1323,7 +1353,7 @@ quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))
1323 1353
1324a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(AFLAGS_KERNEL) \ 1354a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(AFLAGS_KERNEL) \
1325 $(NOSTDINC_FLAGS) $(CPPFLAGS) \ 1355 $(NOSTDINC_FLAGS) $(CPPFLAGS) \
1326 $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o) 1356 $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o)
1327 1357
1328quiet_cmd_as_o_S = AS $@ 1358quiet_cmd_as_o_S = AS $@
1329cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< 1359cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<