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