xref: /linux/tools/scripts/Makefile.include (revision 65fb09922d4ca5da54fe18d7b44e5961caf169ad)
19e4a6648SBorislav Petkovifneq ($(O),)
2bf35182fSDavid Howellsifeq ($(origin O), command line)
3c883122aSSteven Rostedt	dummy := $(if $(shell test -d $(O) || echo $(O)),$(error O=$(O) does not exist),)
4c883122aSSteven Rostedt	ABSOLUTE_O := $(shell cd $(O) ; pwd)
5bf35182fSDavid Howells	OUTPUT := $(ABSOLUTE_O)/$(if $(subdir),$(subdir)/)
6c883122aSSteven Rostedt	COMMAND_O := O=$(ABSOLUTE_O)
7bf35182fSDavid Howellsifeq ($(objtree),)
8bf35182fSDavid Howells	objtree := $(O)
9bf35182fSDavid Howellsendif
1098d89bfdSBorislav Petkovendif
119e4a6648SBorislav Petkovendif
1298d89bfdSBorislav Petkov
1398d89bfdSBorislav Petkov# check that the output directory actually exists
149e4a6648SBorislav Petkovifneq ($(OUTPUT),)
1598d89bfdSBorislav PetkovOUTDIR := $(shell cd $(OUTPUT) && /bin/pwd)
1698d89bfdSBorislav Petkov$(if $(OUTDIR),, $(error output directory "$(OUTPUT)" does not exist))
1798d89bfdSBorislav Petkovendif
1898d89bfdSBorislav Petkov
1998d89bfdSBorislav Petkov#
2098d89bfdSBorislav Petkov# Include saner warnings here, which can catch bugs:
2198d89bfdSBorislav Petkov#
22d8caf3ebSBorislav PetkovEXTRA_WARNINGS := -Wbad-function-cast
23d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wdeclaration-after-statement
24d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wformat-security
25d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wformat-y2k
26d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Winit-self
27d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wmissing-declarations
28d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wmissing-prototypes
29d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wnested-externs
30d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wno-system-headers
31d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wold-style-definition
32d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wpacked
33d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wredundant-decls
34d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wshadow
35d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wstrict-aliasing=3
36d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wstrict-prototypes
37d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wswitch-default
38d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wswitch-enum
39d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wundef
40d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wwrite-strings
41d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wformat
4298d89bfdSBorislav Petkov
4398d89bfdSBorislav Petkovifneq ($(findstring $(MAKEFLAGS), w),w)
4498d89bfdSBorislav PetkovPRINT_DIR = --no-print-directory
4598d89bfdSBorislav Petkovelse
4698d89bfdSBorislav PetkovNO_SUBDIR = :
4798d89bfdSBorislav Petkovendif
4898d89bfdSBorislav Petkov
49ca9dfc6cSDavid Howells#
50ca9dfc6cSDavid Howells# Define a callable command for descending to a new directory
51ca9dfc6cSDavid Howells#
52ca9dfc6cSDavid Howells# Call by doing: $(call descend,directory[,target])
53ca9dfc6cSDavid Howells#
54ca9dfc6cSDavid Howellsdescend = \
55bf35182fSDavid Howells	+mkdir -p $(OUTPUT)$(1) && \
562b73f65dSDavid Howells	$(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1) $(2)
57ca9dfc6cSDavid Howells
58bf35182fSDavid HowellsQUIET_SUBDIR0  = +$(MAKE) $(COMMAND_O) -C # space to separate -C and subdir
5998d89bfdSBorislav PetkovQUIET_SUBDIR1  =
6098d89bfdSBorislav Petkov
6198d89bfdSBorislav Petkovifneq ($(findstring $(MAKEFLAGS),s),s)
625125bc22SRobert Richter  ifneq ($(V),1)
63*65fb0992SIngo Molnar	QUIET_CC       = @echo '  CC       '$@;
64*65fb0992SIngo Molnar	QUIET_AR       = @echo '  AR       '$@;
65*65fb0992SIngo Molnar	QUIET_LINK     = @echo '  LINK     '$@;
66*65fb0992SIngo Molnar	QUIET_MKDIR    = @echo '  MKDIR    '$@;
67*65fb0992SIngo Molnar	QUIET_GEN      = @echo '  GEN      '$@;
6898d89bfdSBorislav Petkov	QUIET_SUBDIR0  = +@subdir=
69*65fb0992SIngo Molnar	QUIET_SUBDIR1  = ;$(NO_SUBDIR) \
70*65fb0992SIngo Molnar			  echo '  SUBDIR   '$$subdir; \
7198d89bfdSBorislav Petkov			 $(MAKE) $(PRINT_DIR) -C $$subdir
72*65fb0992SIngo Molnar	QUIET_FLEX     = @echo '  FLEX     '$@;
73*65fb0992SIngo Molnar	QUIET_BISON    = @echo '  BISON    '$@;
74bf35182fSDavid Howells
75bf35182fSDavid Howells	descend = \
76*65fb0992SIngo Molnar		+@echo	       '  DESCEND  '$(1); \
77bf35182fSDavid Howells		mkdir -p $(OUTPUT)$(1) && \
782b73f65dSDavid Howells		$(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1) $(2)
7998d89bfdSBorislav Petkov  endif
8098d89bfdSBorislav Petkovendif
81