2017-10-05 11:10:04 +08:00
|
|
|
include ../../scripts/Makefile.include
|
|
|
|
include ../../scripts/utilities.mak
|
|
|
|
|
|
|
|
ifeq ($(srctree),)
|
|
|
|
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
|
|
|
|
srctree := $(patsubst %/,%,$(dir $(srctree)))
|
|
|
|
srctree := $(patsubst %/,%,$(dir $(srctree)))
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(V),1)
|
|
|
|
Q =
|
|
|
|
else
|
|
|
|
Q = @
|
|
|
|
endif
|
|
|
|
|
2017-12-08 07:00:17 +08:00
|
|
|
BPF_DIR = $(srctree)/tools/lib/bpf/
|
2017-10-05 11:10:04 +08:00
|
|
|
|
|
|
|
ifneq ($(OUTPUT),)
|
2017-12-08 07:00:17 +08:00
|
|
|
BPF_PATH = $(OUTPUT)
|
2017-10-05 11:10:04 +08:00
|
|
|
else
|
2017-12-08 07:00:17 +08:00
|
|
|
BPF_PATH = $(BPF_DIR)
|
2017-10-05 11:10:04 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
LIBBPF = $(BPF_PATH)libbpf.a
|
|
|
|
|
2017-12-28 03:16:28 +08:00
|
|
|
BPFTOOL_VERSION=$(shell make --no-print-directory -sC ../../.. kernelversion)
|
|
|
|
|
2017-10-05 11:10:04 +08:00
|
|
|
$(LIBBPF): FORCE
|
|
|
|
$(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(OUTPUT) $(OUTPUT)libbpf.a FEATURES_DUMP=$(FEATURE_DUMP_EXPORT)
|
|
|
|
|
|
|
|
$(LIBBPF)-clean:
|
|
|
|
$(call QUIET_CLEAN, libbpf)
|
|
|
|
$(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(OUTPUT) clean >/dev/null
|
|
|
|
|
2017-12-08 07:00:17 +08:00
|
|
|
prefix ?= /usr/local
|
tools: bpftool: unify installation directories
Programs and documentation not managed by package manager are generally
installed under /usr/local/, instead of the user's home directory. In
particular, `man` is generally able to find manual pages under
`/usr/local/share/man`.
bpftool generally follows perf's example, and perf installs to home
directory. However bpftool requires root credentials, so it seems
sensible to follow the more common convention of installing files under
/usr/local instead. So, make /usr/local the default prefix for
installing the binary with `make install`, and the documentation with
`make doc-install`. Also, create /usr/local/sbin if it does not exist.
Note that the bash-completion file, however, is still installed under
/usr/share/bash-completion/completions, as the default setup for bash
does not attempt to load completion files under /usr/local/.
Reported-by: David Beckett <david.beckett@netronome.com>
Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2017-11-29 09:44:32 +08:00
|
|
|
bash_compdir ?= /usr/share/bash-completion/completions
|
2017-10-05 11:10:04 +08:00
|
|
|
|
|
|
|
CC = gcc
|
|
|
|
|
|
|
|
CFLAGS += -O2
|
2018-03-09 06:00:35 +08:00
|
|
|
CFLAGS += -W -Wall -Wextra -Wno-unused-parameter -Wshadow -Wno-missing-field-initializers
|
2018-01-17 07:51:47 +08:00
|
|
|
CFLAGS += -DPACKAGE='"bpftool"' -D__EXPORTED_HEADERS__ -I$(srctree)/tools/include/uapi -I$(srctree)/tools/include -I$(srctree)/tools/lib/bpf -I$(srctree)/kernel/bpf/
|
2017-12-28 03:16:28 +08:00
|
|
|
CFLAGS += -DBPFTOOL_VERSION='"$(BPFTOOL_VERSION)"'
|
2017-10-05 11:10:04 +08:00
|
|
|
LIBS = -lelf -lbfd -lopcodes $(LIBBPF)
|
|
|
|
|
2017-12-08 07:00:17 +08:00
|
|
|
INSTALL ?= install
|
|
|
|
RM ?= rm -f
|
|
|
|
|
2017-12-28 03:16:29 +08:00
|
|
|
FEATURE_USER = .bpftool
|
|
|
|
FEATURE_TESTS = libbfd disassembler-four-args
|
|
|
|
FEATURE_DISPLAY = libbfd disassembler-four-args
|
|
|
|
|
|
|
|
check_feat := 1
|
|
|
|
NON_CHECK_FEAT_TARGETS := clean uninstall doc doc-clean doc-install doc-uninstall
|
|
|
|
ifdef MAKECMDGOALS
|
|
|
|
ifeq ($(filter-out $(NON_CHECK_FEAT_TARGETS),$(MAKECMDGOALS)),)
|
|
|
|
check_feat := 0
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(check_feat),1)
|
|
|
|
ifeq ($(FEATURES_DUMP),)
|
|
|
|
include $(srctree)/tools/build/Makefile.feature
|
|
|
|
else
|
|
|
|
include $(FEATURES_DUMP)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(feature-disassembler-four-args), 1)
|
|
|
|
CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE
|
|
|
|
endif
|
|
|
|
|
2017-10-05 11:10:04 +08:00
|
|
|
include $(wildcard *.d)
|
|
|
|
|
|
|
|
all: $(OUTPUT)bpftool
|
|
|
|
|
2017-12-08 07:00:17 +08:00
|
|
|
SRCS = $(wildcard *.c)
|
|
|
|
OBJS = $(patsubst %.c,$(OUTPUT)%.o,$(SRCS)) $(OUTPUT)disasm.o
|
2017-10-10 01:30:13 +08:00
|
|
|
|
|
|
|
$(OUTPUT)disasm.o: $(srctree)/kernel/bpf/disasm.c
|
|
|
|
$(QUIET_CC)$(COMPILE.c) -MMD -o $@ $<
|
2017-10-05 11:10:04 +08:00
|
|
|
|
|
|
|
$(OUTPUT)bpftool: $(OBJS) $(LIBBPF)
|
|
|
|
$(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
|
|
|
|
|
|
|
|
$(OUTPUT)%.o: %.c
|
|
|
|
$(QUIET_CC)$(COMPILE.c) -MMD -o $@ $<
|
|
|
|
|
|
|
|
clean: $(LIBBPF)-clean
|
|
|
|
$(call QUIET_CLEAN, bpftool)
|
2017-12-08 07:00:17 +08:00
|
|
|
$(Q)$(RM) $(OUTPUT)bpftool $(OUTPUT)*.o $(OUTPUT)*.d
|
2017-10-05 11:10:04 +08:00
|
|
|
|
2017-12-08 07:00:17 +08:00
|
|
|
install: $(OUTPUT)bpftool
|
|
|
|
$(call QUIET_INSTALL, bpftool)
|
|
|
|
$(Q)$(INSTALL) -m 0755 -d $(DESTDIR)$(prefix)/sbin
|
|
|
|
$(Q)$(INSTALL) $(OUTPUT)bpftool $(DESTDIR)$(prefix)/sbin/bpftool
|
|
|
|
$(Q)$(INSTALL) -m 0755 -d $(DESTDIR)$(bash_compdir)
|
|
|
|
$(Q)$(INSTALL) -m 0644 bash-completion/bpftool $(DESTDIR)$(bash_compdir)
|
2017-10-05 11:10:04 +08:00
|
|
|
|
2017-12-08 07:00:18 +08:00
|
|
|
uninstall:
|
|
|
|
$(call QUIET_UNINST, bpftool)
|
|
|
|
$(Q)$(RM) $(DESTDIR)$(prefix)/sbin/bpftool
|
|
|
|
$(Q)$(RM) $(DESTDIR)$(bash_compdir)/bpftool
|
|
|
|
|
2017-10-05 11:10:05 +08:00
|
|
|
doc:
|
2017-12-08 07:00:17 +08:00
|
|
|
$(call descend,Documentation)
|
|
|
|
|
|
|
|
doc-clean:
|
|
|
|
$(call descend,Documentation,clean)
|
2017-10-05 11:10:05 +08:00
|
|
|
|
|
|
|
doc-install:
|
2017-12-08 07:00:17 +08:00
|
|
|
$(call descend,Documentation,install)
|
2017-10-05 11:10:05 +08:00
|
|
|
|
2017-12-08 07:00:18 +08:00
|
|
|
doc-uninstall:
|
|
|
|
$(call descend,Documentation,uninstall)
|
|
|
|
|
2017-10-05 11:10:04 +08:00
|
|
|
FORCE:
|
|
|
|
|
2017-12-08 07:00:18 +08:00
|
|
|
.PHONY: all FORCE clean install uninstall
|
|
|
|
.PHONY: doc doc-clean doc-install doc-uninstall
|
2017-10-05 11:10:04 +08:00
|
|
|
.DEFAULT_GOAL := all
|