blob: 0d0506d55c71348a3ddce72fcec03824ed987bf3 [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)
Robert Richter5125bc22013-05-03 15:49:53 +020062ifneq ($(V),1)
Borislav Petkov98d89bf2012-04-11 18:36:14 +020063 QUIET_CC = @echo ' ' CC $@;
64 QUIET_AR = @echo ' ' AR $@;
65 QUIET_LINK = @echo ' ' LINK $@;
66 QUIET_MKDIR = @echo ' ' MKDIR $@;
67 QUIET_GEN = @echo ' ' GEN $@;
68 QUIET_SUBDIR0 = +@subdir=
69 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
70 $(MAKE) $(PRINT_DIR) -C $$subdir
71 QUIET_FLEX = @echo ' ' FLEX $@;
72 QUIET_BISON = @echo ' ' BISON $@;
David Howellsbf351822012-11-05 21:02:08 +000073
74 descend = \
Borislav Petkova50e4332013-02-20 16:32:28 +010075 +@echo ' ' DESCEND $(1); \
David Howellsbf351822012-11-05 21:02:08 +000076 mkdir -p $(OUTPUT)$(1) && \
David Howells2b73f652012-11-13 14:14:38 -030077 $(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1) $(2)
Borislav Petkov98d89bf2012-04-11 18:36:14 +020078endif
79endif