blob: 8abbef164b4eeaf5fff90118f201dce07539ed81 [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
35EXTRA_WARNINGS += -Wstrict-aliasing=3
36EXTRA_WARNINGS += -Wstrict-prototypes
37EXTRA_WARNINGS += -Wswitch-default
38EXTRA_WARNINGS += -Wswitch-enum
39EXTRA_WARNINGS += -Wundef
40EXTRA_WARNINGS += -Wwrite-strings
41EXTRA_WARNINGS += -Wformat
Borislav Petkov98d89bf2012-04-11 18:36:14 +020042
43ifneq ($(findstring $(MAKEFLAGS), w),w)
44PRINT_DIR = --no-print-directory
45else
46NO_SUBDIR = :
47endif
48
David Howellsca9dfc62012-11-05 15:15:24 +000049#
50# Define a callable command for descending to a new directory
51#
52# Call by doing: $(call descend,directory[,target])
53#
54descend = \
David Howellsbf351822012-11-05 21:02:08 +000055 +mkdir -p $(OUTPUT)$(1) && \
David Howells2b73f652012-11-13 14:14:38 -030056 $(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1) $(2)
David Howellsca9dfc62012-11-05 15:15:24 +000057
David Howellsbf351822012-11-05 21:02:08 +000058QUIET_SUBDIR0 = +$(MAKE) $(COMMAND_O) -C # space to separate -C and subdir
Borislav Petkov98d89bf2012-04-11 18:36:14 +020059QUIET_SUBDIR1 =
60
61ifneq ($(findstring $(MAKEFLAGS),s),s)
Ingo Molnar65fb0992013-10-09 11:49:27 +020062 ifneq ($(V),1)
63 QUIET_CC = @echo ' CC '$@;
Jiri Olsabdebbac2013-12-19 14:42:03 +010064 QUIET_CC_FPIC = @echo ' CC FPIC '$@;
Ingo Molnar65fb0992013-10-09 11:49:27 +020065 QUIET_AR = @echo ' AR '$@;
66 QUIET_LINK = @echo ' LINK '$@;
67 QUIET_MKDIR = @echo ' MKDIR '$@;
68 QUIET_GEN = @echo ' GEN '$@;
Borislav Petkov98d89bf2012-04-11 18:36:14 +020069 QUIET_SUBDIR0 = +@subdir=
Ingo Molnar65fb0992013-10-09 11:49:27 +020070 QUIET_SUBDIR1 = ;$(NO_SUBDIR) \
71 echo ' SUBDIR '$$subdir; \
Borislav Petkov98d89bf2012-04-11 18:36:14 +020072 $(MAKE) $(PRINT_DIR) -C $$subdir
Ingo Molnar65fb0992013-10-09 11:49:27 +020073 QUIET_FLEX = @echo ' FLEX '$@;
74 QUIET_BISON = @echo ' BISON '$@;
David Howellsbf351822012-11-05 21:02:08 +000075
76 descend = \
Ingo Molnar65fb0992013-10-09 11:49:27 +020077 +@echo ' DESCEND '$(1); \
David Howellsbf351822012-11-05 21:02:08 +000078 mkdir -p $(OUTPUT)$(1) && \
David Howells2b73f652012-11-13 14:14:38 -030079 $(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1) $(2)
Jiri Olsab7248de2013-12-19 14:42:00 +010080
81 QUIET_CLEAN = @printf ' CLEAN %s\n' $1;
82 QUIET_INSTALL = @printf ' INSTALL %s\n' $1;
Ingo Molnar65fb0992013-10-09 11:49:27 +020083 endif
Borislav Petkov98d89bf2012-04-11 18:36:14 +020084endif