• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2
3ifneq ($(OUTPUT),)
4$(if $(shell [ -d "$(OUTPUT)" -a -x "$(OUTPUT)" ] && echo 1),, \
5  $(error output directory "$(OUTPUT)" does not exist))
6endif
7
8LLVM_VERSION ?=
9CLANG        ?= clang$(LLVM_VERSION)
10LLVM_STRIP   ?= llvm-strip$(LLVM_VERSION)
11
12ifneq ($(LLVM),)
13  $(if $(findstring default,$(origin CC)),$(eval CC := clang$(LLVM_VERSION)))
14  $(if $(findstring default,$(origin LD)),$(eval LD := ld.lld$(LLVM_VERSION)))
15  HOSTCC ?= clang
16  HOSTLD ?= ld.lld
17else
18  $(if $(findstring default,$(origin CC)),$(eval CC = $(CROSS_COMPILE)$(CC)))
19  $(if $(findstring default,$(origin LD)),$(eval LD = $(CROSS_COMPILE)$(LD)))
20  HOSTCC ?= gcc
21  HOSTLD ?= ld
22endif
23
24EXTRA_WARNINGS := \
25	-Wbad-function-cast \
26	-Wdeclaration-after-statement \
27	-Wformat-security \
28	-Wformat-y2k \
29	-Winit-self \
30	-Wmissing-declarations \
31	-Wmissing-prototypes \
32	-Wold-style-definition \
33	-Wpacked \
34	-Wredundant-decls \
35	-Wshadow \
36	-Wstrict-prototypes \
37	-Wswitch-default \
38	-Wundef \
39	-Wwrite-strings \
40
41ifeq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
42  ifneq ($(V),1)
43
44    define def_quiet_msg
45      $(eval QUIET_$(1) = @printf '  %-9s%s\n' $(1) $$@;)
46    endef
47    $(foreach action,CC CLANG LINK MKDIR GEN,$(call def_quiet_msg,$(action)))
48
49    define def_quiet_msg_subdir
50      $(eval QUIET_$(1) = @printf '  %-9s%s\n' $(1) $$1;)
51    endef
52    $(foreach action,CLEAN INSTALL UNINST,$(call def_quiet_msg_subdir,$(action)))
53
54    define descend
55      @printf '  DESCEND  %s\n' $(1); mkdir -p $(OUTPUT)$(1) && \
56        $(MAKE) --no-print-directory -C $(1) $(2)
57    endef
58
59  endif
60endif
61