diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Kbuild.include | 8 | ||||
-rw-r--r-- | scripts/Kconfig.include | 8 | ||||
-rw-r--r-- | scripts/Makefile.extrawarn | 25 | ||||
-rw-r--r-- | scripts/Makefile.host | 12 | ||||
-rw-r--r-- | scripts/Makefile.lib | 26 | ||||
-rw-r--r-- | scripts/dtc/Makefile | 6 | ||||
-rw-r--r-- | scripts/genksyms/Makefile | 4 | ||||
-rw-r--r-- | scripts/kconfig/Makefile | 8 | ||||
-rw-r--r-- | scripts/kconfig/confdata.c | 13 | ||||
-rwxr-xr-x | scripts/modules-check.sh | 16 |
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 # $(Q)$(MAKE) $(hdr-inst)=dir hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj -# Prefix -I with $(srctree) if it is not an absolute path. -# skip if -I has no parameter -addtree = $(if $(patsubst -I%,%,$(1)), \ -$(if $(filter-out -I/% -I./% -I../%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1)),$(1)),$(1)) - -# Find all -I options and call addtree -flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o))) - # echo command. # Short version is used, if $(quiet) equals `quiet_', otherwise full one. echo-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)") # Return y if <command> exits with 0, n otherwise success = $(if-success,$(1),y,n) +# $(failure,<command>) +# Return n if <command> exits with 0, y otherwise +failure = $(if-success,$(1),n,y) + # $(cc-option,<flag>) # Return y if the compiler supports <flag>, n otherwise cc-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) # Return y if the linker supports <flag>, n otherwise ld-option = $(success,$(LD) -v $(1)) +# check if $(CC) and $(LD) exist +$(error-if,$(failure,command -v $(CC)),compiler '$(CC)' not found) +$(error-if,$(failure,command -v $(LD)),linker '$(LD)' not found) + # gcc version including patch level gcc-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) warning-1 := -Wextra -Wunused -Wno-unused-parameter warning-1 += -Wmissing-declarations warning-1 += -Wmissing-format-attribute -warning-1 += $(call cc-option, -Wmissing-prototypes) +warning-1 += -Wmissing-prototypes warning-1 += -Wold-style-definition -warning-1 += $(call cc-option, -Wmissing-include-dirs) +warning-1 += -Wmissing-include-dirs warning-1 += $(call cc-option, -Wunused-but-set-variable) warning-1 += $(call cc-option, -Wunused-const-variable) warning-1 += $(call cc-option, -Wpacked-not-aligned) warning-1 += $(call cc-option, -Wstringop-truncation) -warning-1 += $(call cc-disable-warning, missing-field-initializers) -warning-1 += $(call cc-disable-warning, sign-compare) +# The following turn off the warnings enabled by -Wextra +warning-1 += -Wno-missing-field-initializers +warning-1 += -Wno-sign-compare warning-2 := -Waggregate-return warning-2 += -Wcast-align @@ -39,8 +40,8 @@ warning-2 += -Wdisabled-optimization warning-2 += -Wnested-externs warning-2 += -Wshadow warning-2 += $(call cc-option, -Wlogical-op) -warning-2 += $(call cc-option, -Wmissing-field-initializers) -warning-2 += $(call cc-option, -Wsign-compare) +warning-2 += -Wmissing-field-initializers +warning-2 += -Wsign-compare warning-2 += $(call cc-option, -Wmaybe-uninitialized) warning-2 += $(call cc-option, -Wunused-macros) @@ -66,11 +67,11 @@ KBUILD_CFLAGS += $(warning) else ifdef CONFIG_CC_IS_CLANG -KBUILD_CFLAGS += $(call cc-disable-warning, initializer-overrides) -KBUILD_CFLAGS += $(call cc-disable-warning, unused-value) -KBUILD_CFLAGS += $(call cc-disable-warning, format) -KBUILD_CFLAGS += $(call cc-disable-warning, sign-compare) -KBUILD_CFLAGS += $(call cc-disable-warning, format-zero-length) -KBUILD_CFLAGS += $(call cc-disable-warning, uninitialized) +KBUILD_CFLAGS += -Wno-initializer-overrides +KBUILD_CFLAGS += -Wno-unused-value +KBUILD_CFLAGS += -Wno-format +KBUILD_CFLAGS += -Wno-sign-compare +KBUILD_CFLAGS += -Wno-format-zero-length +KBUILD_CFLAGS += -Wno-uninitialized endif endif 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) \ _hostcxx_flags = $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \ $(HOSTCXXFLAGS_$(basetarget).o) -__hostc_flags = $(_hostc_flags) -__hostcxx_flags = $(_hostcxx_flags) - +# $(objtree)/$(obj) for including generated headers from checkin source files ifeq ($(KBUILD_EXTMOD),) ifneq ($(srctree),.) -__hostc_flags = -I$(obj) $(call flags,_hostc_flags) -__hostcxx_flags = -I$(obj) $(call flags,_hostcxx_flags) +_hostc_flags += -I $(objtree)/$(obj) +_hostcxx_flags += -I $(objtree)/$(obj) endif endif -hostc_flags = -Wp,-MD,$(depfile) $(__hostc_flags) -hostcxx_flags = -Wp,-MD,$(depfile) $(__hostcxx_flags) +hostc_flags = -Wp,-MD,$(depfile) $(_hostc_flags) +hostcxx_flags = -Wp,-MD,$(depfile) $(_hostcxx_flags) ##### # 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%,, \ $(CFLAGS_KCOV)) endif -__c_flags = $(_c_flags) -__a_flags = $(_a_flags) -__cpp_flags = $(_cpp_flags) - -# If building the kernel in a separate objtree expand all occurrences -# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/'). +# $(srctree)/$(src) for including checkin headers from generated source files +# $(objtree)/$(obj) for including generated headers from checkin source files ifeq ($(KBUILD_EXTMOD),) ifneq ($(srctree),.) - -# -I$(obj) locates generated .h files -# $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files -# and locates generated .h files -# FIXME: Replace both with specific CFLAGS* statements in the makefiles -__c_flags = $(if $(obj),$(call addtree,-I$(src)) -I$(obj)) \ - $(call flags,_c_flags) -__a_flags = $(call flags,_a_flags) -__cpp_flags = $(call flags,_cpp_flags) +_c_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj) +_a_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj) +_cpp_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj) endif endif c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ -include $(srctree)/include/linux/compiler_types.h \ - $(__c_flags) $(modkern_cflags) \ + $(_c_flags) $(modkern_cflags) \ $(basename_flags) $(modname_flags) a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ - $(__a_flags) $(modkern_aflags) + $(_a_flags) $(modkern_aflags) cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ - $(__cpp_flags) + $(_cpp_flags) ld_flags = $(KBUILD_LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F)) 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 \ dtc-objs += dtc-lexer.lex.o dtc-parser.tab.o # Source files need to get at the userspace version of libfdt_env.h to compile -HOST_EXTRACFLAGS := -I$(src)/libfdt +HOST_EXTRACFLAGS := -I $(srctree)/$(src)/libfdt ifeq ($(wildcard /usr/include/yaml.h),) ifneq ($(CHECK_DTBS),) @@ -23,8 +23,8 @@ HOSTLDLIBS_dtc := -lyaml endif # Generated files need one more search path to include headers in source tree -HOSTCFLAGS_dtc-lexer.lex.o := -I$(src) -HOSTCFLAGS_dtc-parser.tab.o := -I$(src) +HOSTCFLAGS_dtc-lexer.lex.o := -I $(srctree)/$(src) +HOSTCFLAGS_dtc-parser.tab.o := -I $(srctree)/$(src) # dependencies on generated files need to be listed explicitly $(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 endif # -I needed for generated C source (shipped source) -HOSTCFLAGS_parse.tab.o := -I$(src) -HOSTCFLAGS_lex.lex.o := -I$(src) +HOSTCFLAGS_parse.tab.o := -I $(srctree)/$(src) +HOSTCFLAGS_lex.lex.o := -I $(srctree)/$(src) # dependencies on generated files need to be listed explicitly $(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 defconfig: $(obj)/conf ifeq ($(KBUILD_DEFCONFIG),) $< $(silent) --defconfig $(Kconfig) -else -ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),) +else ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),) @$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'" $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) else @$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'" $(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG) endif -endif %_defconfig: $(obj)/conf $(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 \ symbol.o $(obj)/lexer.lex.o: $(obj)/parser.tab.h -HOSTCFLAGS_lexer.lex.o := -I$(src) -HOSTCFLAGS_parser.tab.o := -I$(src) +HOSTCFLAGS_lexer.lex.o := -I $(srctree)/$(src) +HOSTCFLAGS_parser.tab.o := -I $(srctree)/$(src) # conf: Used for defconfig, oldconfig and related targets hostprogs-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) const char *str; char tmpname[PATH_MAX + 1], oldname[PATH_MAX + 1]; char *env; + bool need_newline = false; if (!name) name = conf_get_configname(); @@ -912,12 +913,16 @@ int conf_write(const char *name) "#\n" "# %s\n" "#\n", str); + need_newline = false; } else if (!(sym->flags & SYMBOL_CHOICE)) { sym_calc_value(sym); if (!(sym->flags & SYMBOL_WRITE)) goto next; + if (need_newline) { + fprintf(out, "\n"); + need_newline = false; + } sym->flags &= ~SYMBOL_WRITE; - conf_write_symbol(out, sym, &kconfig_printer_cb, NULL); } @@ -929,6 +934,12 @@ next: if (menu->next) menu = menu->next; else while ((menu = menu->parent)) { + if (!menu->sym && menu_is_visible(menu) && + menu != &rootmenu) { + str = menu_get_prompt(menu); + fprintf(out, "# end of %s\n", str); + need_newline = true; + } if (menu->next) { menu = menu->next; 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 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 + +set -e + +# Check uniqueness of module names +check_same_name_modules() +{ + for m in $(sed 's:.*/::' modules.order modules.builtin | sort | uniq -d) + do + echo "warning: same basename if the following are built as modules:" >&2 + sed "/\/$m/!d;s:^kernel/: :" modules.order modules.builtin >&2 + done +} + +check_same_name_modules |