aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Kbuild.include8
-rw-r--r--scripts/Kconfig.include8
-rw-r--r--scripts/Makefile.extrawarn25
-rw-r--r--scripts/Makefile.host12
-rw-r--r--scripts/Makefile.lib26
-rw-r--r--scripts/dtc/Makefile6
-rw-r--r--scripts/genksyms/Makefile4
-rw-r--r--scripts/kconfig/Makefile8
-rw-r--r--scripts/kconfig/confdata.c13
-rwxr-xr-xscripts/modules-check.sh16
10 files changed, 70 insertions, 56 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 7484b9d8272f..a675ce11a573 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -192,14 +192,6 @@ clean := -f $(srctree)/scripts/Makefile.clean obj
192# $(Q)$(MAKE) $(hdr-inst)=dir 192# $(Q)$(MAKE) $(hdr-inst)=dir
193hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj 193hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj
194 194
195# Prefix -I with $(srctree) if it is not an absolute path.
196# skip if -I has no parameter
197addtree = $(if $(patsubst -I%,%,$(1)), \
198$(if $(filter-out -I/% -I./% -I../%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1)),$(1)),$(1))
199
200# Find all -I options and call addtree
201flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o)))
202
203# echo command. 195# echo command.
204# Short version is used, if $(quiet) equals `quiet_', otherwise full one. 196# Short version is used, if $(quiet) equals `quiet_', otherwise full one.
205echo-cmd = $(if $($(quiet)cmd_$(1)),\ 197echo-cmd = $(if $($(quiet)cmd_$(1)),\
diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include
index 87ff1dcc6bd5..0b267fb27f07 100644
--- a/scripts/Kconfig.include
+++ b/scripts/Kconfig.include
@@ -18,6 +18,10 @@ if-success = $(shell,{ $(1); } >/dev/null 2>&1 && echo "$(2)" || echo "$(3)")
18# Return y if <command> exits with 0, n otherwise 18# Return y if <command> exits with 0, n otherwise
19success = $(if-success,$(1),y,n) 19success = $(if-success,$(1),y,n)
20 20
21# $(failure,<command>)
22# Return n if <command> exits with 0, y otherwise
23failure = $(if-success,$(1),n,y)
24
21# $(cc-option,<flag>) 25# $(cc-option,<flag>)
22# Return y if the compiler supports <flag>, n otherwise 26# Return y if the compiler supports <flag>, n otherwise
23cc-option = $(success,$(CC) -Werror $(1) -E -x c /dev/null -o /dev/null) 27cc-option = $(success,$(CC) -Werror $(1) -E -x c /dev/null -o /dev/null)
@@ -26,5 +30,9 @@ cc-option = $(success,$(CC) -Werror $(1) -E -x c /dev/null -o /dev/null)
26# Return y if the linker supports <flag>, n otherwise 30# Return y if the linker supports <flag>, n otherwise
27ld-option = $(success,$(LD) -v $(1)) 31ld-option = $(success,$(LD) -v $(1))
28 32
33# check if $(CC) and $(LD) exist
34$(error-if,$(failure,command -v $(CC)),compiler '$(CC)' not found)
35$(error-if,$(failure,command -v $(LD)),linker '$(LD)' not found)
36
29# gcc version including patch level 37# gcc version including patch level
30gcc-version := $(shell,$(srctree)/scripts/gcc-version.sh $(CC)) 38gcc-version := $(shell,$(srctree)/scripts/gcc-version.sh $(CC))
diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
index 768306add591..3ab8d1a303cd 100644
--- a/scripts/Makefile.extrawarn
+++ b/scripts/Makefile.extrawarn
@@ -23,15 +23,16 @@ warning- := $(empty)
23warning-1 := -Wextra -Wunused -Wno-unused-parameter 23warning-1 := -Wextra -Wunused -Wno-unused-parameter
24warning-1 += -Wmissing-declarations 24warning-1 += -Wmissing-declarations
25warning-1 += -Wmissing-format-attribute 25warning-1 += -Wmissing-format-attribute
26warning-1 += $(call cc-option, -Wmissing-prototypes) 26warning-1 += -Wmissing-prototypes
27warning-1 += -Wold-style-definition 27warning-1 += -Wold-style-definition
28warning-1 += $(call cc-option, -Wmissing-include-dirs) 28warning-1 += -Wmissing-include-dirs
29warning-1 += $(call cc-option, -Wunused-but-set-variable) 29warning-1 += $(call cc-option, -Wunused-but-set-variable)
30warning-1 += $(call cc-option, -Wunused-const-variable) 30warning-1 += $(call cc-option, -Wunused-const-variable)
31warning-1 += $(call cc-option, -Wpacked-not-aligned) 31warning-1 += $(call cc-option, -Wpacked-not-aligned)
32warning-1 += $(call cc-option, -Wstringop-truncation) 32warning-1 += $(call cc-option, -Wstringop-truncation)
33warning-1 += $(call cc-disable-warning, missing-field-initializers) 33# The following turn off the warnings enabled by -Wextra
34warning-1 += $(call cc-disable-warning, sign-compare) 34warning-1 += -Wno-missing-field-initializers
35warning-1 += -Wno-sign-compare
35 36
36warning-2 := -Waggregate-return 37warning-2 := -Waggregate-return
37warning-2 += -Wcast-align 38warning-2 += -Wcast-align
@@ -39,8 +40,8 @@ warning-2 += -Wdisabled-optimization
39warning-2 += -Wnested-externs 40warning-2 += -Wnested-externs
40warning-2 += -Wshadow 41warning-2 += -Wshadow
41warning-2 += $(call cc-option, -Wlogical-op) 42warning-2 += $(call cc-option, -Wlogical-op)
42warning-2 += $(call cc-option, -Wmissing-field-initializers) 43warning-2 += -Wmissing-field-initializers
43warning-2 += $(call cc-option, -Wsign-compare) 44warning-2 += -Wsign-compare
44warning-2 += $(call cc-option, -Wmaybe-uninitialized) 45warning-2 += $(call cc-option, -Wmaybe-uninitialized)
45warning-2 += $(call cc-option, -Wunused-macros) 46warning-2 += $(call cc-option, -Wunused-macros)
46 47
@@ -66,11 +67,11 @@ KBUILD_CFLAGS += $(warning)
66else 67else
67 68
68ifdef CONFIG_CC_IS_CLANG 69ifdef CONFIG_CC_IS_CLANG
69KBUILD_CFLAGS += $(call cc-disable-warning, initializer-overrides) 70KBUILD_CFLAGS += -Wno-initializer-overrides
70KBUILD_CFLAGS += $(call cc-disable-warning, unused-value) 71KBUILD_CFLAGS += -Wno-unused-value
71KBUILD_CFLAGS += $(call cc-disable-warning, format) 72KBUILD_CFLAGS += -Wno-format
72KBUILD_CFLAGS += $(call cc-disable-warning, sign-compare) 73KBUILD_CFLAGS += -Wno-sign-compare
73KBUILD_CFLAGS += $(call cc-disable-warning, format-zero-length) 74KBUILD_CFLAGS += -Wno-format-zero-length
74KBUILD_CFLAGS += $(call cc-disable-warning, uninitialized) 75KBUILD_CFLAGS += -Wno-uninitialized
75endif 76endif
76endif 77endif
diff --git a/scripts/Makefile.host b/scripts/Makefile.host
index 73b804197fca..b6a54bdf0965 100644
--- a/scripts/Makefile.host
+++ b/scripts/Makefile.host
@@ -67,18 +67,16 @@ _hostc_flags = $(KBUILD_HOSTCFLAGS) $(HOST_EXTRACFLAGS) \
67_hostcxx_flags = $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \ 67_hostcxx_flags = $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \
68 $(HOSTCXXFLAGS_$(basetarget).o) 68 $(HOSTCXXFLAGS_$(basetarget).o)
69 69
70__hostc_flags = $(_hostc_flags) 70# $(objtree)/$(obj) for including generated headers from checkin source files
71__hostcxx_flags = $(_hostcxx_flags)
72
73ifeq ($(KBUILD_EXTMOD),) 71ifeq ($(KBUILD_EXTMOD),)
74ifneq ($(srctree),.) 72ifneq ($(srctree),.)
75__hostc_flags = -I$(obj) $(call flags,_hostc_flags) 73_hostc_flags += -I $(objtree)/$(obj)
76__hostcxx_flags = -I$(obj) $(call flags,_hostcxx_flags) 74_hostcxx_flags += -I $(objtree)/$(obj)
77endif 75endif
78endif 76endif
79 77
80hostc_flags = -Wp,-MD,$(depfile) $(__hostc_flags) 78hostc_flags = -Wp,-MD,$(depfile) $(_hostc_flags)
81hostcxx_flags = -Wp,-MD,$(depfile) $(__hostcxx_flags) 79hostcxx_flags = -Wp,-MD,$(depfile) $(_hostcxx_flags)
82 80
83##### 81#####
84# Compile programs on the host 82# Compile programs on the host
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 41e98fa66b91..1b412d4394ae 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -137,36 +137,26 @@ _c_flags += $(if $(patsubst n%,, \
137 $(CFLAGS_KCOV)) 137 $(CFLAGS_KCOV))
138endif 138endif
139 139
140__c_flags = $(_c_flags) 140# $(srctree)/$(src) for including checkin headers from generated source files
141__a_flags = $(_a_flags) 141# $(objtree)/$(obj) for including generated headers from checkin source files
142__cpp_flags = $(_cpp_flags)
143
144# If building the kernel in a separate objtree expand all occurrences
145# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
146ifeq ($(KBUILD_EXTMOD),) 142ifeq ($(KBUILD_EXTMOD),)
147ifneq ($(srctree),.) 143ifneq ($(srctree),.)
148 144_c_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj)
149# -I$(obj) locates generated .h files 145_a_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj)
150# $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files 146_cpp_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj)
151# and locates generated .h files
152# FIXME: Replace both with specific CFLAGS* statements in the makefiles
153__c_flags = $(if $(obj),$(call addtree,-I$(src)) -I$(obj)) \
154 $(call flags,_c_flags)
155__a_flags = $(call flags,_a_flags)
156__cpp_flags = $(call flags,_cpp_flags)
157endif 147endif
158endif 148endif
159 149
160c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ 150c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
161 -include $(srctree)/include/linux/compiler_types.h \ 151 -include $(srctree)/include/linux/compiler_types.h \
162 $(__c_flags) $(modkern_cflags) \ 152 $(_c_flags) $(modkern_cflags) \
163 $(basename_flags) $(modname_flags) 153 $(basename_flags) $(modname_flags)
164 154
165a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ 155a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
166 $(__a_flags) $(modkern_aflags) 156 $(_a_flags) $(modkern_aflags)
167 157
168cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ 158cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
169 $(__cpp_flags) 159 $(_cpp_flags)
170 160
171ld_flags = $(KBUILD_LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F)) 161ld_flags = $(KBUILD_LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F))
172 162
diff --git a/scripts/dtc/Makefile b/scripts/dtc/Makefile
index 5f227d8d39d8..82160808765c 100644
--- a/scripts/dtc/Makefile
+++ b/scripts/dtc/Makefile
@@ -9,7 +9,7 @@ dtc-objs := dtc.o flattree.o fstree.o data.o livetree.o treesource.o \
9dtc-objs += dtc-lexer.lex.o dtc-parser.tab.o 9dtc-objs += dtc-lexer.lex.o dtc-parser.tab.o
10 10
11# Source files need to get at the userspace version of libfdt_env.h to compile 11# Source files need to get at the userspace version of libfdt_env.h to compile
12HOST_EXTRACFLAGS := -I$(src)/libfdt 12HOST_EXTRACFLAGS := -I $(srctree)/$(src)/libfdt
13 13
14ifeq ($(wildcard /usr/include/yaml.h),) 14ifeq ($(wildcard /usr/include/yaml.h),)
15ifneq ($(CHECK_DTBS),) 15ifneq ($(CHECK_DTBS),)
@@ -23,8 +23,8 @@ HOSTLDLIBS_dtc := -lyaml
23endif 23endif
24 24
25# Generated files need one more search path to include headers in source tree 25# Generated files need one more search path to include headers in source tree
26HOSTCFLAGS_dtc-lexer.lex.o := -I$(src) 26HOSTCFLAGS_dtc-lexer.lex.o := -I $(srctree)/$(src)
27HOSTCFLAGS_dtc-parser.tab.o := -I$(src) 27HOSTCFLAGS_dtc-parser.tab.o := -I $(srctree)/$(src)
28 28
29# dependencies on generated files need to be listed explicitly 29# dependencies on generated files need to be listed explicitly
30$(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.h 30$(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.h
diff --git a/scripts/genksyms/Makefile b/scripts/genksyms/Makefile
index 03b7ce97de14..66c314bc5933 100644
--- a/scripts/genksyms/Makefile
+++ b/scripts/genksyms/Makefile
@@ -31,8 +31,8 @@ $(obj)/parse.tab.h: $(src)/parse.y FORCE
31endif 31endif
32 32
33# -I needed for generated C source (shipped source) 33# -I needed for generated C source (shipped source)
34HOSTCFLAGS_parse.tab.o := -I$(src) 34HOSTCFLAGS_parse.tab.o := -I $(srctree)/$(src)
35HOSTCFLAGS_lex.lex.o := -I$(src) 35HOSTCFLAGS_lex.lex.o := -I $(srctree)/$(src)
36 36
37# dependencies on generated files need to be listed explicitly 37# dependencies on generated files need to be listed explicitly
38$(obj)/lex.lex.o: $(obj)/parse.tab.h 38$(obj)/lex.lex.o: $(obj)/parse.tab.h
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 7c5dc31c1d95..3f327e21f60e 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -76,15 +76,13 @@ savedefconfig: $(obj)/conf
76defconfig: $(obj)/conf 76defconfig: $(obj)/conf
77ifeq ($(KBUILD_DEFCONFIG),) 77ifeq ($(KBUILD_DEFCONFIG),)
78 $< $(silent) --defconfig $(Kconfig) 78 $< $(silent) --defconfig $(Kconfig)
79else 79else ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),)
80ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),)
81 @$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'" 80 @$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
82 $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) 81 $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
83else 82else
84 @$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'" 83 @$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'"
85 $(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG) 84 $(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG)
86endif 85endif
87endif
88 86
89%_defconfig: $(obj)/conf 87%_defconfig: $(obj)/conf
90 $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig) 88 $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
@@ -147,8 +145,8 @@ common-objs := confdata.o expr.o lexer.lex.o parser.tab.o preprocess.o \
147 symbol.o 145 symbol.o
148 146
149$(obj)/lexer.lex.o: $(obj)/parser.tab.h 147$(obj)/lexer.lex.o: $(obj)/parser.tab.h
150HOSTCFLAGS_lexer.lex.o := -I$(src) 148HOSTCFLAGS_lexer.lex.o := -I $(srctree)/$(src)
151HOSTCFLAGS_parser.tab.o := -I$(src) 149HOSTCFLAGS_parser.tab.o := -I $(srctree)/$(src)
152 150
153# conf: Used for defconfig, oldconfig and related targets 151# conf: Used for defconfig, oldconfig and related targets
154hostprogs-y += conf 152hostprogs-y += conf
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 492ac3410147..6006154d36bd 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -867,6 +867,7 @@ int conf_write(const char *name)
867 const char *str; 867 const char *str;
868 char tmpname[PATH_MAX + 1], oldname[PATH_MAX + 1]; 868 char tmpname[PATH_MAX + 1], oldname[PATH_MAX + 1];
869 char *env; 869 char *env;
870 bool need_newline = false;
870 871
871 if (!name) 872 if (!name)
872 name = conf_get_configname(); 873 name = conf_get_configname();
@@ -912,12 +913,16 @@ int conf_write(const char *name)
912 "#\n" 913 "#\n"
913 "# %s\n" 914 "# %s\n"
914 "#\n", str); 915 "#\n", str);
916 need_newline = false;
915 } else if (!(sym->flags & SYMBOL_CHOICE)) { 917 } else if (!(sym->flags & SYMBOL_CHOICE)) {
916 sym_calc_value(sym); 918 sym_calc_value(sym);
917 if (!(sym->flags & SYMBOL_WRITE)) 919 if (!(sym->flags & SYMBOL_WRITE))
918 goto next; 920 goto next;
921 if (need_newline) {
922 fprintf(out, "\n");
923 need_newline = false;
924 }
919 sym->flags &= ~SYMBOL_WRITE; 925 sym->flags &= ~SYMBOL_WRITE;
920
921 conf_write_symbol(out, sym, &kconfig_printer_cb, NULL); 926 conf_write_symbol(out, sym, &kconfig_printer_cb, NULL);
922 } 927 }
923 928
@@ -929,6 +934,12 @@ next:
929 if (menu->next) 934 if (menu->next)
930 menu = menu->next; 935 menu = menu->next;
931 else while ((menu = menu->parent)) { 936 else while ((menu = menu->parent)) {
937 if (!menu->sym && menu_is_visible(menu) &&
938 menu != &rootmenu) {
939 str = menu_get_prompt(menu);
940 fprintf(out, "# end of %s\n", str);
941 need_newline = true;
942 }
932 if (menu->next) { 943 if (menu->next) {
933 menu = menu->next; 944 menu = menu->next;
934 break; 945 break;
diff --git a/scripts/modules-check.sh b/scripts/modules-check.sh
new file mode 100755
index 000000000000..2f659530e1ec
--- /dev/null
+++ b/scripts/modules-check.sh
@@ -0,0 +1,16 @@
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3
4set -e
5
6# Check uniqueness of module names
7check_same_name_modules()
8{
9 for m in $(sed 's:.*/::' modules.order modules.builtin | sort | uniq -d)
10 do
11 echo "warning: same basename if the following are built as modules:" >&2
12 sed "/\/$m/!d;s:^kernel/: :" modules.order modules.builtin >&2
13 done
14}
15
16check_same_name_modules