Linus TorvaldsLinux v2.6.17427abfa20 years agoHistory
1354 lines · 43.6 KB · Makefile
RawDownload
VERSION = 2PATCHLEVEL = 6SUBLEVEL = 17EXTRAVERSION =NAME=Crazed Snow-Weasel # *DOCUMENTATION*# To see a list of typical targets execute "make help"# More info can be located in ./README# Comments in this file are targeted only to the developer, do not# expect to learn how to build the kernel reading this file. # Do not print "Entering directory ..."MAKEFLAGS += --no-print-directory # We are using a recursive build, so we need to do a little thinking# to get the ordering right.## Most importantly: sub-Makefiles should only ever modify files in# their own directory. If in some directory we have a dependency on# a file in another dir (which doesn't happen often, but it's often# unavoidable when linking the built-in.o targets which finally# turn into vmlinux), we will call a sub make in that other dir, and# after that we are sure that everything which is in that other dir# is now up to date.## The only cases where we need to modify files which have global# effects are thus separated out and done before the recursive# descending is started. They are now explicitly listed as the# prepare rule. # To put more focus on warnings, be less verbose as default# Use 'make V=1' to see the full commands ifdef V  ifeq ("$(origin V)", "command line")    KBUILD_VERBOSE = $(V)  endifendififndef KBUILD_VERBOSE  KBUILD_VERBOSE = 0endif # Call sparse as part of compilation of C files# Use 'make C=1' to enable sparse checking ifdef C  ifeq ("$(origin C)", "command line")    KBUILD_CHECKSRC = $(C)  endifendififndef KBUILD_CHECKSRC  KBUILD_CHECKSRC = 0endif # Use make M=dir to specify directory of external module to build# Old syntax make ... SUBDIRS=$PWD is still supported# Setting the environment variable KBUILD_EXTMOD take precedenceifdef SUBDIRS  KBUILD_EXTMOD ?= $(SUBDIRS)endififdef M  ifeq ("$(origin M)", "command line")    KBUILD_EXTMOD := $(M)  endifendif  # kbuild supports saving output files in a separate directory.# To locate output files in a separate directory two syntaxes are supported.# In both cases the working directory must be the root of the kernel src.# 1) O=# Use "make O=dir/to/store/output/files/"# # 2) Set KBUILD_OUTPUT# Set the environment variable KBUILD_OUTPUT to point to the directory# where the output files shall be placed.# export KBUILD_OUTPUT=dir/to/store/output/files/# make## The O= assignment takes precedence over the KBUILD_OUTPUT environment# variable.  # KBUILD_SRC is set on invocation of make in OBJ directory# KBUILD_SRC is not intended to be used by the regular user (for now)ifeq ($(KBUILD_SRC),) # OK, Make called in directory where kernel src resides# Do we want to locate output files in a separate directory?ifdef O  ifeq ("$(origin O)", "command line")    KBUILD_OUTPUT := $(O)  endifendif # That's our default target when none is given on the command linePHONY := _all_all: ifneq ($(KBUILD_OUTPUT),)# Invoke a second make in the output directory, passing relevant variables# check that the output directory actually existssaved-output := $(KBUILD_OUTPUT)KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd)$(if $(KBUILD_OUTPUT),, \     $(error output directory "$(saved-output)" does not exist)) PHONY += $(MAKECMDGOALS) $(filter-out _all,$(MAKECMDGOALS)) _all:	$(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \	KBUILD_SRC=$(CURDIR) \	KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile $@ # Leave processing to above invocation of makeskip-makefile := 1endif # ifneq ($(KBUILD_OUTPUT),)endif # ifeq ($(KBUILD_SRC),) # We process the rest of the Makefile if this is the final invocation of makeifeq ($(skip-makefile),) # If building an external module we do not care about the all: rule# but instead _all depend on modulesPHONY += allifeq ($(KBUILD_EXTMOD),)_all: allelse_all: modulesendif srctree		:= $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR))TOPDIR		:= $(srctree)# FIXME - TOPDIR is obsolete, use srctree/objtreeobjtree		:= $(CURDIR)src		:= $(srctree)obj		:= $(objtree) VPATH		:= $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD)) export srctree objtree VPATH TOPDIR  # SUBARCH tells the usermode build what the underlying arch is.  That is set# first, and if a usermode build is happening, the "ARCH=um" on the command# line overrides the setting of ARCH below.  If a native build is happening,# then ARCH is assigned, getting whatever value it gets normally, and # SUBARCH is subsequently ignored. SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \				  -e s/arm.*/arm/ -e s/sa110/arm/ \				  -e s/s390x/s390/ -e s/parisc64/parisc/ \				  -e s/ppc.*/powerpc/ -e s/mips.*/mips/ ) # Cross compiling and selecting different set of gcc/bin-utils# ---------------------------------------------------------------------------## When performing cross compilation for other architectures ARCH shall be set# to the target architecture. (See arch/* for the possibilities).# ARCH can be set during invocation of make:# make ARCH=ia64# Another way is to have ARCH set in the environment.# The default ARCH is the host where make is executed. # CROSS_COMPILE specify the prefix used for all executables used# during compilation. Only gcc and related bin-utils executables# are prefixed with $(CROSS_COMPILE).# CROSS_COMPILE can be set on the command line# make CROSS_COMPILE=ia64-linux-# Alternatively CROSS_COMPILE can be set in the environment.# Default value for CROSS_COMPILE is not to prefix executables# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile ARCH		?= $(SUBARCH)CROSS_COMPILE	?= # Architecture as present in compile.hUTS_MACHINE := $(ARCH) # SHELL used by kbuildCONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \	  else if [ -x /bin/bash ]; then echo /bin/bash; \	  else echo sh; fi ; fi) HOSTCC  	= gccHOSTCXX  	= g++HOSTCFLAGS	= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointerHOSTCXXFLAGS	= -O2 # 	Decide whether to build built-in, modular, or both.#	Normally, just do built-in. KBUILD_MODULES :=KBUILD_BUILTIN := 1 #	If we have only "make modules", don't compile built-in objects.#	When we're building modules with modversions, we need to consider#	the built-in objects during the descend as well, in order to#	make sure the checksums are uptodate before we record them. ifeq ($(MAKECMDGOALS),modules)  KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1)endif #	If we have "make <whatever> modules", compile modules#	in addition to whatever we do anyway.#	Just "make" or "make all" shall build modules as well ifneq ($(filter all _all modules,$(MAKECMDGOALS)),)  KBUILD_MODULES := 1endif ifeq ($(MAKECMDGOALS),)  KBUILD_MODULES := 1endif export KBUILD_MODULES KBUILD_BUILTINexport KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD # Beautify output# ---------------------------------------------------------------------------## Normally, we echo the whole command before executing it. By making# that echo $($(quiet)$(cmd)), we now have the possibility to set# $(quiet) to choose other forms of output instead, e.g.##         quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@#         cmd_cc_o_c       = $(CC) $(c_flags) -c -o $@ $<## If $(quiet) is empty, the whole command will be printed.# If it is set to "quiet_", only the short version will be printed. # If it is set to "silent_", nothing wil be printed at all, since# the variable $(silent_cmd_cc_o_c) doesn't exist.## A simple variant is to prefix commands with $(Q) - that's useful# for commands that shall be hidden in non-verbose mode.##	$(Q)ln $@ :<## If KBUILD_VERBOSE equals 0 then the above command will be hidden.# If KBUILD_VERBOSE equals 1 then the above command is displayed. ifeq ($(KBUILD_VERBOSE),1)  quiet =  Q =else  quiet=quiet_  Q = @endif # If the user is running make -s (silent mode), suppress echoing of# commands ifneq ($(findstring s,$(MAKEFLAGS)),)  quiet=silent_endif export quiet Q KBUILD_VERBOSE  # Look for make include files relative to root of kernel srcMAKEFLAGS += --include-dir=$(srctree) # We need some generic definitionsinclude  $(srctree)/scripts/Kbuild.include # For maximum performance (+ possibly random breakage, uncomment# the following) #MAKEFLAGS += -rR # Make variables (CC, etc...) AS		= $(CROSS_COMPILE)asLD		= $(CROSS_COMPILE)ldCC		= $(CROSS_COMPILE)gccCPP		= $(CC) -EAR		= $(CROSS_COMPILE)arNM		= $(CROSS_COMPILE)nmSTRIP		= $(CROSS_COMPILE)stripOBJCOPY		= $(CROSS_COMPILE)objcopyOBJDUMP		= $(CROSS_COMPILE)objdumpAWK		= awkGENKSYMS	= scripts/genksyms/genksymsDEPMOD		= /sbin/depmodKALLSYMS	= scripts/kallsymsPERL		= perlCHECK		= sparse CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise $(CF)MODFLAGS	= -DMODULECFLAGS_MODULE   = $(MODFLAGS)AFLAGS_MODULE   = $(MODFLAGS)LDFLAGS_MODULE  = -rCFLAGS_KERNEL	=AFLAGS_KERNEL	=  # Use LINUXINCLUDE when you must reference the include/ directory.# Needed to be compatible with the O= optionLINUXINCLUDE    := -Iinclude \                   $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) \		   -include include/linux/autoconf.h CPPFLAGS        := -D__KERNEL__ $(LINUXINCLUDE) CFLAGS 		:= -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \	  	   -fno-strict-aliasing -fno-commonAFLAGS		:= -D__ASSEMBLY__ # Read KERNELRELEASE from .kernelrelease (if it exists)KERNELRELEASE = $(shell cat .kernelrelease 2> /dev/null)KERNELVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) export	VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION \	ARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \	CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE \	HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGSexport CFLAGS CFLAGS_KERNEL CFLAGS_MODULE export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE # When compiling out-of-tree modules, put MODVERDIR in the module# tree rather than in the kernel tree. The kernel tree might# even be read-only.export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions # Files to ignore in find ... statements RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o -name .pc -o -name .hg -o -name .git \) -prune -oexport RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS --exclude .pc --exclude .hg --exclude .git # ===========================================================================# Rules shared between *config targets and build targets # Basic helpers built in scripts/PHONY += scripts_basicscripts_basic:	$(Q)$(MAKE) $(build)=scripts/basic # To avoid any implicit rule to kick in, define an empty command.scripts/basic/%: scripts_basic ; PHONY += outputmakefile# outputmakefile generates a Makefile in the output directory, if using a# separate output directory. This allows convenient use of make in the# output directory.outputmakefile:ifneq ($(KBUILD_SRC),)	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \	    $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)endif # To make sure we do not include .config for any of the *config targets# catch them early, and hand them over to scripts/kconfig/Makefile# It is allowed to specify more targets when calling make, including# mixing *config targets and build targets.# For example 'make oldconfig all'. # Detect when mixed targets is specified, and make a second invocation# of make so .config is not included in this case either (for *config). no-dot-config-targets := clean mrproper distclean \			 cscope TAGS tags help %docs check% config-targets := 0mixed-targets  := 0dot-config     := 1 ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)	ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)		dot-config := 0	endifendif ifeq ($(KBUILD_EXTMOD),)        ifneq ($(filter config %config,$(MAKECMDGOALS)),)                config-targets := 1                ifneq ($(filter-out config %config,$(MAKECMDGOALS)),)                        mixed-targets := 1                endif        endifendif ifeq ($(mixed-targets),1)# ===========================================================================# We're called with mixed targets (*config and build targets).# Handle them one by one. %:: FORCE	$(Q)$(MAKE) -C $(srctree) KBUILD_SRC= $@ elseifeq ($(config-targets),1)# ===========================================================================# *config targets only - make sure prerequisites are updated, and descend# in scripts/kconfig to make the *config target # Read arch specific Makefile to set KBUILD_DEFCONFIG as needed.# KBUILD_DEFCONFIG may point out an alternative default configuration# used for 'make defconfig'include $(srctree)/arch/$(ARCH)/Makefileexport KBUILD_DEFCONFIG config %config: scripts_basic outputmakefile FORCE	$(Q)mkdir -p include/linux	$(Q)$(MAKE) $(build)=scripts/kconfig $@	$(Q)$(MAKE) -C $(srctree) KBUILD_SRC= .kernelrelease else# ===========================================================================# Build targets only - this includes vmlinux, arch specific targets, clean# targets and others. In general all targets except *config targets. ifeq ($(KBUILD_EXTMOD),)# Additional helpers built in scripts/# Carefully list dependencies so we do not try to build scripts twice# in parrallelPHONY += scriptsscripts: scripts_basic include/config/MARKER	$(Q)$(MAKE) $(build)=$(@) scripts_basic: include/linux/autoconf.h # Objects we will link into vmlinux / subdirs we need to visitinit-y		:= init/drivers-y	:= drivers/ sound/net-y		:= net/libs-y		:= lib/core-y		:= usr/endif # KBUILD_EXTMOD ifeq ($(dot-config),1)# In this section, we need .config # Read in dependencies to all Kconfig* files, make sure to run# oldconfig if changes are detected.-include .kconfig.d include .config # If .config needs to be updated, it will be done via the dependency# that autoconf has on .config.# To avoid any implicit rule to kick in, define an empty command.config .kconfig.d: ; # If .config is newer than include/linux/autoconf.h, someone tinkered# with it and forgot to run make oldconfig.# If kconfig.d is missing then we are probarly in a cleaned tree so# we execute the config step to be sure to catch updated Kconfig filesinclude/linux/autoconf.h: .kconfig.d .config	$(Q)mkdir -p include/linux	$(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfigelse# Dummy target needed, because used as prerequisiteinclude/linux/autoconf.h: ;endif # The all: target is the default when no target is given on the# command line.# This allow a user to issue only 'make' to build a kernel including modules# Defaults vmlinux but it is usually overriden in the arch makefileall: vmlinux ifdef CONFIG_CC_OPTIMIZE_FOR_SIZECFLAGS		+= -OselseCFLAGS		+= -O2endif ifdef CONFIG_FRAME_POINTERCFLAGS		+= -fno-omit-frame-pointer $(call cc-option,-fno-optimize-sibling-calls,)elseCFLAGS		+= -fomit-frame-pointerendif ifdef CONFIG_UNWIND_INFOCFLAGS		+= -fasynchronous-unwind-tablesendif ifdef CONFIG_DEBUG_INFOCFLAGS		+= -gendif include $(srctree)/arch/$(ARCH)/Makefile # arch Makefile may override CC so keep this after arch Makefile is includedNOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)CHECKFLAGS     += $(NOSTDINC_FLAGS) # warn about C99 declaration after statementCFLAGS += $(call cc-option,-Wdeclaration-after-statement,) # disable pointer signedness warnings in gcc 4.0CFLAGS += $(call cc-option,-Wno-pointer-sign,) # Default kernel image to build when no specific target is given.# KBUILD_IMAGE may be overruled on the commandline or# set in the environment

Lines 1–500 of 1354.