1 include ../../scripts/Makefile.include
3 include ../../scripts/utilities.mak
6 srctree := $(patsubst %/,%,$(dir $(CURDIR)))
7 srctree := $(patsubst %/,%,$(dir $(srctree)))
8 srctree := $(patsubst %/,%,$(dir $(srctree)))
9 #$(info Determined 'srctree' to be $(srctree))
13 #$(info Determined 'objtree' to be $(objtree))
17 #$(info Determined 'OUTPUT' to be $(OUTPUT))
18 # Adding $(OUTPUT) as a directory to look for source files,
19 # because use generated output files as sources dependency
20 # for flex/bison parsers.
31 BPF_DIR = $(srctree)/tools/lib/bpf/
39 LIBBPF = $(BPF_PATH)libbpf.a
42 $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(OUTPUT) $(OUTPUT)libbpf.a FEATURES_DUMP=$(FEATURE_DUMP_EXPORT)
45 $(call QUIET_CLEAN, libbpf)
46 $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(OUTPUT) clean >/dev/null
49 bash_compdir ?= /usr/share/bash-completion/completions
54 CFLAGS += -W -Wall -Wextra -Wno-unused-parameter -Wshadow
55 CFLAGS += -D__EXPORTED_HEADERS__ -I$(srctree)/tools/include/uapi -I$(srctree)/tools/include -I$(srctree)/tools/lib/bpf -I$(srctree)/kernel/bpf/
56 LIBS = -lelf -lbfd -lopcodes $(LIBBPF)
58 include $(wildcard *.d)
63 OBJS=$(patsubst %.c,$(OUTPUT)%.o,$(SRCS)) $(OUTPUT)disasm.o
65 $(OUTPUT)disasm.o: $(srctree)/kernel/bpf/disasm.c
66 $(QUIET_CC)$(COMPILE.c) -MMD -o $@ $<
68 $(OUTPUT)bpftool: $(OBJS) $(LIBBPF)
69 $(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
72 $(QUIET_CC)$(COMPILE.c) -MMD -o $@ $<
74 clean: $(LIBBPF)-clean
75 $(call QUIET_CLEAN, bpftool)
76 $(Q)rm -rf $(OUTPUT)bpftool $(OUTPUT)*.o $(OUTPUT)*.d
79 install -m 0755 -d $(prefix)/sbin
80 install $(OUTPUT)bpftool $(prefix)/sbin/bpftool
81 install -m 0755 -d $(bash_compdir)
82 install -m 0644 bash-completion/bpftool $(bash_compdir)
85 $(Q)$(MAKE) -C Documentation/
88 $(Q)$(MAKE) -C Documentation/ install
92 .PHONY: all clean FORCE install doc doc-install