xref: /aosp_15_r20/external/bpftool/src/Makefile.include (revision 858ea5e570667251cdc31d3fe7b846b591105938)
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_CONFIG  ?= llvm-config$(LLVM_VERSION)
11LLVM_STRIP   ?= llvm-strip$(LLVM_VERSION)
12
13ifneq ($(LLVM),)
14  $(if $(findstring default,$(origin AR)),$(eval AR := llvm-ar$(LLVM_VERSION)))
15  $(if $(findstring default,$(origin CC)),$(eval CC := clang$(LLVM_VERSION)))
16  $(if $(findstring default,$(origin LD)),$(eval LD := ld.lld$(LLVM_VERSION)))
17  HOSTAR ?= llvm-ar
18  HOSTCC ?= clang
19  HOSTLD ?= ld.lld
20else
21  $(if $(findstring default,$(origin AR)),$(eval AR = $(CROSS_COMPILE)$(AR)))
22  $(if $(findstring default,$(origin CC)),$(eval CC = $(CROSS_COMPILE)$(CC)))
23  $(if $(findstring default,$(origin LD)),$(eval LD = $(CROSS_COMPILE)$(LD)))
24  HOSTAR ?= ar
25  HOSTCC ?= gcc
26  HOSTLD ?= ld
27endif
28
29EXTRA_WARNINGS := \
30	-Wbad-function-cast \
31	-Wdeclaration-after-statement \
32	-Wformat-security \
33	-Wformat-y2k \
34	-Winit-self \
35	-Wmissing-declarations \
36	-Wmissing-prototypes \
37	-Wold-style-definition \
38	-Wpacked \
39	-Wredundant-decls \
40	-Wshadow \
41	-Wstrict-prototypes \
42	-Wswitch-default \
43	-Wundef \
44	-Wwrite-strings \
45
46ifeq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
47  ifneq ($(V),1)
48
49    define def_quiet_msg
50      $(eval QUIET_$(1) = @printf '  %-9s%s\n' $(1) $$@;)
51    endef
52    $(foreach action,CC CLANG LINK MKDIR GEN,$(call def_quiet_msg,$(action)))
53
54    define def_quiet_msg_subdir
55      $(eval QUIET_$(1) = @printf '  %-9s%s\n' $(1) $$1;)
56    endef
57    $(foreach action,CLEAN INSTALL UNINST,$(call def_quiet_msg_subdir,$(action)))
58
59    define descend
60      @printf '  DESCEND  %s\n' $(1); mkdir -p $(OUTPUT)$(1) && \
61        $(MAKE) --no-print-directory -C $(1) $(2)
62    endef
63
64  endif
65endif
66