home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / src / linux-headers-2.6.17-6 / Makefile < prev   
Encoding:
Makefile  |  2006-08-11  |  44.4 KB  |  1,381 lines

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