xref: /linux/tools/scripts/Makefile.include (revision 3866058ef15b6ae6f4ff48e088428b46bcc43fa1)
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-prototypes
36d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wswitch-default
37d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wswitch-enum
38d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wundef
39d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wwrite-strings
40d8caf3ebSBorislav PetkovEXTRA_WARNINGS += -Wformat
4198d89bfdSBorislav Petkov
42*3866058eSDavid Carrillo-CisnerosCC_NO_CLANG := $(shell $(CC) -dM -E -x c /dev/null | grep -Fq "__clang__"; echo $$?)
43*3866058eSDavid Carrillo-Cisneros
44*3866058eSDavid Carrillo-Cisnerosifeq ($(CC_NO_CLANG), 1)
45093b75efSArnaldo Carvalho de MeloEXTRA_WARNINGS += -Wstrict-aliasing=3
46093b75efSArnaldo Carvalho de Meloendif
47093b75efSArnaldo Carvalho de Melo
483337e682SArnaldo Carvalho de Melo# Hack to avoid type-punned warnings on old systems such as RHEL5:
493337e682SArnaldo Carvalho de Melo# We should be changing CFLAGS and checking gcc version, but this
503337e682SArnaldo Carvalho de Melo# will do for now and keep the above -Wstrict-aliasing=3 in place
513337e682SArnaldo Carvalho de Melo# in newer systems.
523337e682SArnaldo Carvalho de Melo# Needed for the __raw_cmpxchg in tools/arch/x86/include/asm/cmpxchg.h
533337e682SArnaldo Carvalho de Meloifneq ($(filter 3.%,$(MAKE_VERSION)),)  # make-3
543337e682SArnaldo Carvalho de MeloEXTRA_WARNINGS += -fno-strict-aliasing
553337e682SArnaldo Carvalho de Meloendif
563337e682SArnaldo Carvalho de Melo
5798d89bfdSBorislav Petkovifneq ($(findstring $(MAKEFLAGS), w),w)
5898d89bfdSBorislav PetkovPRINT_DIR = --no-print-directory
5998d89bfdSBorislav Petkovelse
6098d89bfdSBorislav PetkovNO_SUBDIR = :
6198d89bfdSBorislav Petkovendif
6298d89bfdSBorislav Petkov
636f0fa58eSMasahiro Yamadaifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
64e572d088SJosh Poimboeuf  silent=1
65e572d088SJosh Poimboeufendif
66e572d088SJosh Poimboeuf
67ca9dfc6cSDavid Howells#
68ca9dfc6cSDavid Howells# Define a callable command for descending to a new directory
69ca9dfc6cSDavid Howells#
70ca9dfc6cSDavid Howells# Call by doing: $(call descend,directory[,target])
71ca9dfc6cSDavid Howells#
72ca9dfc6cSDavid Howellsdescend = \
73bf35182fSDavid Howells	+mkdir -p $(OUTPUT)$(1) && \
742b73f65dSDavid Howells	$(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1) $(2)
75ca9dfc6cSDavid Howells
76bf35182fSDavid HowellsQUIET_SUBDIR0  = +$(MAKE) $(COMMAND_O) -C # space to separate -C and subdir
7798d89bfdSBorislav PetkovQUIET_SUBDIR1  =
7898d89bfdSBorislav Petkov
79e572d088SJosh Poimboeufifneq ($(silent),1)
805125bc22SRobert Richter  ifneq ($(V),1)
8165fb0992SIngo Molnar	QUIET_CC       = @echo '  CC       '$@;
82bdebbacdSJiri Olsa	QUIET_CC_FPIC  = @echo '  CC FPIC  '$@;
8365fb0992SIngo Molnar	QUIET_AR       = @echo '  AR       '$@;
8465fb0992SIngo Molnar	QUIET_LINK     = @echo '  LINK     '$@;
8565fb0992SIngo Molnar	QUIET_MKDIR    = @echo '  MKDIR    '$@;
8665fb0992SIngo Molnar	QUIET_GEN      = @echo '  GEN      '$@;
8798d89bfdSBorislav Petkov	QUIET_SUBDIR0  = +@subdir=
8865fb0992SIngo Molnar	QUIET_SUBDIR1  = ;$(NO_SUBDIR) \
8965fb0992SIngo Molnar			  echo '  SUBDIR   '$$subdir; \
9098d89bfdSBorislav Petkov			 $(MAKE) $(PRINT_DIR) -C $$subdir
9165fb0992SIngo Molnar	QUIET_FLEX     = @echo '  FLEX     '$@;
9265fb0992SIngo Molnar	QUIET_BISON    = @echo '  BISON    '$@;
93bf35182fSDavid Howells
94bf35182fSDavid Howells	descend = \
9565fb0992SIngo Molnar		+@echo	       '  DESCEND  '$(1); \
96bf35182fSDavid Howells		mkdir -p $(OUTPUT)$(1) && \
972b73f65dSDavid Howells		$(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1) $(2)
98b7248defSJiri Olsa
99b7248defSJiri Olsa	QUIET_CLEAN    = @printf '  CLEAN    %s\n' $1;
100b7248defSJiri Olsa	QUIET_INSTALL  = @printf '  INSTALL  %s\n' $1;
10198d89bfdSBorislav Petkov  endif
10298d89bfdSBorislav Petkovendif
103