PageRenderTime 2677ms CodeModel.GetById 42ms RepoModel.GetById 1ms app.codeStats 0ms

/linux-2.6.21.x/Makefile

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