Makefile 56 KB

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