Linux 5.1.15
[linux/fpc-iii.git] / tools / bpf / bpftool / Makefile
blob4ad1f0894d5312ef81e162cc5ecd34f114405725
1 include ../../scripts/Makefile.include
2 include ../../scripts/utilities.mak
4 ifeq ($(srctree),)
5 srctree := $(patsubst %/,%,$(dir $(CURDIR)))
6 srctree := $(patsubst %/,%,$(dir $(srctree)))
7 srctree := $(patsubst %/,%,$(dir $(srctree)))
8 endif
10 ifeq ($(V),1)
11 Q =
12 else
13 Q = @
14 endif
16 BPF_DIR = $(srctree)/tools/lib/bpf/
18 ifneq ($(OUTPUT),)
19 BPF_PATH = $(OUTPUT)
20 else
21 BPF_PATH = $(BPF_DIR)
22 endif
24 LIBBPF = $(BPF_PATH)libbpf.a
26 BPFTOOL_VERSION := $(shell make --no-print-directory -sC ../../.. kernelversion)
28 $(LIBBPF): FORCE
29 $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(OUTPUT) $(OUTPUT)libbpf.a
31 $(LIBBPF)-clean:
32 $(call QUIET_CLEAN, libbpf)
33 $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(OUTPUT) clean >/dev/null
35 prefix ?= /usr/local
36 bash_compdir ?= /usr/share/bash-completion/completions
38 CFLAGS += -O2
39 CFLAGS += -W -Wall -Wextra -Wno-unused-parameter -Wshadow -Wno-missing-field-initializers
40 CFLAGS += -DPACKAGE='"bpftool"' -D__EXPORTED_HEADERS__ \
41 -I$(srctree)/kernel/bpf/ \
42 -I$(srctree)/tools/include \
43 -I$(srctree)/tools/include/uapi \
44 -I$(srctree)/tools/lib/bpf \
45 -I$(srctree)/tools/perf
46 CFLAGS += -DBPFTOOL_VERSION='"$(BPFTOOL_VERSION)"'
47 ifneq ($(EXTRA_CFLAGS),)
48 CFLAGS += $(EXTRA_CFLAGS)
49 endif
50 ifneq ($(EXTRA_LDFLAGS),)
51 LDFLAGS += $(EXTRA_LDFLAGS)
52 endif
54 LIBS = -lelf $(LIBBPF)
56 INSTALL ?= install
57 RM ?= rm -f
59 FEATURE_USER = .bpftool
60 FEATURE_TESTS = libbfd disassembler-four-args reallocarray
61 FEATURE_DISPLAY = libbfd disassembler-four-args
63 check_feat := 1
64 NON_CHECK_FEAT_TARGETS := clean uninstall doc doc-clean doc-install doc-uninstall
65 ifdef MAKECMDGOALS
66 ifeq ($(filter-out $(NON_CHECK_FEAT_TARGETS),$(MAKECMDGOALS)),)
67 check_feat := 0
68 endif
69 endif
71 ifeq ($(check_feat),1)
72 ifeq ($(FEATURES_DUMP),)
73 include $(srctree)/tools/build/Makefile.feature
74 else
75 include $(FEATURES_DUMP)
76 endif
77 endif
79 ifeq ($(feature-disassembler-four-args), 1)
80 CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE
81 endif
83 ifeq ($(feature-reallocarray), 0)
84 CFLAGS += -DCOMPAT_NEED_REALLOCARRAY
85 endif
87 include $(wildcard $(OUTPUT)*.d)
89 all: $(OUTPUT)bpftool
91 BFD_SRCS = jit_disasm.c
93 SRCS = $(filter-out $(BFD_SRCS),$(wildcard *.c))
95 ifeq ($(feature-libbfd),1)
96 LIBS += -lbfd -ldl -lopcodes
97 else ifeq ($(feature-libbfd-liberty),1)
98 LIBS += -lbfd -ldl -lopcodes -liberty
99 else ifeq ($(feature-libbfd-liberty-z),1)
100 LIBS += -lbfd -ldl -lopcodes -liberty -lz
101 endif
103 ifneq ($(filter -lbfd,$(LIBS)),)
104 CFLAGS += -DHAVE_LIBBFD_SUPPORT
105 SRCS += $(BFD_SRCS)
106 endif
108 OBJS = $(patsubst %.c,$(OUTPUT)%.o,$(SRCS)) $(OUTPUT)disasm.o
110 $(OUTPUT)disasm.o: $(srctree)/kernel/bpf/disasm.c
111 $(QUIET_CC)$(COMPILE.c) -MMD -o $@ $<
113 $(OUTPUT)bpftool: $(OBJS) $(LIBBPF)
114 $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
116 $(OUTPUT)%.o: %.c
117 $(QUIET_CC)$(COMPILE.c) -MMD -o $@ $<
119 clean: $(LIBBPF)-clean
120 $(call QUIET_CLEAN, bpftool)
121 $(Q)$(RM) $(OUTPUT)bpftool $(OUTPUT)*.o $(OUTPUT)*.d
122 $(call QUIET_CLEAN, core-gen)
123 $(Q)$(RM) $(OUTPUT)FEATURE-DUMP.bpftool
125 install: $(OUTPUT)bpftool
126 $(call QUIET_INSTALL, bpftool)
127 $(Q)$(INSTALL) -m 0755 -d $(DESTDIR)$(prefix)/sbin
128 $(Q)$(INSTALL) $(OUTPUT)bpftool $(DESTDIR)$(prefix)/sbin/bpftool
129 $(Q)$(INSTALL) -m 0755 -d $(DESTDIR)$(bash_compdir)
130 $(Q)$(INSTALL) -m 0644 bash-completion/bpftool $(DESTDIR)$(bash_compdir)
132 uninstall:
133 $(call QUIET_UNINST, bpftool)
134 $(Q)$(RM) $(DESTDIR)$(prefix)/sbin/bpftool
135 $(Q)$(RM) $(DESTDIR)$(bash_compdir)/bpftool
137 doc:
138 $(call descend,Documentation)
140 doc-clean:
141 $(call descend,Documentation,clean)
143 doc-install:
144 $(call descend,Documentation,install)
146 doc-uninstall:
147 $(call descend,Documentation,uninstall)
149 FORCE:
151 .PHONY: all FORCE clean install uninstall
152 .PHONY: doc doc-clean doc-install doc-uninstall
153 .DEFAULT_GOAL := all