blob: 8ea87ef28acc29db791cca2310febeb339fda4fd [file] [log] [blame]
tarun.kundu46c8a902023-02-02 15:25:03 -08001ROOT ?= $(abspath ../../..)
2include $(ROOT)/Makefile.config
Denis Vlasenko7d219aa2006-10-05 10:17:08 +00003VERSION = 1
Denys Vlasenko44075922021-12-26 18:40:55 +01004PATCHLEVEL = 36
Denis Vlasenkoa883fa42006-12-13 23:52:32 +00005SUBLEVEL = 0
Denys Vlasenko70f77e42023-01-03 15:15:41 +01006EXTRAVERSION =
Denis Vlasenkoda8f43f2006-10-09 19:47:38 +00007NAME = Unnamed
Denis Vlasenko7d219aa2006-10-05 10:17:08 +00008
9# *DOCUMENTATION*
10# To see a list of typical targets execute "make help"
11# More info can be located in ./README
12# Comments in this file are targeted only to the developer, do not
13# expect to learn how to build the kernel reading this file.
14
15# Do not print "Entering directory ..."
16MAKEFLAGS += --no-print-directory
17
18# We are using a recursive build, so we need to do a little thinking
19# to get the ordering right.
Eric Andersenc4996011999-10-20 22:08:37 +000020#
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000021# Most importantly: sub-Makefiles should only ever modify files in
22# their own directory. If in some directory we have a dependency on
23# a file in another dir (which doesn't happen often, but it's often
24# unavoidable when linking the built-in.o targets which finally
25# turn into busybox), we will call a sub make in that other dir, and
26# after that we are sure that everything which is in that other dir
27# is now up to date.
Erik Andersen9ffdaa62000-02-11 21:55:04 +000028#
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000029# The only cases where we need to modify files which have global
30# effects are thus separated out and done before the recursive
31# descending is started. They are now explicitly listed as the
32# prepare rule.
Eric Andersenc4996011999-10-20 22:08:37 +000033
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000034# To put more focus on warnings, be less verbose as default
35# Use 'make V=1' to see the full commands
Rob Landleyd9872aa2006-05-27 21:24:16 +000036
Bernhard Reutner-Fischer7b8ff222006-06-13 14:20:17 +000037ifdef V
38 ifeq ("$(origin V)", "command line")
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000039 KBUILD_VERBOSE = $(V)
Bernhard Reutner-Fischer7b8ff222006-06-13 14:20:17 +000040 endif
41endif
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000042ifndef KBUILD_VERBOSE
43 KBUILD_VERBOSE = 0
44endif
45
46# Call sparse as part of compilation of C files
47# Use 'make C=1' to enable sparse checking
48
49ifdef C
50 ifeq ("$(origin C)", "command line")
51 KBUILD_CHECKSRC = $(C)
52 endif
53endif
54ifndef KBUILD_CHECKSRC
55 KBUILD_CHECKSRC = 0
56endif
57
58# Use make M=dir to specify directory of external module to build
59# Old syntax make ... SUBDIRS=$PWD is still supported
60# Setting the environment variable KBUILD_EXTMOD take precedence
61ifdef SUBDIRS
62 KBUILD_EXTMOD ?= $(SUBDIRS)
63endif
64ifdef M
65 ifeq ("$(origin M)", "command line")
66 KBUILD_EXTMOD := $(M)
Bernhard Reutner-Fischer7b8ff222006-06-13 14:20:17 +000067 endif
68endif
69
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000070
71# kbuild supports saving output files in a separate directory.
72# To locate output files in a separate directory two syntaxes are supported.
73# In both cases the working directory must be the root of the kernel src.
74# 1) O=
75# Use "make O=dir/to/store/output/files/"
Denis Vlasenkof7996f32007-01-11 17:20:00 +000076#
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000077# 2) Set KBUILD_OUTPUT
78# Set the environment variable KBUILD_OUTPUT to point to the directory
79# where the output files shall be placed.
80# export KBUILD_OUTPUT=dir/to/store/output/files/
81# make
82#
83# The O= assignment takes precedence over the KBUILD_OUTPUT environment
84# variable.
85
86
87# KBUILD_SRC is set on invocation of make in OBJ directory
88# KBUILD_SRC is not intended to be used by the regular user (for now)
89ifeq ($(KBUILD_SRC),)
90
91# OK, Make called in directory where kernel src resides
92# Do we want to locate output files in a separate directory?
93ifdef O
94 ifeq ("$(origin O)", "command line")
95 KBUILD_OUTPUT := $(O)
96 endif
Eric Andersen7daa0762004-10-08 07:46:08 +000097endif
98
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000099# That's our default target when none is given on the command line
100PHONY := _all
101_all:
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000102
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000103ifneq ($(KBUILD_OUTPUT),)
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000104# Invoke a second make in the output directory, passing relevant variables
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000105# check that the output directory actually exists
106saved-output := $(KBUILD_OUTPUT)
107KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd)
108$(if $(KBUILD_OUTPUT),, \
Eric Andersen7daa0762004-10-08 07:46:08 +0000109 $(error output directory "$(saved-output)" does not exist))
110
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000111PHONY += $(MAKECMDGOALS)
Eric Andersen7daa0762004-10-08 07:46:08 +0000112
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000113$(filter-out _all,$(MAKECMDGOALS)) _all:
114 $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
115 KBUILD_SRC=$(CURDIR) \
116 KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile $@
Eric Andersen7daa0762004-10-08 07:46:08 +0000117
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000118# Leave processing to above invocation of make
119skip-makefile := 1
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000120endif # ifneq ($(KBUILD_OUTPUT),)
121endif # ifeq ($(KBUILD_SRC),)
Eric Andersen7daa0762004-10-08 07:46:08 +0000122
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000123# We process the rest of the Makefile if this is the final invocation of make
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000124ifeq ($(skip-makefile),)
Eric Andersen7daa0762004-10-08 07:46:08 +0000125
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000126# If building an external module we do not care about the all: rule
127# but instead _all depend on modules
128PHONY += all
129ifeq ($(KBUILD_EXTMOD),)
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000130_all: all
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000131else
132_all: modules
133endif
Glenn L McGrath6376b582003-09-24 15:48:29 +0000134
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000135srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR))
136TOPDIR := $(srctree)
137# FIXME - TOPDIR is obsolete, use srctree/objtree
138objtree := $(CURDIR)
139src := $(srctree)
140obj := $(objtree)
141
142VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))
143
144export srctree objtree VPATH TOPDIR
Bernhard Reutner-Fischer4d635252005-10-07 10:53:15 +0000145
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000146
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000147# Cross compiling and selecting different set of gcc/bin-utils
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000148# ---------------------------------------------------------------------------
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000149#
150# When performing cross compilation for other architectures ARCH shall be set
151# to the target architecture. (See arch/* for the possibilities).
152# ARCH can be set during invocation of make:
153# make ARCH=ia64
154# Another way is to have ARCH set in the environment.
155# The default ARCH is the host where make is executed.
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000156
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000157# CROSS_COMPILE specify the prefix used for all executables used
158# during compilation. Only gcc and related bin-utils executables
159# are prefixed with $(CROSS_COMPILE).
160# CROSS_COMPILE can be set on the command line
161# make CROSS_COMPILE=ia64-linux-
162# Alternatively CROSS_COMPILE can be set in the environment.
163# Default value for CROSS_COMPILE is not to prefix executables
164# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000165
Denis Vlasenko630a7f72008-06-02 22:24:34 +0000166CROSS_COMPILE ?=
Denis Vlasenkob8e653b2008-06-02 04:51:29 +0000167# bbox: we may have CONFIG_CROSS_COMPILER_PREFIX in .config,
168# and it has not been included yet... thus using an awkward syntax.
169ifeq ($(CROSS_COMPILE),)
170CROSS_COMPILE := $(shell grep ^CONFIG_CROSS_COMPILER_PREFIX .config 2>/dev/null)
171CROSS_COMPILE := $(subst CONFIG_CROSS_COMPILER_PREFIX=,,$(CROSS_COMPILE))
172CROSS_COMPILE := $(subst ",,$(CROSS_COMPILE))
Bernhard Reutner-Fischera7542dd2009-01-27 18:54:41 +0000173#")
Denis Vlasenkob8e653b2008-06-02 04:51:29 +0000174endif
175
176# SUBARCH tells the usermode build what the underlying arch is. That is set
177# first, and if a usermode build is happening, the "ARCH=um" on the command
178# line overrides the setting of ARCH below. If a native build is happening,
179# then ARCH is assigned, getting whatever value it gets normally, and
180# SUBARCH is subsequently ignored.
181
182ifneq ($(CROSS_COMPILE),)
Denys Vlasenko1ef3ce92017-07-19 17:56:56 +0200183SUBARCH := $(shell echo $(CROSS_COMPILE) | cut -d- -f1 | sed 's:^.*/::g')
Denis Vlasenkob8e653b2008-06-02 04:51:29 +0000184else
185SUBARCH := $(shell uname -m)
186endif
187SUBARCH := $(shell echo $(SUBARCH) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
188 -e s/arm.*/arm/ -e s/sa110/arm/ \
189 -e s/s390x/s390/ -e s/parisc64/parisc/ \
190 -e s/ppc.*/powerpc/ -e s/mips.*/mips/ )
191
Denis Vlasenko630a7f72008-06-02 22:24:34 +0000192ARCH ?= $(SUBARCH)
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000193
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000194# Architecture as present in compile.h
195UTS_MACHINE := $(ARCH)
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000196
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000197# SHELL used by kbuild
198CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
199 else if [ -x /bin/bash ]; then echo /bin/bash; \
200 else echo sh; fi ; fi)
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000201
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000202# Decide whether to build built-in, modular, or both.
203# Normally, just do built-in.
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000204
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000205KBUILD_MODULES :=
206KBUILD_BUILTIN := 1
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000207
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000208# If we have only "make modules", don't compile built-in objects.
209# When we're building modules with modversions, we need to consider
210# the built-in objects during the descend as well, in order to
211# make sure the checksums are uptodate before we record them.
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000212
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000213ifeq ($(MAKECMDGOALS),modules)
214 KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1)
215endif
Rob Landleya167ec52006-01-31 02:42:50 +0000216
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000217# If we have "make <whatever> modules", compile modules
218# in addition to whatever we do anyway.
219# Just "make" or "make all" shall build modules as well
220
221ifneq ($(filter all _all modules,$(MAKECMDGOALS)),)
222 KBUILD_MODULES := 1
223endif
224
225ifeq ($(MAKECMDGOALS),)
226 KBUILD_MODULES := 1
227endif
228
229export KBUILD_MODULES KBUILD_BUILTIN
230export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD
231
232# Beautify output
233# ---------------------------------------------------------------------------
234#
235# Normally, we echo the whole command before executing it. By making
236# that echo $($(quiet)$(cmd)), we now have the possibility to set
237# $(quiet) to choose other forms of output instead, e.g.
238#
239# quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
240# cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
241#
242# If $(quiet) is empty, the whole command will be printed.
Denis Vlasenkof7996f32007-01-11 17:20:00 +0000243# If it is set to "quiet_", only the short version will be printed.
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000244# If it is set to "silent_", nothing wil be printed at all, since
245# the variable $(silent_cmd_cc_o_c) doesn't exist.
246#
247# A simple variant is to prefix commands with $(Q) - that's useful
248# for commands that shall be hidden in non-verbose mode.
249#
250# $(Q)ln $@ :<
251#
252# If KBUILD_VERBOSE equals 0 then the above command will be hidden.
253# If KBUILD_VERBOSE equals 1 then the above command is displayed.
254
255ifeq ($(KBUILD_VERBOSE),1)
256 quiet =
257 Q =
258else
259 quiet=quiet_
260 Q = @
261endif
262
263# If the user is running make -s (silent mode), suppress echoing of
264# commands
265
266ifneq ($(findstring s,$(MAKEFLAGS)),)
267 quiet=silent_
268endif
269
270export quiet Q KBUILD_VERBOSE
Rob Landleya167ec52006-01-31 02:42:50 +0000271
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000272
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000273# Look for make include files relative to root of kernel src
274MAKEFLAGS += --include-dir=$(srctree)
Bernhard Reutner-Fischera9d89132005-10-07 18:45:03 +0000275
Bernhard Reutner-Fischeree921392007-06-20 10:01:12 +0000276HOSTCC = gcc
277HOSTCXX = g++
278HOSTCFLAGS :=
279HOSTCXXFLAGS :=
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000280# We need some generic definitions
Denis Vlasenko14aa9f72006-10-31 23:03:09 +0000281include $(srctree)/scripts/Kbuild.include
Bernhard Reutner-Fischere28d1d62006-05-26 13:22:57 +0000282
Bernhard Reutner-Fischeree921392007-06-20 10:01:12 +0000283HOSTCFLAGS += $(call hostcc-option,-Wall -Wstrict-prototypes -O2 -fomit-frame-pointer,)
284HOSTCXXFLAGS += -O2
285
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000286# For maximum performance (+ possibly random breakage, uncomment
287# the following)
Eric Andersen00814662001-04-26 23:29:10 +0000288
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000289MAKEFLAGS += -rR
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000290
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000291# Make variables (CC, etc...)
292
293AS = $(CROSS_COMPILE)as
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000294CC = $(CROSS_COMPILE)gcc
Bernhard Reutner-Fischere86bd6c2007-01-09 17:36:26 +0000295LD = $(CC) -nostdlib
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000296CPP = $(CC) -E
297AR = $(CROSS_COMPILE)ar
298NM = $(CROSS_COMPILE)nm
299STRIP = $(CROSS_COMPILE)strip
300OBJCOPY = $(CROSS_COMPILE)objcopy
301OBJDUMP = $(CROSS_COMPILE)objdump
Mike Frysinger5694afd2012-10-20 15:01:26 -0400302PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000303AWK = awk
304GENKSYMS = scripts/genksyms/genksyms
305DEPMOD = /sbin/depmod
306KALLSYMS = scripts/kallsyms
307PERL = perl
308CHECK = sparse
309
310CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise $(CF)
311MODFLAGS = -DMODULE
312CFLAGS_MODULE = $(MODFLAGS)
313AFLAGS_MODULE = $(MODFLAGS)
314LDFLAGS_MODULE = -r
315CFLAGS_KERNEL =
316AFLAGS_KERNEL =
317
318
319# Use LINUXINCLUDE when you must reference the include/ directory.
320# Needed to be compatible with the O= option
Mike Frysinger5b6195c2007-01-26 07:14:01 +0000321CFLAGS := $(CFLAGS)
Denis Vlasenko1da86d22008-06-04 11:28:24 +0000322# Added only to final link stage of busybox binary
323CFLAGS_busybox := $(CFLAGS_busybox)
Mike Frysinger5b6195c2007-01-26 07:14:01 +0000324CPPFLAGS := $(CPPFLAGS)
325AFLAGS := $(AFLAGS)
Mike Frysinger52a9db62007-03-30 05:44:15 +0000326LDFLAGS := $(LDFLAGS)
327LDLIBS :=
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000328
329# Read KERNELRELEASE from .kernelrelease (if it exists)
330KERNELRELEASE = $(shell cat .kernelrelease 2> /dev/null)
331KERNELVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
332
333export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION \
334 ARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \
335 CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE \
Mike Frysinger9020d852007-04-05 21:14:29 +0000336 HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000337
338export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
Denis Vlasenkof7996f32007-01-11 17:20:00 +0000339export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000340export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
Mike Frysinger9020d852007-04-05 21:14:29 +0000341export FLTFLAGS
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000342
343# When compiling out-of-tree modules, put MODVERDIR in the module
344# tree rather than in the kernel tree. The kernel tree might
345# even be read-only.
346export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions
347
348# Files to ignore in find ... statements
349
350RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o -name .pc -o -name .hg -o -name .git \) -prune -o
351export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS --exclude .pc --exclude .hg --exclude .git
352
353# ===========================================================================
354# Rules shared between *config targets and build targets
355
356# Basic helpers built in scripts/
357PHONY += scripts_basic
358scripts_basic:
359 $(Q)$(MAKE) $(build)=scripts/basic
360
361# To avoid any implicit rule to kick in, define an empty command.
362scripts/basic/%: scripts_basic ;
363
Denys Vlasenko6c5bf0d2010-06-06 00:53:45 +0200364# This target generates Kbuild's and Config.in's from *.c files
365PHONY += gen_build_files
Ron Yorstonaf694a42018-11-18 07:40:40 +0000366gen_build_files: $(wildcard $(srctree)/*/*.c) $(wildcard $(srctree)/*/*/*.c) $(wildcard $(srctree)/embed/*)
Denys Vlasenko6c5bf0d2010-06-06 00:53:45 +0200367 $(Q)$(srctree)/scripts/gen_build_files.sh $(srctree) $(objtree)
368
Denys Vlasenkob24c1132009-11-24 22:23:21 +0100369# bbox: we have helpers in applets/
Denys Vlasenko18221502009-11-25 00:22:31 +0100370# we depend on scripts_basic, since scripts/basic/fixdep
371# must be built before any other host prog
Denys Vlasenkob24c1132009-11-24 22:23:21 +0100372PHONY += applets_dir
Michael Olbrich43dd0062018-04-12 10:36:54 +0200373applets_dir: scripts_basic gen_build_files include/config/MARKER
Denys Vlasenkob24c1132009-11-24 22:23:21 +0100374 $(Q)$(MAKE) $(build)=applets
375
376applets/%: applets_dir ;
377
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000378PHONY += outputmakefile
379# outputmakefile generates a Makefile in the output directory, if using a
380# separate output directory. This allows convenient use of make in the
381# output directory.
382outputmakefile:
383ifneq ($(KBUILD_SRC),)
384 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \
385 $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
386endif
387
388# To make sure we do not include .config for any of the *config targets
389# catch them early, and hand them over to scripts/kconfig/Makefile
390# It is allowed to specify more targets when calling make, including
391# mixing *config targets and build targets.
Denis Vlasenkof7996f32007-01-11 17:20:00 +0000392# For example 'make oldconfig all'.
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000393# Detect when mixed targets is specified, and make a second invocation
394# of make so .config is not included in this case either (for *config).
395
396no-dot-config-targets := clean mrproper distclean \
Denis Vlasenkob75a1c32008-04-10 19:59:20 +0000397 cscope TAGS tags help %docs
398#bbox# check% is removed from above
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000399
400config-targets := 0
401mixed-targets := 0
402dot-config := 1
403
404ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
405 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
406 dot-config := 0
407 endif
408endif
409
410ifeq ($(KBUILD_EXTMOD),)
411 ifneq ($(filter config %config,$(MAKECMDGOALS)),)
412 config-targets := 1
413 ifneq ($(filter-out config %config,$(MAKECMDGOALS)),)
414 mixed-targets := 1
415 endif
416 endif
417endif
418
419ifeq ($(mixed-targets),1)
420# ===========================================================================
421# We're called with mixed targets (*config and build targets).
422# Handle them one by one.
423
424%:: FORCE
425 $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= $@
426
427else
428ifeq ($(config-targets),1)
429# ===========================================================================
430# *config targets only - make sure prerequisites are updated, and descend
431# in scripts/kconfig to make the *config target
432
433# Read arch specific Makefile to set KBUILD_DEFCONFIG as needed.
434# KBUILD_DEFCONFIG may point out an alternative default configuration
435# used for 'make defconfig'
436-include $(srctree)/arch/$(ARCH)/Makefile
437export KBUILD_DEFCONFIG
438
Denys Vlasenkoadbe3b52010-08-22 09:28:46 +0200439config: scripts_basic outputmakefile gen_build_files FORCE
440 $(Q)mkdir -p include
441 $(Q)$(MAKE) $(build)=scripts/kconfig $@
442 $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= .kernelrelease
443
444%config: scripts_basic outputmakefile gen_build_files FORCE
Denis Vlasenko665b02c2006-10-11 21:24:42 +0000445 $(Q)mkdir -p include
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000446 $(Q)$(MAKE) $(build)=scripts/kconfig $@
447 $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= .kernelrelease
448
449else
450# ===========================================================================
451# Build targets only - this includes busybox, arch specific targets, clean
452# targets and others. In general all targets except *config targets.
453
454ifeq ($(KBUILD_EXTMOD),)
455# Additional helpers built in scripts/
456# Carefully list dependencies so we do not try to build scripts twice
Denys Vlasenko6c5bf0d2010-06-06 00:53:45 +0200457# in parallel
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000458PHONY += scripts
Denys Vlasenko7fb68f12010-05-09 04:22:48 +0200459scripts: gen_build_files scripts_basic include/config/MARKER
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000460 $(Q)$(MAKE) $(build)=$(@)
461
462scripts_basic: include/autoconf.h
463
464# Objects we will link into busybox / subdirs we need to visit
465core-y := \
466 applets/ \
467
468libs-y := \
469 archival/ \
Denys Vlasenko833d4e72010-11-03 02:38:31 +0100470 archival/libarchive/ \
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000471 console-tools/ \
472 coreutils/ \
473 coreutils/libcoreutils/ \
474 debianutils/ \
Denys Vlasenkoab77e812017-08-18 19:15:29 +0200475 klibc-utils/ \
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000476 e2fsprogs/ \
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000477 editors/ \
478 findutils/ \
479 init/ \
480 libbb/ \
481 libpwdgrp/ \
482 loginutils/ \
Denis Vlasenkob9d572a2008-11-06 23:41:38 +0000483 mailutils/ \
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000484 miscutils/ \
485 modutils/ \
486 networking/ \
487 networking/libiproute/ \
488 networking/udhcp/ \
Denis Vlasenko68444b92008-02-22 22:24:48 +0000489 printutils/ \
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000490 procps/ \
491 runit/ \
Denis Vlasenkod46d3c22007-02-06 19:28:50 +0000492 selinux/ \
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000493 shell/ \
494 sysklogd/ \
495 util-linux/ \
Denis Vlasenkode7684a2008-02-18 21:08:49 +0000496 util-linux/volume_id/ \
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000497
498endif # KBUILD_EXTMOD
499
500ifeq ($(dot-config),1)
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000501# In this section, we need .config
Eric Andersen7daa0762004-10-08 07:46:08 +0000502
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000503# Read in dependencies to all Kconfig* files, make sure to run
504# oldconfig if changes are detected.
505-include .kconfig.d
Bernhard Reutner-Fischer5c071bc2005-10-05 07:40:46 +0000506
Denis Vlasenko8bf7bb82006-10-05 17:42:55 +0000507-include .config
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000508
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000509# If .config needs to be updated, it will be done via the dependency
510# that autoconf has on .config.
511# To avoid any implicit rule to kick in, define an empty command
512.config .kconfig.d: ;
Bernhard Reutner-Fischer5d261262006-03-01 22:54:48 +0000513
Thomas Petazzonie9a25ac2017-07-14 23:08:38 +0200514-include $(srctree)/arch/$(ARCH)/Makefile
515
Denis Vlasenkob54b2082006-10-27 09:05:40 +0000516# Now we can define CFLAGS etc according to .config
517include $(srctree)/Makefile.flags
518
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000519# If .config is newer than include/autoconf.h, someone tinkered
520# with it and forgot to run make oldconfig.
521# If kconfig.d is missing then we are probarly in a cleaned tree so
522# we execute the config step to be sure to catch updated Kconfig files
Denys Vlasenko8d444492010-06-25 13:56:28 +0200523include/autoconf.h: .kconfig.d .config $(wildcard $(srctree)/*/*.c) $(wildcard $(srctree)/*/*/*.c) | gen_build_files
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000524 $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000525
Denys Vlasenko5c296de2010-07-03 14:28:35 +0200526include/usage.h: gen_build_files
527
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000528else
529# Dummy target needed, because used as prerequisite
530include/autoconf.h: ;
Bernhard Reutner-Fischer08c5a172006-01-25 15:58:04 +0000531endif
532
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000533# The all: target is the default when no target is given on the
534# command line.
535# This allow a user to issue only 'make' to build a kernel including modules
Mike Frysinger757ed502007-03-17 06:26:51 +0000536# Defaults busybox but it is usually overridden in the arch makefile
Bernhard Reutner-Fischera28a05b2008-08-21 21:15:28 +0000537all: busybox doc
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000538
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000539# arch Makefile may override CC so keep this after arch Makefile is included
540#bbox# NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
541CHECKFLAGS += $(NOSTDINC_FLAGS)
542
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000543# Default kernel image to build when no specific target is given.
544# KBUILD_IMAGE may be overruled on the commandline or
545# set in the environment
546# Also any assignments in arch/$(ARCH)/Makefile take precedence over
547# this default value
548export KBUILD_IMAGE ?= busybox
549
550#
551# INSTALL_PATH specifies where to place the updated kernel and system map
552# images. Default is /boot, but you can set it to other values
553export INSTALL_PATH ?= /boot
554
555#
556# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
557# relocations required by build roots. This is not defined in the
Maninder Singh97c64912015-05-25 13:46:36 +0200558# makefile but the argument can be passed to make if needed.
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000559#
560
561MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
562export MODLIB
563
564
565ifeq ($(KBUILD_EXTMOD),)
566busybox-dirs := $(patsubst %/,%,$(filter %/, $(core-y) $(core-m) $(libs-y) $(libs-m)))
567
568busybox-alldirs := $(sort $(busybox-dirs) $(patsubst %/,%,$(filter %/, \
569 $(core-n) $(core-) $(libs-n) $(libs-) \
570 )))
571
572core-y := $(patsubst %/, %/built-in.o, $(core-y))
573libs-y1 := $(patsubst %/, %/lib.a, $(libs-y))
574libs-y2 := $(patsubst %/, %/built-in.o, $(libs-y))
575libs-y := $(libs-y1) $(libs-y2)
576
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000577# Build busybox
578# ---------------------------------------------------------------------------
579# busybox is build from the objects selected by $(busybox-init) and
580# $(busybox-main). Most are built-in.o files from top-level directories
581# in the kernel tree, others are specified in arch/$(ARCH)Makefile.
582# Ordering when linking is important, and $(busybox-init) must be first.
583#
584# busybox
585# ^
586# |
587# +-< $(busybox-init)
588# | +--< init/version.o + more
589# |
590# +--< $(busybox-main)
591# | +--< driver/built-in.o mm/built-in.o + more
592# |
593# +-< kallsyms.o (see description in CONFIG_KALLSYMS section)
594#
595# busybox version (uname -v) cannot be updated during normal
596# descending-into-subdirs phase since we do not yet know if we need to
597# update busybox.
598# Therefore this step is delayed until just before final link of busybox -
599# except in the kallsyms case where it is done just before adding the
600# symbols to the kernel.
601#
602# System.map is generated to document addresses of all kernel symbols
603
604busybox-all := $(core-y) $(libs-y)
605
606# Rule to link busybox - also used during CONFIG_KALLSYMS
607# May be overridden by arch/$(ARCH)/Makefile
608quiet_cmd_busybox__ ?= LINK $@
Denis Vlasenko32404742007-10-07 17:05:22 +0000609 cmd_busybox__ ?= $(srctree)/scripts/trylink \
610 "$@" \
611 "$(CC)" \
Denis Vlasenko1da86d22008-06-04 11:28:24 +0000612 "$(CFLAGS) $(CFLAGS_busybox)" \
Denis Vlasenko32404742007-10-07 17:05:22 +0000613 "$(LDFLAGS) $(EXTRA_LDFLAGS)" \
614 "$(core-y)" \
615 "$(libs-y)" \
Denys Vlasenkoe6a2f4c2016-04-21 16:26:30 +0200616 "$(LDLIBS)" \
Denys Vlasenko1f9ed022021-02-23 23:09:49 +0100617 "$(CONFIG_EXTRA_LDLIBS)" \
Denys Vlasenkod7b502c2016-04-21 23:52:35 +0200618 && $(srctree)/scripts/generate_BUFSIZ.sh --post include/common_bufsiz.h
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000619
620# Generate System.map
Denis Vlasenkof7996f32007-01-11 17:20:00 +0000621quiet_cmd_sysmap = SYSMAP
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000622 cmd_sysmap = $(CONFIG_SHELL) $(srctree)/scripts/mksysmap
623
624# Link of busybox
625# If CONFIG_KALLSYMS is set .version is already updated
626# Generate System.map and verify that the content is consistent
627# Use + in front of the busybox_version rule to silent warning with make -j2
628# First command is ':' to allow us to use + in front of the rule
629define rule_busybox__
630 :
631 $(call cmd,busybox__)
632 $(Q)echo 'cmd_$@ := $(cmd_busybox__)' > $(@D)/.$(@F).cmd
633endef
634
635
636ifdef CONFIG_KALLSYMS
637# Generate section listing all symbols and add it into busybox $(kallsyms.o)
638# It's a three stage process:
639# o .tmp_busybox1 has all symbols and sections, but __kallsyms is
640# empty
641# Running kallsyms on that gives us .tmp_kallsyms1.o with
642# the right size - busybox version (uname -v) is updated during this step
643# o .tmp_busybox2 now has a __kallsyms section of the right size,
644# but due to the added section, some addresses have shifted.
645# From here, we generate a correct .tmp_kallsyms2.o
646# o The correct .tmp_kallsyms2.o is linked into the final busybox.
647# o Verify that the System.map from busybox matches the map from
648# .tmp_busybox2, just in case we did not generate kallsyms correctly.
649# o If CONFIG_KALLSYMS_EXTRA_PASS is set, do an extra pass using
650# .tmp_busybox3 and .tmp_kallsyms3.o. This is only meant as a
651# temporary bypass to allow the kernel to be built while the
652# maintainers work out what went wrong with kallsyms.
653
654ifdef CONFIG_KALLSYMS_EXTRA_PASS
655last_kallsyms := 3
656else
657last_kallsyms := 2
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000658endif
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000659
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000660kallsyms.o := .tmp_kallsyms$(last_kallsyms).o
Bernhard Reutner-Fischer7ca61b62006-01-15 14:04:57 +0000661
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000662define verify_kallsyms
663 $(Q)$(if $($(quiet)cmd_sysmap), \
664 echo ' $($(quiet)cmd_sysmap) .tmp_System.map' &&) \
665 $(cmd_sysmap) .tmp_busybox$(last_kallsyms) .tmp_System.map
666 $(Q)cmp -s System.map .tmp_System.map || \
667 (echo Inconsistent kallsyms data; \
668 echo Try setting CONFIG_KALLSYMS_EXTRA_PASS; \
669 rm .tmp_kallsyms* ; /bin/false )
670endef
671
672# Update busybox version before link
673# Use + in front of this rule to silent warning about make -j1
674# First command is ':' to allow us to use + in front of this rule
675cmd_ksym_ld = $(cmd_busybox__)
676define rule_ksym_ld
Denis Vlasenkof7996f32007-01-11 17:20:00 +0000677 :
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000678 +$(call cmd,busybox_version)
679 $(call cmd,busybox__)
680 $(Q)echo 'cmd_$@ := $(cmd_busybox__)' > $(@D)/.$(@F).cmd
681endef
682
683# Generate .S file with all kernel symbols
684quiet_cmd_kallsyms = KSYM $@
685 cmd_kallsyms = $(NM) -n $< | $(KALLSYMS) \
686 $(if $(CONFIG_KALLSYMS_ALL),--all-symbols) > $@
687
688.tmp_kallsyms1.o .tmp_kallsyms2.o .tmp_kallsyms3.o: %.o: %.S scripts FORCE
689 $(call if_changed_dep,as_o_S)
690
691.tmp_kallsyms%.S: .tmp_busybox% $(KALLSYMS)
692 $(call cmd,kallsyms)
693
694# .tmp_busybox1 must be complete except kallsyms, so update busybox version
695.tmp_busybox1: $(busybox-lds) $(busybox-all) FORCE
696 $(call if_changed_rule,ksym_ld)
697
698.tmp_busybox2: $(busybox-lds) $(busybox-all) .tmp_kallsyms1.o FORCE
699 $(call if_changed,busybox__)
700
701.tmp_busybox3: $(busybox-lds) $(busybox-all) .tmp_kallsyms2.o FORCE
702 $(call if_changed,busybox__)
703
704# Needs to visit scripts/ before $(KALLSYMS) can be used.
705$(KALLSYMS): scripts ;
706
707# Generate some data for debugging strange kallsyms problems
708debug_kallsyms: .tmp_map$(last_kallsyms)
709
710.tmp_map%: .tmp_busybox% FORCE
711 ($(OBJDUMP) -h $< | $(AWK) '/^ +[0-9]/{print $$4 " 0 " $$2}'; $(NM) $<) | sort > $@
712
713.tmp_map3: .tmp_map2
714
715.tmp_map2: .tmp_map1
716
717endif # ifdef CONFIG_KALLSYMS
718
719# busybox image - including updated kernel symbols
720busybox_unstripped: $(busybox-all) FORCE
721 $(call if_changed_rule,busybox__)
722 $(Q)rm -f .old_version
Bernhard Reutner-Fischercfc5d862006-03-02 09:44:32 +0000723
724busybox: busybox_unstripped
Mike Frysinger5b5bcf22007-06-19 15:58:02 +0000725ifeq ($(SKIP_STRIP),y)
726 $(Q)cp $< $@
727else
Denis Vlasenko4e33e072006-10-16 18:24:57 +0000728 $(Q)$(STRIP) -s --remove-section=.note --remove-section=.comment \
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000729 busybox_unstripped -o $@
Denis Vlasenkocc3f20b2008-06-23 22:31:52 +0000730# strip is confused by PIE executable and does not set exec bits
731 $(Q)chmod a+x $@
Mike Frysinger5b5bcf22007-06-19 15:58:02 +0000732endif
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000733
Denis Vlasenkof7996f32007-01-11 17:20:00 +0000734# The actual objects are generated when descending,
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000735# make sure no implicit rule kicks in
736$(sort $(busybox-all)): $(busybox-dirs) ;
Mike Frysinger586ea612006-04-21 01:18:07 +0000737
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000738# Handle descending into subdirectories listed in $(busybox-dirs)
739# Preset locale variables to speed up the build process. Limit locale
740# tweaks to this spot to avoid wrong language settings when running
741# make menuconfig etc.
742# Error messages still appears in the original language
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000743
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000744PHONY += $(busybox-dirs)
745$(busybox-dirs): prepare scripts
746 $(Q)$(MAKE) $(build)=$@
747
748# Build the kernel release string
749# The KERNELRELEASE is stored in a file named .kernelrelease
750# to be used when executing for example make install or make modules_install
751#
752# Take the contents of any files called localversion* and the config
753# variable CONFIG_LOCALVERSION and append them to KERNELRELEASE.
754# LOCALVERSION from the command line override all of this
755
756nullstring :=
757space := $(nullstring) # end of line
758
759___localver = $(objtree)/localversion* $(srctree)/localversion*
760__localver = $(sort $(wildcard $(___localver)))
761# skip backup files (containing '~')
762_localver = $(foreach f, $(__localver), $(if $(findstring ~, $(f)),,$(f)))
763
764localver = $(subst $(space),, \
765 $(shell cat /dev/null $(_localver)) \
766 $(patsubst "%",%,$(CONFIG_LOCALVERSION)))
Denis Vlasenkof7996f32007-01-11 17:20:00 +0000767
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000768# If CONFIG_LOCALVERSION_AUTO is set scripts/setlocalversion is called
769# and if the SCM is know a tag from the SCM is appended.
770# The appended tag is determinded by the SCM used.
771#
772# Currently, only git is supported.
773# Other SCMs can edit scripts/setlocalversion and add the appropriate
774# checks as needed.
Mike Frysinger534b8d02008-02-07 22:44:27 +0000775ifdef _BB_DISABLED_CONFIG_LOCALVERSION_AUTO
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000776 _localver-auto = $(shell $(CONFIG_SHELL) \
777 $(srctree)/scripts/setlocalversion $(srctree))
778 localver-auto = $(LOCALVERSION)$(_localver-auto)
Eric Andersen13879102004-08-26 23:13:00 +0000779endif
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000780
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000781localver-full = $(localver)$(localver-auto)
Eric Andersen1f30a412002-04-13 13:39:48 +0000782
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000783# Store (new) KERNELRELASE string in .kernelrelease
784kernelrelease = $(KERNELVERSION)$(localver-full)
785.kernelrelease: FORCE
786 $(Q)rm -f $@
787 $(Q)echo $(kernelrelease) > $@
Eric Andersenbdfd0d72001-10-24 05:00:29 +0000788
Rob Landleyd9872aa2006-05-27 21:24:16 +0000789
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000790# Things we need to do before we recursively start building the kernel
791# or the modules are listed in "prepare".
792# A multi level approach is used. prepareN is processed before prepareN-1.
793# archprepare is used in arch Makefiles and when processed asm symlink,
794# version.h and scripts_basic is processed / created.
Rob Landleyd9872aa2006-05-27 21:24:16 +0000795
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000796# Listed in dependency order
797PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
Rob Landley16890752005-09-02 00:41:53 +0000798
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000799# prepare-all is deprecated, use prepare as valid replacement
800PHONY += prepare-all
Rob Landleyd9872aa2006-05-27 21:24:16 +0000801
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000802# prepare3 is used to check if we are building in a separate output directory,
803# and if so do:
804# 1) Check that make has not been executed in the kernel src $(srctree)
805# 2) Create the include2 directory, used for the second asm symlink
806prepare3: .kernelrelease
807ifneq ($(KBUILD_SRC),)
Denis Vlasenkoff65cd42007-08-12 20:59:07 +0000808 @echo ' Using $(srctree) as source for busybox'
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000809 $(Q)if [ -f $(srctree)/.config ]; then \
810 echo " $(srctree) is not clean, please run 'make mrproper'";\
811 echo " in the '$(srctree)' directory.";\
812 /bin/false; \
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000813 fi;
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000814 $(Q)if [ ! -d include2 ]; then mkdir -p include2; fi;
815 $(Q)ln -fsn $(srctree)/include/asm-$(ARCH) include2/asm
816endif
Eric Andersen85208e22002-04-12 12:05:57 +0000817
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000818# prepare2 creates a makefile if using a separate output directory
819prepare2: prepare3 outputmakefile
Eric Andersencc8ed391999-10-05 16:24:54 +0000820
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000821prepare1: prepare2 include/config/MARKER
822ifneq ($(KBUILD_MODULES),)
823 $(Q)mkdir -p $(MODVERDIR)
824 $(Q)rm -f $(MODVERDIR)/*
825endif
Eric Andersencc8ed391999-10-05 16:24:54 +0000826
Denys Vlasenkob24c1132009-11-24 22:23:21 +0100827archprepare: prepare1 scripts_basic applets_dir
Mark Whitleydd23b8b2000-07-10 23:00:47 +0000828
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000829prepare0: archprepare FORCE
830 $(Q)$(MAKE) $(build)=.
Matt Kraai4e05da82001-11-19 19:47:56 +0000831
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000832# All the preparing..
833prepare prepare-all: prepare0
Bernhard Reutner-Fischerfa61ca72006-06-16 17:19:39 +0000834
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000835# Leave this as default for preprocessing busybox.lds.S, which is now
836# done in arch/$(ARCH)/kernel/Makefile
837
838export CPPFLAGS_busybox.lds += -P -C -U$(ARCH)
839
840# FIXME: The asm symlink changes when $(ARCH) changes. That's
841# hard to detect, but I suppose "make mrproper" is a good idea
842# before switching between archs anyway.
843
844#bbox# include/asm:
845#bbox# @echo ' SYMLINK $@ -> include/asm-$(ARCH)'
846#bbox# $(Q)if [ ! -d include ]; then mkdir -p include; fi;
847#bbox# @ln -fsn asm-$(ARCH) $@
848
849# Split autoconf.h into include/linux/config/*
Mike Frysingerd514ba22006-12-31 11:46:19 +0000850quiet_cmd_gen_bbconfigopts = GEN include/bbconfigopts.h
Denys Vlasenko9ce07e72010-08-29 14:36:11 +0200851 cmd_gen_bbconfigopts = $(srctree)/scripts/mkconfigs include/bbconfigopts.h include/bbconfigopts_bz2.h
Denys Vlasenkoe6a2f4c2016-04-21 16:26:30 +0200852quiet_cmd_gen_common_bufsiz = GEN include/common_bufsiz.h
853 cmd_gen_common_bufsiz = $(srctree)/scripts/generate_BUFSIZ.sh include/common_bufsiz.h
Mike Frysingerd514ba22006-12-31 11:46:19 +0000854quiet_cmd_split_autoconf = SPLIT include/autoconf.h -> include/config/*
855 cmd_split_autoconf = scripts/basic/split-include include/autoconf.h include/config
Denys Vlasenko4f2ef4a2018-11-01 09:53:25 +0100856quiet_cmd_gen_embedded_scripts = GEN include/embedded_scripts.h
Ron Yorston37788982018-11-17 17:48:14 +0000857 cmd_gen_embedded_scripts = $(srctree)/scripts/embedded_scripts include/embedded_scripts.h $(srctree)/embed $(srctree)/applets_sh
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000858#bbox# piggybacked generation of few .h files
Ron Yorston7b42f8f2018-11-21 10:11:01 +0000859include/config/MARKER: scripts/basic/split-include include/autoconf.h $(wildcard $(srctree)/embed/*) $(wildcard $(srctree)/applets_sh/*) $(srctree)/scripts/embedded_scripts
Mike Frysingerd514ba22006-12-31 11:46:19 +0000860 $(call cmd,split_autoconf)
861 $(call cmd,gen_bbconfigopts)
Denys Vlasenkoe6a2f4c2016-04-21 16:26:30 +0200862 $(call cmd,gen_common_bufsiz)
Denys Vlasenko4f2ef4a2018-11-01 09:53:25 +0100863 $(call cmd,gen_embedded_scripts)
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000864 @touch $@
865
866# Generate some files
867# ---------------------------------------------------------------------------
868
869# KERNELRELEASE can change from a few different places, meaning version.h
870# needs to be updated, so this check is forced on all builds
871
872uts_len := 64
873
874define filechk_version.h
875 if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \
876 echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \
877 exit 1; \
878 fi; \
879 (echo \#define UTS_RELEASE \"$(KERNELRELEASE)\"; \
880 echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)`; \
881 echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))'; \
882 )
883endef
884
885# ---------------------------------------------------------------------------
886
887PHONY += depend dep
888depend dep:
889 @echo '*** Warning: make $@ is unnecessary now.'
890
891# ---------------------------------------------------------------------------
892# Modules
893
Mike Frysinger61160dd2008-01-27 09:41:24 +0000894ifdef _BB_DISABLED_CONFIG_MODULES
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000895
896# By default, build modules as well
897
898all: modules
899
900# Build modules
901
902PHONY += modules
903modules: $(busybox-dirs) $(if $(KBUILD_BUILTIN),busybox)
904 @echo ' Building modules, stage 2.';
905 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
Bernhard Reutner-Fischerfa61ca72006-06-16 17:19:39 +0000906
Bernhard Reutner-Fischer07a79e72006-03-09 09:03:37 +0000907
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000908# Target to prepare building external modules
909PHONY += modules_prepare
910modules_prepare: prepare scripts
Bernhard Reutner-Fischerdf100942006-03-13 19:04:00 +0000911
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000912# Target to install modules
913PHONY += modules_install
914modules_install: _modinst_ _modinst_post
915
916PHONY += _modinst_
917_modinst_:
918 @if [ -z "`$(DEPMOD) -V 2>/dev/null | grep module-init-tools`" ]; then \
919 echo "Warning: you may need to install module-init-tools"; \
920 echo "See http://www.codemonkey.org.uk/docs/post-halloween-2.6.txt";\
921 sleep 1; \
922 fi
923 @rm -rf $(MODLIB)/kernel
924 @rm -f $(MODLIB)/source
925 @mkdir -p $(MODLIB)/kernel
926 @ln -s $(srctree) $(MODLIB)/source
927 @if [ ! $(objtree) -ef $(MODLIB)/build ]; then \
928 rm -f $(MODLIB)/build ; \
929 ln -s $(objtree) $(MODLIB)/build ; \
930 fi
931 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst
932
933# If System.map exists, run depmod. This deliberately does not have a
934# dependency on System.map since that would run the dependency tree on
935# busybox. This depmod is only for convenience to give the initial
936# boot a modules.dep even before / is mounted read-write. However the
937# boot script depmod is the master version.
938ifeq "$(strip $(INSTALL_MOD_PATH))" ""
939depmod_opts :=
940else
941depmod_opts := -b $(INSTALL_MOD_PATH) -r
942endif
943PHONY += _modinst_post
944_modinst_post: _modinst_
945 if [ -r System.map -a -x $(DEPMOD) ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi
946
947else # CONFIG_MODULES
948
949# Modules not configured
950# ---------------------------------------------------------------------------
951
952modules modules_install: FORCE
953 @echo
Denis Vlasenkoeb98be02006-11-30 22:40:32 +0000954 @echo "The present busybox configuration has modules disabled."
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000955 @echo "Type 'make config' and enable loadable module support."
956 @echo "Then build a kernel with module support enabled."
957 @echo
958 @exit 1
959
960endif # CONFIG_MODULES
961
962###
963# Cleaning is done on three levels.
964# make clean Delete most generated files
965# Leave enough to build external modules
966# make mrproper Delete the current configuration, and all generated files
967# make distclean Remove editor backup files, patch leftover files and the like
968
969# Directories & files removed with 'make clean'
Denis Vlasenko2b68c8f2008-07-20 18:37:54 +0000970CLEAN_DIRS += $(MODVERDIR) _install 0_lib
971CLEAN_FILES += busybox busybox_unstripped* busybox.links \
972 System.map .kernelrelease \
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000973 .tmp_kallsyms* .tmp_version .tmp_busybox* .tmp_System.map
974
975# Directories & files removed with 'make mrproper'
976MRPROPER_DIRS += include/config include2
977MRPROPER_FILES += .config .config.old include/asm .version .old_version \
Denys Vlasenkod488f5e2011-06-07 10:01:58 +0200978 include/NUM_APPLETS.h \
Denys Vlasenkoe6a2f4c2016-04-21 16:26:30 +0200979 include/common_bufsiz.h \
Denis Vlasenko8bf7bb82006-10-05 17:42:55 +0000980 include/autoconf.h \
981 include/bbconfigopts.h \
Denys Vlasenkod488f5e2011-06-07 10:01:58 +0200982 include/bbconfigopts_bz2.h \
Denys Vlasenko4f2ef4a2018-11-01 09:53:25 +0100983 include/embedded_scripts.h \
Denis Vlasenko8bf7bb82006-10-05 17:42:55 +0000984 include/usage_compressed.h \
Denis Vlasenko1aa7e472007-11-28 06:49:03 +0000985 include/applet_tables.h \
Denys Vlasenkod488f5e2011-06-07 10:01:58 +0200986 include/applets.h \
987 include/usage.h \
Denis Vlasenko1aa7e472007-11-28 06:49:03 +0000988 applets/usage \
Denis Vlasenko2b68c8f2008-07-20 18:37:54 +0000989 .kernelrelease Module.symvers tags TAGS cscope* \
990 busybox_old
Denis Vlasenko7d219aa2006-10-05 10:17:08 +0000991
992# clean - Delete most, but leave enough to build external modules
993#
994clean: rm-dirs := $(CLEAN_DIRS)
995clean: rm-files := $(CLEAN_FILES)
996clean-dirs := $(addprefix _clean_,$(srctree) $(busybox-alldirs))
997
998PHONY += $(clean-dirs) clean archclean
999$(clean-dirs):
1000 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
1001
1002clean: archclean $(clean-dirs)
1003 $(call cmd,rmdirs)
1004 $(call cmd,rmfiles)
1005 @find . $(RCS_FIND_IGNORE) \
Denis Vlasenko52ec4b92008-07-12 23:02:43 +00001006 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
Denis Vlasenko7d219aa2006-10-05 10:17:08 +00001007 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \
1008 -type f -print | xargs rm -f
1009
Bernhard Reutner-Fischer8eeaa742008-08-21 13:47:20 +00001010PHONY += doc-clean
1011doc-clean: rm-files := docs/busybox.pod \
Denys Vlasenko17fc33d2010-10-24 03:46:16 +02001012 docs/BusyBox.html docs/busybox.1 docs/BusyBox.txt
Bernhard Reutner-Fischer8eeaa742008-08-21 13:47:20 +00001013doc-clean:
1014 $(call cmd,rmfiles)
1015
Denis Vlasenko7d219aa2006-10-05 10:17:08 +00001016# mrproper - Delete all generated files, including .config
1017#
1018mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS))
1019mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
Denis Vlasenko8bf7bb82006-10-05 17:42:55 +00001020mrproper-dirs := $(addprefix _mrproper_,scripts)
Denis Vlasenko7d219aa2006-10-05 10:17:08 +00001021
1022PHONY += $(mrproper-dirs) mrproper archmrproper
1023$(mrproper-dirs):
1024 $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
1025
1026mrproper: clean archmrproper $(mrproper-dirs)
1027 $(call cmd,rmdirs)
1028 $(call cmd,rmfiles)
Chris Rees12caabf2010-11-30 09:41:39 +01001029 @find . -name Config.src | sed 's/.src$$/.in/' | xargs -r rm -f
1030 @find . -name Kbuild.src | sed 's/.src$$//' | xargs -r rm -f
Denis Vlasenko7d219aa2006-10-05 10:17:08 +00001031
1032# distclean
1033#
1034PHONY += distclean
1035
1036distclean: mrproper
1037 @find $(srctree) $(RCS_FIND_IGNORE) \
Denis Vlasenko52ec4b92008-07-12 23:02:43 +00001038 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
Denis Vlasenko7d219aa2006-10-05 10:17:08 +00001039 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
Denis Vlasenko52ec4b92008-07-12 23:02:43 +00001040 -o -name '.*.rej' -o -name '*.tmp' -o -size 0 \
Denis Vlasenko7d219aa2006-10-05 10:17:08 +00001041 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
1042 -type f -print | xargs rm -f
1043
1044
1045# Packaging of the kernel to various formats
1046# ---------------------------------------------------------------------------
1047# rpm target kept for backward compatibility
1048package-dir := $(srctree)/scripts/package
1049
1050%pkg: FORCE
1051 $(Q)$(MAKE) $(build)=$(package-dir) $@
1052rpm: FORCE
1053 $(Q)$(MAKE) $(build)=$(package-dir) $@
1054
1055
1056# Brief documentation of the typical targets used
1057# ---------------------------------------------------------------------------
1058
Daniel Fandrich126f2b22011-07-08 07:59:16 +02001059boards := $(wildcard $(srctree)/configs/*_defconfig)
Denis Vlasenko7d219aa2006-10-05 10:17:08 +00001060boards := $(notdir $(boards))
1061
Denis Vlasenko14aa9f72006-10-31 23:03:09 +00001062-include $(srctree)/Makefile.help
Denis Vlasenko7d219aa2006-10-05 10:17:08 +00001063
1064# Documentation targets
1065# ---------------------------------------------------------------------------
1066%docs: scripts_basic FORCE
1067 $(Q)$(MAKE) $(build)=Documentation/DocBook $@
1068
1069else # KBUILD_EXTMOD
1070
1071###
1072# External module support.
1073# When building external modules the kernel used as basis is considered
1074# read-only, and no consistency checks are made and the make
1075# system is not used on the basis kernel. If updates are required
1076# in the basis kernel ordinary make commands (without M=...) must
1077# be used.
1078#
1079# The following are the only valid targets when building external
1080# modules.
1081# make M=dir clean Delete all automatically generated files
1082# make M=dir modules Make all modules in specified dir
1083# make M=dir Same as 'make M=dir modules'
1084# make M=dir modules_install
1085# Install the modules build in the module directory
1086# Assumes install directory is already created
1087
1088# We are always building modules
1089KBUILD_MODULES := 1
1090PHONY += crmodverdir
1091crmodverdir:
1092 $(Q)mkdir -p $(MODVERDIR)
1093 $(Q)rm -f $(MODVERDIR)/*
1094
1095PHONY += $(objtree)/Module.symvers
1096$(objtree)/Module.symvers:
1097 @test -e $(objtree)/Module.symvers || ( \
1098 echo; \
1099 echo " WARNING: Symbol version dump $(objtree)/Module.symvers"; \
1100 echo " is missing; modules will have no dependencies and modversions."; \
1101 echo )
1102
1103module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD))
1104PHONY += $(module-dirs) modules
1105$(module-dirs): crmodverdir $(objtree)/Module.symvers
1106 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
1107
1108modules: $(module-dirs)
1109 @echo ' Building modules, stage 2.';
1110 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
1111
1112PHONY += modules_install
1113modules_install: _emodinst_ _emodinst_post
1114
1115install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra)
1116PHONY += _emodinst_
1117_emodinst_:
1118 $(Q)mkdir -p $(MODLIB)/$(install-dir)
1119 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst
1120
1121# Run depmod only is we have System.map and depmod is executable
1122quiet_cmd_depmod = DEPMOD $(KERNELRELEASE)
1123 cmd_depmod = if [ -r System.map -a -x $(DEPMOD) ]; then \
1124 $(DEPMOD) -ae -F System.map \
1125 $(if $(strip $(INSTALL_MOD_PATH)), \
1126 -b $(INSTALL_MOD_PATH) -r) \
1127 $(KERNELRELEASE); \
1128 fi
1129
1130PHONY += _emodinst_post
1131_emodinst_post: _emodinst_
1132 $(call cmd,depmod)
1133
1134clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD))
1135
1136PHONY += $(clean-dirs) clean
1137$(clean-dirs):
1138 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
1139
1140clean: rm-dirs := $(MODVERDIR)
1141clean: $(clean-dirs)
1142 $(call cmd,rmdirs)
1143 @find $(KBUILD_EXTMOD) $(RCS_FIND_IGNORE) \
Denis Vlasenko52ec4b92008-07-12 23:02:43 +00001144 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
Denis Vlasenko7d219aa2006-10-05 10:17:08 +00001145 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \
1146 -type f -print | xargs rm -f
1147
Denis Vlasenko7d219aa2006-10-05 10:17:08 +00001148# Dummies...
1149PHONY += prepare scripts
1150prepare: ;
1151scripts: ;
1152endif # KBUILD_EXTMOD
1153
1154# Generate tags for editors
1155# ---------------------------------------------------------------------------
1156
1157#We want __srctree to totally vanish out when KBUILD_OUTPUT is not set
1158#(which is the most common case IMHO) to avoid unneeded clutter in the big tags file.
1159#Adding $(srctree) adds about 20M on i386 to the size of the output file!
1160
1161ifeq ($(src),$(obj))
1162__srctree =
1163else
1164__srctree = $(srctree)/
1165endif
1166
1167ifeq ($(ALLSOURCE_ARCHS),)
1168ifeq ($(ARCH),um)
1169ALLINCLUDE_ARCHS := $(ARCH) $(SUBARCH)
1170else
1171ALLINCLUDE_ARCHS := $(ARCH)
1172endif
1173else
1174#Allow user to specify only ALLSOURCE_PATHS on the command line, keeping existing behaviour.
1175ALLINCLUDE_ARCHS := $(ALLSOURCE_ARCHS)
1176endif
1177
1178ALLSOURCE_ARCHS := $(ARCH)
1179
1180define all-sources
Bartosz Golaszewski6c19d352014-12-17 17:58:23 +01001181 ( find -regex '.*\.[ch]$$' )
Denis Vlasenko7d219aa2006-10-05 10:17:08 +00001182endef
1183
1184quiet_cmd_cscope-file = FILELST cscope.files
1185 cmd_cscope-file = (echo \-k; echo \-q; $(all-sources)) > cscope.files
1186
1187quiet_cmd_cscope = MAKE cscope.out
1188 cmd_cscope = cscope -b
1189
1190cscope: FORCE
1191 $(call cmd,cscope-file)
1192 $(call cmd,cscope)
1193
1194quiet_cmd_TAGS = MAKE $@
1195define cmd_TAGS
1196 rm -f $@; \
1197 ETAGSF=`etags --version | grep -i exuberant >/dev/null && \
1198 echo "-I __initdata,__exitdata,__acquires,__releases \
1199 -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \
1200 --extra=+f --c-kinds=+px"`; \
1201 $(all-sources) | xargs etags $$ETAGSF -a
1202endef
1203
1204TAGS: FORCE
1205 $(call cmd,TAGS)
1206
1207
1208quiet_cmd_tags = MAKE $@
1209define cmd_tags
1210 rm -f $@; \
1211 CTAGSF=`ctags --version | grep -i exuberant >/dev/null && \
1212 echo "-I __initdata,__exitdata,__acquires,__releases \
1213 -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \
1214 --extra=+f --c-kinds=+px"`; \
1215 $(all-sources) | xargs ctags $$CTAGSF -a
1216endef
1217
1218tags: FORCE
1219 $(call cmd,tags)
1220
1221
1222# Scripts to check various things for consistency
1223# ---------------------------------------------------------------------------
1224
1225includecheck:
1226 find * $(RCS_FIND_IGNORE) \
1227 -name '*.[hcS]' -type f -print | sort \
1228 | xargs $(PERL) -w scripts/checkincludes.pl
1229
1230versioncheck:
1231 find * $(RCS_FIND_IGNORE) \
1232 -name '*.[hcS]' -type f -print | sort \
1233 | xargs $(PERL) -w scripts/checkversion.pl
1234
1235namespacecheck:
1236 $(PERL) $(srctree)/scripts/namespace.pl
1237
1238endif #ifeq ($(config-targets),1)
1239endif #ifeq ($(mixed-targets),1)
1240
1241PHONY += checkstack
1242checkstack:
1243 $(OBJDUMP) -d busybox $$(find . -name '*.ko') | \
1244 $(PERL) $(src)/scripts/checkstack.pl $(ARCH)
1245
1246kernelrelease:
1247 $(if $(wildcard .kernelrelease), $(Q)echo $(KERNELRELEASE), \
1248 $(error kernelrelease not valid - run 'make *config' to update it))
1249kernelversion:
1250 @echo $(KERNELVERSION)
1251
1252# Single targets
1253# ---------------------------------------------------------------------------
1254# Single targets are compatible with:
1255# - build whith mixed source and output
1256# - build with separate output dir 'make O=...'
1257# - external modules
1258#
1259# target-dir => where to store outputfile
1260# build-dir => directory in kernel source tree to use
1261
1262ifeq ($(KBUILD_EXTMOD),)
1263 build-dir = $(patsubst %/,%,$(dir $@))
1264 target-dir = $(dir $@)
1265else
1266 zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@)))
1267 build-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash))
1268 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
1269endif
1270
1271%.s: %.c prepare scripts FORCE
1272 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1273%.i: %.c prepare scripts FORCE
1274 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1275%.o: %.c prepare scripts FORCE
1276 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1277%.lst: %.c prepare scripts FORCE
1278 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1279%.s: %.S prepare scripts FORCE
1280 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1281%.o: %.S prepare scripts FORCE
1282 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1283
1284# Modules
Denys Vlasenkoadbe3b52010-08-22 09:28:46 +02001285%/: prepare scripts FORCE
Denis Vlasenko7d219aa2006-10-05 10:17:08 +00001286 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
1287 $(build)=$(build-dir)
Denys Vlasenkoadbe3b52010-08-22 09:28:46 +02001288/: prepare scripts FORCE
1289 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
1290 $(build)=$(build-dir)
1291
Denis Vlasenko7d219aa2006-10-05 10:17:08 +00001292%.ko: prepare scripts FORCE
1293 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
1294 $(build)=$(build-dir) $(@:.ko=.o)
1295 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
1296
Denis Vlasenkof7996f32007-01-11 17:20:00 +00001297# FIXME Should go into a make.lib or something
Denis Vlasenko7d219aa2006-10-05 10:17:08 +00001298# ===========================================================================
1299
1300quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-dirs)))
1301 cmd_rmdirs = rm -rf $(rm-dirs)
1302
1303quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)))
1304 cmd_rmfiles = rm -f $(rm-files)
1305
Denis Vlasenko7d219aa2006-10-05 10:17:08 +00001306# read all saved command lines
1307
1308targets := $(wildcard $(sort $(targets)))
1309cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
1310
1311ifneq ($(cmd_files),)
1312 $(cmd_files): ; # Do not try to update included dependency files
1313 include $(cmd_files)
1314endif
1315
1316# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir
1317# Usage:
1318# $(Q)$(MAKE) $(clean)=dir
1319clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
1320
1321endif # skip-makefile
1322
1323PHONY += FORCE
1324FORCE:
1325
Denis Vlasenko14aa9f72006-10-31 23:03:09 +00001326-include $(srctree)/Makefile.custom
Denis Vlasenko7d219aa2006-10-05 10:17:08 +00001327
1328# Declare the contents of the .PHONY variable as phony. We keep that
1329# information in a variable se we can use it in if_changed and friends.
1330.PHONY: $(PHONY)