xref: /linux/tools/scripts/Makefile.include (revision bf35182ffcd00d8b36d56210ffdac110e5624d7d)
1*bf35182fSDavid Howellsifeq ($(origin O), command line)
2c883122aSSteven Rostedt	dummy := $(if $(shell test -d $(O) || echo $(O)),$(error O=$(O) does not exist),)
3c883122aSSteven Rostedt	ABSOLUTE_O := $(shell cd $(O) ; pwd)
4*bf35182fSDavid Howells	OUTPUT := $(ABSOLUTE_O)/$(if $(subdir),$(subdir)/)
5c883122aSSteven Rostedt	COMMAND_O := O=$(ABSOLUTE_O)
6*bf35182fSDavid Howellsifeq ($(objtree),)
7*bf35182fSDavid Howells	objtree := $(O)
8*bf35182fSDavid Howellsendif
998d89bfdSBorislav Petkovendif
1098d89bfdSBorislav Petkov
1198d89bfdSBorislav Petkovifneq ($(OUTPUT),)
1298d89bfdSBorislav Petkov# check that the output directory actually exists
1398d89bfdSBorislav PetkovOUTDIR := $(shell cd $(OUTPUT) && /bin/pwd)
1498d89bfdSBorislav Petkov$(if $(OUTDIR),, $(error output directory "$(OUTPUT)" does not exist))
1598d89bfdSBorislav Petkovendif
1698d89bfdSBorislav Petkov
1798d89bfdSBorislav Petkov#
1898d89bfdSBorislav Petkov# Include saner warnings here, which can catch bugs:
1998d89bfdSBorislav Petkov#
20d8caf3ebSBorislav PetkovEXTRA_WARNINGS := -Wbad-function-cast
21d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wdeclaration-after-statement
22d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wformat-security
23d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wformat-y2k
24d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Winit-self
25d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wmissing-declarations
26d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wmissing-prototypes
27d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wnested-externs
28d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wno-system-headers
29d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wold-style-definition
30d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wpacked
31d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wredundant-decls
32d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wshadow
33d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wstrict-aliasing=3
34d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wstrict-prototypes
35d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wswitch-default
36d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wswitch-enum
37d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wundef
38d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wwrite-strings
39d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wformat
4098d89bfdSBorislav Petkov
4198d89bfdSBorislav Petkovifneq ($(findstring $(MAKEFLAGS), w),w)
4298d89bfdSBorislav PetkovPRINT_DIR = --no-print-directory
4398d89bfdSBorislav Petkovelse
4498d89bfdSBorislav PetkovNO_SUBDIR = :
4598d89bfdSBorislav Petkovendif
4698d89bfdSBorislav Petkov
47ca9dfc6cSDavid Howells#
48ca9dfc6cSDavid Howells# Define a callable command for descending to a new directory
49ca9dfc6cSDavid Howells#
50ca9dfc6cSDavid Howells# Call by doing: $(call descend,directory[,target])
51ca9dfc6cSDavid Howells#
52ca9dfc6cSDavid Howellsdescend = \
53*bf35182fSDavid Howells	+mkdir -p $(OUTPUT)$(1) && \
54*bf35182fSDavid Howells	$(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1)
55ca9dfc6cSDavid Howells
56*bf35182fSDavid HowellsQUIET_SUBDIR0  = +$(MAKE) $(COMMAND_O) -C # space to separate -C and subdir
5798d89bfdSBorislav PetkovQUIET_SUBDIR1  =
5898d89bfdSBorislav Petkov
5998d89bfdSBorislav Petkovifneq ($(findstring $(MAKEFLAGS),s),s)
6098d89bfdSBorislav Petkovifndef V
6198d89bfdSBorislav Petkov	QUIET_CC       = @echo '   ' CC $@;
6298d89bfdSBorislav Petkov	QUIET_AR       = @echo '   ' AR $@;
6398d89bfdSBorislav Petkov	QUIET_LINK     = @echo '   ' LINK $@;
6498d89bfdSBorislav Petkov	QUIET_MKDIR    = @echo '   ' MKDIR $@;
6598d89bfdSBorislav Petkov	QUIET_GEN      = @echo '   ' GEN $@;
6698d89bfdSBorislav Petkov	QUIET_SUBDIR0  = +@subdir=
6798d89bfdSBorislav Petkov	QUIET_SUBDIR1  = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \
6898d89bfdSBorislav Petkov			 $(MAKE) $(PRINT_DIR) -C $$subdir
6998d89bfdSBorislav Petkov	QUIET_FLEX     = @echo '   ' FLEX $@;
7098d89bfdSBorislav Petkov	QUIET_BISON    = @echo '   ' BISON $@;
71*bf35182fSDavid Howells
72*bf35182fSDavid Howells	descend = \
73*bf35182fSDavid Howells		@echo '   ' DESCEND $(1); \
74*bf35182fSDavid Howells		mkdir -p $(OUTPUT)$(1) && \
75*bf35182fSDavid Howells		$(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1)
7698d89bfdSBorislav Petkovendif
7798d89bfdSBorislav Petkovendif
78