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.
13 # Do not print "Entering directory ..."
14 MAKEFLAGS
+= --no-print-directory
16 # We are using a recursive build, so we need to do a little thinking
17 # to get the ordering right.
19 # Most importantly: sub-Makefiles should only ever modify files in
20 # their own directory. If in some directory we have a dependency on
21 # a file in another dir (which doesn't happen often, but it's of
22 # unavoidable when linking the built-in.o targets which finally
23 # turn into vmlinux), we will call a sub make in that other dir, and
24 # after that we are sure that everything which is in that other dir
27 # The only cases where we need to modify files which have global
28 # effects are thus separated out and done before the recursive
29 # descending is started. They are now explicitly listed as the
32 # To put more focus on warnings, be less verbose as default
33 # Use 'make V=1' to see the full commands
36 ifeq ("$(origin V)", "command line")
44 # Call sparse as part of compilation of C files
45 # Use 'make C=1' to enable sparse checking
48 ifeq ("$(origin C)", "command line")
49 KBUILD_CHECKSRC
= $(C
)
52 ifndef KBUILD_CHECKSRC
56 # kbuild supports saving output files in a separate directory.
57 # To locate output files in a separate directory two syntax'es are supported.
58 # In both cases the working directory must be the root of the kernel src.
60 # Use "make O=dir/to/store/output/files/"
62 # 2) Set KBUILD_OUTPUT
63 # Set the environment variable KBUILD_OUTPUT to point to the directory
64 # where the output files shall be placed.
65 # export KBUILD_OUTPUT=dir/to/store/output/files/
68 # The O= assigment takes precedence over the KBUILD_OUTPUT environment variable.
71 # KBUILD_SRC is set on invocation of make in OBJ directory
72 # KBUILD_SRC is not intended to be used by the regular user (for now)
75 # OK, Make called in directory where kernel src resides
76 # Do we want to locate output files in a separate directory?
78 ifeq ("$(origin O)", "command line")
83 # That's our default target when none is given on the command line
87 ifneq ($(KBUILD_OUTPUT
),)
88 # Invoke a second make in the output directory, passing relevant variables
89 # check that the output directory actually exists
90 saved-output
:= $(KBUILD_OUTPUT
)
91 KBUILD_OUTPUT
:= $(shell cd
$(KBUILD_OUTPUT
) && /bin
/pwd
)
92 $(if
$(wildcard $(KBUILD_OUTPUT
)),, \
93 $(error output directory
"$(saved-output)" does not exist
))
95 .PHONY
: $(MAKECMDGOALS
)
97 $(filter-out all,$(MAKECMDGOALS
)) all:
98 $(if
$(KBUILD_VERBOSE
:1=),@
)$(MAKE
) -C
$(KBUILD_OUTPUT
) \
99 KBUILD_SRC
=$(CURDIR
) KBUILD_VERBOSE
=$(KBUILD_VERBOSE
) \
100 KBUILD_CHECK
=$(KBUILD_CHECK
) -f
$(CURDIR
)/Makefile
$@
102 # Leave processing to above invocation of make
104 endif # ifneq ($(KBUILD_OUTPUT),)
105 endif # ifeq ($(KBUILD_SRC),)
107 # We process the rest of the Makefile if this is the final invocation of make
108 ifeq ($(skip-makefile
),)
110 # Make sure we're not wasting cpu-cycles doing locale handling, yet do make
111 # sure error messages appear in the user-desired language
118 export LANG LC_ALL LC_COLLATE LC_CTYPE
120 srctree
:= $(if
$(KBUILD_SRC
),$(KBUILD_SRC
),$(CURDIR
))
122 # FIXME - TOPDIR is obsolete, use srctree/objtree
129 export srctree objtree VPATH TOPDIR
131 KERNELRELEASE
=$(VERSION
).
$(PATCHLEVEL
).
$(SUBLEVEL
)$(EXTRAVERSION
)
133 # SUBARCH tells the usermode build what the underlying arch is. That is set
134 # first, and if a usermode build is happening, the "ARCH=um" on the command
135 # line overrides the setting of ARCH below. If a native build is happening,
136 # then ARCH is assigned, getting whatever value it gets normally, and
137 # SUBARCH is subsequently ignored.
139 SUBARCH
:= $(shell uname
-m | sed
-e s
/i
.86/i386
/ -e s
/sun4u
/sparc64
/ \
140 -e s
/arm.
*/arm
/ -e s
/sa110
/arm
/ \
141 -e s
/s390x
/s390
/ -e s
/parisc64
/parisc
/ )
143 # Cross compiling and selecting different set of gcc/bin-utils
144 # ---------------------------------------------------------------------------
146 # When performing cross compilation for other architectures ARCH shall be set
147 # to the target architecture. (See arch/* for the possibilities).
148 # ARCH can be set during invocation of make:
150 # Another way is to have ARCH set in the environment.
151 # The default ARCH is the host where make is executed.
153 # CROSS_COMPILE specify the prefix used for all executables used
154 # during compilation. Only gcc and related bin-utils executables
155 # are prefixed with $(CROSS_COMPILE).
156 # CROSS_COMPILE can be set on the command line
157 # make CROSS_COMPILE=ia64-linux-
158 # Alternatively CROSS_COMPILE can be set in the environment.
159 # Default value for CROSS_COMPILE is not to prefix executables
160 # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
165 # Architecture as present in compile.h
166 UTS_MACHINE
:= $(ARCH
)
168 # SHELL used by kbuild
169 CONFIG_SHELL
:= $(shell if
[ -x
"$$BASH" ]; then echo
$$BASH; \
170 else if
[ -x
/bin
/bash
]; then echo
/bin
/bash
; \
171 else echo sh
; fi
; fi
)
175 HOSTCFLAGS
= -Wall
-Wstrict-prototypes
-O2
-fomit-frame-pointer
178 # Decide whether to build built-in, modular, or both.
179 # Normally, just do built-in.
184 # If we have only "make modules", don't compile built-in objects.
185 # When we're building modules with modversions, we need to consider
186 # the built-in objects during the descend as well, in order to
187 # make sure the checksums are uptodate before we record them.
189 ifeq ($(MAKECMDGOALS
),modules
)
190 KBUILD_BUILTIN
:= $(if
$(CONFIG_MODVERSIONS
),1)
193 # If we have "make <whatever> modules", compile modules
194 # in addition to whatever we do anyway.
195 # Just "make" or "make all" shall build modules as well
197 ifneq ($(filter all modules
,$(MAKECMDGOALS
)),)
201 ifeq ($(MAKECMDGOALS
),)
205 export KBUILD_MODULES KBUILD_BUILTIN KBUILD_VERBOSE
206 export KBUILD_CHECKSRC KBUILD_SRC
209 # ---------------------------------------------------------------------------
211 # Normally, we echo the whole command before executing it. By making
212 # that echo $($(quiet)$(cmd)), we now have the possibility to set
213 # $(quiet) to choose other forms of output instead, e.g.
215 # quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
216 # cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
218 # If $(quiet) is empty, the whole command will be printed.
219 # If it is set to "quiet_", only the short version will be printed.
220 # If it is set to "silent_", nothing wil be printed at all, since
221 # the variable $(silent_cmd_cc_o_c) doesn't exist.
223 # A simple variant is to prefix commands with $(Q) - that's usefull
224 # for commands that shall be hidden in non-verbose mode.
228 # If KBUILD_VERBOSE equals 0 then the above command will be hidden.
229 # If KBUILD_VERBOSE equals 1 then the above command is displayed.
231 ifeq ($(KBUILD_VERBOSE
),1)
239 # If the user is running make -s (silent mode), suppress echoing of
242 ifneq ($(findstring s
,$(MAKEFLAGS
)),)
246 check_gcc
= $(shell if
$(CC
) $(CFLAGS
) $(1) -S
-o
/dev
/null
-xc
/dev
/null
> /dev
/null
2>&1; then echo
"$(1)"; else echo
"$(2)"; fi
;)
248 export quiet Q KBUILD_VERBOSE check_gcc
250 # Look for make include files relative to root of kernel src
251 MAKEFLAGS
+= --include-dir
=$(srctree
)
253 # For maximum performance (+ possibly random breakage, uncomment
258 # Make variables (CC, etc...)
260 AS
= $(CROSS_COMPILE
)as
261 LD
= $(CROSS_COMPILE
)ld
262 CC
= $(CROSS_COMPILE
)gcc
264 AR
= $(CROSS_COMPILE
)ar
265 NM
= $(CROSS_COMPILE
)nm
266 STRIP
= $(CROSS_COMPILE
)strip
267 OBJCOPY
= $(CROSS_COMPILE
)objcopy
268 OBJDUMP
= $(CROSS_COMPILE
)objdump
270 RPM
:= $(shell if
[ -x
"/usr/bin/rpmbuild" ]; then echo rpmbuild
; \
272 GENKSYMS
= scripts
/genksyms
/genksyms
273 DEPMOD
= /sbin
/depmod
274 KALLSYMS
= scripts
/kallsyms
278 CFLAGS_MODULE
= $(MODFLAGS
)
279 AFLAGS_MODULE
= $(MODFLAGS
)
284 NOSTDINC_FLAGS
= -nostdinc
-iwithprefix
include
286 CPPFLAGS
:= -D__KERNEL__
-Iinclude \
287 $(if
$(KBUILD_SRC
),-Iinclude2
-I
$(srctree
)/include)
289 CFLAGS
:= -Wall
-Wstrict-prototypes
-Wno-trigraphs \
290 -fno-strict-aliasing
-fno-common
291 AFLAGS
:= -D__ASSEMBLY__
293 export VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION KERNELRELEASE ARCH \
294 CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \
295 CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE \
296 HOSTCXX HOSTCXXFLAGS LDFLAGS_BLOB LDFLAGS_MODULE CHECK
298 export CPPFLAGS NOSTDINC_FLAGS OBJCOPYFLAGS LDFLAGS
299 export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
300 export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
302 export MODVERDIR
:= .tmp_versions
304 # The temporary file to save gcc -MD generated dependencies must not
307 depfile
= $(subst $(comma
),_
,$(@D
)/.
$(@F
).d
)
309 # Files to ignore in find ... statements
311 RCS_FIND_IGNORE
:= \
( -name SCCS
-o
-name BitKeeper
-o
-name .svn
-o
-name CVS \
) -prune
-o
312 RCS_TAR_IGNORE
:= --exclude SCCS
--exclude BitKeeper
--exclude .svn
--exclude CVS
314 # ===========================================================================
315 # Rules shared between *config targets and build targets
317 # Basic helpers built in scripts/
318 .PHONY
: scripts_basic
320 $(Q
)$(MAKE
) $(build
)=scripts
/basic
322 # To make sure we do not include .config for any of the *config targets
323 # catch them early, and hand them over to scripts/kconfig/Makefile
324 # It is allowed to specify more targets when calling make, including
325 # mixing *config targets and build targets.
326 # For example 'make oldconfig all'.
327 # Detect when mixed targets is specified, and make a second invocation
328 # of make so .config is not included in this case either (for *config).
330 no-dot-config-targets
:= clean mrproper
distclean \
331 cscope TAGS
tags help
%docs
check%
337 ifneq ($(filter $(no-dot-config-targets
), $(MAKECMDGOALS
)),)
338 ifeq ($(filter-out $(no-dot-config-targets
), $(MAKECMDGOALS
)),)
343 ifneq ($(filter config
%config
,$(MAKECMDGOALS
)),)
345 ifneq ($(filter-out config
%config
,$(MAKECMDGOALS
)),)
350 ifeq ($(mixed-targets
),1)
351 # ===========================================================================
352 # We're called with mixed targets (*config and build targets).
353 # Handle them one by one.
356 $(Q
)$(MAKE
) -C
$(srctree
) KBUILD_SRC
= $@
359 ifeq ($(config-targets
),1)
360 # ===========================================================================
361 # *config targets only - make sure prerequisites are updated, and descend
362 # in scripts/kconfig to make the *config target
364 config
: scripts_basic FORCE
365 $(Q
)$(MAKE
) $(build
)=scripts
/kconfig
$@
366 %config
: scripts_basic FORCE
367 $(Q
)$(MAKE
) $(build
)=scripts
/kconfig
$@
370 # ===========================================================================
371 # Build targets only - this includes vmlinux, arch specific targets, clean
372 # targets and others. In general all targets except *config targets.
374 # Additional helpers built in scripts/
375 # Carefully list dependencies so we do not try to build scripts twice
378 scripts
: scripts_basic
include/config
/MARKER
379 $(Q
)$(MAKE
) $(build
)=$(@
)
381 scripts_basic
: include/linux
/autoconf.h
384 # That's our default target when none is given on the command line
385 # Note that 'modules' will be added as a prerequisite as well,
386 # in the CONFIG_MODULES part below
390 # Objects we will link into vmlinux / subdirs we need to visit
392 drivers-y
:= drivers
/ sound
/
398 ifeq ($(dot-config
),1)
399 # In this section, we need .config
401 # Read in dependencies to all Kconfig* files, make sure to run
402 # oldconfig if changes are detected.
407 # If .config needs to be updated, it will be done via the dependency
408 # that autoconf has on .config.
409 # To avoid any implicit rule to kick in, define an empty command
412 # If .config is newer than include/linux/autoconf.h, someone tinkered
413 # with it and forgot to run make oldconfig
414 include/linux
/autoconf.h
: .config
415 $(Q
)$(MAKE
) -f
$(srctree
)/Makefile silentoldconfig
417 # Dummy target needed, because used as prerequisite
418 include/linux
/autoconf.h
: ;
421 include $(srctree
)/arch
/$(ARCH
)/Makefile
423 # Let architecture Makefiles change CPPFLAGS if needed
424 CFLAGS
:= $(CPPFLAGS
) $(CFLAGS
)
425 AFLAGS
:= $(CPPFLAGS
) $(AFLAGS
)
427 core-y
+= kernel
/ mm
/ fs
/ ipc
/ security
/ crypto
/
429 SUBDIRS
+= $(patsubst %/,%,$(filter %/, $(init-y
) $(init-m
) \
430 $(core-y
) $(core-m
) $(drivers-y
) $(drivers-m
) \
431 $(net-y
) $(net-m
) $(libs-y
) $(libs-m
)))
433 ALL_SUBDIRS
:= $(sort $(SUBDIRS
) $(patsubst %/,%,$(filter %/, \
435 $(core-n
) $(core-
) $(drivers-n
) $(drivers-
) \
436 $(net-n
) $(net-
) $(libs-n
) $(libs-
))))
438 init-y
:= $(patsubst %/, %/built-in.o
, $(init-y
))
439 core-y
:= $(patsubst %/, %/built-in.o
, $(core-y
))
440 drivers-y
:= $(patsubst %/, %/built-in.o
, $(drivers-y
))
441 net-y
:= $(patsubst %/, %/built-in.o
, $(net-y
))
442 libs-y1
:= $(patsubst %/, %/lib.a
, $(libs-y
))
443 libs-y2
:= $(patsubst %/, %/built-in.o
, $(libs-y
))
444 libs-y
:= $(libs-y1
) $(libs-y2
)
446 # Here goes the main Makefile
447 # ---------------------------------------------------------------------------
450 ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
456 ifndef CONFIG_FRAME_POINTER
457 CFLAGS
+= -fomit-frame-pointer
460 ifdef CONFIG_DEBUG_INFO
464 # warn about C99 declaration after statement
465 CFLAGS
+= $(call check_gcc
,-Wdeclaration-after-statement
,)
468 # INSTALL_PATH specifies where to place the updated kernel and system map
469 # images. Uncomment if you want to place them anywhere other than root.
472 #export INSTALL_PATH=/boot
475 # INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
476 # relocations required by build roots. This is not defined in the
477 # makefile but the arguement can be passed to make if needed.
480 MODLIB
:= $(INSTALL_MOD_PATH
)/lib
/modules
/$(KERNELRELEASE
)
484 # ---------------------------------------------------------------------------
486 # This is a bit tricky: If we need to relink vmlinux, we want
487 # the version number incremented, which means recompile init/version.o
488 # and relink init/init.o. However, we cannot do this during the
489 # normal descending-into-subdirs phase, since at that time
490 # we cannot yet know if we will need to relink vmlinux.
491 # So we descend into init/ inside the rule for vmlinux again.
493 vmlinux-objs
:= $(head-y
) $(init-y
) $(core-y
) $(libs-y
) $(drivers-y
) $(net-y
)
495 quiet_cmd_vmlinux__
= LD
$@
497 $(LD
) $(LDFLAGS
) $(LDFLAGS_vmlinux
) $(head-y
) $(init-y
) \
504 $(filter .tmp_kallsyms
%,$^
) \
508 # set -e makes the rule exit immediately on error
510 define rule_vmlinux__
512 $(if
$(filter .tmp_kallsyms
%,$^
),, \
513 echo
' GEN .version'; \
514 .
$(srctree
)/scripts
/mkversion
> .tmp_version
; \
515 mv
-f .tmp_version .version
; \
516 $(MAKE
) $(build
)=init
; \
518 $(if
$($(quiet
)cmd_vmlinux__
), \
519 echo
' $($(quiet)cmd_vmlinux__)' &&) \
521 echo
'cmd_$@ := $(cmd_vmlinux__)' > $(@D
)/.
$(@F
).cmd
526 $(NM
) $@ | grep
-v
'\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' |
sort > System.map
529 LDFLAGS_vmlinux
+= -T arch
/$(ARCH
)/kernel
/vmlinux.lds.s
531 # Generate section listing all symbols and add it into vmlinux
532 # It's a three stage process:
533 # o .tmp_vmlinux1 has all symbols and sections, but __kallsyms is
535 # Running kallsyms on that gives us .tmp_kallsyms1.o with
537 # o .tmp_vmlinux2 now has a __kallsyms section of the right size,
538 # but due to the added section, some addresses have shifted
539 # From here, we generate a correct .tmp_kallsyms2.o
540 # o The correct .tmp_kallsyms2.o is linked into the final vmlinux.
542 ifdef CONFIG_KALLSYMS
544 kallsyms.o
:= .tmp_kallsyms2.o
546 quiet_cmd_kallsyms
= KSYM
$@
547 cmd_kallsyms
= $(NM
) -n
$< |
$(KALLSYMS
) > $@
549 .tmp_kallsyms1.o .tmp_kallsyms2.o
: %.o
: %.S scripts FORCE
550 $(call if_changed_dep
,as_o_S
)
552 .tmp_kallsyms
%.S
: .tmp_vmlinux
%
555 .tmp_vmlinux1
: $(vmlinux-objs
) arch
/$(ARCH
)/kernel
/vmlinux.lds.s FORCE
556 +$(call if_changed_rule
,vmlinux__
)
558 .tmp_vmlinux2
: $(vmlinux-objs
) .tmp_kallsyms1.o arch
/$(ARCH
)/kernel
/vmlinux.lds.s FORCE
559 $(call if_changed_rule
,vmlinux__
)
563 # Finally the vmlinux rule
565 vmlinux
: $(vmlinux-objs
) $(kallsyms.o
) arch
/$(ARCH
)/kernel
/vmlinux.lds.s FORCE
566 $(call if_changed_rule
,vmlinux
)
568 # The actual objects are generated when descending,
569 # make sure no implicit rule kicks in
571 $(sort $(vmlinux-objs
)) arch
/$(ARCH
)/kernel
/vmlinux.lds.s
: $(SUBDIRS
) ;
573 # Handle descending into subdirectories listed in $(SUBDIRS)
576 $(SUBDIRS
): prepare-all scripts
577 $(Q
)$(MAKE
) $(build
)=$@
579 # Things we need to do before we recursively start building the kernel
580 # or the modules are listed in "prepare-all".
581 # A multi level approach is used. prepare1 is updated first, then prepare0.
582 # prepare-all is the collection point for the prepare targets.
584 .PHONY
: prepare-all prepare prepare0 prepare1
586 # prepare1 is used to check if we are building in a separate output directory,
588 # 1) Check that make has not been executed in the kernel src $(srctree)
589 # 2) Create the include2 directory, used for the second asm symlink
592 ifneq ($(KBUILD_SRC
),)
593 @echo
' Using $(srctree) as source for kernel'
594 $(Q
)if
[ -h
$(srctree
)/include/asm
-o
-f
$(srctree
)/.config
]; then \
595 echo
" $(srctree) is not clean, please run 'make mrproper'";\
596 echo
" in the '$(srctree)' directory.";\
599 $(Q
)if
[ ! -d include2
]; then mkdir
-p include2
; fi
;
600 $(Q
)ln
-fsn
$(srctree
)/include/asm-
$(ARCH
) include2
/asm
603 prepare0
: prepare1
include/linux
/version.h
include/asm
include/config
/MARKER
605 ifeq ($(origin SUBDIRS
),file
)
606 $(Q
)rm -rf
$(MODVERDIR
)
608 @echo
'*** Warning: Overriding SUBDIRS on the command line can cause'
609 @echo
'*** inconsistencies'
612 $(if
$(CONFIG_MODULES
),$(Q
)mkdir
-p
$(MODVERDIR
))
614 # All the preparing..
615 prepare-all
: prepare0 prepare
617 # Leave this as default for preprocessing vmlinux.lds.S, which is now
618 # done in arch/$(ARCH)/kernel/Makefile
620 export AFLAGS_vmlinux.lds.o
+= -P
-C
-U
$(ARCH
)
623 # ---------------------------------------------------------------------------
625 %.s
: %.c scripts FORCE
626 $(Q
)$(MAKE
) $(build
)=$(@D
) $@
627 %.i
: %.c scripts FORCE
628 $(Q
)$(MAKE
) $(build
)=$(@D
) $@
629 %.o
: %.c scripts FORCE
630 $(Q
)$(MAKE
) $(build
)=$(@D
) $@
631 %/: scripts prepare FORCE
632 $(Q
)$(MAKE
) KBUILD_MODULES
=$(if
$(CONFIG_MODULES
),1) $(build
)=$(@D
)
633 %.lst
: %.c scripts FORCE
634 $(Q
)$(MAKE
) $(build
)=$(@D
) $@
635 %.s
: %.S scripts FORCE
636 $(Q
)$(MAKE
) $(build
)=$(@D
) $@
637 %.o
: %.S scripts FORCE
638 $(Q
)$(MAKE
) $(build
)=$(@D
) $@
640 # FIXME: The asm symlink changes when $(ARCH) changes. That's
641 # hard to detect, but I suppose "make mrproper" is a good idea
642 # before switching between archs anyway.
645 @echo
' SYMLINK $@ -> include/asm-$(ARCH)'
646 $(Q
)if
[ ! -d
include ]; then mkdir
-p
include; fi
;
647 @ln
-fsn asm-
$(ARCH
) $@
649 # Split autoconf.h into include/linux/config/*
651 include/config
/MARKER
: include/linux
/autoconf.h
652 @echo
' SPLIT include/linux/autoconf.h -> include/config/*'
653 @scripts
/basic
/split-include
include/linux
/autoconf.h
include/config
656 # Generate some files
657 # ---------------------------------------------------------------------------
659 # version.h changes when $(KERNELRELEASE) etc change, as defined in
664 define filechk_version.h
665 if
((`echo -n "$(KERNELRELEASE)" | wc -c ` > $(uts_len
))); then \
666 echo
'"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \
669 (echo \
#define UTS_RELEASE \"$(KERNELRELEASE)\"; \
670 echo \
#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)`; \
671 echo
'#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))'; \
675 include/linux
/version.h
: Makefile
676 $(call filechk
,version.h
)
678 # ---------------------------------------------------------------------------
682 @echo
'*** Warning: make $@ is unnecessary now.'
684 # ---------------------------------------------------------------------------
689 # By default, build modules as well
696 modules
: $(SUBDIRS
) $(if
$(KBUILD_BUILTIN
),vmlinux
)
697 @echo
' Building modules, stage 2.';
698 $(Q
)$(MAKE
) -rR
-f
$(srctree
)/scripts
/Makefile.modpost
702 .PHONY
: modules_install
703 modules_install
: _modinst_ _modinst_post
707 @if
[ -z
"`$(DEPMOD) -V | grep module-init-tools`" ]; then \
708 echo
"Warning: you may need to install module-init-tools"; \
709 echo
"See http://www.codemonkey.org.uk/docs/post-halloween-2.6.txt";\
712 @
rm -rf
$(MODLIB
)/kernel
713 @
rm -f
$(MODLIB
)/build
714 @mkdir
-p
$(MODLIB
)/kernel
715 @ln
-s
$(TOPDIR
) $(MODLIB
)/build
716 $(Q
)$(MAKE
) -rR
-f
$(srctree
)/scripts
/Makefile.modinst
718 # If System.map exists, run depmod. This deliberately does not have a
719 # dependency on System.map since that would run the dependency tree on
720 # vmlinux. This depmod is only for convenience to give the initial
721 # boot a modules.dep even before / is mounted read-write. However the
722 # boot script depmod is the master version.
723 ifeq "$(strip $(INSTALL_MOD_PATH))" ""
726 depmod_opts
:= -b
$(INSTALL_MOD_PATH
) -r
728 .PHONY
: _modinst_post
729 _modinst_post
: _modinst_
730 if
[ -r System.map
]; then
$(DEPMOD
) -ae
-F System.map
$(depmod_opts
) $(KERNELRELEASE
); fi
732 else # CONFIG_MODULES
734 # Modules not configured
735 # ---------------------------------------------------------------------------
737 modules modules_install
: FORCE
739 @echo
"The present kernel configuration has modules disabled."
740 @echo
"Type 'make config' and enable loadable module support."
741 @echo
"Then build a kernel with module support enabled."
745 endif # CONFIG_MODULES
747 # Generate asm-offsets.h
748 # ---------------------------------------------------------------------------
750 define filechk_gen-asm-offsets
752 echo
"#ifndef __ASM_OFFSETS_H__"; \
753 echo
"#define __ASM_OFFSETS_H__"; \
755 echo
" * DO NOT MODIFY."; \
757 echo
" * This file was generated by arch/$(ARCH)/Makefile"; \
761 sed
-ne
"/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
768 # Cleaning is done on three levels.
769 # make clean Delete all automatically generated files, including
770 # tools and firmware.
771 # make mrproper Delete the current configuration, and related files
772 # Any core files spread around are deleted as well
773 # make distclean Remove editor backup files, patch leftover files and the like
775 # Directories & files removed with 'make clean'
776 CLEAN_DIRS
+= $(MODVERDIR
) include/config include2
777 CLEAN_FILES
+= vmlinux System.map \
778 include/linux
/autoconf.h
include/linux
/version.h \
779 include/asm
include/linux
/modversions.h \
782 # Files removed with 'make mrproper'
783 MRPROPER_FILES
+= .version .config .config.old
tags TAGS cscope
*
785 # clean - Delete all intermediate files
787 clean-dirs
+= $(addprefix _clean_
,$(ALL_SUBDIRS
) Documentation
/DocBook scripts
)
788 .PHONY
: $(clean-dirs
) clean archclean mrproper archmrproper
distclean
790 $(Q
)$(MAKE
) $(clean)=$(patsubst _clean_
%,%,$@
)
792 clean: rm-dirs
:= $(wildcard $(CLEAN_DIRS
))
793 mrproper
: rm-dirs
:= $(wildcard $(MRPROPER_DIRS
))
794 quiet_cmd_rmdirs
= $(if
$(rm-dirs
),CLEAN
$(rm-dirs
))
795 cmd_rmdirs
= rm -rf
$(rm-dirs
)
797 clean: rm-files
:= $(wildcard $(CLEAN_FILES
))
798 mrproper
: rm-files
:= $(wildcard $(MRPROPER_FILES
))
799 quiet_cmd_rmfiles
= $(if
$(rm-files
),CLEAN
$(rm-files
))
800 cmd_rmfiles
= rm -rf
$(rm-files
)
802 clean: archclean
$(clean-dirs
)
805 @find .
$(RCS_FIND_IGNORE
) \
806 \
( -name
'*.[oas]' -o
-name
'*.ko' -o
-name
'.*.cmd' \
807 -o
-name
'.*.d' -o
-name
'.*.tmp' -o
-name
'*.mod.c' \
) \
808 -type f
-print | xargs
rm -f
813 mrproper
: clean archmrproper
816 @find .
$(RCS_FIND_IGNORE
) \
817 \
( -name
'*.orig' -o
-name
'*.rej' -o
-name
'*~' \
818 -o
-name
'*.bak' -o
-name
'#*#' -o
-name
'.*.orig' \
819 -o
-name
'.*.rej' -o
-size
0 \
820 -o
-name
'*%' -o
-name
'.*.cmd' -o
-name
'core' \
) \
821 -type f
-print | xargs
rm -f
823 # Generate tags for editors
824 # ---------------------------------------------------------------------------
827 ( find .
$(RCS_FIND_IGNORE
) \
828 \
( -name
include -o
-name arch \
) -prune
-o \
829 -name
'*.[chS]' -print; \
830 find arch
/$(ARCH
) $(RCS_FIND_IGNORE
) \
831 -name
'*.[chS]' -print; \
832 find
include $(RCS_FIND_IGNORE
) \
833 \
( -name config
-o
-name
'asm-*' \
) -prune \
834 -o
-name
'*.[chS]' -print; \
835 find
include/asm-
$(ARCH
) $(RCS_FIND_IGNORE
) \
836 -name
'*.[chS]' -print; \
837 find
include/asm-generic
$(RCS_FIND_IGNORE
) \
838 -name
'*.[chS]' -print )
841 quiet_cmd_cscope-file
= FILELST cscope.files
842 cmd_cscope-file
= $(all-sources
) > cscope.files
844 quiet_cmd_cscope
= MAKE cscope.out
845 cmd_cscope
= cscope
-k
-b
-q
848 $(call cmd
,cscope-file
)
851 quiet_cmd_TAGS
= MAKE
$@
852 cmd_TAGS
= $(all-sources
) | etags
-
854 # Exuberant ctags works better with -I
856 quiet_cmd_tags
= MAKE
$@
859 CTAGSF
=`ctags --version | grep -i exuberant >/dev/null && echo "-I __initdata,__exitdata,EXPORT_SYMBOL,EXPORT_SYMBOL_NOVERS"`; \
860 $(all-sources
) | xargs ctags
$$CTAGSF -a
870 # ---------------------------------------------------------------------------
874 # Remove hyphens since they have special meaning in RPM filenames
875 KERNELPATH
=kernel-
$(subst -,,$(KERNELRELEASE
))
877 # If you do a make spec before packing the tarball you can rpm -ta it
880 $(CONFIG_SHELL
) $(srctree
)/scripts
/mkspec
> $(objtree
)/kernel.spec
882 # a) Build a tar ball
883 # b) generate an rpm from it
884 # c) and pack the result
885 # - Use /. to avoid tar packing just the symlink
890 ln
-sf
$(srctree
) $(KERNELPATH
) ; \
891 tar -cvz
$(RCS_TAR_IGNORE
) -f
$(KERNELPATH
).
tar.gz
$(KERNELPATH
)/.
; \
895 $(CONFIG_SHELL
) $(srctree
)/scripts
/mkversion
> $(objtree
)/.tmp_version
;\
896 mv
-f
$(objtree
)/.tmp_version
$(objtree
)/.version
;
898 $(RPM
) --target
$(UTS_MACHINE
) -ta ..
/$(KERNELPATH
).
tar.gz
899 rm ..
/$(KERNELPATH
).
tar.gz
901 # Brief documentation of the typical targets used
902 # ---------------------------------------------------------------------------
904 boards
:= $(wildcard $(srctree
)/arch
/$(ARCH
)/configs
/*_defconfig
)
905 boards
:= $(notdir $(boards
))
908 @echo
'Cleaning targets:'
909 @echo
' clean - remove most generated files but keep the config'
910 @echo
' mrproper - remove all generated files + config + various backup files'
912 @echo
'Configuration targets:'
913 @
$(MAKE
) -f
$(srctree
)/scripts
/kconfig
/Makefile help
915 @echo
'Other generic targets:'
916 @echo
' all - Build all targets marked with [*]'
917 @echo
'* vmlinux - Build the bare kernel'
918 @echo
'* modules - Build all modules'
919 @echo
' modules_install - Install all modules'
920 @echo
' dir/ - Build all files in dir and below'
921 @echo
' dir/file.[ois] - Build specified target only'
922 @echo
' rpm - Build a kernel as an RPM package'
923 @echo
' tags/TAGS - Generate tags file for editors'
924 @echo
' cscope - Generate cscope index'
926 @echo
'Documentation targets:'
927 @
$(MAKE
) -f
$(srctree
)/Documentation
/DocBook
/Makefile dochelp
929 @echo
'Architecture specific targets ($(ARCH)):'
930 @
$(if
$(archhelp
),$(archhelp
),\
931 echo
' No architecture specific help defined for $(ARCH)')
934 $(foreach b
, $(boards
), \
935 printf
" %-24s - Build for %s\\n" $(b
) $(subst _defconfig
,,$(b
));) \
938 @echo
' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
939 @echo
' make O=dir [targets] Locate all output files in "dir", including .config'
940 @echo
' make C=1 [targets] Check all c source with checker tool'
942 @echo
'Execute "make" or "make all" to build all targets marked with [*] '
943 @echo
'For further info see the ./README file'
946 # Documentation targets
947 # ---------------------------------------------------------------------------
949 $(Q
)$(MAKE
) $(build
)=Documentation
/DocBook
$@
951 # Scripts to check various things for consistency
952 # ---------------------------------------------------------------------------
955 find
* $(RCS_FIND_IGNORE
) \
956 -name
'*.[hcS]' -type f
-print |
sort \
957 | xargs
$(PERL
) -w scripts
/checkconfig.pl
960 find
* $(RCS_FIND_IGNORE
) \
961 -name
'*.[hcS]' -type f
-print |
sort \
962 | xargs
$(PERL
) -w scripts
/checkincludes.pl
965 find
* $(RCS_FIND_IGNORE
) \
966 -name
'*.[hcS]' -type f
-print |
sort \
967 | xargs
$(PERL
) -w scripts
/checkversion.pl
969 endif #ifeq ($(config-targets),1)
970 endif #ifeq ($(mixed-targets),1)
972 # FIXME Should go into a make.lib or something
973 # ===========================================================================
975 a_flags
= -Wp
,-MD
,$(depfile
) $(AFLAGS
) $(AFLAGS_KERNEL
) \
976 $(NOSTDINC_FLAGS
) $(CPPFLAGS
) \
977 $(modkern_aflags
) $(EXTRA_AFLAGS
) $(AFLAGS_
$(*F
).o
)
979 quiet_cmd_as_o_S
= AS
$@
980 cmd_as_o_S
= $(CC
) $(a_flags
) -c
-o
$@
$<
982 # read all saved command lines
984 targets
:= $(wildcard $(sort $(targets
)))
985 cmd_files
:= $(wildcard .
*.cmd
$(foreach f
,$(targets
),$(dir $(f
)).
$(notdir $(f
)).cmd
))
987 ifneq ($(cmd_files
),)
988 $(cmd_files
): ; # Do not try to update included dependency files
992 # execute the command and also postprocess generated .d dependencies
995 if_changed_dep
= $(if
$(strip $?
$(filter-out FORCE
$(wildcard $^
),$^
)\
996 $(filter-out $(cmd_
$(1)),$(cmd_
$@
))\
997 $(filter-out $(cmd_
$@
),$(cmd_
$(1)))),\
999 $(if
$($(quiet
)cmd_
$(1)),echo
' $(subst ','\'',$($(quiet
)cmd_
$(1)))';) \
1001 scripts/basic/fixdep $(depfile) $@ '$(subst $$,$$$$,$(subst ','\'',$(cmd_$(1))))' > $(@D
)/.
$(@F
).tmp
; \
1003 mv
-f
$(@D
)/.
$(@F
).tmp
$(@D
)/.
$(@F
).cmd
)
1005 # Usage: $(call if_changed_rule,foo)
1006 # will check if $(cmd_foo) changed, or any of the prequisites changed,
1007 # and if so will execute $(rule_foo)
1009 if_changed_rule
= $(if
$(strip $? \
1010 $(filter-out $(cmd_
$(1)),$(cmd_
$(@F
)))\
1011 $(filter-out $(cmd_
$(@F
)),$(cmd_
$(1)))),\
1014 # If quiet is set, only print short version of command
1016 cmd
= @
$(if
$($(quiet
)cmd_
$(1)),echo
' $($(quiet)cmd_$(1))' &&) $(cmd_
$(1))
1018 # filechk is used to check if the content of a generated file is updated.
1020 # define filechk_sample
1021 # echo $KERNELRELEASE
1023 # version.h : Makefile
1024 # $(call filechk,sample)
1025 # The rule defined shall write to stdout the content of the new file.
1026 # The existing file will be compared with the new one.
1027 # - If no file exist it is created
1028 # - If the content differ the new file is used
1029 # - If they are equal no change, and no timestamp update
1034 mkdir
-p
$(dir $@
); \
1035 $(filechk_
$(1)) < $< > $@.tmp
; \
1036 if
[ -r
$@
] && cmp
-s
$@
$@.tmp
; then \
1044 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=dir
1046 # $(Q)$(MAKE) $(build)=dir
1047 build
:= -f
$(if
$(KBUILD_SRC
),$(srctree
)/)scripts
/Makefile.build obj
1049 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir
1051 # $(Q)$(MAKE) $(clean)=dir
1052 clean := -f
$(if
$(KBUILD_SRC
),$(srctree
)/)scripts
/Makefile.
clean obj
1054 # $(call descend,<dir>,<target>)
1055 # Recursively call a sub-make in <dir> with target <target>
1056 # Usage is deprecated, because make does not see this as an invocation of make.
1057 descend
=$(Q
)$(MAKE
) -f
$(if
$(KBUILD_SRC
),$(srctree
)/)scripts
/Makefile.build obj
=$(1) $(2)
1059 endif # skip-makefile