OSDN Git Service

clk: at91: fix masterck name
[uclinux-h8/linux.git] / tools / bpf / bpftool / Makefile
1 include ../../scripts/Makefile.include
2 include ../../scripts/utilities.mak
3
4 ifeq ($(srctree),)
5 srctree := $(patsubst %/,%,$(dir $(CURDIR)))
6 srctree := $(patsubst %/,%,$(dir $(srctree)))
7 srctree := $(patsubst %/,%,$(dir $(srctree)))
8 endif
9
10 ifeq ($(V),1)
11   Q =
12 else
13   Q = @
14 endif
15
16 BPF_DIR = $(srctree)/tools/lib/bpf/
17
18 ifneq ($(OUTPUT),)
19   BPF_PATH = $(OUTPUT)
20 else
21   BPF_PATH = $(BPF_DIR)
22 endif
23
24 LIBBPF = $(BPF_PATH)libbpf.a
25
26 BPFTOOL_VERSION := $(shell make --no-print-directory -sC ../../.. kernelversion)
27
28 $(LIBBPF): FORCE
29         $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(OUTPUT) $(OUTPUT)libbpf.a
30
31 $(LIBBPF)-clean:
32         $(call QUIET_CLEAN, libbpf)
33         $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(OUTPUT) clean >/dev/null
34
35 prefix ?= /usr/local
36 bash_compdir ?= /usr/share/bash-completion/completions
37
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
53
54 LIBS = -lelf $(LIBBPF)
55
56 INSTALL ?= install
57 RM ?= rm -f
58
59 FEATURE_USER = .bpftool
60 FEATURE_TESTS = libbfd disassembler-four-args reallocarray
61 FEATURE_DISPLAY = libbfd disassembler-four-args
62
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
70
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
78
79 ifeq ($(feature-disassembler-four-args), 1)
80 CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE
81 endif
82
83 ifeq ($(feature-reallocarray), 0)
84 CFLAGS += -DCOMPAT_NEED_REALLOCARRAY
85 endif
86
87 include $(wildcard $(OUTPUT)*.d)
88
89 all: $(OUTPUT)bpftool
90
91 BFD_SRCS = jit_disasm.c
92
93 SRCS = $(filter-out $(BFD_SRCS),$(wildcard *.c))
94
95 ifeq ($(feature-libbfd),1)
96 CFLAGS += -DHAVE_LIBBFD_SUPPORT
97 SRCS += $(BFD_SRCS)
98 LIBS += -lbfd -lopcodes
99 endif
100
101 OBJS = $(patsubst %.c,$(OUTPUT)%.o,$(SRCS)) $(OUTPUT)disasm.o
102
103 $(OUTPUT)disasm.o: $(srctree)/kernel/bpf/disasm.c
104         $(QUIET_CC)$(COMPILE.c) -MMD -o $@ $<
105
106 $(OUTPUT)bpftool: $(OBJS) $(LIBBPF)
107         $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
108
109 $(OUTPUT)%.o: %.c
110         $(QUIET_CC)$(COMPILE.c) -MMD -o $@ $<
111
112 clean: $(LIBBPF)-clean
113         $(call QUIET_CLEAN, bpftool)
114         $(Q)$(RM) $(OUTPUT)bpftool $(OUTPUT)*.o $(OUTPUT)*.d
115         $(call QUIET_CLEAN, core-gen)
116         $(Q)$(RM) $(OUTPUT)FEATURE-DUMP.bpftool
117
118 install: $(OUTPUT)bpftool
119         $(call QUIET_INSTALL, bpftool)
120         $(Q)$(INSTALL) -m 0755 -d $(DESTDIR)$(prefix)/sbin
121         $(Q)$(INSTALL) $(OUTPUT)bpftool $(DESTDIR)$(prefix)/sbin/bpftool
122         $(Q)$(INSTALL) -m 0755 -d $(DESTDIR)$(bash_compdir)
123         $(Q)$(INSTALL) -m 0644 bash-completion/bpftool $(DESTDIR)$(bash_compdir)
124
125 uninstall:
126         $(call QUIET_UNINST, bpftool)
127         $(Q)$(RM) $(DESTDIR)$(prefix)/sbin/bpftool
128         $(Q)$(RM) $(DESTDIR)$(bash_compdir)/bpftool
129
130 doc:
131         $(call descend,Documentation)
132
133 doc-clean:
134         $(call descend,Documentation,clean)
135
136 doc-install:
137         $(call descend,Documentation,install)
138
139 doc-uninstall:
140         $(call descend,Documentation,uninstall)
141
142 FORCE:
143
144 .PHONY: all FORCE clean install uninstall
145 .PHONY: doc doc-clean doc-install doc-uninstall
146 .DEFAULT_GOAL := all