Makefile 56 KB

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