diff options
Diffstat (limited to 'scripts/Makefile.build')
-rw-r--r-- | scripts/Makefile.build | 86 |
1 files changed, 54 insertions, 32 deletions
diff --git a/scripts/Makefile.build b/scripts/Makefile.build index d5f925abe4d2..a0fd5029cfe7 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build | |||
@@ -51,36 +51,52 @@ ifeq ($(KBUILD_NOPEDANTIC),) | |||
51 | endif | 51 | endif |
52 | 52 | ||
53 | # | 53 | # |
54 | # make W=1 settings | 54 | # make W=... settings |
55 | # | 55 | # |
56 | # $(call cc-option... ) handles gcc -W.. options which | 56 | # W=1 - warnings that may be relevant and does not occur too often |
57 | # W=2 - warnings that occur quite often but may still be relevant | ||
58 | # W=3 - the more obscure warnings, can most likely be ignored | ||
59 | # | ||
60 | # $(call cc-option, -W...) handles gcc -W.. options which | ||
57 | # are not supported by all versions of the compiler | 61 | # are not supported by all versions of the compiler |
58 | ifdef KBUILD_ENABLE_EXTRA_GCC_CHECKS | 62 | ifdef KBUILD_ENABLE_EXTRA_GCC_CHECKS |
59 | KBUILD_EXTRA_WARNINGS := -Wextra | 63 | warning- := $(empty) |
60 | KBUILD_EXTRA_WARNINGS += -Wunused -Wno-unused-parameter | 64 | |
61 | KBUILD_EXTRA_WARNINGS += -Waggregate-return | 65 | warning-1 := -Wextra -Wunused -Wno-unused-parameter |
62 | KBUILD_EXTRA_WARNINGS += -Wbad-function-cast | 66 | warning-1 += -Wmissing-declarations |
63 | KBUILD_EXTRA_WARNINGS += -Wcast-qual | 67 | warning-1 += -Wmissing-format-attribute |
64 | KBUILD_EXTRA_WARNINGS += -Wcast-align | 68 | warning-1 += -Wmissing-prototypes |
65 | KBUILD_EXTRA_WARNINGS += -Wconversion | 69 | warning-1 += -Wold-style-definition |
66 | KBUILD_EXTRA_WARNINGS += -Wdisabled-optimization | 70 | warning-1 += $(call cc-option, -Wmissing-include-dirs) |
67 | KBUILD_EXTRA_WARNINGS += -Wlogical-op | 71 | warning-1 += $(call cc-option, -Wunused-but-set-variable) |
68 | KBUILD_EXTRA_WARNINGS += -Wmissing-declarations | 72 | |
69 | KBUILD_EXTRA_WARNINGS += -Wmissing-format-attribute | 73 | warning-2 := -Waggregate-return |
70 | KBUILD_EXTRA_WARNINGS += $(call cc-option, -Wmissing-include-dirs,) | 74 | warning-2 += -Wcast-align |
71 | KBUILD_EXTRA_WARNINGS += -Wmissing-prototypes | 75 | warning-2 += -Wdisabled-optimization |
72 | KBUILD_EXTRA_WARNINGS += -Wnested-externs | 76 | warning-2 += -Wnested-externs |
73 | KBUILD_EXTRA_WARNINGS += -Wold-style-definition | 77 | warning-2 += -Wshadow |
74 | KBUILD_EXTRA_WARNINGS += $(call cc-option, -Woverlength-strings,) | 78 | warning-2 += $(call cc-option, -Wlogical-op) |
75 | KBUILD_EXTRA_WARNINGS += -Wpacked | 79 | |
76 | KBUILD_EXTRA_WARNINGS += -Wpacked-bitfield-compat | 80 | warning-3 := -Wbad-function-cast |
77 | KBUILD_EXTRA_WARNINGS += -Wpadded | 81 | warning-3 += -Wcast-qual |
78 | KBUILD_EXTRA_WARNINGS += -Wpointer-arith | 82 | warning-3 += -Wconversion |
79 | KBUILD_EXTRA_WARNINGS += -Wredundant-decls | 83 | warning-3 += -Wpacked |
80 | KBUILD_EXTRA_WARNINGS += -Wshadow | 84 | warning-3 += -Wpadded |
81 | KBUILD_EXTRA_WARNINGS += -Wswitch-default | 85 | warning-3 += -Wpointer-arith |
82 | KBUILD_EXTRA_WARNINGS += $(call cc-option, -Wvla,) | 86 | warning-3 += -Wredundant-decls |
83 | KBUILD_CFLAGS += $(KBUILD_EXTRA_WARNINGS) | 87 | warning-3 += -Wswitch-default |
88 | warning-3 += $(call cc-option, -Wpacked-bitfield-compat) | ||
89 | warning-3 += $(call cc-option, -Wvla) | ||
90 | |||
91 | warning := $(warning-$(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS))) | ||
92 | warning += $(warning-$(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS))) | ||
93 | warning += $(warning-$(findstring 3, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS))) | ||
94 | |||
95 | ifeq ("$(strip $(warning))","") | ||
96 | $(error W=$(KBUILD_ENABLE_EXTRA_GCC_CHECKS) is unknown) | ||
97 | endif | ||
98 | |||
99 | KBUILD_CFLAGS += $(warning) | ||
84 | endif | 100 | endif |
85 | 101 | ||
86 | include scripts/Makefile.lib | 102 | include scripts/Makefile.lib |
@@ -244,14 +260,19 @@ endif | |||
244 | 260 | ||
245 | ifdef CONFIG_FTRACE_MCOUNT_RECORD | 261 | ifdef CONFIG_FTRACE_MCOUNT_RECORD |
246 | ifdef BUILD_C_RECORDMCOUNT | 262 | ifdef BUILD_C_RECORDMCOUNT |
263 | ifeq ("$(origin RECORDMCOUNT_WARN)", "command line") | ||
264 | RECORDMCOUNT_FLAGS = -w | ||
265 | endif | ||
247 | # Due to recursion, we must skip empty.o. | 266 | # Due to recursion, we must skip empty.o. |
248 | # The empty.o file is created in the make process in order to determine | 267 | # The empty.o file is created in the make process in order to determine |
249 | # the target endianness and word size. It is made before all other C | 268 | # the target endianness and word size. It is made before all other C |
250 | # files, including recordmcount. | 269 | # files, including recordmcount. |
251 | sub_cmd_record_mcount = \ | 270 | sub_cmd_record_mcount = \ |
252 | if [ $(@) != "scripts/mod/empty.o" ]; then \ | 271 | if [ $(@) != "scripts/mod/empty.o" ]; then \ |
253 | $(objtree)/scripts/recordmcount "$(@)"; \ | 272 | $(objtree)/scripts/recordmcount $(RECORDMCOUNT_FLAGS) "$(@)"; \ |
254 | fi; | 273 | fi; |
274 | recordmcount_source := $(srctree)/scripts/recordmcount.c \ | ||
275 | $(srctree)/scripts/recordmcount.h | ||
255 | else | 276 | else |
256 | sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ | 277 | sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ |
257 | "$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \ | 278 | "$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \ |
@@ -259,6 +280,7 @@ sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH | |||
259 | "$(OBJDUMP)" "$(OBJCOPY)" "$(CC) $(KBUILD_CFLAGS)" \ | 280 | "$(OBJDUMP)" "$(OBJCOPY)" "$(CC) $(KBUILD_CFLAGS)" \ |
260 | "$(LD)" "$(NM)" "$(RM)" "$(MV)" \ | 281 | "$(LD)" "$(NM)" "$(RM)" "$(MV)" \ |
261 | "$(if $(part-of-module),1,0)" "$(@)"; | 282 | "$(if $(part-of-module),1,0)" "$(@)"; |
283 | recordmcount_source := $(srctree)/scripts/recordmcount.pl | ||
262 | endif | 284 | endif |
263 | cmd_record_mcount = \ | 285 | cmd_record_mcount = \ |
264 | if [ "$(findstring -pg,$(_c_flags))" = "-pg" ]; then \ | 286 | if [ "$(findstring -pg,$(_c_flags))" = "-pg" ]; then \ |
@@ -279,13 +301,13 @@ define rule_cc_o_c | |||
279 | endef | 301 | endef |
280 | 302 | ||
281 | # Built-in and composite module parts | 303 | # Built-in and composite module parts |
282 | $(obj)/%.o: $(src)/%.c FORCE | 304 | $(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE |
283 | $(call cmd,force_checksrc) | 305 | $(call cmd,force_checksrc) |
284 | $(call if_changed_rule,cc_o_c) | 306 | $(call if_changed_rule,cc_o_c) |
285 | 307 | ||
286 | # Single-part modules are special since we need to mark them in $(MODVERDIR) | 308 | # Single-part modules are special since we need to mark them in $(MODVERDIR) |
287 | 309 | ||
288 | $(single-used-m): $(obj)/%.o: $(src)/%.c FORCE | 310 | $(single-used-m): $(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE |
289 | $(call cmd,force_checksrc) | 311 | $(call cmd,force_checksrc) |
290 | $(call if_changed_rule,cc_o_c) | 312 | $(call if_changed_rule,cc_o_c) |
291 | @{ echo $(@:.o=.ko); echo $@; } > $(MODVERDIR)/$(@F:.o=.mod) | 313 | @{ echo $(@:.o=.ko); echo $@; } > $(MODVERDIR)/$(@F:.o=.mod) |
@@ -345,7 +367,7 @@ quiet_cmd_link_o_target = LD $@ | |||
345 | cmd_link_o_target = $(if $(strip $(obj-y)),\ | 367 | cmd_link_o_target = $(if $(strip $(obj-y)),\ |
346 | $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^) \ | 368 | $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^) \ |
347 | $(cmd_secanalysis),\ | 369 | $(cmd_secanalysis),\ |
348 | rm -f $@; $(AR) rcs $@) | 370 | rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@) |
349 | 371 | ||
350 | $(builtin-target): $(obj-y) FORCE | 372 | $(builtin-target): $(obj-y) FORCE |
351 | $(call if_changed,link_o_target) | 373 | $(call if_changed,link_o_target) |
@@ -371,7 +393,7 @@ $(modorder-target): $(subdir-ym) FORCE | |||
371 | # | 393 | # |
372 | ifdef lib-target | 394 | ifdef lib-target |
373 | quiet_cmd_link_l_target = AR $@ | 395 | quiet_cmd_link_l_target = AR $@ |
374 | cmd_link_l_target = rm -f $@; $(AR) rcs $@ $(lib-y) | 396 | cmd_link_l_target = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@ $(lib-y) |
375 | 397 | ||
376 | $(lib-target): $(lib-y) FORCE | 398 | $(lib-target): $(lib-y) FORCE |
377 | $(call if_changed,link_l_target) | 399 | $(call if_changed,link_l_target) |