blob: ee3e292fa50905eb47a941864f9dbe6f0910265c [file] [log] [blame]
Juan Manuel Cruz6de34002015-02-15 21:46:45 -06001VERSION_GENERATION = 2
2VERSION_MAJOR = 2
3VERSION_MINOR = 3
4VERSION_REVISION = 0
5VERSION_RESERVED = 0
6PATCHLEVEL = 0
7SUBLEVEL = 0
8NAME = Tiny Mountain
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -06009
Juan Manuel Cruzde1cec22015-05-11 19:19:37 -050010export SOURCE_DIR PROJECT VPFILE KLIBC_DIR
Juan Manuel Cruzba741fe2015-02-15 14:12:00 -060011
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -060012# *DOCUMENTATION*
13# To see a list of typical targets execute "make help"
14# More info can be located in ./README
15# Comments in this file are targeted only to the developer, do not
16# expect to learn how to build the kernel reading this file.
17
18# Do not use make's built-in rules and variables
19# (this increases performance and avoids hard-to-debug behaviour);
20MAKEFLAGS += -rR
21
22# Avoid funny character set dependencies
23unexport LC_ALL
24LC_COLLATE=C
25LC_NUMERIC=C
26export LC_COLLATE LC_NUMERIC
27
28# Avoid interference with shell env settings
29unexport GREP_OPTIONS
30
31# We are using a recursive build, so we need to do a little thinking
32# to get the ordering right.
33#
34# Most importantly: sub-Makefiles should only ever modify files in
35# their own directory. If in some directory we have a dependency on
36# a file in another dir (which doesn't happen often, but it's often
37# unavoidable when linking the built-in.o targets which finally
Juan Manuel Cruz7ac851a2015-04-08 17:19:22 -050038# turn into tinymountain), we will call a sub make in that other dir, and
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -060039# after that we are sure that everything which is in that other dir
40# is now up to date.
41#
42# The only cases where we need to modify files which have global
43# effects are thus separated out and done before the recursive
44# descending is started. They are now explicitly listed as the
45# prepare rule.
46
47# Beautify output
48# ---------------------------------------------------------------------------
49#
50# Normally, we echo the whole command before executing it. By making
51# that echo $($(quiet)$(cmd)), we now have the possibility to set
52# $(quiet) to choose other forms of output instead, e.g.
53#
54# quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
55# cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
56#
57# If $(quiet) is empty, the whole command will be printed.
58# If it is set to "quiet_", only the short version will be printed.
59# If it is set to "silent_", nothing will be printed at all, since
60# the variable $(silent_cmd_cc_o_c) doesn't exist.
61#
62# A simple variant is to prefix commands with $(Q) - that's useful
63# for commands that shall be hidden in non-verbose mode.
64#
65# $(Q)ln $@ :<
66#
67# If KBUILD_VERBOSE equals 0 then the above command will be hidden.
68# If KBUILD_VERBOSE equals 1 then the above command is displayed.
69#
70# To put more focus on warnings, be less verbose as default
71# Use 'make V=1' to see the full commands
72
73ifeq ("$(origin V)", "command line")
74 KBUILD_VERBOSE = $(V)
75endif
76ifndef KBUILD_VERBOSE
77 KBUILD_VERBOSE = 0
78endif
79
80ifeq ($(KBUILD_VERBOSE),1)
81 quiet =
82 Q =
83else
84 quiet=quiet_
85 Q = @
86endif
87
88# If the user is running make -s (silent mode), suppress echoing of
89# commands
90
91ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4
92ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),)
93 quiet=silent_
94endif
95else # make-3.8x
96ifneq ($(filter s% -s%,$(MAKEFLAGS)),)
97 quiet=silent_
98endif
99endif
100
101export quiet Q KBUILD_VERBOSE
102
103# kbuild supports saving output files in a separate directory.
104# To locate output files in a separate directory two syntaxes are supported.
105# In both cases the working directory must be the root of the kernel src.
106# 1) O=
107# Use "make O=dir/to/store/output/files/"
108#
109# 2) Set KBUILD_OUTPUT
110# Set the environment variable KBUILD_OUTPUT to point to the directory
111# where the output files shall be placed.
112# export KBUILD_OUTPUT=dir/to/store/output/files/
113# make
114#
115# The O= assignment takes precedence over the KBUILD_OUTPUT environment
116# variable.
117
118# KBUILD_SRC is set on invocation of make in OBJ directory
119# KBUILD_SRC is not intended to be used by the regular user (for now)
120ifeq ($(KBUILD_SRC),)
121
122# OK, Make called in directory where kernel src resides
123# Do we want to locate output files in a separate directory?
124ifeq ("$(origin O)", "command line")
125 KBUILD_OUTPUT := $(O)
126endif
127
128# That's our default target when none is given on the command line
129PHONY := _all
130_all:
131
132# Cancel implicit rules on top Makefile
133$(CURDIR)/Makefile Makefile: ;
134
135ifneq ($(KBUILD_OUTPUT),)
136# Invoke a second make in the output directory, passing relevant variables
137# check that the output directory actually exists
138saved-output := $(KBUILD_OUTPUT)
139KBUILD_OUTPUT := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) \
140 && /bin/pwd)
141$(if $(KBUILD_OUTPUT),, \
142 $(error failed to create output directory "$(saved-output)"))
143
144PHONY += $(MAKECMDGOALS) sub-make
145
146$(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
147 @:
148
149sub-make: FORCE
150 $(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \
151 -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS))
152
153# Leave processing to above invocation of make
154skip-makefile := 1
155endif # ifneq ($(KBUILD_OUTPUT),)
156endif # ifeq ($(KBUILD_SRC),)
157
158# We process the rest of the Makefile if this is the final invocation of make
159ifeq ($(skip-makefile),)
160
161# Do not print "Entering directory ...",
162# but we want to display it when entering to the output directory
163# so that IDEs/editors are able to understand relative filenames.
164MAKEFLAGS += --no-print-directory
165
166# Call a source code checker (by default, "sparse") as part of the
167# C compilation.
168#
169# Use 'make C=1' to enable checking of only re-compiled files.
170# Use 'make C=2' to enable checking of *all* source files, regardless
171# of whether they are re-compiled or not.
172#
173# See the file "Documentation/sparse.txt" for more details, including
174# where to get the "sparse" utility.
175
176ifeq ("$(origin C)", "command line")
177 KBUILD_CHECKSRC = $(C)
178endif
179ifndef KBUILD_CHECKSRC
180 KBUILD_CHECKSRC = 0
181endif
182
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600183PHONY += all
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600184_all: all
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600185
186ifeq ($(KBUILD_SRC),)
187 # building in the source tree
188 srctree := .
189else
190 ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR)))
191 # building in a subdirectory of the source tree
192 srctree := ..
193 else
194 srctree := $(KBUILD_SRC)
195 endif
196endif
197objtree := .
198src := $(srctree)
199obj := $(objtree)
200
Anas Nashifd6ebd182015-05-28 12:54:03 -0400201VPATH := $(srctree)
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600202
203export srctree objtree VPATH
204
205
206# SUBARCH tells the usermode build what the underlying arch is. That is set
207# first, and if a usermode build is happening, the "ARCH=um" on the command
208# line overrides the setting of ARCH below. If a native build is happening,
209# then ARCH is assigned, getting whatever value it gets normally, and
210# SUBARCH is subsequently ignored.
211
212SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \
213 -e s/sun4u/sparc64/ \
214 -e s/arm.*/arm/ -e s/sa110/arm/ \
215 -e s/s390x/s390/ -e s/parisc64/parisc/ \
216 -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
217 -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ )
218
219# Cross compiling and selecting different set of gcc/bin-utils
220# ---------------------------------------------------------------------------
221#
222# When performing cross compilation for other architectures ARCH shall be set
223# to the target architecture. (See arch/* for the possibilities).
224# ARCH can be set during invocation of make:
Anas Nashif67fc2062015-04-24 18:29:24 -0400225# make ARCH=x86
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600226# Another way is to have ARCH set in the environment.
227# The default ARCH is the host where make is executed.
228
229# CROSS_COMPILE specify the prefix used for all executables used
230# during compilation. Only gcc and related bin-utils executables
231# are prefixed with $(CROSS_COMPILE).
232# CROSS_COMPILE can be set on the command line
Anas Nashif67fc2062015-04-24 18:29:24 -0400233# make CROSS_COMPILE=i586-pc-elf
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600234# Alternatively CROSS_COMPILE can be set in the environment.
235# A third alternative is to store a setting in .config so that plain
236# "make" in the configured kernel build directory always uses that.
237# Default value for CROSS_COMPILE is not to prefix executables
238# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
239ARCH ?= $(SUBARCH)
240CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)
241
242# Architecture as present in compile.h
243UTS_MACHINE := $(ARCH)
244SRCARCH := $(ARCH)
245
246# Additional ARCH settings for x86
247ifeq ($(ARCH),i386)
248 SRCARCH := x86
249endif
250ifeq ($(ARCH),x86_64)
251 SRCARCH := x86
252endif
253
254# Additional ARCH settings for sparc
255ifeq ($(ARCH),sparc32)
256 SRCARCH := sparc
257endif
258ifeq ($(ARCH),sparc64)
259 SRCARCH := sparc
260endif
261
262# Additional ARCH settings for sh
263ifeq ($(ARCH),sh64)
264 SRCARCH := sh
265endif
266
267# Additional ARCH settings for tile
268ifeq ($(ARCH),tilepro)
269 SRCARCH := tile
270endif
271ifeq ($(ARCH),tilegx)
272 SRCARCH := tile
273endif
274
275# Where to locate arch specific headers
276hdr-arch := $(SRCARCH)
277
Juan Manuel Cruz4d7f9542015-05-25 18:15:11 -0500278ifdef O
279KCONFIG_CONFIG := $(O)/.config
280KCONFIG_AUTOCONFIG := $(O)/include/config/auto.conf
281KCONFIG_AUTOHEADER := $(O)/include/generated/autoconf.h
282KCONFIG_TRISTATE := $(O)/include/config/tristate.conf
283KCONFIG_AUTOCMD := $(O)/include/config/auto.conf.cmd
284else
285KCONFIG_CONFIG := .config
286endif
287
288export KCONFIG_CONFIG KCONFIG_AUTOCONFIG KCONFIG_AUTOHEADER KCONFIG_TRISTATE KCONFIG_AUTOCMD
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600289
290# SHELL used by kbuild
291CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
292 else if [ -x /bin/bash ]; then echo /bin/bash; \
293 else echo sh; fi ; fi)
294
295HOSTCC = gcc
296HOSTCXX = g++
297HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89
298HOSTCXXFLAGS = -O2
299
300ifeq ($(shell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1)
301HOSTCFLAGS += -Wno-unused-value -Wno-unused-parameter \
302 -Wno-missing-field-initializers -fno-delete-null-pointer-checks
303endif
304
305# Decide whether to build built-in, modular, or both.
306# Normally, just do built-in.
307
308KBUILD_MODULES :=
309KBUILD_BUILTIN := 1
310
311# If we have only "make modules", don't compile built-in objects.
312# When we're building modules with modversions, we need to consider
313# the built-in objects during the descend as well, in order to
314# make sure the checksums are up to date before we record them.
315
316ifeq ($(MAKECMDGOALS),modules)
317 KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1)
318endif
319
320# If we have "make <whatever> modules", compile modules
321# in addition to whatever we do anyway.
322# Just "make" or "make all" shall build modules as well
323
324ifneq ($(filter all _all modules,$(MAKECMDGOALS)),)
325 KBUILD_MODULES := 1
326endif
327
328ifeq ($(MAKECMDGOALS),)
329 KBUILD_MODULES := 1
330endif
331
332export KBUILD_MODULES KBUILD_BUILTIN
Anas Nashifd6ebd182015-05-28 12:54:03 -0400333export KBUILD_CHECKSRC KBUILD_SRC
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600334
335ifneq ($(CC),)
336ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1)
337COMPILER := clang
338else
339COMPILER := gcc
340endif
341export COMPILER
342endif
343
344# Look for make include files relative to root of kernel src
345MAKEFLAGS += --include-dir=$(srctree)
346
347# We need some generic definitions (do not try to remake the file).
348$(srctree)/scripts/Kbuild.include: ;
349include $(srctree)/scripts/Kbuild.include
350
351# Make variables (CC, etc...)
352AS = $(CROSS_COMPILE)as
353LD = $(CROSS_COMPILE)ld
354CC = $(CROSS_COMPILE)gcc
355CPP = $(CC) -E
356AR = $(CROSS_COMPILE)ar
357NM = $(CROSS_COMPILE)nm
358STRIP = $(CROSS_COMPILE)strip
359OBJCOPY = $(CROSS_COMPILE)objcopy
360OBJDUMP = $(CROSS_COMPILE)objdump
361AWK = awk
Juan Manuel Cruz4d7f9542015-05-25 18:15:11 -0500362GENKSYMS = $(TIMO_BASE)/scripts/genksyms/genksyms
363GENIDT = $(TIMO_BASE)/scripts/gen_idt/gen_idt
364FIXDEP = $(TIMO_BASE)/scripts/basic/fixdep
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600365INSTALLKERNEL := installkernel
366DEPMOD = /sbin/depmod
367PERL = perl
368PYTHON = python
369CHECK = sparse
370
Anas Nashif6afc4852015-04-24 18:30:36 -0400371CHECKFLAGS := -Wbitwise -Wno-return-void $(CF)
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600372CFLAGS_MODULE =
373AFLAGS_MODULE =
374LDFLAGS_MODULE =
375CFLAGS_KERNEL =
376AFLAGS_KERNEL =
377CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
378
379
380# Use USERINCLUDE when you must reference the UAPI directories only.
Juan Manuel Cruza0b54662015-02-17 11:16:47 -0600381USERINCLUDE := -include $(CURDIR)/include/generated/autoconf.h
382PROJECTINCLUDE := $(strip -I$(srctree)/include/microkernel \
Anas Nashif8e9d8eb2015-05-29 11:48:25 -0400383 -I$(CURDIR)/misc/generated/sysgen) \
Juan Manuel Cruza0b54662015-02-17 11:16:47 -0600384 $(USERINCLUDE)
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600385
Juan Manuel Cruz7ac851a2015-04-08 17:19:22 -0500386# Use TIMOINCLUDE when you must reference the include/ directory.
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600387# Needed to be compatible with the O= option
Juan Manuel Cruz7ac851a2015-04-08 17:19:22 -0500388TIMOINCLUDE := \
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600389 -I$(srctree)/arch/$(hdr-arch)/include \
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600390 $(if $(KBUILD_SRC), -I$(srctree)/include) \
Juan Manuel Cruza0b54662015-02-17 11:16:47 -0600391 -I$(srctree)/include \
392 -I$(CURDIR)/include/generated \
393 $(USERINCLUDE) \
394 $(STDINCLUDE)
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600395
Juan Manuel Cruza0b54662015-02-17 11:16:47 -0600396KBUILD_CPPFLAGS := -DKERNEL
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600397
Juan Manuel Cruz4d8c7252015-05-04 17:13:48 -0500398DEFAULTFLAGS ?= -Os
Juan Manuel Cruza0b54662015-02-17 11:16:47 -0600399
Juan Manuel Cruz068ebc02015-05-06 10:41:08 -0500400KBUILD_CFLAGS := -c -g -std=c99 \
Juan Manuel Cruz4d8c7252015-05-04 17:13:48 -0500401 $(DEFAULTFLAGS) \
402 $(CONFIG_COMPILER_OPT) \
Juan Manuel Cruza0b54662015-02-17 11:16:47 -0600403 -fno-reorder-functions \
404 -fno-asynchronous-unwind-tables \
405 -fno-omit-frame-pointer \
406 -fno-defer-pop -Wall \
407 -Wno-unused-but-set-variable \
408 -Wno-main -ffreestanding
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600409
410KBUILD_AFLAGS_KERNEL :=
411KBUILD_CFLAGS_KERNEL :=
Juan Manuel Cruza0b54662015-02-17 11:16:47 -0600412KBUILD_AFLAGS := -c -g -xassembler-with-cpp
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600413
Juan Manuel Cruza0b54662015-02-17 11:16:47 -0600414LDFLAGS += $(call cc-ldoption,-nostartfiles)
415LDFLAGS += $(call cc-ldoption,-nodefaultlibs)
416LDFLAGS += $(call cc-ldoption,-nostdlib)
417LDFLAGS += $(call cc-ldoption,-static)
Juan Manuel Cruz0c47e4f2015-05-13 11:52:55 -0500418LDLIBS_TOOLCHAIN ?= -lgcc
Juan Manuel Cruza0b54662015-02-17 11:16:47 -0600419
Juan Manuel Cruz6de34002015-02-15 21:46:45 -0600420KERNELVERSION = $(VERSION_GENERATION).$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_REVISION)
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600421
Juan Manuel Cruz6de34002015-02-15 21:46:45 -0600422export VERSION_GENERATION VERSION_MAJOR VERSION_MINOR VERSION_REVISION VERSION_RESERVED
423export PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600424export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC
425export CPP AR NM STRIP OBJCOPY OBJDUMP
Juan Manuel Cruz4d7f9542015-05-25 18:15:11 -0500426export MAKE AWK GENKSYMS INSTALLKERNEL PERL PYTHON UTS_MACHINE GENIDT FIXDEP
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600427export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
428
Juan Manuel Cruz7ac851a2015-04-08 17:19:22 -0500429export KBUILD_CPPFLAGS NOSTDINC_FLAGS TIMOINCLUDE OBJCOPYFLAGS LDFLAGS
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600430export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_GCOV
431export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
432export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
433export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
Juan Manuel Cruz0c47e4f2015-05-13 11:52:55 -0500434export KBUILD_ARFLAGS PROJECTINCLUDE LDLIBS_TOOLCHAIN
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600435
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600436
437# Files to ignore in find ... statements
438
439export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o \
440 -name CVS -o -name .pc -o -name .hg -o -name .git \) \
441 -prune -o
442export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
443 --exclude CVS --exclude .pc --exclude .hg --exclude .git
444
445# ===========================================================================
446# Rules shared between *config targets and build targets
447
448# Basic helpers built in scripts/
449PHONY += scripts_basic
450scripts_basic:
Juan Manuel Cruz4d7f9542015-05-25 18:15:11 -0500451 $(Q)$(MAKE) -C $(TIMO_BASE) $(build)=scripts/basic
452 $(Q)$(MAKE) -C $(TIMO_BASE) $(build)=scripts/gen_idt
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600453 $(Q)rm -f .tmp_quiet_recordmcount
454
455# To avoid any implicit rule to kick in, define an empty command.
456scripts/basic/%: scripts_basic ;
457
458PHONY += outputmakefile
459# outputmakefile generates a Makefile in the output directory, if using a
460# separate output directory. This allows convenient use of make in the
461# output directory.
462outputmakefile:
463ifneq ($(KBUILD_SRC),)
464 $(Q)ln -fsn $(srctree) source
465 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \
466 $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
467endif
468
469# Support for using generic headers in asm-generic
470PHONY += asm-generic
471asm-generic:
472 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \
473 src=asm obj=arch/$(SRCARCH)/include/generated/asm
474 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \
475 src=uapi/asm obj=arch/$(SRCARCH)/include/generated/uapi/asm
476
477# To make sure we do not include .config for any of the *config targets
478# catch them early, and hand them over to scripts/kconfig/Makefile
479# It is allowed to specify more targets when calling make, including
480# mixing *config targets and build targets.
481# For example 'make oldconfig all'.
482# Detect when mixed targets is specified, and make a second invocation
483# of make so .config is not included in this case either (for *config).
484
Juan Manuel Cruz6de34002015-02-15 21:46:45 -0600485version_h := include/generated/version.h
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600486
487no-dot-config-targets := clean mrproper distclean \
488 cscope gtags TAGS tags help% %docs check% coccicheck \
489 $(version_h) headers_% archheaders archscripts \
490 kernelversion %src-pkg
491
492config-targets := 0
493mixed-targets := 0
494dot-config := 1
495
496ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
497 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
498 dot-config := 0
499 endif
500endif
501
Anas Nashifd6ebd182015-05-28 12:54:03 -0400502ifneq ($(filter config %config,$(MAKECMDGOALS)),)
503 config-targets := 1
504 ifneq ($(filter-out config %config,$(MAKECMDGOALS)),)
505 mixed-targets := 1
506 endif
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600507endif
508
509ifeq ($(mixed-targets),1)
510# ===========================================================================
511# We're called with mixed targets (*config and build targets).
512# Handle them one by one.
513
514PHONY += $(MAKECMDGOALS) __build_one_by_one
515
516$(filter-out __build_one_by_one, $(MAKECMDGOALS)): __build_one_by_one
517 @:
518
519__build_one_by_one:
520 $(Q)set -e; \
521 for i in $(MAKECMDGOALS); do \
522 $(MAKE) -f $(srctree)/Makefile $$i; \
523 done
524
525else
526ifeq ($(config-targets),1)
527# ===========================================================================
528# *config targets only - make sure prerequisites are updated, and descend
529# in scripts/kconfig to make the *config target
530
531# Read arch specific Makefile to set KBUILD_DEFCONFIG as needed.
532# KBUILD_DEFCONFIG may point out an alternative default configuration
533# used for 'make defconfig'
534include $(srctree)/arch/$(SRCARCH)/Makefile
535export KBUILD_DEFCONFIG KBUILD_KCONFIG
536
537config: scripts_basic outputmakefile FORCE
Juan Manuel Cruz4d7f9542015-05-25 18:15:11 -0500538 $(Q)$(MAKE) -C $(TIMO_BASE) $(build)=scripts/kconfig $@
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600539
540%config: scripts_basic outputmakefile FORCE
Juan Manuel Cruz4d7f9542015-05-25 18:15:11 -0500541 $(Q)$(MAKE) -C $(TIMO_BASE) $(build)=scripts/kconfig $@
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600542
543else
544# ===========================================================================
Juan Manuel Cruz7ac851a2015-04-08 17:19:22 -0500545# Build targets only - this includes tinymountain, arch specific targets, clean
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600546# targets and others. In general all targets except *config targets.
547
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600548# Additional helpers built in scripts/
549# Carefully list dependencies so we do not try to build scripts twice
550# in parallel
551PHONY += scripts
Dirk Brandewie991e9d32015-06-01 09:48:10 -0700552scripts: scripts_basic include/config/auto.conf include/config/tristate.conf
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600553 $(Q)$(MAKE) $(build)=$(@)
554
Anas Nashif3b9199d2015-05-18 09:00:49 -0400555
Juan Manuel Cruzde1cec22015-05-11 19:19:37 -0500556core-y := arch/ kernel/ misc/ net/
Juan Manuel Cruzba741fe2015-02-15 14:12:00 -0600557bsp-y := drivers/
558
559ifneq ($(strip $(PROJECT)),)
Anas Nashif5c8ff0f2015-05-09 18:34:57 -0400560core-y += $(SOURCE_DIR)
Juan Manuel Cruzba741fe2015-02-15 14:12:00 -0600561endif
562
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600563
564ifeq ($(dot-config),1)
565# Read in config
566-include include/config/auto.conf
567
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600568# Read in dependencies to all Kconfig* files, make sure to run
569# oldconfig if changes are detected.
570-include include/config/auto.conf.cmd
571
572# To avoid any implicit rule to kick in, define an empty command
573$(KCONFIG_CONFIG) include/config/auto.conf.cmd: ;
574
575# If .config is newer than include/config/auto.conf, someone tinkered
576# with it and forgot to run make oldconfig.
577# if auto.conf.cmd is missing then we are probably in a cleaned tree so
578# we execute the config step to be sure to catch updated Kconfig files
579include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
580 $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600581
582else
583# Dummy target needed, because used as prerequisite
584include/config/auto.conf: ;
585endif # $(dot-config)
586
Anas Nashif3b9199d2015-05-18 09:00:49 -0400587ifdef CONFIG_MINIMAL_LIBC
588# Objects we will link into tinymountain / subdirs we need to visit
589KLIBC_DIR := lib/libc/minimal
590libs-y := $(KLIBC_DIR)/
591TIMOINCLUDE += -I$(srctree)/lib/libc/minimal/include
592endif
593
Anas Nashif19f0ff22015-05-18 08:57:17 -0400594ifdef CONFIG_TOOLCHAIN_NEWLIB
595libs-y += lib/libc/newlib/
Anas Nashife439f512015-05-18 19:55:02 -0400596ALL_LIBS += c m
Anas Nashif19f0ff22015-05-18 08:57:17 -0400597endif
598
Juan Manuel Cruzba741fe2015-02-15 14:12:00 -0600599#File that includes all prepare special embedded architecture targets.
600include $(srctree)/scripts/Makefile.preparch
Juan Manuel Cruza0b54662015-02-17 11:16:47 -0600601sinclude $(srctree)/scripts/Makefile.$(SRCARCH).preparch
Anas Nashifaca245d2015-05-13 00:44:22 -0400602ifdef VXMICRO_GCC_VARIANT
603include $(srctree)/scripts/Makefile.toolchain.$(VXMICRO_GCC_VARIANT)
604endif
Juan Manuel Cruzba741fe2015-02-15 14:12:00 -0600605
Anas Nashiff1c7c172015-06-01 10:34:57 -0400606QEMU_BIN_PATH ?= /usr/bin
607QEMU = $(QEMU_BIN_PATH)/$(QEMU_$(SRCARCH))
608
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600609# The all: target is the default when no target is given on the
610# command line.
611# This allow a user to issue only 'make' to build a kernel including modules
Juan Manuel Cruz7ac851a2015-04-08 17:19:22 -0500612# Defaults to tinymountain, but the arch makefile usually adds further targets
613all: tinymountain
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600614
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600615ifdef CONFIG_READABLE_ASM
616# Disable optimizations that make assembler listings hard to read.
617# reorder blocks reorders the control in the function
618# ipa clone creates specialized cloned functions
619# partial inlining inlines only parts of functions
620KBUILD_CFLAGS += $(call cc-option,-fno-reorder-blocks,) \
621 $(call cc-option,-fno-ipa-cp-clone,) \
622 $(call cc-option,-fno-partial-inlining)
623endif
624
Juan Manuel Cruzfbc59562015-05-04 17:31:43 -0500625ISA_FLAG=$(ISA_FLAG_$(SRCARCH))
Juan Manuel Cruza0b54662015-02-17 11:16:47 -0600626
627STACK_CANARIES_FLAG_y = $(call cc-option,-fstack-protector-all,)
628STACK_CANARIES_FLAG_ = $(call cc-option,-fno-stack-protector,)
629STACK_CANARIES_FLAG = $(STACK_CANARIES_FLAG_$(CONFIG_STACK_CANARIES))
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600630
631# Handle stack protector mode.
632#
633# Since kbuild can potentially perform two passes (first with the old
634# .config values and then with updated .config values), we cannot error out
635# if a desired compiler option is unsupported. If we were to error, kbuild
636# could never get to the second pass and actually notice that we changed
637# the option to something that was supported.
638#
639# Additionally, we don't want to fallback and/or silently change which compiler
640# flags will be used, since that leads to producing kernels with different
641# security feature characteristics depending on the compiler used. ("But I
642# selected CC_STACKPROTECTOR_STRONG! Why did it build with _REGULAR?!")
643#
644# The middle ground is to warn here so that the failed option is obvious, but
645# to let the build fail with bad compiler flags so that we can't produce a
646# kernel when there is a CONFIG and compiler mismatch.
647#
648ifdef CONFIG_CC_STACKPROTECTOR_REGULAR
649 stackp-flag := -fstack-protector
650 ifeq ($(call cc-option, $(stackp-flag)),)
651 $(warning Cannot use CONFIG_CC_STACKPROTECTOR_REGULAR: \
652 -fstack-protector not supported by compiler)
653 endif
654else
655ifdef CONFIG_CC_STACKPROTECTOR_STRONG
656 stackp-flag := -fstack-protector-strong
657 ifeq ($(call cc-option, $(stackp-flag)),)
658 $(warning Cannot use CONFIG_CC_STACKPROTECTOR_STRONG: \
659 -fstack-protector-strong not supported by compiler)
660 endif
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600661endif
662endif
663KBUILD_CFLAGS += $(stackp-flag)
664
Juan Manuel Cruza0b54662015-02-17 11:16:47 -0600665export x86_FLAGS arm_FLAGS arc_FLAGS LDFLAG_LINKERCMD
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600666
Juan Manuel Cruza0b54662015-02-17 11:16:47 -0600667ARCHFLAGS = $($(SRCARCH)_FLAGS)
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600668
Juan Manuel Cruza0b54662015-02-17 11:16:47 -0600669KBUILD_CFLAGS += $(SSE_FP_MATH_FLAG) \
670 $(ISA_FLAG) \
671 $(STACK_CANARIES_FLAG) \
672 $(ARCHFLAGS)
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600673
674ifdef CONFIG_DEBUG_INFO_REDUCED
675KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \
676 $(call cc-option,-fno-var-tracking)
677endif
Juan Manuel Cruza0b54662015-02-17 11:16:47 -0600678KBUILD_CFLAGS += $(CFLAGS)
Juan Manuel Cruzfbc59562015-05-04 17:31:43 -0500679KBUILD_AFLAGS += $(ARCHFLAGS) $(ISA_FLAG)
Juan Manuel Cruza0b54662015-02-17 11:16:47 -0600680KBUILD_AFLAGS += $(CFLAGS)
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600681
682ifdef CONFIG_FUNCTION_TRACER
683ifdef CONFIG_HAVE_FENTRY
684CC_USING_FENTRY := $(call cc-option, -mfentry -DCC_USING_FENTRY)
685endif
686KBUILD_CFLAGS += -pg $(CC_USING_FENTRY)
687KBUILD_AFLAGS += $(CC_USING_FENTRY)
688ifdef CONFIG_DYNAMIC_FTRACE
689 ifdef CONFIG_HAVE_C_RECORDMCOUNT
690 BUILD_C_RECORDMCOUNT := y
691 export BUILD_C_RECORDMCOUNT
692 endif
693endif
694endif
695
696# We trigger additional mismatches with less inlining
697ifdef CONFIG_DEBUG_SECTION_MISMATCH
698KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once)
699endif
700
Juan Manuel Cruza0b54662015-02-17 11:16:47 -0600701# Adding specific KBUILD_CFLAGS. This one is an specific example of how to set up KBUILD flags
Juan Manuel Cruza0b54662015-02-17 11:16:47 -0600702KBUILD_ARFLAGS := $(call ar-option,D)
703
704#FIXME This group of flags are under review
705ifdef REVIEW_BLOCK
706
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600707# arch Makefile may override CC so keep this after arch Makefile is included
708NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
709CHECKFLAGS += $(NOSTDINC_FLAGS)
710
711# warn about C99 declaration after statement
712KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
713
714# disable pointer signed / unsigned warnings in gcc 4.0
715KBUILD_CFLAGS += $(call cc-disable-warning, pointer-sign)
716
717# disable invalid "can't wrap" optimizations for signed / pointers
718KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow)
719
720# conserve stack if available
721KBUILD_CFLAGS += $(call cc-option,-fconserve-stack)
722
723# disallow errors like 'EXPORT_GPL(foo);' with missing header
724KBUILD_CFLAGS += $(call cc-option,-Werror=implicit-int)
725
726# require functions to have arguments in prototypes, not empty 'int foo()'
727KBUILD_CFLAGS += $(call cc-option,-Werror=strict-prototypes)
728
729# Prohibit date/time macros, which would make the build non-deterministic
730KBUILD_CFLAGS += $(call cc-option,-Werror=date-time)
Juan Manuel Cruza0b54662015-02-17 11:16:47 -0600731endif
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600732
733# use the deterministic mode of AR if available
734KBUILD_ARFLAGS := $(call ar-option,D)
735
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600736include $(srctree)/scripts/Makefile.extrawarn
737
738# Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments
739KBUILD_CPPFLAGS += $(KCPPFLAGS)
740KBUILD_AFLAGS += $(KAFLAGS)
741KBUILD_CFLAGS += $(KCFLAGS)
742
743# Use --build-id when available.
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600744
Juan Manuel Cruz7ac851a2015-04-08 17:19:22 -0500745LDFLAGS_tinymountain += $(call cc-ldoption,-nostartfiles)
746LDFLAGS_tinymountain += $(call cc-ldoption,-nodefaultlibs)
747LDFLAGS_tinymountain += $(call cc-ldoption,-nostdlib)
748LDFLAGS_tinymountain += $(call cc-ldoption,-static)
Anas Nashif3a4073d2015-05-09 10:47:33 -0400749#LDFLAGS_tinymountain += $(call cc-ldoption,-Wl$(comma)--unresolved-symbols=ignore-in-object-files)
Juan Manuel Cruz7ac851a2015-04-08 17:19:22 -0500750LDFLAGS_tinymountain += $(call cc-ldoption,-Wl$(comma)-X)
751LDFLAGS_tinymountain += $(call cc-ldoption,-Wl$(comma)-N)
752LDFLAGS_tinymountain += $(call cc-ldoption,-Wl$(comma)--gc-sections)
753LDFLAGS_tinymountain += $(call cc-ldoption,-Wl$(comma)--build-id=none)
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600754
Juan Manuel Cruz0d01f5b2015-02-22 14:29:18 -0600755LD_TOOLCHAIN ?= -D__GCC_LINKER_CMD__
Juan Manuel Cruz1c8f5a72015-04-30 17:19:04 -0500756
757ifeq ("$(CONFIG_MICROKERNEL)", "y")
758KERNEL_NAME=microkernel
759else
760KERNEL_NAME=nanokernel
761endif
762
763export LD_TOOLCHAIN KERNEL_NAME
Juan Manuel Cruz0d01f5b2015-02-22 14:29:18 -0600764
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600765# Default kernel image to build when no specific target is given.
766# KBUILD_IMAGE may be overruled on the command line or
767# set in the environment
768# Also any assignments in arch/$(ARCH)/Makefile take precedence over
769# this default value
Juan Manuel Cruz7ac851a2015-04-08 17:19:22 -0500770export KBUILD_IMAGE ?= tinymountain
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600771
772#
773# INSTALL_PATH specifies where to place the updated kernel and system map
774# images. Default is /boot, but you can set it to other values
775export INSTALL_PATH ?= /boot
776
777#
778# INSTALL_DTBS_PATH specifies a prefix for relocations required by build roots.
779# Like INSTALL_MOD_PATH, it isn't defined in the Makefile, but can be passed as
780# an argument if needed. Otherwise it defaults to the kernel install path
781#
782export INSTALL_DTBS_PATH ?= $(INSTALL_PATH)/dtbs/$(KERNELRELEASE)
783
784#
785# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
786# relocations required by build roots. This is not defined in the
787# makefile but the argument can be passed to make if needed.
788#
789
790MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
791export MODLIB
792
793#
794# INSTALL_MOD_STRIP, if defined, will cause modules to be
795# stripped after they are installed. If INSTALL_MOD_STRIP is '1', then
796# the default option --strip-debug will be used. Otherwise,
797# INSTALL_MOD_STRIP value will be used as the options to the strip command.
798
799ifdef INSTALL_MOD_STRIP
800ifeq ($(INSTALL_MOD_STRIP),1)
801mod_strip_cmd = $(STRIP) --strip-debug
802else
803mod_strip_cmd = $(STRIP) $(INSTALL_MOD_STRIP)
804endif # INSTALL_MOD_STRIP=1
805else
806mod_strip_cmd = true
807endif # INSTALL_MOD_STRIP
808export mod_strip_cmd
809
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600810
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600811
812ifdef CONFIG_MODULE_SIG_ALL
813MODSECKEY = ./signing_key.priv
814MODPUBKEY = ./signing_key.x509
815export MODPUBKEY
816mod_sign_cmd = perl $(srctree)/scripts/sign-file $(CONFIG_MODULE_SIG_HASH) $(MODSECKEY) $(MODPUBKEY)
817else
818mod_sign_cmd = true
819endif
820export mod_sign_cmd
821
822
Juan Manuel Cruzba741fe2015-02-15 14:12:00 -0600823core-y +=
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600824
Juan Manuel Cruz7ac851a2015-04-08 17:19:22 -0500825tinymountain-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600826 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
Juan Manuel Cruzba741fe2015-02-15 14:12:00 -0600827 $(bsp-y) $(bsp-m) $(libs-y) $(libs-m)))
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600828
Juan Manuel Cruz7ac851a2015-04-08 17:19:22 -0500829tinymountain-alldirs := $(sort $(tinymountain-dirs) $(patsubst %/,%,$(filter %/, \
Juan Manuel Cruzba741fe2015-02-15 14:12:00 -0600830 $(init-) $(core-) $(drivers-) $(bsp-) $(libs-))))
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600831
832init-y := $(patsubst %/, %/built-in.o, $(init-y))
833core-y := $(patsubst %/, %/built-in.o, $(core-y))
834drivers-y := $(patsubst %/, %/built-in.o, $(drivers-y))
Juan Manuel Cruzba741fe2015-02-15 14:12:00 -0600835bsp-y := $(patsubst %/, %/built-in.o, $(bsp-y))
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600836libs-y1 := $(patsubst %/, %/lib.a, $(libs-y))
837libs-y2 := $(patsubst %/, %/built-in.o, $(libs-y))
838libs-y := $(libs-y1) $(libs-y2)
839
Juan Manuel Cruz7ac851a2015-04-08 17:19:22 -0500840# Externally visible symbols (used by link-tinymountain.sh)
Juan Manuel Cruza0b54662015-02-17 11:16:47 -0600841DQUOTE = "
842#This comment line is to fix the highlighting of some editors due the quote effect."
Juan Manuel Cruz7ac851a2015-04-08 17:19:22 -0500843export KBUILD_TIMO_INIT := $(head-y) $(init-y)
844export KBUILD_TIMO_MAIN := $(core-y) $(libs-y) $(drivers-y) $(bsp-y)
Juan Manuel Cruza0b54662015-02-17 11:16:47 -0600845export KBUILD_LDS := $(srctree)/arch/$(SRCARCH)/$(subst $(DQUOTE),,$(CONFIG_BSP_DIR))/linker.cmd
Juan Manuel Cruz7ac851a2015-04-08 17:19:22 -0500846export LDFLAGS_tinymountain
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600847# used by scripts/pacmage/Makefile
Juan Manuel Cruz7ac851a2015-04-08 17:19:22 -0500848export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(tinymountain-alldirs)) arch Documentation include samples scripts tools virt)
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600849
Juan Manuel Cruz7ac851a2015-04-08 17:19:22 -0500850tinymountain-deps := $(KBUILD_LDS) $(KBUILD_TIMO_INIT) $(KBUILD_TIMO_MAIN)
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600851
Anas Nashif369cf082015-05-17 08:55:21 -0400852ALL_LIBS += $(TOOLCHAIN_LIBS)
853export ALL_LIBS
854
Juan Manuel Cruz7ac851a2015-04-08 17:19:22 -0500855# Final link of tinymountain
Anas Nashif369cf082015-05-17 08:55:21 -0400856 cmd_link-tinymountain = $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_tinymountain) $(LIB_INCLUDE_DIR) $(ALL_LIBS)
Juan Manuel Cruz7ac851a2015-04-08 17:19:22 -0500857quiet_cmd_link-tinymountain = LINK $@
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600858
859# Include targets which we want to
860# execute if the rest of the kernel build went well.
Juan Manuel Cruz7ac851a2015-04-08 17:19:22 -0500861tinymountain: scripts/link-tinymountain.sh $(tinymountain-deps) FORCE
Dirk Brandewiebc9c8842015-06-01 09:48:10 -0700862 @touch tinymountain
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600863ifdef CONFIG_HEADERS_CHECK
864 $(Q)$(MAKE) -f $(srctree)/Makefile headers_check
865endif
866ifdef CONFIG_SAMPLES
867 $(Q)$(MAKE) $(build)=samples
868endif
869ifdef CONFIG_BUILD_DOCSRC
870 $(Q)$(MAKE) $(build)=Documentation
871endif
Juan Manuel Cruzba741fe2015-02-15 14:12:00 -0600872
873ifneq ($(strip $(PROJECT)),)
Juan Manuel Cruz7ac851a2015-04-08 17:19:22 -0500874 +$(call if_changed,link-tinymountain)
Juan Manuel Cruzba741fe2015-02-15 14:12:00 -0600875endif
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600876
877# The actual objects are generated when descending,
878# make sure no implicit rule kicks in
Juan Manuel Cruz7ac851a2015-04-08 17:19:22 -0500879$(sort $(tinymountain-deps)): $(tinymountain-dirs) ;
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600880
Juan Manuel Cruz7ac851a2015-04-08 17:19:22 -0500881# Handle descending into subdirectories listed in $(tinymountain-dirs)
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600882# Preset locale variables to speed up the build process. Limit locale
883# tweaks to this spot to avoid wrong language settings when running
884# make menuconfig etc.
885# Error messages still appears in the original language
886
Juan Manuel Cruz7ac851a2015-04-08 17:19:22 -0500887PHONY += $(tinymountain-dirs)
888$(tinymountain-dirs): prepare scripts
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600889 $(Q)$(MAKE) $(build)=$@
890
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600891# Things we need to do before we recursively start building the kernel
892# or the modules are listed in "prepare".
893# A multi level approach is used. prepareN is processed before prepareN-1.
894# archprepare is used in arch Makefiles and when processed asm symlink,
895# version.h and scripts_basic is processed / created.
896
897# Listed in dependency order
Juan Manuel Cruz0167ee42015-06-05 13:08:53 -0500898PHONY += prepare prepare1 prepare2 prepare3
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600899
900# prepare3 is used to check if we are building in a separate output directory,
901# and if so do:
902# 1) Check that make has not been executed in the kernel src $(srctree)
Juan Manuel Cruz8b16a172015-05-22 18:38:45 -0500903prepare3:
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600904ifneq ($(KBUILD_SRC),)
905 @$(kecho) ' Using $(srctree) as source for kernel'
Juan Manuel Cruzce3533a2015-02-23 16:48:02 -0600906 $(Q)if [ -f $(srctree)/.config ]; then \
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600907 echo >&2 " $(srctree) is not clean, please run 'make mrproper'"; \
908 echo >&2 " in the '$(srctree)' directory.";\
909 /bin/false; \
910 fi;
911endif
912
913# prepare2 creates a makefile if using a separate output directory
Juan Manuel Cruz8b16a172015-05-22 18:38:45 -0500914prepare2: prepare3 outputmakefile
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600915
Juan Manuel Cruz8b16a172015-05-22 18:38:45 -0500916prepare1: prepare2 $(version_h) \
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600917 include/config/auto.conf
918 $(cmd_crmodverdir)
919
Juan Manuel Cruzba741fe2015-02-15 14:12:00 -0600920ifneq ($(strip $(PROJECT)),)
921SYSGEN_EXEC=y
922endif
923
924ifneq ($(CONFIG_MICROKERNEL),y)
925SYSGEN_EXEC=n
926endif
927
928export SYSGEN_EXEC
929
930archprepare_common = $(strip \
931 archheaders archscripts prepare1 scripts_basic \
932 misc/generated/configs.c \
933 include/generated/offsets.h \
934 )
935
Anas Nashif8e9d8eb2015-05-29 11:48:25 -0400936archprepare_microkernel-y = misc/generated/sysgen/kernel_main.c
Juan Manuel Cruzba741fe2015-02-15 14:12:00 -0600937
Juan Manuel Cruz0167ee42015-06-05 13:08:53 -0500938archprepare = $(strip \
Juan Manuel Cruzba741fe2015-02-15 14:12:00 -0600939 $(archprepare_common) \
940 $(archprepare_microkernel-$(SYSGEN_EXEC)) \
941 )
942
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600943# All the preparing..
Juan Manuel Cruz0167ee42015-06-05 13:08:53 -0500944prepare: $(archprepare) FORCE
945 $(Q)$(MAKE) $(build)=.
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600946
947# Generate some files
948# ---------------------------------------------------------------------------
949
950# KERNELRELEASE can change from a few different places, meaning version.h
951# needs to be updated, so this check is forced on all builds
952
Juan Manuel Cruza0b54662015-02-17 11:16:47 -0600953KERNEL_VERSION_HEX=0x$(VERSION_GENERATION)$(VERSION_MAJOR)$(VERSION_MINOR)$(VERSION_REVISION)
Juan Manuel Cruz6de34002015-02-15 21:46:45 -0600954KERNEL_CODE=40
955
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600956define filechk_version.h
Juan Manuel Cruz6de34002015-02-15 21:46:45 -0600957 (echo "#ifndef _KERNEL_VERSION_H_"; \
958 echo "#define _KERNEL_VERSION_H_"; \
959 echo ;\
960 echo "#define KERNELVERSION \\"; \
961 echo "$(KERNEL_VERSION_HEX)$(KERNEL_CODE)$(VERSION_RESERVED)"; \
962 echo "#define KERNEL_VERSION_NUMBER $(KERNEL_VERSION_HEX)"; \
963 echo "#define KERNEL_VERSION_GENERATION $(VERSION_GENERATION)"; \
964 echo "#define KERNEL_VERSION_MAJOR $(VERSION_MAJOR)"; \
965 echo "#define KERNEL_VERSION_MINOR $(VERSION_MINOR)"; \
966 echo "#define KERNEL_VERSION_REVISION $(VERSION_REVISION)"; \
967 echo "#define KERNEL_VERSION_STRING \"$(KERNELVERSION)\""; \
968 echo; \
969 echo "#endif /* _KERNEL_VERSION_H_ */";)
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600970endef
971
972$(version_h): $(srctree)/Makefile FORCE
973 $(call filechk,version.h)
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600974
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600975PHONY += headerdep
976headerdep:
977 $(Q)find $(srctree)/include/ -name '*.h' | xargs --max-args 1 \
978 $(srctree)/scripts/headerdep.pl -I$(srctree)/include
979
980# ---------------------------------------------------------------------------
981
982PHONY += depend dep
983depend dep:
984 @echo '*** Warning: make $@ is unnecessary now.'
985
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -0600986
987# ---------------------------------------------------------------------------
988# Kernel headers
989
990#Default location for installed headers
991export INSTALL_HDR_PATH = $(objtree)/usr
992
993# If we do an all arch process set dst to asm-$(hdr-arch)
994hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm)
995
996PHONY += archheaders
997archheaders:
998
999PHONY += archscripts
1000archscripts:
1001
1002PHONY += __headers
1003__headers: $(version_h) scripts_basic asm-generic archheaders archscripts FORCE
1004 $(Q)$(MAKE) $(build)=scripts build_unifdef
1005
1006PHONY += headers_install_all
1007headers_install_all:
1008 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/headers.sh install
1009
1010PHONY += headers_install
1011headers_install: __headers
1012 $(if $(wildcard $(srctree)/arch/$(hdr-arch)/include/uapi/asm/Kbuild),, \
1013 $(error Headers not exportable for the $(SRCARCH) architecture))
1014 $(Q)$(MAKE) $(hdr-inst)=include/uapi
1015 $(Q)$(MAKE) $(hdr-inst)=arch/$(hdr-arch)/include/uapi/asm $(hdr-dst)
1016
1017PHONY += headers_check_all
1018headers_check_all: headers_install_all
1019 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/headers.sh check
1020
1021PHONY += headers_check
1022headers_check: headers_install
1023 $(Q)$(MAKE) $(hdr-inst)=include/uapi HDRCHECK=1
1024 $(Q)$(MAKE) $(hdr-inst)=arch/$(hdr-arch)/include/uapi/asm $(hdr-dst) HDRCHECK=1
1025
1026# ---------------------------------------------------------------------------
1027# Kernel selftest
1028
1029PHONY += kselftest
1030kselftest:
1031 $(Q)$(MAKE) -C tools/testing/selftests run_tests
1032
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -06001033
1034###
1035# Cleaning is done on three levels.
1036# make clean Delete most generated files
1037# Leave enough to build external modules
1038# make mrproper Delete the current configuration, and all generated files
1039# make distclean Remove editor backup files, patch leftover files and the like
1040
1041# Directories & files removed with 'make clean'
1042CLEAN_DIRS += $(MODVERDIR)
1043
Anas Nashif8e9d8eb2015-05-29 11:48:25 -04001044CLEAN_FILES += misc/generated/sysgen/kernel_main.c \
Allan Stephens5b291d32015-06-05 08:32:54 -04001045 misc/generated/sysgen/zephyr.h \
Anas Nashif8e9d8eb2015-05-29 11:48:25 -04001046 misc/generated/sysgen/prj.vpf
Juan Manuel Cruzce3533a2015-02-23 16:48:02 -06001047
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -06001048# Directories & files removed with 'make mrproper'
1049MRPROPER_DIRS += include/config usr/include include/generated \
1050 arch/*/include/generated .tmp_objdiff
Anas Nashif1e8dc5a2015-04-24 18:32:55 -04001051MRPROPER_FILES += .config .config.old .version $(version_h) \
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -06001052 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
1053 signing_key.priv signing_key.x509 x509.genkey \
1054 extra_certificates signing_key.x509.keyid \
1055 signing_key.x509.signer
1056
1057# clean - Delete most, but leave enough to build external modules
1058#
1059clean: rm-dirs := $(CLEAN_DIRS)
1060clean: rm-files := $(CLEAN_FILES)
Juan Manuel Cruz7ac851a2015-04-08 17:19:22 -05001061clean-dirs := $(addprefix _clean_, . $(tinymountain-alldirs) )
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -06001062
Juan Manuel Cruz7ac851a2015-04-08 17:19:22 -05001063PHONY += $(clean-dirs) clean archclean tinymountainclean
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -06001064$(clean-dirs):
1065 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
1066
Juan Manuel Cruz7ac851a2015-04-08 17:19:22 -05001067tinymountainclean:
1068 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-tinymountain.sh clean
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -06001069
Juan Manuel Cruz7ac851a2015-04-08 17:19:22 -05001070clean: archclean tinymountainclean
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -06001071
1072# mrproper - Delete all generated files, including .config
1073#
1074mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS))
1075mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
Juan Manuel Cruzce3533a2015-02-23 16:48:02 -06001076mrproper-dirs := $(addprefix _mrproper_,scripts)
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -06001077
1078PHONY += $(mrproper-dirs) mrproper archmrproper
1079$(mrproper-dirs):
1080 $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
1081
1082mrproper: clean archmrproper $(mrproper-dirs)
1083 $(call cmd,rmdirs)
1084 $(call cmd,rmfiles)
1085
1086# distclean
1087#
1088PHONY += distclean
1089
1090distclean: mrproper
1091 @find $(srctree) $(RCS_FIND_IGNORE) \
1092 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
1093 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
1094 -o -name '.*.rej' -o -name '*%' -o -name 'core' \) \
1095 -type f -print | xargs rm -f
1096
1097
1098# Packaging of the kernel to various formats
1099# ---------------------------------------------------------------------------
1100# rpm target kept for backward compatibility
1101package-dir := scripts/package
1102
1103%src-pkg: FORCE
1104 $(Q)$(MAKE) $(build)=$(package-dir) $@
Juan Manuel Cruzef07b962015-06-05 12:58:50 -05001105%pkg: $(version_h) FORCE
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -06001106 $(Q)$(MAKE) $(build)=$(package-dir) $@
Juan Manuel Cruzef07b962015-06-05 12:58:50 -05001107rpm: $(version_h) FORCE
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -06001108 $(Q)$(MAKE) $(build)=$(package-dir) $@
1109
1110
1111# Brief documentation of the typical targets used
1112# ---------------------------------------------------------------------------
1113
1114boards := $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*_defconfig)
1115boards := $(sort $(notdir $(boards)))
1116board-dirs := $(dir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*/*_defconfig))
1117board-dirs := $(sort $(notdir $(board-dirs:/=)))
1118
1119help:
1120 @echo 'Cleaning targets:'
1121 @echo ' clean - Remove most generated files but keep the config and'
1122 @echo ' enough build support to build external modules'
1123 @echo ' mrproper - Remove all generated files + config + various backup files'
1124 @echo ' distclean - mrproper + remove editor backup and patch files'
1125 @echo ''
1126 @echo 'Configuration targets:'
1127 @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
1128 @echo ''
1129 @echo 'Other generic targets:'
1130 @echo ' all - Build all targets marked with [*]'
Juan Manuel Cruz7ac851a2015-04-08 17:19:22 -05001131 @echo '* tinymountain - Build the bare kernel'
Juan Manuel Cruze7de0f62015-04-30 14:14:29 -05001132 @echo ' qemu - Build the bare kernel and runs the emulation with qemu'
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -06001133 @echo 'Architecture specific targets ($(SRCARCH)):'
1134 @$(if $(archhelp),$(archhelp),\
1135 echo ' No architecture specific help defined for $(SRCARCH)')
1136 @echo ''
1137 @$(if $(boards), \
1138 $(foreach b, $(boards), \
1139 printf " %-24s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \
1140 echo '')
1141 @$(if $(board-dirs), \
1142 $(foreach b, $(board-dirs), \
1143 printf " %-16s - Show %s-specific targets\\n" help-$(b) $(b);) \
1144 printf " %-16s - Show all of the above\\n" help-boards; \
1145 echo '')
1146
1147 @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
1148 @echo ' make V=2 [targets] 2 => give reason for rebuild of target'
1149 @echo ' make O=dir [targets] Locate all output files in "dir", including .config'
1150 @echo ' make C=1 [targets] Check all c source with $$CHECK (sparse by default)'
1151 @echo ' make C=2 [targets] Force check of all c source with $$CHECK'
1152 @echo ' make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections'
1153 @echo ' make W=n [targets] Enable extra gcc checks, n=1,2,3 where'
1154 @echo ' 1: warnings which may be relevant and do not occur too often'
1155 @echo ' 2: warnings which occur quite often but may still be relevant'
1156 @echo ' 3: more obscure warnings, can most likely be ignored'
1157 @echo ' Multiple levels can be combined with W=12 or W=123'
1158 @echo ''
1159 @echo 'Execute "make" or "make all" to build all targets marked with [*] '
1160 @echo 'For further info see the ./README file'
1161
1162
1163help-board-dirs := $(addprefix help-,$(board-dirs))
1164
1165help-boards: $(help-board-dirs)
1166
1167boards-per-dir = $(sort $(notdir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/$*/*_defconfig)))
1168
1169$(help-board-dirs): help-%:
1170 @echo 'Architecture specific targets ($(SRCARCH) $*):'
1171 @$(if $(boards-per-dir), \
1172 $(foreach b, $(boards-per-dir), \
1173 printf " %-24s - Build for %s\\n" $*/$(b) $(subst _defconfig,,$(b));) \
1174 echo '')
1175
1176
1177# Documentation targets
1178# ---------------------------------------------------------------------------
1179%docs: scripts_basic FORCE
1180 $(Q)$(MAKE) $(build)=scripts build_docproc
1181 $(Q)$(MAKE) $(build)=Documentation/DocBook $@
1182
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -06001183
Juan Manuel Cruzce3533a2015-02-23 16:48:02 -06001184#BUG [oas] regular expression is substituted by [oa] to ommit the removal
1185# of .s files. This change can be undone once all .s files have been
1186# renamed to .S files.
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -06001187clean: $(clean-dirs)
1188 $(call cmd,rmdirs)
1189 $(call cmd,rmfiles)
1190 @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
Juan Manuel Cruzce3533a2015-02-23 16:48:02 -06001191 \( -name '*.[oa]' -o -name '*.ko' -o -name '.*.cmd' \
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -06001192 -o -name '*.ko.*' \
1193 -o -name '*.dwo' \
1194 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
Dirk Brandewie08760392015-06-01 09:48:10 -07001195 -o -name '*.symtypes' \
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -06001196 -o -name modules.builtin -o -name '.tmp_*.o.*' \
1197 -o -name '*.gcno' \) -type f -print | xargs rm -f
1198
1199# Generate tags for editors
1200# ---------------------------------------------------------------------------
1201quiet_cmd_tags = GEN $@
1202 cmd_tags = $(CONFIG_SHELL) $(srctree)/scripts/tags.sh $@
1203
1204tags TAGS cscope gtags: FORCE
1205 $(call cmd,tags)
1206
1207# Scripts to check various things for consistency
1208# ---------------------------------------------------------------------------
1209
1210PHONY += includecheck versioncheck coccicheck namespacecheck export_report
1211
1212includecheck:
1213 find $(srctree)/* $(RCS_FIND_IGNORE) \
1214 -name '*.[hcS]' -type f -print | sort \
1215 | xargs $(PERL) -w $(srctree)/scripts/checkincludes.pl
1216
1217versioncheck:
1218 find $(srctree)/* $(RCS_FIND_IGNORE) \
1219 -name '*.[hcS]' -type f -print | sort \
1220 | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl
1221
1222coccicheck:
1223 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/$@
1224
1225namespacecheck:
1226 $(PERL) $(srctree)/scripts/namespace.pl
1227
1228export_report:
1229 $(PERL) $(srctree)/scripts/export_report.pl
1230
1231endif #ifeq ($(config-targets),1)
1232endif #ifeq ($(mixed-targets),1)
1233
Juan Manuel Cruzef07b962015-06-05 12:58:50 -05001234PHONY += checkstack kernelversion image_name
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -06001235
1236# UML needs a little special treatment here. It wants to use the host
1237# toolchain, so needs $(SUBARCH) passed to checkstack.pl. Everyone
1238# else wants $(ARCH), including people doing cross-builds, which means
1239# that $(SUBARCH) doesn't work here.
1240ifeq ($(ARCH), um)
1241CHECKSTACK_ARCH := $(SUBARCH)
1242else
1243CHECKSTACK_ARCH := $(ARCH)
1244endif
1245checkstack:
Juan Manuel Cruz7ac851a2015-04-08 17:19:22 -05001246 $(OBJDUMP) -d tinymountain $$(find . -name '*.ko') | \
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -06001247 $(PERL) $(src)/scripts/checkstack.pl $(CHECKSTACK_ARCH)
1248
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -06001249kernelversion:
1250 @echo $(KERNELVERSION)
1251
1252image_name:
1253 @echo $(KBUILD_IMAGE)
1254
1255# Clear a bunch of variables before executing the submake
1256tools/: FORCE
1257 $(Q)mkdir -p $(objtree)/tools
1258 $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(filter --j% -j,$(MAKEFLAGS))" O=$(objtree) subdir=tools -C $(src)/tools/
1259
1260tools/%: FORCE
1261 $(Q)mkdir -p $(objtree)/tools
1262 $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(filter --j% -j,$(MAKEFLAGS))" O=$(objtree) subdir=tools -C $(src)/tools/ $*
1263
Anas Nashif848c5c82015-05-10 18:44:17 -04001264QEMU_FLAGS = $(QEMU_FLAGS_$(SRCARCH)) -pidfile qemu.pid
Juan Manuel Cruze7de0f62015-04-30 14:14:29 -05001265
1266qemu: tinymountain
Anas Nashif848c5c82015-05-10 18:44:17 -04001267 @echo "To exit from QEMU enter: 'CTRL+a, x'"
Juan Manuel Cruze7de0f62015-04-30 14:14:29 -05001268 @echo '[QEMU] CPU: $(QEMU_CPU_TYPE_$(SRCARCH))'
Juan Manuel Cruz638fb2c2015-05-10 21:52:56 -05001269 $(Q)$(QEMU) $(QEMU_FLAGS) $(QEMU_EXTRA_FLAGS) -kernel $(KERNEL_NAME).elf
Juan Manuel Cruze7de0f62015-04-30 14:14:29 -05001270
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -06001271# Single targets
1272# ---------------------------------------------------------------------------
1273# Single targets are compatible with:
1274# - build with mixed source and output
1275# - build with separate output dir 'make O=...'
1276# - external modules
1277#
1278# target-dir => where to store outputfile
1279# build-dir => directory in kernel source tree to use
1280
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -06001281 build-dir = $(patsubst %/,%,$(dir $@))
1282 target-dir = $(dir $@)
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -06001283
1284%.s: %.c prepare scripts FORCE
1285 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1286%.i: %.c prepare scripts FORCE
1287 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1288%.o: %.c prepare scripts FORCE
1289 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1290%.lst: %.c prepare scripts FORCE
1291 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1292%.s: %.S prepare scripts FORCE
1293 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1294%.o: %.S prepare scripts FORCE
1295 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1296%.symtypes: %.c prepare scripts FORCE
1297 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1298
1299# Modules
1300/: prepare scripts FORCE
1301 $(cmd_crmodverdir)
1302 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
1303 $(build)=$(build-dir)
1304# Make sure the latest headers are built for Documentation
1305Documentation/: headers_install
1306%/: prepare scripts FORCE
1307 $(cmd_crmodverdir)
1308 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
1309 $(build)=$(build-dir)
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -06001310
1311# FIXME Should go into a make.lib or something
1312# ===========================================================================
1313
1314quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-dirs)))
1315 cmd_rmdirs = rm -rf $(rm-dirs)
1316
1317quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)))
1318 cmd_rmfiles = rm -f $(rm-files)
1319
1320# Run depmod only if we have System.map and depmod is executable
1321quiet_cmd_depmod = DEPMOD $(KERNELRELEASE)
1322 cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \
1323 $(KERNELRELEASE) "$(patsubst y,_,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX))"
1324
Juan Manuel Cruza9b1c742015-01-29 15:22:58 -06001325
1326# read all saved command lines
1327
1328targets := $(wildcard $(sort $(targets)))
1329cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
1330
1331ifneq ($(cmd_files),)
1332 $(cmd_files): ; # Do not try to update included dependency files
1333 include $(cmd_files)
1334endif
1335
1336endif # skip-makefile
1337
1338PHONY += FORCE
1339FORCE:
1340
1341# Declare the contents of the .PHONY variable as phony. We keep that
1342# information in a variable so we can use it in if_changed and friends.
1343.PHONY: $(PHONY)