Skip to content

Commit 658e85a

Browse files
qmonnetborkmann
authored andcommitted
tools: bpftool: harmonise Makefile and Documentation/Makefile
Several minor fixes and harmonisation items for Makefiles: * Use the same mechanism for verbose/non-verbose output in two files ("$(Q)"), for all commands. * Use calls to "QUIET_INSTALL" and equivalent in Makefile. In particular, use "call(descend, ...)" instead of "make -C" to run documentation targets. * Add a "doc-clean" target, aligned on "doc" and "doc-install". * Make "install" target in Makefile depend on "bpftool". * Remove condition on DESTDIR to initialise prefix in doc Makefile. * Remove modification of VPATH based on OUTPUT, it is unused. * Formatting: harmonise spaces around equal signs. * Make install path for man pages /usr/local/man instead of /usr/local/share/man (respects the Makefile conventions, and the latter is usually a symbolic link to the former anyway). * Do not erase prefix if set by user in bpftool Makefile. * Fix install target for bpftool: append DESTDIR to install path. Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
1 parent 62cd277 commit 658e85a

2 files changed

Lines changed: 36 additions & 39 deletions

File tree

‎tools/bpf/bpftool/Documentation/Makefile‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ include ../../../scripts/utilities.mak
44
INSTALL ?= install
55
RM ?= rm -f
66

7-
# Make the path relative to DESTDIR, not prefix
8-
ifndef DESTDIR
9-
prefix ?= /usr/local
7+
ifeq ($(V),1)
8+
Q =
9+
else
10+
Q = @
1011
endif
11-
mandir ?= $(prefix)/share/man
12+
13+
prefix ?= /usr/local
14+
mandir ?= $(prefix)/man
1215
man8dir = $(mandir)/man8
1316

1417
MAN8_RST = $(wildcard *.rst)
@@ -20,15 +23,16 @@ man: man8
2023
man8: $(DOC_MAN8)
2124

2225
$(OUTPUT)%.8: %.rst
23-
rst2man $< > $@
26+
$(QUIET_GEN)rst2man $< > $@
2427

2528
clean:
26-
$(call QUIET_CLEAN, Documentation) $(RM) $(DOC_MAN8)
29+
$(call QUIET_CLEAN, Documentation)
30+
$(Q)$(RM) $(DOC_MAN8)
2731

2832
install: man
29-
$(call QUIET_INSTALL, Documentation-man) \
30-
$(INSTALL) -d -m 755 $(DESTDIR)$(man8dir); \
31-
$(INSTALL) -m 644 $(DOC_MAN8) $(DESTDIR)$(man8dir);
33+
$(call QUIET_INSTALL, Documentation-man)
34+
$(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(man8dir)
35+
$(Q)$(INSTALL) -m 644 $(DOC_MAN8) $(DESTDIR)$(man8dir)
3236

3337
.PHONY: man man8 clean install
3438
.DEFAULT_GOAL := man

‎tools/bpf/bpftool/Makefile‎

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,10 @@
11
include ../../scripts/Makefile.include
2-
32
include ../../scripts/utilities.mak
43

54
ifeq ($(srctree),)
65
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
76
srctree := $(patsubst %/,%,$(dir $(srctree)))
87
srctree := $(patsubst %/,%,$(dir $(srctree)))
9-
#$(info Determined 'srctree' to be $(srctree))
10-
endif
11-
12-
ifneq ($(objtree),)
13-
#$(info Determined 'objtree' to be $(objtree))
14-
endif
15-
16-
ifneq ($(OUTPUT),)
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.
21-
VPATH += $(OUTPUT)
22-
export VPATH
238
endif
249

2510
ifeq ($(V),1)
@@ -28,12 +13,12 @@ else
2813
Q = @
2914
endif
3015

31-
BPF_DIR = $(srctree)/tools/lib/bpf/
16+
BPF_DIR = $(srctree)/tools/lib/bpf/
3217

3318
ifneq ($(OUTPUT),)
34-
BPF_PATH=$(OUTPUT)
19+
BPF_PATH = $(OUTPUT)
3520
else
36-
BPF_PATH=$(BPF_DIR)
21+
BPF_PATH = $(BPF_DIR)
3722
endif
3823

3924
LIBBPF = $(BPF_PATH)libbpf.a
@@ -45,7 +30,7 @@ $(LIBBPF)-clean:
4530
$(call QUIET_CLEAN, libbpf)
4631
$(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(OUTPUT) clean >/dev/null
4732

48-
prefix = /usr/local
33+
prefix ?= /usr/local
4934
bash_compdir ?= /usr/share/bash-completion/completions
5035

5136
CC = gcc
@@ -55,12 +40,15 @@ CFLAGS += -W -Wall -Wextra -Wno-unused-parameter -Wshadow
5540
CFLAGS += -D__EXPORTED_HEADERS__ -I$(srctree)/tools/include/uapi -I$(srctree)/tools/include -I$(srctree)/tools/lib/bpf -I$(srctree)/kernel/bpf/
5641
LIBS = -lelf -lbfd -lopcodes $(LIBBPF)
5742

43+
INSTALL ?= install
44+
RM ?= rm -f
45+
5846
include $(wildcard *.d)
5947

6048
all: $(OUTPUT)bpftool
6149

62-
SRCS=$(wildcard *.c)
63-
OBJS=$(patsubst %.c,$(OUTPUT)%.o,$(SRCS)) $(OUTPUT)disasm.o
50+
SRCS = $(wildcard *.c)
51+
OBJS = $(patsubst %.c,$(OUTPUT)%.o,$(SRCS)) $(OUTPUT)disasm.o
6452

6553
$(OUTPUT)disasm.o: $(srctree)/kernel/bpf/disasm.c
6654
$(QUIET_CC)$(COMPILE.c) -MMD -o $@ $<
@@ -73,21 +61,26 @@ $(OUTPUT)%.o: %.c
7361

7462
clean: $(LIBBPF)-clean
7563
$(call QUIET_CLEAN, bpftool)
76-
$(Q)rm -rf $(OUTPUT)bpftool $(OUTPUT)*.o $(OUTPUT)*.d
64+
$(Q)$(RM) $(OUTPUT)bpftool $(OUTPUT)*.o $(OUTPUT)*.d
7765

78-
install:
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)
66+
install: $(OUTPUT)bpftool
67+
$(call QUIET_INSTALL, bpftool)
68+
$(Q)$(INSTALL) -m 0755 -d $(DESTDIR)$(prefix)/sbin
69+
$(Q)$(INSTALL) $(OUTPUT)bpftool $(DESTDIR)$(prefix)/sbin/bpftool
70+
$(Q)$(INSTALL) -m 0755 -d $(DESTDIR)$(bash_compdir)
71+
$(Q)$(INSTALL) -m 0644 bash-completion/bpftool $(DESTDIR)$(bash_compdir)
8372

8473
doc:
85-
$(Q)$(MAKE) -C Documentation/
74+
$(call descend,Documentation)
75+
76+
doc-clean:
77+
$(call descend,Documentation,clean)
8678

8779
doc-install:
88-
$(Q)$(MAKE) -C Documentation/ install
80+
$(call descend,Documentation,install)
8981

9082
FORCE:
9183

92-
.PHONY: all clean FORCE install doc doc-install
84+
.PHONY: all FORCE clean install
85+
.PHONY: doc doc-clean doc-install
9386
.DEFAULT_GOAL := all

0 commit comments

Comments
 (0)