summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-07-12 19:03:16 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-07-12 19:03:16 -0400
commit39ceda5ce1b002e30563fcb8ad1bb5ac8e4d59ee (patch)
tree18751f981a3a540379b9f4b01292e1b4f401aa38 /Makefile
parent5f26f1143678d0fed8115afdcc0de99ee7cc9675 (diff)
parentd4a74bbfee03acf7bbddc77b9c9236462c744fc7 (diff)
Merge tag 'kbuild-v5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull Kbuild updates from Masahiro Yamada: - remove headers_{install,check}_all targets - remove unreasonable 'depends on !UML' from CONFIG_SAMPLES - re-implement 'make headers_install' more cleanly - add new header-test-y syntax to compile-test headers - compile-test exported headers to ensure they are compilable in user-space - compile-test headers under include/ to ensure they are self-contained - remove -Waggregate-return, -Wno-uninitialized, -Wno-unused-value flags - add -Werror=unknown-warning-option for Clang - add 128-bit built-in types support to genksyms - fix missed rebuild of modules.builtin - propagate 'No space left on device' error in fixdep to Make - allow Clang to use its integrated assembler - improve some coccinelle scripts - add a new flag KBUILD_ABS_SRCTREE to request Kbuild to use absolute path for $(srctree). - do not ignore errors when compression utility is missing - misc cleanups * tag 'kbuild-v5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (49 commits) kbuild: use -- separater intead of $(filter-out ...) for cc-cross-prefix kbuild: Inform user to pass ARCH= for make mrproper kbuild: fix compression errors getting ignored kbuild: add a flag to force absolute path for srctree kbuild: replace KBUILD_SRCTREE with boolean building_out_of_srctree kbuild: remove src and obj from the top Makefile scripts/tags.sh: remove unused environment variables from comments scripts/tags.sh: drop SUBARCH support for ARM kbuild: compile-test kernel headers to ensure they are self-contained kheaders: include only headers into kheaders_data.tar.xz kheaders: remove meaningless -R option of 'ls' kbuild: support header-test-pattern-y kbuild: do not create wrappers for header-test-y kbuild: compile-test exported headers to ensure they are self-contained init/Kconfig: add CONFIG_CC_CAN_LINK kallsyms: exclude kasan local symbols on s390 kbuild: add more hints about SUBDIRS replacement coccinelle: api/stream_open: treat all wait_.*() calls as blocking coccinelle: put_device: Add a cast to an expression for an assignment coccinelle: put_device: Adjust a message construction ...
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile117
1 files changed, 66 insertions, 51 deletions
diff --git a/Makefile b/Makefile
index 3e4868a6498b..2c5d00ba537e 100644
--- a/Makefile
+++ b/Makefile
@@ -212,6 +212,13 @@ endif
212ifdef SUBDIRS 212ifdef SUBDIRS
213 $(warning ================= WARNING ================) 213 $(warning ================= WARNING ================)
214 $(warning 'SUBDIRS' will be removed after Linux 5.3) 214 $(warning 'SUBDIRS' will be removed after Linux 5.3)
215 $(warning )
216 $(warning If you are building an individual subdirectory)
217 $(warning in the kernel tree, you can do like this:)
218 $(warning $$ make path/to/dir/you/want/to/build/)
219 $(warning (Do not forget the trailing slash))
220 $(warning )
221 $(warning If you are building an external module,)
215 $(warning Please use 'M=' or 'KBUILD_EXTMOD' instead) 222 $(warning Please use 'M=' or 'KBUILD_EXTMOD' instead)
216 $(warning ==========================================) 223 $(warning ==========================================)
217 KBUILD_EXTMOD ?= $(SUBDIRS) 224 KBUILD_EXTMOD ?= $(SUBDIRS)
@@ -221,9 +228,12 @@ ifeq ("$(origin M)", "command line")
221 KBUILD_EXTMOD := $(M) 228 KBUILD_EXTMOD := $(M)
222endif 229endif
223 230
231export KBUILD_CHECKSRC KBUILD_EXTMOD
232
224ifeq ($(abs_srctree),$(abs_objtree)) 233ifeq ($(abs_srctree),$(abs_objtree))
225 # building in the source tree 234 # building in the source tree
226 srctree := . 235 srctree := .
236 building_out_of_srctree :=
227else 237else
228 ifeq ($(abs_srctree)/,$(dir $(abs_objtree))) 238 ifeq ($(abs_srctree)/,$(dir $(abs_objtree)))
229 # building in a subdirectory of the source tree 239 # building in a subdirectory of the source tree
@@ -231,22 +241,17 @@ else
231 else 241 else
232 srctree := $(abs_srctree) 242 srctree := $(abs_srctree)
233 endif 243 endif
234 244 building_out_of_srctree := 1
235 # TODO:
236 # KBUILD_SRC is only used to distinguish in-tree/out-of-tree build.
237 # Replace it with $(srctree) or something.
238 KBUILD_SRC := $(abs_srctree)
239endif 245endif
240 246
241export KBUILD_CHECKSRC KBUILD_EXTMOD KBUILD_SRC 247ifneq ($(KBUILD_ABS_SRCTREE),)
248srctree := $(abs_srctree)
249endif
242 250
243objtree := . 251objtree := .
244src := $(srctree)
245obj := $(objtree)
246
247VPATH := $(srctree) 252VPATH := $(srctree)
248 253
249export srctree objtree VPATH 254export building_out_of_srctree srctree objtree VPATH
250 255
251# To make sure we do not include .config for any of the *config targets 256# To make sure we do not include .config for any of the *config targets
252# catch them early, and hand them over to scripts/kconfig/Makefile 257# catch them early, and hand them over to scripts/kconfig/Makefile
@@ -262,7 +267,7 @@ old_version_h := include/linux/version.h
262clean-targets := %clean mrproper cleandocs 267clean-targets := %clean mrproper cleandocs
263no-dot-config-targets := $(clean-targets) \ 268no-dot-config-targets := $(clean-targets) \
264 cscope gtags TAGS tags help% %docs check% coccicheck \ 269 cscope gtags TAGS tags help% %docs check% coccicheck \
265 $(version_h) headers_% archheaders archscripts \ 270 $(version_h) headers headers_% archheaders archscripts \
266 %asm-generic kernelversion %src-pkg 271 %asm-generic kernelversion %src-pkg
267no-sync-config-targets := $(no-dot-config-targets) install %install \ 272no-sync-config-targets := $(no-dot-config-targets) install %install \
268 kernelrelease 273 kernelrelease
@@ -449,7 +454,7 @@ USERINCLUDE := \
449LINUXINCLUDE := \ 454LINUXINCLUDE := \
450 -I$(srctree)/arch/$(SRCARCH)/include \ 455 -I$(srctree)/arch/$(SRCARCH)/include \
451 -I$(objtree)/arch/$(SRCARCH)/include/generated \ 456 -I$(objtree)/arch/$(SRCARCH)/include/generated \
452 $(if $(filter .,$(srctree)),,-I$(srctree)/include) \ 457 $(if $(building_out_of_srctree),-I$(srctree)/include) \
453 -I$(objtree)/include \ 458 -I$(objtree)/include \
454 $(USERINCLUDE) 459 $(USERINCLUDE)
455 460
@@ -510,7 +515,7 @@ PHONY += outputmakefile
510# At the same time when output Makefile generated, generate .gitignore to 515# At the same time when output Makefile generated, generate .gitignore to
511# ignore whole output directory 516# ignore whole output directory
512outputmakefile: 517outputmakefile:
513ifneq ($(srctree),.) 518ifdef building_out_of_srctree
514 $(Q)ln -fsn $(srctree) source 519 $(Q)ln -fsn $(srctree) source
515 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree) 520 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree)
516 $(Q)test -e .gitignore || \ 521 $(Q)test -e .gitignore || \
@@ -527,7 +532,10 @@ endif
527ifneq ($(GCC_TOOLCHAIN),) 532ifneq ($(GCC_TOOLCHAIN),)
528CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN) 533CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN)
529endif 534endif
535ifeq ($(shell $(AS) --version 2>&1 | head -n 1 | grep clang),)
530CLANG_FLAGS += -no-integrated-as 536CLANG_FLAGS += -no-integrated-as
537endif
538CLANG_FLAGS += -Werror=unknown-warning-option
531KBUILD_CFLAGS += $(CLANG_FLAGS) 539KBUILD_CFLAGS += $(CLANG_FLAGS)
532KBUILD_AFLAGS += $(CLANG_FLAGS) 540KBUILD_AFLAGS += $(CLANG_FLAGS)
533export CLANG_FLAGS 541export CLANG_FLAGS
@@ -608,6 +616,7 @@ ifeq ($(KBUILD_EXTMOD),)
608init-y := init/ 616init-y := init/
609drivers-y := drivers/ sound/ 617drivers-y := drivers/ sound/
610drivers-$(CONFIG_SAMPLES) += samples/ 618drivers-$(CONFIG_SAMPLES) += samples/
619drivers-$(CONFIG_KERNEL_HEADER_TEST) += include/
611net-y := net/ 620net-y := net/
612libs-y := lib/ 621libs-y := lib/
613core-y := usr/ 622core-y := usr/
@@ -1053,9 +1062,6 @@ vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE
1053 1062
1054targets := vmlinux 1063targets := vmlinux
1055 1064
1056# Some samples need headers_install.
1057samples: headers_install
1058
1059# The actual objects are generated when descending, 1065# The actual objects are generated when descending,
1060# make sure no implicit rule kicks in 1066# make sure no implicit rule kicks in
1061$(sort $(vmlinux-deps)): $(vmlinux-dirs) ; 1067$(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
@@ -1096,12 +1102,12 @@ PHONY += prepare archprepare prepare1 prepare3
1096# and if so do: 1102# and if so do:
1097# 1) Check that make has not been executed in the kernel src $(srctree) 1103# 1) Check that make has not been executed in the kernel src $(srctree)
1098prepare3: include/config/kernel.release 1104prepare3: include/config/kernel.release
1099ifneq ($(srctree),.) 1105ifdef building_out_of_srctree
1100 @$(kecho) ' Using $(srctree) as source for kernel' 1106 @$(kecho) ' Using $(srctree) as source for kernel'
1101 $(Q)if [ -f $(srctree)/.config -o \ 1107 $(Q)if [ -f $(srctree)/.config -o \
1102 -d $(srctree)/include/config -o \ 1108 -d $(srctree)/include/config -o \
1103 -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \ 1109 -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \
1104 echo >&2 " $(srctree) is not clean, please run 'make mrproper'"; \ 1110 echo >&2 " $(srctree) is not clean, please run 'make ARCH=$(ARCH) mrproper'"; \
1105 echo >&2 " in the '$(srctree)' directory.";\ 1111 echo >&2 " in the '$(srctree)' directory.";\
1106 /bin/false; \ 1112 /bin/false; \
1107 fi; 1113 fi;
@@ -1181,39 +1187,44 @@ headerdep:
1181#Default location for installed headers 1187#Default location for installed headers
1182export INSTALL_HDR_PATH = $(objtree)/usr 1188export INSTALL_HDR_PATH = $(objtree)/usr
1183 1189
1184# If we do an all arch process set dst to include/arch-$(SRCARCH) 1190quiet_cmd_headers_install = INSTALL $(INSTALL_HDR_PATH)/include
1185hdr-dst = $(if $(KBUILD_HEADERS), dst=include/arch-$(SRCARCH), dst=include) 1191 cmd_headers_install = \
1192 mkdir -p $(INSTALL_HDR_PATH); \
1193 rsync -mrl --include='*/' --include='*\.h' --exclude='*' \
1194 usr/include $(INSTALL_HDR_PATH)
1186 1195
1187PHONY += archheaders archscripts 1196PHONY += headers_install
1197headers_install: headers
1198 $(call cmd,headers_install)
1188 1199
1189PHONY += __headers 1200PHONY += archheaders archscripts
1190__headers: $(version_h) scripts_basic uapi-asm-generic archheaders archscripts
1191 $(Q)$(MAKE) $(build)=scripts build_unifdef
1192 1201
1193PHONY += headers_install_all 1202hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj
1194headers_install_all:
1195 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/headers.sh install
1196 1203
1197PHONY += headers_install 1204PHONY += headers
1198headers_install: __headers 1205headers: $(version_h) scripts_unifdef uapi-asm-generic archheaders archscripts
1199 $(if $(wildcard $(srctree)/arch/$(SRCARCH)/include/uapi/asm/Kbuild),, \ 1206 $(if $(wildcard $(srctree)/arch/$(SRCARCH)/include/uapi/asm/Kbuild),, \
1200 $(error Headers not exportable for the $(SRCARCH) architecture)) 1207 $(error Headers not exportable for the $(SRCARCH) architecture))
1201 $(Q)$(MAKE) $(hdr-inst)=include/uapi dst=include 1208 $(Q)$(MAKE) $(hdr-inst)=include/uapi
1202 $(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi $(hdr-dst) 1209 $(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi
1203
1204PHONY += headers_check_all
1205headers_check_all: headers_install_all
1206 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/headers.sh check
1207 1210
1208PHONY += headers_check 1211PHONY += headers_check
1209headers_check: headers_install 1212headers_check: headers
1210 $(Q)$(MAKE) $(hdr-inst)=include/uapi dst=include HDRCHECK=1 1213 $(Q)$(MAKE) $(hdr-inst)=include/uapi HDRCHECK=1
1211 $(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi $(hdr-dst) HDRCHECK=1 1214 $(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi HDRCHECK=1
1215
1216ifdef CONFIG_HEADERS_INSTALL
1217prepare: headers
1218endif
1212 1219
1213ifdef CONFIG_HEADERS_CHECK 1220ifdef CONFIG_HEADERS_CHECK
1214all: headers_check 1221all: headers_check
1215endif 1222endif
1216 1223
1224PHONY += scripts_unifdef
1225scripts_unifdef: scripts_basic
1226 $(Q)$(MAKE) $(build)=scripts scripts/unifdef
1227
1217# --------------------------------------------------------------------------- 1228# ---------------------------------------------------------------------------
1218# Kernel selftest 1229# Kernel selftest
1219 1230
@@ -1283,18 +1294,24 @@ all: modules
1283# using awk while concatenating to the final file. 1294# using awk while concatenating to the final file.
1284 1295
1285PHONY += modules 1296PHONY += modules
1286modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin 1297modules: $(if $(KBUILD_BUILTIN),vmlinux) modules.order modules.builtin
1287 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
1288 @$(kecho) ' Building modules, stage 2.'; 1298 @$(kecho) ' Building modules, stage 2.';
1289 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost 1299 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1290 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh 1300 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh
1291 1301
1292modules.builtin: $(vmlinux-dirs:%=%/modules.builtin) 1302modules.order: $(vmlinux-dirs)
1293 $(Q)$(AWK) '!x[$$0]++' $^ > $(objtree)/modules.builtin 1303 $(Q)$(AWK) '!x[$$0]++' $(addsuffix /$@, $(vmlinux-dirs)) > $@
1304
1305modbuiltin-dirs := $(addprefix _modbuiltin_, $(vmlinux-dirs))
1294 1306
1295%/modules.builtin: include/config/auto.conf include/config/tristate.conf 1307modules.builtin: $(modbuiltin-dirs)
1296 $(Q)$(MAKE) $(modbuiltin)=$* 1308 $(Q)$(AWK) '!x[$$0]++' $(addsuffix /$@, $(vmlinux-dirs)) > $@
1297 1309
1310PHONY += $(modbuiltin-dirs)
1311# tristate.conf is not included from this Makefile. Add it as a prerequisite
1312# here to make it self-healing in case somebody accidentally removes it.
1313$(modbuiltin-dirs): include/config/tristate.conf
1314 $(Q)$(MAKE) $(modbuiltin)=$(patsubst _modbuiltin_%,%,$@)
1298 1315
1299# Target to prepare building external modules 1316# Target to prepare building external modules
1300PHONY += modules_prepare 1317PHONY += modules_prepare
@@ -1360,7 +1377,7 @@ CLEAN_DIRS += $(MODVERDIR) include/ksym
1360CLEAN_FILES += modules.builtin.modinfo 1377CLEAN_FILES += modules.builtin.modinfo
1361 1378
1362# Directories & files removed with 'make mrproper' 1379# Directories & files removed with 'make mrproper'
1363MRPROPER_DIRS += include/config usr/include include/generated \ 1380MRPROPER_DIRS += include/config include/generated \
1364 arch/$(SRCARCH)/include/generated .tmp_objdiff 1381 arch/$(SRCARCH)/include/generated .tmp_objdiff
1365MRPROPER_FILES += .config .config.old .version \ 1382MRPROPER_FILES += .config .config.old .version \
1366 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \ 1383 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
@@ -1551,7 +1568,7 @@ $(DOC_TARGETS): scripts_basic FORCE
1551# --------------------------------------------------------------------------- 1568# ---------------------------------------------------------------------------
1552 1569
1553PHONY += scripts_gdb 1570PHONY += scripts_gdb
1554scripts_gdb: prepare 1571scripts_gdb: prepare0
1555 $(Q)$(MAKE) $(build)=scripts/gdb 1572 $(Q)$(MAKE) $(build)=scripts/gdb
1556 $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py) 1573 $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py)
1557 1574
@@ -1698,7 +1715,7 @@ CHECKSTACK_ARCH := $(ARCH)
1698endif 1715endif
1699checkstack: 1716checkstack:
1700 $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \ 1717 $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
1701 $(PERL) $(src)/scripts/checkstack.pl $(CHECKSTACK_ARCH) 1718 $(PERL) $(srctree)/scripts/checkstack.pl $(CHECKSTACK_ARCH)
1702 1719
1703kernelrelease: 1720kernelrelease:
1704 @echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" 1721 @echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
@@ -1717,11 +1734,11 @@ endif
1717 1734
1718tools/: FORCE 1735tools/: FORCE
1719 $(Q)mkdir -p $(objtree)/tools 1736 $(Q)mkdir -p $(objtree)/tools
1720 $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(src)/tools/ 1737 $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/
1721 1738
1722tools/%: FORCE 1739tools/%: FORCE
1723 $(Q)mkdir -p $(objtree)/tools 1740 $(Q)mkdir -p $(objtree)/tools
1724 $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(src)/tools/ $* 1741 $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ $*
1725 1742
1726# Single targets 1743# Single targets
1727# --------------------------------------------------------------------------- 1744# ---------------------------------------------------------------------------
@@ -1755,8 +1772,6 @@ build-dir = $(patsubst %/,%,$(dir $(build-target)))
1755PHONY += / 1772PHONY += /
1756/: ./ 1773/: ./
1757 1774
1758# Make sure the latest headers are built for Documentation
1759Documentation/ samples/: headers_install
1760%/: prepare FORCE 1775%/: prepare FORCE
1761 $(Q)$(MAKE) KBUILD_MODULES=1 $(build)=$(build-dir) 1776 $(Q)$(MAKE) KBUILD_MODULES=1 $(build)=$(build-dir)
1762 1777