5 NAME
= Amissive Actinocutious Kiwi
8 # To see a list of typical targets execute "make help"
9 # More info can be located in ./README
10 # Comments in this file are targeted only to the developer, do not
11 # expect to learn how to build the kernel reading this file.
14 # o use make's built-in rules and variables
15 # (this increases performance and avoid hard-to-debug behavour);
16 # o print "Entering directory ...";
17 MAKEFLAGS
+= -rR
--no-print-directory
19 # We are using a recursive build, so we need to do a little thinking
20 # to get the ordering right.
22 # Most importantly: sub-Makefiles should only ever modify files in
23 # their own directory. If in some directory we have a dependency on
24 # a file in another dir (which doesn't happen often, but it's often
25 # unavoidable when linking the built-in.o targets which finally
26 # turn into uboot), we will call a sub make in that other dir, and
27 # after that we are sure that everything which is in that other dir
30 # The only cases where we need to modify files which have global
31 # effects are thus separated out and done before the recursive
32 # descending is started. They are now explicitly listed as the
35 # To put more focus on warnings, be less verbose as default
36 # Use 'make V=1' to see the full commands
39 ifeq ("$(origin V)", "command line")
47 # Call a source code checker (by default, "sparse") as part of the
50 # Use 'make C=1' to enable checking of only re-compiled files.
51 # Use 'make C=2' to enable checking of *all* source files, regardless
52 # of whether they are re-compiled or not.
54 # See the file "Documentation/sparse.txt" for more details, including
55 # where to get the "sparse" utility.
58 ifeq ("$(origin C)", "command line")
59 KBUILD_CHECKSRC
= $(C
)
62 ifndef KBUILD_CHECKSRC
66 # Use make M=dir to specify directory of external module to build
67 # Old syntax make ... SUBDIRS=$PWD is still supported
68 # Setting the environment variable KBUILD_EXTMOD take precedence
70 KBUILD_EXTMOD ?
= $(SUBDIRS
)
73 ifeq ("$(origin M)", "command line")
79 # kbuild supports saving output files in a separate directory.
80 # To locate output files in a separate directory two syntaxes are supported.
81 # In both cases the working directory must be the root of the kernel src.
83 # Use "make O=dir/to/store/output/files/"
85 # 2) Set KBUILD_OUTPUT
86 # Set the environment variable KBUILD_OUTPUT to point to the directory
87 # where the output files shall be placed.
88 # export KBUILD_OUTPUT=dir/to/store/output/files/
91 # The O= assignment takes precedence over the KBUILD_OUTPUT environment
95 # KBUILD_SRC is set on invocation of make in OBJ directory
96 # KBUILD_SRC is not intended to be used by the regular user (for now)
99 # OK, Make called in directory where kernel src resides
100 # Do we want to locate output files in a separate directory?
102 ifeq ("$(origin O)", "command line")
103 KBUILD_OUTPUT
:= $(O
)
107 # That's our default target when none is given on the command line
111 ifneq ($(KBUILD_OUTPUT
),)
112 # Invoke a second make in the output directory, passing relevant variables
113 # check that the output directory actually exists
114 saved-output
:= $(KBUILD_OUTPUT
)
115 KBUILD_OUTPUT
:= $(shell cd
$(KBUILD_OUTPUT
) && /bin
/pwd
)
116 $(if
$(KBUILD_OUTPUT
),, \
117 $(error output directory
"$(saved-output)" does not exist
))
119 PHONY
+= $(MAKECMDGOALS
)
121 $(filter-out _all
,$(MAKECMDGOALS
)) _all
:
122 $(if
$(KBUILD_VERBOSE
:1=),@
)$(MAKE
) -C
$(KBUILD_OUTPUT
) \
123 KBUILD_SRC
=$(CURDIR
) \
124 KBUILD_EXTMOD
="$(KBUILD_EXTMOD)" -f
$(CURDIR
)/Makefile
$@
126 # Leave processing to above invocation of make
128 endif # ifneq ($(KBUILD_OUTPUT),)
129 endif # ifeq ($(KBUILD_SRC),)
131 # We process the rest of the Makefile if this is the final invocation of make
132 ifeq ($(skip-makefile
),)
134 # If building an external module we do not care about the all: rule
135 # but instead _all depend on modules
139 srctree
:= $(if
$(KBUILD_SRC
),$(KBUILD_SRC
),$(CURDIR
))
144 VPATH
:= $(srctree
)$(if
$(KBUILD_EXTMOD
),:$(KBUILD_EXTMOD
))
146 export srctree objtree VPATH
148 # Cross compiling and selecting different set of gcc/bin-utils
149 # ---------------------------------------------------------------------------
151 # When performing cross compilation for other architectures ARCH shall be set
152 # to the target architecture. (See arch/* for the possibilities).
153 # ARCH can be set during invocation of make:
155 # Another way is to have ARCH set in the environment.
156 # The default ARCH is the host where make is executed.
158 # CROSS_COMPILE specify the prefix used for all executables used
159 # during compilation. Only gcc and related bin-utils executables
160 # are prefixed with $(CROSS_COMPILE).
161 # CROSS_COMPILE can be set on the command line
162 # make CROSS_COMPILE=ia64-linux-
163 # Alternatively CROSS_COMPILE can be set in the environment.
164 # Default value for CROSS_COMPILE is not to prefix executables
169 # Architecture as present in compile.h
170 UTS_MACHINE
:= $(ARCH
)
172 KCONFIG_CONFIG ?
= .config
174 # SHELL used by kbuild
175 CONFIG_SHELL
:= $(shell if
[ -x
"$$BASH" ]; then echo
$$BASH; \
176 else if
[ -x
/bin
/bash
]; then echo
/bin
/bash
; \
177 else echo sh
; fi
; fi
)
181 HOSTCFLAGS
= -Wall
-Wstrict-prototypes
-O2
-fomit-frame-pointer
184 # Decide whether to build built-in, modular, or both.
185 # Normally, just do built-in.
190 # If we have only "make modules", don't compile built-in objects.
191 # When we're building modules with modversions, we need to consider
192 # the built-in objects during the descend as well, in order to
193 # make sure the checksums are up to date before we record them.
195 ifeq ($(MAKECMDGOALS
),modules
)
196 KBUILD_BUILTIN
:= $(if
$(CONFIG_MODVERSIONS
),1)
199 # If we have "make <whatever> modules", compile modules
200 # in addition to whatever we do anyway.
201 # Just "make" or "make all" shall build modules as well
203 ifneq ($(filter all _all modules
,$(MAKECMDGOALS
)),)
207 export KBUILD_MODULES KBUILD_BUILTIN
208 export KBUILD_CHECKSRC KBUILD_SRC
211 # ---------------------------------------------------------------------------
213 # Normally, we echo the whole command before executing it. By making
214 # that echo $($(quiet)$(cmd)), we now have the possibility to set
215 # $(quiet) to choose other forms of output instead, e.g.
217 # quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
218 # cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
220 # If $(quiet) is empty, the whole command will be printed.
221 # If it is set to "quiet_", only the short version will be printed.
222 # If it is set to "silent_", nothing will be printed at all, since
223 # the variable $(silent_cmd_cc_o_c) doesn't exist.
225 # A simple variant is to prefix commands with $(Q) - that's useful
226 # for commands that shall be hidden in non-verbose mode.
230 # If KBUILD_VERBOSE equals 0 then the above command will be hidden.
231 # If KBUILD_VERBOSE equals 1 then the above command is displayed.
233 ifeq ($(KBUILD_VERBOSE
),1)
241 # If the user is running make -s (silent mode), suppress echoing of
244 ifneq ($(findstring s
,$(MAKEFLAGS
)),)
248 export quiet Q KBUILD_VERBOSE
251 # Look for make include files relative to root of kernel src
252 MAKEFLAGS
+= --include-dir
=$(srctree
)
254 # We need some generic definitions.
255 include $(srctree
)/scripts
/Kbuild.
include
257 # Make variables (CC, etc...)
259 AS
= $(CROSS_COMPILE
)as
260 LD
= $(CROSS_COMPILE
)ld
261 CC
= $(CROSS_COMPILE
)gcc
263 AR
= $(CROSS_COMPILE
)ar
264 NM
= $(CROSS_COMPILE
)nm
265 STRIP
= $(CROSS_COMPILE
)strip
266 OBJCOPY
= $(CROSS_COMPILE
)objcopy
267 OBJDUMP
= $(CROSS_COMPILE
)objdump
269 GENKSYMS
= scripts
/genksyms
/genksyms
270 DEPMOD
= /sbin
/depmod
271 KALLSYMS
= scripts
/kallsyms
275 CHECKFLAGS
:= -D__linux__
-Dlinux
-D__STDC__
-Dunix
-D__unix__
-Wbitwise
$(CF
)
279 LDFLAGS_MODULE
= -T common
/module.lds
281 # When compiling out-of-tree modules, put MODVERDIR in the module
282 # tree rather than in the kernel tree. The kernel tree might
284 export MODVERDIR
:= $(if
$(KBUILD_EXTMOD
),$(firstword $(KBUILD_EXTMOD
))/).tmp_versions
286 # Use LINUXINCLUDE when you must reference the include/ directory.
287 # Needed to be compatible with the O= option
288 LINUXINCLUDE
:= -Iinclude \
289 $(if
$(KBUILD_SRC
),-Iinclude2
-I
$(srctree
)/include) \
290 -include include/linux
/autoconf.h
292 CPPFLAGS
:= -D__KERNEL__
-D__U_BOOT__
$(LINUXINCLUDE
) -fno-builtin
-ffreestanding
294 CFLAGS
:= -Wall
-Wundef
-Wstrict-prototypes
-Wno-trigraphs \
295 -fno-strict-aliasing
-fno-common
-Os
-pipe
296 AFLAGS
:= -D__ASSEMBLY__
298 # Read KERNELRELEASE from include/config/kernel.release (if it exists)
299 KERNELRELEASE
= $(shell cat
include/config
/kernel.release
2> /dev
/null
)
300 KERNELVERSION
= $(VERSION
).
$(PATCHLEVEL
).
$(SUBLEVEL
)$(EXTRAVERSION
)
302 export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
303 export ARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC
304 export CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE
305 export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
307 export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
308 export CFLAGS CFLAGS_KERNEL
309 export AFLAGS AFLAGS_KERNEL
311 # Files to ignore in find ... statements
313 RCS_FIND_IGNORE
:= \
( -name SCCS
-o
-name BitKeeper
-o
-name .svn
-o
-name CVS
-o
-name .
pc -o
-name .hg
-o
-name .git \
) -prune
-o
314 export RCS_TAR_IGNORE
:= --exclude SCCS
--exclude BitKeeper
--exclude .svn
--exclude CVS
--exclude .
pc --exclude .hg
--exclude .git
316 # ===========================================================================
317 # Rules shared between *config targets and build targets
319 # Basic helpers built in scripts/
320 PHONY
+= scripts_basic
322 $(Q
)$(MAKE
) $(build
)=scripts
/basic
324 # To avoid any implicit rule to kick in, define an empty command.
325 scripts
/basic
/%: scripts_basic
;
327 PHONY
+= outputmakefile
328 # outputmakefile generates a Makefile in the output directory, if using a
329 # separate output directory. This allows convenient use of make in the
332 ifneq ($(KBUILD_SRC
),)
333 $(Q
)$(CONFIG_SHELL
) $(srctree
)/scripts
/mkmakefile \
334 $(srctree
) $(objtree
) $(VERSION
) $(PATCHLEVEL
)
337 # To make sure we do not include .config for any of the *config targets
338 # catch them early, and hand them over to scripts/kconfig/Makefile
339 # It is allowed to specify more targets when calling make, including
340 # mixing *config targets and build targets.
341 # For example 'make oldconfig all'.
342 # Detect when mixed targets is specified, and make a second invocation
343 # of make so .config is not included in this case either (for *config).
345 no-dot-config-targets
:= clean mrproper
distclean \
346 cscope TAGS
tags help
%docs
check% \
347 include/linux
/version.h headers_
% \
348 kernelrelease kernelversion
354 ifneq ($(filter $(no-dot-config-targets
), $(MAKECMDGOALS
)),)
355 ifeq ($(filter-out $(no-dot-config-targets
), $(MAKECMDGOALS
)),)
360 ifneq ($(filter config
%config
,$(MAKECMDGOALS
)),)
362 ifneq ($(filter-out config
%config
,$(MAKECMDGOALS
)),)
367 ifeq ($(mixed-targets
),1)
368 # ===========================================================================
369 # We're called with mixed targets (*config and build targets).
370 # Handle them one by one.
373 $(Q
)$(MAKE
) -C
$(srctree
) KBUILD_SRC
= $@
376 ifeq ($(config-targets
),1)
377 # ===========================================================================
378 # *config targets only - make sure prerequisites are updated, and descend
379 # in scripts/kconfig to make the *config target
381 # Read arch specific Makefile to set KBUILD_DEFCONFIG as needed.
382 # KBUILD_DEFCONFIG may point out an alternative default configuration
383 # used for 'make defconfig'
384 include $(srctree
)/arch
/$(ARCH
)/Makefile
385 export KBUILD_DEFCONFIG
387 config
%config
: scripts_basic outputmakefile FORCE
388 $(Q
)mkdir
-p
include/linux
include/config
389 $(Q
)$(MAKE
) $(build
)=scripts
/kconfig
$@
392 # ===========================================================================
393 # Build targets only - this includes uboot, arch specific targets, clean
394 # targets and others. In general all targets except *config targets.
396 # Additional helpers built in scripts/
397 # Carefully list dependencies so we do not try to build scripts twice
400 scripts
: scripts_basic
include/config
/auto.conf
401 $(Q
)$(MAKE
) $(build
)=$(@
)
403 # Objects we will link into uboot / subdirs we need to visit
404 common-y
:= common
/ drivers
/ commands
/ lib
/ net
/ fs
/
406 ifeq ($(dot-config
),1)
408 -include include/config
/auto.conf
410 # Read in dependencies to all Kconfig* files, make sure to run
411 # oldconfig if changes are detected.
412 -include include/config
/auto.conf.cmd
414 # To avoid any implicit rule to kick in, define an empty command
415 $(KCONFIG_CONFIG
) include/config
/auto.conf.cmd
: ;
417 # If .config is newer than include/config/auto.conf, someone tinkered
418 # with it and forgot to run make oldconfig.
419 # if auto.conf.cmd is missing then we are probably in a cleaned tree so
420 # we execute the config step to be sure to catch updated Kconfig files
421 include/config
/auto.conf
: $(KCONFIG_CONFIG
) include/config
/auto.conf.cmd
422 $(Q
)$(MAKE
) -f
$(srctree
)/Makefile silentoldconfig
425 # Dummy target needed, because used as prerequisite
426 include/config
/auto.conf
: ;
427 endif # $(dot-config)
429 # The all: target is the default when no target is given on the
431 # This allow a user to issue only 'make' to build a kernel
432 # Defaults uboot but it is usually overridden in the arch makefile
435 include $(srctree
)/arch
/$(ARCH
)/Makefile
437 ifdef CONFIG_DEBUG_INFO
441 # Force gcc to behave correct even for buggy distributions
442 CFLAGS
+= $(call cc-option
, -fno-stack-protector
)
444 # arch Makefile may override CC so keep this after arch Makefile is included
445 NOSTDINC_FLAGS
+= -nostdinc
-isystem
$(shell $(CC
) -print-file-name
=include)
446 CHECKFLAGS
+= $(NOSTDINC_FLAGS
)
448 # warn about C99 declaration after statement
449 CFLAGS
+= $(call cc-option
,-Wdeclaration-after-statement
,)
451 # disable pointer signed / unsigned warnings in gcc 4.0
452 CFLAGS
+= $(call cc-option
,-Wno-pointer-sign
,)
454 # Default kernel image to build when no specific target is given.
455 # KBUILD_IMAGE may be overruled on the command line or
456 # set in the environment
457 # Also any assignments in arch/$(ARCH)/Makefile take precedence over
459 export KBUILD_IMAGE ?
= uboot
461 uboot-dirs
:= $(patsubst %/,%,$(filter %/, $(common-y
)))
463 uboot-alldirs
:= $(sort $(uboot-dirs
) $(patsubst %/,%,$(filter %/, \
464 $(common-n
) $(common-
) \
465 $(core-n
) $(core-
) $(drivers-n
) $(drivers-
) \
466 $(net-n
) $(net-
) $(libs-n
) $(libs-
))))
468 common-y
:= $(patsubst %/, %/built-in.o
, $(common-y
))
471 # ---------------------------------------------------------------------------
472 # uboot is built from the objects selected by $(uboot-init) and
473 # $(uboot-main). Most are built-in.o files from top-level directories
474 # in the kernel tree, others are specified in arch/$(ARCH)Makefile.
475 # Ordering when linking is important, and $(uboot-init) must be first.
477 # FIXME: This picture is wrong for U-Boot. We have no init, driver, mm
483 # | +--< init/version.o + more
486 # | +--< driver/built-in.o mm/built-in.o + more
488 # +-< kallsyms.o (see description in CONFIG_KALLSYMS section)
490 # uboot version cannot be updated during normal
491 # descending-into-subdirs phase since we do not yet know if we need to
494 # System.map is generated to document addresses of all kernel symbols
496 uboot-common
:= $(common-y
)
497 uboot-all
:= $(uboot-common
)
498 uboot-lds
:= $(lds-y
)
501 # May be overridden by arch/$(ARCH)/Makefile
502 quiet_cmd_uboot__ ?
= LD
$@
503 cmd_uboot__ ?
= $(LD
) $(LDFLAGS
) $(LDFLAGS_uboot
) -o
$@ \
504 -T
$(uboot-lds
) $(uboot-head
) \
505 --start-group
$(uboot-common
) --end-group \
506 $(filter-out $(uboot-lds
) $(uboot-common
) FORCE
,$^
)
508 # Generate new uboot version
509 quiet_cmd_uboot_version
= GEN .version
510 cmd_uboot_version
= set
-e
; \
511 if
[ ! -r .version
]; then \
515 mv .version .old_version
; \
516 expr
0$$(cat .old_version
) + 1 >.version
; \
520 # Generate System.map
521 quiet_cmd_sysmap
= SYSMAP
522 cmd_sysmap
= $(CONFIG_SHELL
) $(srctree
)/scripts
/mksysmap
525 # Generate System.map and verify that the content is consistent
526 # Use + in front of the uboot_version rule to silent warning with make -j2
527 # First command is ':' to allow us to use + in front of the rule
533 $(Q
)echo
'cmd_$@ := $(cmd_uboot__)' > $(@D
)/.
$(@F
).cmd
535 $(Q
)$(if
$($(quiet
)cmd_sysmap
), \
536 echo
' $($(quiet)cmd_sysmap) System.map' &&) \
537 $(cmd_sysmap
) $@ System.map
; \
538 if
[ $$?
-ne
0 ]; then \
544 ifdef CONFIG_KALLSYMS
545 # Generate section listing all symbols and add it into uboot $(kallsyms.o)
546 # It's a three stage process:
547 # o .tmp_uboot1 has all symbols and sections, but __kallsyms is
549 # Running kallsyms on that gives us .tmp_kallsyms1.o with
550 # the right size - uboot version is updated during this step
551 # o .tmp_uboot2 now has a __kallsyms section of the right size,
552 # but due to the added section, some addresses have shifted.
553 # From here, we generate a correct .tmp_kallsyms2.o
554 # o The correct .tmp_kallsyms2.o is linked into the final uboot.
555 # o Verify that the System.map from uboot matches the map from
556 # .tmp_uboot2, just in case we did not generate kallsyms correctly.
557 # o If CONFIG_KALLSYMS_EXTRA_PASS is set, do an extra pass using
558 # .tmp_uboot3 and .tmp_kallsyms3.o. This is only meant as a
559 # temporary bypass to allow the kernel to be built while the
560 # maintainers work out what went wrong with kallsyms.
562 ifdef CONFIG_KALLSYMS_EXTRA_PASS
568 kallsyms.o
:= .tmp_kallsyms
$(last_kallsyms
).o
570 define verify_kallsyms
571 $(Q
)$(if
$($(quiet
)cmd_sysmap
), \
572 echo
' $($(quiet)cmd_sysmap) .tmp_System.map' &&) \
573 $(cmd_sysmap
) .tmp_uboot
$(last_kallsyms
) .tmp_System.map
574 $(Q
)cmp
-s System.map .tmp_System.map || \
575 (echo Inconsistent kallsyms data
; \
576 echo Try setting CONFIG_KALLSYMS_EXTRA_PASS
; \
577 rm .tmp_kallsyms
* ; /bin
/false
)
580 # Update uboot version before link
581 # Use + in front of this rule to silent warning about make -j1
582 # First command is ':' to allow us to use + in front of this rule
583 cmd_ksym_ld
= $(cmd_uboot__
)
586 +$(call cmd
,uboot_version
)
588 $(Q
)echo
'cmd_$@ := $(cmd_uboot__)' > $(@D
)/.
$(@F
).cmd
591 # Generate .S file with all kernel symbols
592 quiet_cmd_kallsyms
= KSYM
$@
593 cmd_kallsyms
= $(NM
) -g
-n
$< |
$(KALLSYMS
) > $@
595 .tmp_kallsyms1.o .tmp_kallsyms2.o .tmp_kallsyms3.o
: %.o
: %.S scripts FORCE
596 $(call if_changed_dep
,as_o_S
)
598 .tmp_kallsyms
%.S
: .tmp_uboot
% $(KALLSYMS
)
601 # .tmp_uboot1 must be complete except kallsyms, so update uboot version
602 .tmp_uboot1
: $(uboot-lds
) $(uboot-all
) FORCE
603 $(call if_changed_rule
,ksym_ld
)
605 .tmp_uboot2
: $(uboot-lds
) $(uboot-all
) .tmp_kallsyms1.o FORCE
606 $(call if_changed
,uboot__
)
608 .tmp_uboot3
: $(uboot-lds
) $(uboot-all
) .tmp_kallsyms2.o FORCE
609 $(call if_changed
,uboot__
)
611 # Needs to visit scripts/ before $(KALLSYMS) can be used.
612 $(KALLSYMS
): scripts
;
614 # Generate some data for debugging strange kallsyms problems
615 debug_kallsyms
: .tmp_map
$(last_kallsyms
)
617 .tmp_map
%: .tmp_uboot
% FORCE
618 ($(OBJDUMP
) -h
$< |
$(AWK
) '/^ +[0-9]/{print $$4 " 0 " $$2}'; $(NM
) $<) |
sort > $@
624 endif # ifdef CONFIG_KALLSYMS
626 # Do modpost on a prelinked vmlinux. The finally linked vmlinux has
627 # relevant sections renamed as per the linker script.
628 quiet_cmd_uboot-modpost
= LD
$@
629 cmd_uboot-modpost
= $(LD
) $(LDFLAGS
) -r
-o
$@ \
630 $(vmlinux-init
) --start-group
$(uboot-main
) --end-group \
631 $(filter-out $(uboot-init
) $(uboot-main
) $(uboot-lds
) FORCE
,$^
)
632 define rule_uboot-modpost
634 +$(call cmd
,uboot-modpost
)
635 $(Q
)$(MAKE
) -f
$(srctree
)/scripts
/Makefile.modpost
$@
636 $(Q
)echo
'cmd_$@ := $(cmd_uboot-modpost)' > $(dot-target
).cmd
640 $(Q
)$(OBJCOPY
) -O binary uboot uboot.bin
641 $(Q
)$(OBJDUMP
) -d uboot
> uboot.S
644 uboot
: $(uboot-lds
) $(uboot-head
) $(uboot-common
) $(kallsyms.o
) FORCE
645 $(call uboot-modpost
)
646 $(call if_changed_rule
,uboot__
)
647 $(Q
)rm -f .old_version
649 # The actual objects are generated when descending,
650 # make sure no implicit rule kicks in
651 $(sort $(uboot-head
) $(uboot-common
) ) $(uboot-lds
): $(uboot-dirs
) ;
653 # Handle descending into subdirectories listed in $(uboot-dirs)
654 # Preset locale variables to speed up the build process. Limit locale
655 # tweaks to this spot to avoid wrong language settings when running
656 # make menuconfig etc.
657 # Error messages still appears in the original language
659 PHONY
+= $(uboot-dirs
)
660 $(uboot-dirs
): prepare scripts
661 $(Q
)$(MAKE
) $(build
)=$@
663 # Build the kernel release string
665 # The KERNELRELEASE value built here is stored in the file
666 # include/config/kernel.release, and is used when executing several
667 # make targets, such as "make install" or "make modules_install."
669 # The eventual kernel release string consists of the following fields,
670 # shown in a hierarchical format to show how smaller parts are concatenated
671 # to form the larger and final value, with values coming from places like
672 # the Makefile, kernel config options, make command line options and/or
673 # SCM tag information.
677 # $(PATCHLEVEL) eg, 6
679 # $(EXTRAVERSION) eg, -rc6
682 # localversion* (all localversion* files)
683 # $(CONFIG_LOCALVERSION) (from kernel config setting)
684 # $(localver-auto) (only if CONFIG_LOCALVERSION_AUTO is set)
685 # ./scripts/setlocalversion (SCM tag, if one exists)
686 # $(LOCALVERSION) (from make command line if provided)
688 # Note how the final $(localver-auto) string is included *only* if the
689 # kernel config option CONFIG_LOCALVERSION_AUTO is selected. Also, at the
690 # moment, only git is supported but other SCMs can edit the script
691 # scripts/setlocalversion and add the appropriate checks as needed.
694 space
:= $(nullstring
) # end of line
696 ___localver
= $(objtree
)/localversion
* $(srctree
)/localversion
*
697 __localver
= $(sort $(wildcard $(___localver
)))
698 # skip backup files (containing '~')
699 _localver
= $(foreach f
, $(__localver
), $(if
$(findstring ~
, $(f
)),,$(f
)))
701 localver
= $(subst $(space
),, \
702 $(shell cat
/dev
/null
$(_localver
)) \
703 $(patsubst "%",%,$(CONFIG_LOCALVERSION
)))
705 # If CONFIG_LOCALVERSION_AUTO is set scripts/setlocalversion is called
706 # and if the SCM is know a tag from the SCM is appended.
707 # The appended tag is determined by the SCM used.
709 # Currently, only git is supported.
710 # Other SCMs can edit scripts/setlocalversion and add the appropriate
712 ifdef CONFIG_LOCALVERSION_AUTO
713 _localver-auto
= $(shell $(CONFIG_SHELL
) \
714 $(srctree
)/scripts
/setlocalversion
$(srctree
))
715 localver-auto
= $(LOCALVERSION
)$(_localver-auto
)
718 localver-full
= $(localver
)$(localver-auto
)
720 # Store (new) KERNELRELASE string in include/config/kernel.release
721 kernelrelease
= $(KERNELVERSION
)$(localver-full
)
722 include/config
/kernel.release
: include/config
/auto.conf FORCE
724 $(Q
)echo
$(kernelrelease
) > $@
727 # Things we need to do before we recursively start building the kernel
728 # or the modules are listed in "prepare".
729 # A multi level approach is used. prepareN is processed before prepareN-1.
730 # archprepare is used in arch Makefiles and when processed asm symlink,
731 # version.h and scripts_basic is processed / created.
733 # Listed in dependency order
734 PHONY
+= prepare archprepare prepare0 prepare1 prepare2 prepare3
736 # prepare-all is deprecated, use prepare as valid replacement
739 # prepare3 is used to check if we are building in a separate output directory,
741 # 1) Check that make has not been executed in the kernel src $(srctree)
742 # 2) Create the include2 directory, used for the second asm symlink
743 prepare3
: include/config
/kernel.release
744 ifneq ($(KBUILD_SRC
),)
745 @echo
' Using $(srctree) as source for kernel'
746 $(Q
)if
[ -f
$(srctree
)/.config
-o
-d
$(srctree
)/include/config
]; then \
747 echo
" $(srctree) is not clean, please run 'make mrproper'";\
748 echo
" in the '$(srctree)' directory.";\
751 $(Q
)if
[ ! -d include2
]; then mkdir
-p include2
; fi
;
752 $(Q
)ln
-fsn
$(srctree
)/include/asm-
$(ARCH
) include2
/asm
755 # prepare2 creates a makefile if using a separate output directory
756 prepare2
: prepare3 outputmakefile
758 prepare1
: prepare2
include/linux
/version.h
include/linux
/utsrelease.h \
759 include/asm
include/config.h
include/config
/auto.conf
761 ifneq ($(KBUILD_MODULES
),)
762 $(Q
)mkdir
-p
$(MODVERDIR
)
763 $(Q
)rm -f
$(MODVERDIR
)/*
766 archprepare
: prepare1 scripts_basic
768 prepare0
: archprepare FORCE
769 $(Q
)$(MAKE
) $(build
)=.
771 # All the preparing..
772 prepare prepare-all
: prepare0
774 # Leave this as default for preprocessing uboot.lds.S, which is now
775 # done in arch/$(ARCH)/kernel/Makefile
777 export CPPFLAGS_uboot.lds
+= -P
-C
-U
$(ARCH
)
779 # FIXME: The asm symlink changes when $(ARCH) changes. That's
780 # hard to detect, but I suppose "make mrproper" is a good idea
781 # before switching between archs anyway.
784 @echo
' SYMLINK $@ -> include/asm-$(ARCH)'
785 $(Q
)if
[ ! -d
include ]; then mkdir
-p
include; fi
;
786 @ln
-fsn asm-
$(ARCH
) $@
788 include/config.h
: include/config
/auto.conf
789 @echo
' SYMLINK $@ -> board/$(board-y)/config.h'
790 ifneq ($(KBUILD_SRC
),)
791 $(Q
)ln
-fsn
$(srctree
)/board
/$(board-y
)/config.h
$@
793 @ln
-fsn ..
/board
/$(board-y
)/config.h
$@
796 # Generate some files
797 # ---------------------------------------------------------------------------
799 # KERNELRELEASE can change from a few different places, meaning version.h
800 # needs to be updated, so this check is forced on all builds
803 define filechk_utsrelease.h
804 if
[ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt
$(uts_len
) ]; then \
805 echo
'"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \
808 (echo \
#define UTS_RELEASE \"$(KERNELRELEASE)\";)
811 define filechk_version.h
812 (echo \
#define LINUX_VERSION_CODE $(shell \
813 expr
$(VERSION
) \
* 65536 + $(PATCHLEVEL
) \
* 256 + $(SUBLEVEL
)); \
814 echo
'#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';)
817 include/linux
/version.h
: $(srctree
)/Makefile FORCE
818 $(call filechk
,version.h
)
820 include/linux
/utsrelease.h
: include/config
/kernel.release FORCE
821 $(call filechk
,utsrelease.h
)
823 # ---------------------------------------------------------------------------
827 @echo
'*** Warning: make $@ is unnecessary now.'
829 # ---------------------------------------------------------------------------
834 # By default, build modules as well
841 modules
: $(uboot-dirs
) $(if
$(KBUILD_BUILTIN
),uboot
)
842 @echo
' Building modules, stage 2.';
843 $(Q
)$(MAKE
) -f
$(srctree
)/scripts
/Makefile.modpost
846 # Target to prepare building external modules
847 PHONY
+= modules_prepare
848 modules_prepare
: prepare scripts
850 # Target to install modules
851 PHONY
+= modules_install
852 modules_install
: _modinst_ _modinst_post
856 @if
[ -z
"`$(DEPMOD) -V 2>/dev/null | grep module-init-tools`" ]; then \
857 echo
"Warning: you may need to install module-init-tools"; \
858 echo
"See http://www.codemonkey.org.uk/docs/post-halloween-2.6.txt";\
861 @
rm -rf
$(MODLIB
)/kernel
862 @
rm -f
$(MODLIB
)/source
863 @mkdir
-p
$(MODLIB
)/kernel
864 @ln
-s
$(srctree
) $(MODLIB
)/source
865 @if
[ ! $(objtree
) -ef
$(MODLIB
)/build
]; then \
866 rm -f
$(MODLIB
)/build
; \
867 ln
-s
$(objtree
) $(MODLIB
)/build
; \
869 $(Q
)$(MAKE
) -f
$(srctree
)/scripts
/Makefile.modinst
871 # If System.map exists, run depmod. This deliberately does not have a
872 # dependency on System.map since that would run the dependency tree on
873 # vmlinux. This depmod is only for convenience to give the initial
874 # boot a modules.dep even before / is mounted read-write. However the
875 # boot script depmod is the master version.
876 ifeq "$(strip $(INSTALL_MOD_PATH))" ""
879 depmod_opts
:= -b
$(INSTALL_MOD_PATH
) -r
881 PHONY
+= _modinst_post
882 _modinst_post
: _modinst_
883 if
[ -r System.map
-a
-x
$(DEPMOD
) ]; then
$(DEPMOD
) -ae
-F System.map
$(depmod_opts
) $(KERNELRELEASE
); fi
885 else # CONFIG_MODULES
887 # Modules not configured
888 # ---------------------------------------------------------------------------
890 modules modules_install
: FORCE
892 @echo
"The present kernel configuration has modules disabled."
893 @echo
"Type 'make config' and enable loadable module support."
894 @echo
"Then build a kernel with module support enabled."
898 endif # CONFIG_MODULES
901 # Cleaning is done on three levels.
902 # make clean Delete most generated files
903 # Leave enough to build external modules
904 # make mrproper Delete the current configuration, and all generated files
905 # make distclean Remove editor backup files, patch leftover files and the like
907 # Directories & files removed with 'make clean'
908 CLEAN_DIRS
+= $(MODVERDIR
)
909 CLEAN_FILES
+= uboot System.map
include/uboot_default_env.h \
910 .tmp_version .tmp_uboot
* uboot.bin uboot.S \
911 .tmp_kallsyms
* uboot_default_env
913 # Directories & files removed with 'make mrproper'
914 MRPROPER_DIRS
+= include/config include2 usr
/include
915 MRPROPER_FILES
+= .config .config.old
include/asm .version .old_version \
916 include/linux
/autoconf.h
include/linux
/version.h \
917 include/linux
/utsrelease.h
include/config.h \
918 Module.symvers
tags TAGS cscope
*
920 # clean - Delete most, but leave enough to build external modules
922 clean: rm-dirs
:= $(CLEAN_DIRS
)
923 clean: rm-files
:= $(CLEAN_FILES
)
924 clean-dirs
:= $(addprefix _clean_
,$(srctree
) $(uboot-alldirs
))
926 PHONY
+= $(clean-dirs
) clean archclean
928 $(Q
)$(MAKE
) $(clean)=$(patsubst _clean_
%,%,$@
)
930 clean: archclean
$(clean-dirs
)
933 @find .
$(RCS_FIND_IGNORE
) \
934 \
( -name
'*.[oas]' -o
-name
'*.ko' -o
-name
'.*.cmd' \
935 -o
-name
'.*.d' -o
-name
'.*.tmp' -o
-name
'*.mod.c' \
936 -o
-name
'*.symtypes' \
) \
937 -type f
-print | xargs
rm -f
939 # mrproper - Delete all generated files, including .config
941 mrproper
: rm-dirs
:= $(wildcard $(MRPROPER_DIRS
))
942 mrproper
: rm-files
:= $(wildcard $(MRPROPER_FILES
))
943 mrproper-dirs
:= $(addprefix _mrproper_
,scripts
)
945 PHONY
+= $(mrproper-dirs
) mrproper archmrproper
947 $(Q
)$(MAKE
) $(clean)=$(patsubst _mrproper_
%,%,$@
)
949 mrproper
: clean archmrproper
$(mrproper-dirs
)
958 @find
$(srctree
) $(RCS_FIND_IGNORE
) \
959 \
( -name
'*.orig' -o
-name
'*.rej' -o
-name
'*~' \
960 -o
-name
'*.bak' -o
-name
'#*#' -o
-name
'.*.orig' \
961 -o
-name
'.*.rej' -o
-size
0 \
962 -o
-name
'*%' -o
-name
'.*.cmd' -o
-name
'core' \
) \
963 -type f
-print | xargs
rm -f
966 # Packaging of the kernel to various formats
967 # ---------------------------------------------------------------------------
968 # rpm target kept for backward compatibility
969 package-dir
:= $(srctree
)/scripts
/package
971 %pkg
: include/config
/kernel.release FORCE
972 $(Q
)$(MAKE
) $(build
)=$(package-dir
) $@
973 rpm
: include/config
/kernel.release FORCE
974 $(Q
)$(MAKE
) $(build
)=$(package-dir
) $@
977 # Brief documentation of the typical targets used
978 # ---------------------------------------------------------------------------
980 boards
:= $(wildcard $(srctree
)/arch
/$(ARCH
)/configs
/*_defconfig
)
981 boards
:= $(notdir $(boards
))
984 @echo
'Cleaning targets:'
985 @echo
' clean - Remove most generated files but keep the config and'
986 @echo
' enough build support to build external modules'
987 @echo
' mrproper - Remove all generated files + config + various backup files'
988 @echo
' distclean - mrproper + remove editor backup and patch files'
989 @echo
' docs - start doxygen for all output types (only HTML - FIXME)'
990 @echo
' htmldocs - create documentation in HTML format'
992 @echo
'Configuration targets:'
993 @
$(MAKE
) -f
$(srctree
)/scripts
/kconfig
/Makefile help
995 @echo
'Other generic targets:'
996 @echo
' all - Build all targets marked with [*]'
997 @echo
'* uboot - Build the bare kernel'
998 @echo
' dir/ - Build all files in dir and below'
999 @echo
' dir/file.[ois] - Build specified target only'
1000 @echo
' dir/file.ko - Build module including final link'
1001 @echo
' tags/TAGS - Generate tags file for editors'
1002 @echo
' cscope - Generate cscope index'
1003 @echo
' (default: $(INSTALL_HDR_PATH))'
1005 @echo
'Static analysers'
1006 @echo
' checkstack - Generate a list of stack hogs'
1007 @echo
' namespacecheck - Name space analysis on compiled kernel'
1008 @if
[ -r
include/asm-
$(ARCH
)/Kbuild
]; then \
1009 echo
' headers_check - Sanity check on exported headers'; \
1012 @echo
'Architecture specific targets ($(ARCH)):'
1013 @
$(if
$(archhelp
),$(archhelp
),\
1014 echo
' No architecture specific help defined for $(ARCH)')
1017 $(foreach b
, $(boards
), \
1018 printf
" %-24s - Build for %s\\n" $(b
) $(subst _defconfig
,,$(b
));) \
1021 @echo
' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
1022 @echo
' make V=2 [targets] 2 => give reason for rebuild of target'
1023 @echo
' make O=dir [targets] Locate all output files in "dir", including .config'
1024 @echo
' make C=1 [targets] Check all c source with $$CHECK (sparse by default)'
1025 @echo
' make C=2 [targets] Force check of all c source with $$CHECK'
1027 @echo
'Execute "make" or "make all" to build all targets marked with [*] '
1028 @echo
'For further info see the ./README file'
1030 # Generate doxygen docs
1031 # ---------------------------------------------------------------------------
1032 .PHONY
+= docs htmldocs
1037 @echo
'Running doxygen with local Doxyfile'
1038 $(Q
)doxygen Doxyfile
1040 # Generate tags for editors
1041 # ---------------------------------------------------------------------------
1043 #We want __srctree to totally vanish out when KBUILD_OUTPUT is not set
1044 #(which is the most common case IMHO) to avoid unneeded clutter in the big tags file.
1045 #Adding $(srctree) adds about 20M on i386 to the size of the output file!
1047 ifeq ($(src
),$(obj
))
1050 __srctree
= $(srctree
)/
1053 ifeq ($(ALLSOURCE_ARCHS
),)
1055 ALLINCLUDE_ARCHS
:= $(ARCH
) $(SUBARCH
)
1057 ALLINCLUDE_ARCHS
:= $(ARCH
)
1060 #Allow user to specify only ALLSOURCE_PATHS on the command line, keeping existing behavour.
1061 ALLINCLUDE_ARCHS
:= $(ALLSOURCE_ARCHS
)
1064 ALLSOURCE_ARCHS
:= $(ARCH
)
1067 ( find
$(__srctree
) $(RCS_FIND_IGNORE
) \
1068 \
( -name
include -o
-name arch \
) -prune
-o \
1070 for ARCH in
$(ALLSOURCE_ARCHS
) ; do \
1071 find
$(__srctree
)arch
/$${ARCH} $(RCS_FIND_IGNORE
) \
1074 find
$(__srctree
)include $(RCS_FIND_IGNORE
) \
1075 \
( -name config
-o
-name
'asm-*' \
) -prune \
1076 -o
-name
$1 -print; \
1077 for ARCH in
$(ALLINCLUDE_ARCHS
) ; do \
1078 find
$(__srctree
)include/asm-
$${ARCH} $(RCS_FIND_IGNORE
) \
1081 find
$(__srctree
)include/asm-generic
$(RCS_FIND_IGNORE
) \
1086 $(call find-sources
,'*.[chS]')
1089 $(call find-sources
,'Kconfig*')
1091 define all-defconfigs
1092 $(call find-sources
,'defconfig')
1096 if
$1 --version
2>&1 | grep
-iq exuberant
; then \
1097 $(all-sources
) | xargs
$1 -a \
1098 -I __initdata
,__exitdata
,__acquires
,__releases \
1099 -I EXPORT_SYMBOL
,EXPORT_SYMBOL_GPL \
1100 --extra
=+f
--c-kinds
=+px \
1101 --regex-asm
='/ENTRY\(([^)]*)\).*/\1/'; \
1102 $(all-kconfigs
) | xargs
$1 -a \
1104 --language-force
=kconfig \
1105 --regex-kconfig
='/^[[:blank:]]*config[[:blank:]]+([[:alnum:]_]+)/\1/'; \
1106 $(all-defconfigs
) | xargs
-r
$1 -a \
1107 --langdef
=dotconfig \
1108 --language-force
=dotconfig \
1109 --regex-dotconfig
='/^#?[[:blank:]]*(CONFIG_[[:alnum:]_]+)/\1/'; \
1110 elif
$1 --version
2>&1 | grep
-iq emacs
; then \
1111 $(all-sources
) | xargs
$1 -a
; \
1112 $(all-kconfigs
) | xargs
$1 -a \
1113 --regex
='/^[ \t]*config[ \t]+\([a-zA-Z0-9_]+\)/\1/'; \
1114 $(all-defconfigs
) | xargs
-r
$1 -a \
1115 --regex
='/^#?[ \t]?\(CONFIG_[a-zA-Z0-9_]+\)/\1/'; \
1117 $(all-sources
) | xargs
$1 -a
; \
1121 quiet_cmd_cscope-file
= FILELST cscope.files
1122 cmd_cscope-file
= (echo \
-k
; echo \
-q
; $(all-sources
)) > cscope.files
1124 quiet_cmd_cscope
= MAKE cscope.out
1125 cmd_cscope
= cscope
-b
1128 $(call cmd
,cscope-file
)
1131 quiet_cmd_TAGS
= MAKE
$@
1140 quiet_cmd_tags
= MAKE
$@
1150 endif #ifeq ($(config-targets),1)
1151 endif #ifeq ($(mixed-targets),1)
1154 # ---------------------------------------------------------------------------
1155 # Single targets are compatible with:
1156 # - build whith mixed source and output
1157 # - build with separate output dir 'make O=...'
1158 # - external modules
1160 # target-dir => where to store outputfile
1161 # build-dir => directory in kernel source tree to use
1163 build-dir
= $(patsubst %/,%,$(dir $@
))
1164 target-dir
= $(dir $@
)
1166 %.s
: %.c prepare scripts FORCE
1167 $(Q
)$(MAKE
) $(build
)=$(build-dir
) $(target-dir
)$(notdir $@
)
1168 %.i
: %.c prepare scripts FORCE
1169 $(Q
)$(MAKE
) $(build
)=$(build-dir
) $(target-dir
)$(notdir $@
)
1170 %.o
: %.c prepare scripts FORCE
1171 $(Q
)$(MAKE
) $(build
)=$(build-dir
) $(target-dir
)$(notdir $@
)
1172 %.lst
: %.c prepare scripts FORCE
1173 $(Q
)$(MAKE
) $(build
)=$(build-dir
) $(target-dir
)$(notdir $@
)
1174 %.s
: %.S prepare scripts FORCE
1175 $(Q
)$(MAKE
) $(build
)=$(build-dir
) $(target-dir
)$(notdir $@
)
1176 %.o
: %.S prepare scripts FORCE
1177 $(Q
)$(MAKE
) $(build
)=$(build-dir
) $(target-dir
)$(notdir $@
)
1178 %.symtypes
: %.c prepare scripts FORCE
1179 $(Q
)$(MAKE
) $(build
)=$(build-dir
) $(target-dir
)$(notdir $@
)
1182 / %/: prepare scripts FORCE
1183 $(Q
)$(MAKE
) $(build
)=$(build-dir
)
1184 %.ko
: prepare scripts FORCE
1185 $(Q
)$(MAKE
) KBUILD_MODULES
=$(if
$(CONFIG_MODULES
),1) \
1186 $(build
)=$(build-dir
) $(@
:.ko
=.o
)
1187 $(Q
)$(MAKE
) -f
$(srctree
)/scripts
/Makefile.modpost
1189 # FIXME Should go into a make.lib or something
1190 # ===========================================================================
1192 quiet_cmd_rmdirs
= $(if
$(wildcard $(rm-dirs
)),CLEAN
$(wildcard $(rm-dirs
)))
1193 cmd_rmdirs
= rm -rf
$(rm-dirs
)
1195 quiet_cmd_rmfiles
= $(if
$(wildcard $(rm-files
)),CLEAN
$(wildcard $(rm-files
)))
1196 cmd_rmfiles
= rm -f
$(rm-files
)
1199 a_flags
= -Wp
,-MD
,$(depfile
) $(AFLAGS
) $(AFLAGS_KERNEL
) \
1200 $(NOSTDINC_FLAGS
) $(CPPFLAGS
) \
1201 $(modkern_aflags
) $(EXTRA_AFLAGS
) $(AFLAGS_
$(basetarget
).o
)
1203 quiet_cmd_as_o_S
= AS
$@
1204 cmd_as_o_S
= $(CC
) $(a_flags
) -c
-o
$@
$<
1206 # read all saved command lines
1208 targets
:= $(wildcard $(sort $(targets
)))
1209 cmd_files
:= $(wildcard .
*.cmd
$(foreach f
,$(targets
),$(dir $(f
)).
$(notdir $(f
)).cmd
))
1211 ifneq ($(cmd_files
),)
1212 $(cmd_files
): ; # Do not try to update included dependency files
1213 include $(cmd_files
)
1216 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir
1218 # $(Q)$(MAKE) $(clean)=dir
1219 clean := -f
$(if
$(KBUILD_SRC
),$(srctree
)/)scripts
/Makefile.
clean obj
1221 endif # skip-makefile
1226 # Cancel implicit rules on top Makefile, `-rR' will apply to sub-makes.
1229 # Declare the contents of the .PHONY variable as phony. We keep that
1230 # information in a variable se we can use it in if_changed and friends.
1234 # sanity checks for check default environemnt
1236 ifdef CONFIG_DEFAULT_ENVIRONMENT
1238 ifeq ($(CONFIG_DEFAULT_ENVIRONMENT_PATH
),"")
1239 $(error default environment path empty
))
1242 saved-env_path
:= $(CONFIG_DEFAULT_ENVIRONMENT_PATH
)
1243 CONFIG_DEFAULT_ENVIRONMENT_PATH
:= $(shell cd
$(if
$(filter /%,$(CONFIG_DEFAULT_ENVIRONMENT_PATH
)),,$(srctree
)/)$(CONFIG_DEFAULT_ENVIRONMENT_PATH
) && /bin
/pwd
)
1244 $(if
$(CONFIG_DEFAULT_ENVIRONMENT_PATH
),, \
1245 $(error default environment path
$(saved-env_path
) does not exist
))
1247 endif # ifdef CONFIG_DEFAULT_ENVIRONMENT