blob: ccad8ce925e427b845972adcf75694edf0e92b63 [file] [log] [blame]
Borislav Petkov9e4a6642013-02-20 16:32:29 +01001ifneq ($(O),)
David Howellsbf351822012-11-05 21:02:08 +00002ifeq ($(origin O), command line)
Steven Rostedtc8831222012-08-13 10:23:02 -04003 dummy := $(if $(shell test -d $(O) || echo $(O)),$(error O=$(O) does not exist),)
4 ABSOLUTE_O := $(shell cd $(O) ; pwd)
David Howellsbf351822012-11-05 21:02:08 +00005 OUTPUT := $(ABSOLUTE_O)/$(if $(subdir),$(subdir)/)
Steven Rostedtc8831222012-08-13 10:23:02 -04006 COMMAND_O := O=$(ABSOLUTE_O)
David Howellsbf351822012-11-05 21:02:08 +00007ifeq ($(objtree),)
8 objtree := $(O)
9endif
Borislav Petkov98d89bf2012-04-11 18:36:14 +020010endif
Borislav Petkov9e4a6642013-02-20 16:32:29 +010011endif
Borislav Petkov98d89bf2012-04-11 18:36:14 +020012
Borislav Petkov98d89bf2012-04-11 18:36:14 +020013# check that the output directory actually exists
Borislav Petkov9e4a6642013-02-20 16:32:29 +010014ifneq ($(OUTPUT),)
Borislav Petkov98d89bf2012-04-11 18:36:14 +020015OUTDIR := $(shell cd $(OUTPUT) && /bin/pwd)
16$(if $(OUTDIR),, $(error output directory "$(OUTPUT)" does not exist))
17endif
18
19#
20# Include saner warnings here, which can catch bugs:
21#
Borislav Petkovd8caf3e2012-04-11 18:36:15 +020022EXTRA_WARNINGS := -Wbad-function-cast
23EXTRA_WARNINGS += -Wdeclaration-after-statement
24EXTRA_WARNINGS += -Wformat-security
25EXTRA_WARNINGS += -Wformat-y2k
26EXTRA_WARNINGS += -Winit-self
27EXTRA_WARNINGS += -Wmissing-declarations
28EXTRA_WARNINGS += -Wmissing-prototypes
29EXTRA_WARNINGS += -Wnested-externs
30EXTRA_WARNINGS += -Wno-system-headers
31EXTRA_WARNINGS += -Wold-style-definition
32EXTRA_WARNINGS += -Wpacked
33EXTRA_WARNINGS += -Wredundant-decls
34EXTRA_WARNINGS += -Wshadow
Borislav Petkovd8caf3e2012-04-11 18:36:15 +020035EXTRA_WARNINGS += -Wstrict-prototypes
36EXTRA_WARNINGS += -Wswitch-default
37EXTRA_WARNINGS += -Wswitch-enum
38EXTRA_WARNINGS += -Wundef
39EXTRA_WARNINGS += -Wwrite-strings
40EXTRA_WARNINGS += -Wformat
Borislav Petkov98d89bf2012-04-11 18:36:14 +020041
Arnaldo Carvalho de Melo093b75e2017-02-14 10:34:35 -030042ifneq ($(CC), clang)
43EXTRA_WARNINGS += -Wstrict-aliasing=3
44endif
45
Arnaldo Carvalho de Melo3337e682017-02-22 16:54:53 -030046# Hack to avoid type-punned warnings on old systems such as RHEL5:
47# We should be changing CFLAGS and checking gcc version, but this
48# will do for now and keep the above -Wstrict-aliasing=3 in place
49# in newer systems.
50# Needed for the __raw_cmpxchg in tools/arch/x86/include/asm/cmpxchg.h
51ifneq ($(filter 3.%,$(MAKE_VERSION)),) # make-3
52EXTRA_WARNINGS += -fno-strict-aliasing
53endif
54
Borislav Petkov98d89bf2012-04-11 18:36:14 +020055ifneq ($(findstring $(MAKEFLAGS), w),w)
56PRINT_DIR = --no-print-directory
57else
58NO_SUBDIR = :
59endif
60
Masahiro Yamada6f0fa582017-05-19 20:42:30 +090061ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
Josh Poimboeufe572d082017-01-18 22:16:55 -060062 silent=1
63endif
Josh Poimboeufe572d082017-01-18 22:16:55 -060064
David Howellsca9dfc62012-11-05 15:15:24 +000065#
66# Define a callable command for descending to a new directory
67#
68# Call by doing: $(call descend,directory[,target])
69#
70descend = \
David Howellsbf351822012-11-05 21:02:08 +000071 +mkdir -p $(OUTPUT)$(1) && \
David Howells2b73f652012-11-13 14:14:38 -030072 $(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1) $(2)
David Howellsca9dfc62012-11-05 15:15:24 +000073
David Howellsbf351822012-11-05 21:02:08 +000074QUIET_SUBDIR0 = +$(MAKE) $(COMMAND_O) -C # space to separate -C and subdir
Borislav Petkov98d89bf2012-04-11 18:36:14 +020075QUIET_SUBDIR1 =
76
Josh Poimboeufe572d082017-01-18 22:16:55 -060077ifneq ($(silent),1)
Ingo Molnar65fb0992013-10-09 11:49:27 +020078 ifneq ($(V),1)
79 QUIET_CC = @echo ' CC '$@;
Jiri Olsabdebbac2013-12-19 14:42:03 +010080 QUIET_CC_FPIC = @echo ' CC FPIC '$@;
Ingo Molnar65fb0992013-10-09 11:49:27 +020081 QUIET_AR = @echo ' AR '$@;
82 QUIET_LINK = @echo ' LINK '$@;
83 QUIET_MKDIR = @echo ' MKDIR '$@;
84 QUIET_GEN = @echo ' GEN '$@;
Borislav Petkov98d89bf2012-04-11 18:36:14 +020085 QUIET_SUBDIR0 = +@subdir=
Ingo Molnar65fb0992013-10-09 11:49:27 +020086 QUIET_SUBDIR1 = ;$(NO_SUBDIR) \
87 echo ' SUBDIR '$$subdir; \
Borislav Petkov98d89bf2012-04-11 18:36:14 +020088 $(MAKE) $(PRINT_DIR) -C $$subdir
Ingo Molnar65fb0992013-10-09 11:49:27 +020089 QUIET_FLEX = @echo ' FLEX '$@;
90 QUIET_BISON = @echo ' BISON '$@;
David Howellsbf351822012-11-05 21:02:08 +000091
92 descend = \
Ingo Molnar65fb0992013-10-09 11:49:27 +020093 +@echo ' DESCEND '$(1); \
David Howellsbf351822012-11-05 21:02:08 +000094 mkdir -p $(OUTPUT)$(1) && \
David Howells2b73f652012-11-13 14:14:38 -030095 $(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1) $(2)
Jiri Olsab7248de2013-12-19 14:42:00 +010096
97 QUIET_CLEAN = @printf ' CLEAN %s\n' $1;
98 QUIET_INSTALL = @printf ' INSTALL %s\n' $1;
Ingo Molnar65fb0992013-10-09 11:49:27 +020099 endif
Borislav Petkov98d89bf2012-04-11 18:36:14 +0200100endif