Commit 97c50589 authored by Daniel Borkmann's avatar Daniel Borkmann

Merge branch 'bpf-bpftool-makefile-cleanups'

Quentin Monnet says:

====================
First patch of this series cleans up the two Makefiles (Makefile and
Documentation/Makefile) and make their contents more consistent.

The second one add "uninstall" and "doc-uninstall" targets, to remove
files previously installed on the system with "install" and "doc-install"
targets.
====================
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parents 62cd2770 d3244248
...@@ -3,12 +3,16 @@ include ../../../scripts/utilities.mak ...@@ -3,12 +3,16 @@ include ../../../scripts/utilities.mak
INSTALL ?= install INSTALL ?= install
RM ?= rm -f RM ?= rm -f
RMDIR ?= rmdir --ignore-fail-on-non-empty
# Make the path relative to DESTDIR, not prefix ifeq ($(V),1)
ifndef DESTDIR Q =
prefix ?= /usr/local else
Q = @
endif endif
mandir ?= $(prefix)/share/man
prefix ?= /usr/local
mandir ?= $(prefix)/man
man8dir = $(mandir)/man8 man8dir = $(mandir)/man8
MAN8_RST = $(wildcard *.rst) MAN8_RST = $(wildcard *.rst)
...@@ -20,15 +24,21 @@ man: man8 ...@@ -20,15 +24,21 @@ man: man8
man8: $(DOC_MAN8) man8: $(DOC_MAN8)
$(OUTPUT)%.8: %.rst $(OUTPUT)%.8: %.rst
rst2man $< > $@ $(QUIET_GEN)rst2man $< > $@
clean: clean:
$(call QUIET_CLEAN, Documentation) $(RM) $(DOC_MAN8) $(call QUIET_CLEAN, Documentation)
$(Q)$(RM) $(DOC_MAN8)
install: man install: man
$(call QUIET_INSTALL, Documentation-man) \ $(call QUIET_INSTALL, Documentation-man)
$(INSTALL) -d -m 755 $(DESTDIR)$(man8dir); \ $(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(man8dir)
$(INSTALL) -m 644 $(DOC_MAN8) $(DESTDIR)$(man8dir); $(Q)$(INSTALL) -m 644 $(DOC_MAN8) $(DESTDIR)$(man8dir)
uninstall:
$(call QUIET_UNINST, Documentation-man)
$(Q)$(RM) $(addprefix $(DESTDIR)$(man8dir)/,$(_DOC_MAN8))
$(Q)$(RMDIR) $(DESTDIR)$(man8dir)
.PHONY: man man8 clean install .PHONY: man man8 clean install uninstall
.DEFAULT_GOAL := man .DEFAULT_GOAL := man
include ../../scripts/Makefile.include include ../../scripts/Makefile.include
include ../../scripts/utilities.mak include ../../scripts/utilities.mak
ifeq ($(srctree),) ifeq ($(srctree),)
srctree := $(patsubst %/,%,$(dir $(CURDIR))) srctree := $(patsubst %/,%,$(dir $(CURDIR)))
srctree := $(patsubst %/,%,$(dir $(srctree))) srctree := $(patsubst %/,%,$(dir $(srctree)))
srctree := $(patsubst %/,%,$(dir $(srctree))) srctree := $(patsubst %/,%,$(dir $(srctree)))
#$(info Determined 'srctree' to be $(srctree))
endif
ifneq ($(objtree),)
#$(info Determined 'objtree' to be $(objtree))
endif
ifneq ($(OUTPUT),)
#$(info Determined 'OUTPUT' to be $(OUTPUT))
# Adding $(OUTPUT) as a directory to look for source files,
# because use generated output files as sources dependency
# for flex/bison parsers.
VPATH += $(OUTPUT)
export VPATH
endif endif
ifeq ($(V),1) ifeq ($(V),1)
...@@ -28,12 +13,12 @@ else ...@@ -28,12 +13,12 @@ else
Q = @ Q = @
endif endif
BPF_DIR = $(srctree)/tools/lib/bpf/ BPF_DIR = $(srctree)/tools/lib/bpf/
ifneq ($(OUTPUT),) ifneq ($(OUTPUT),)
BPF_PATH=$(OUTPUT) BPF_PATH = $(OUTPUT)
else else
BPF_PATH=$(BPF_DIR) BPF_PATH = $(BPF_DIR)
endif endif
LIBBPF = $(BPF_PATH)libbpf.a LIBBPF = $(BPF_PATH)libbpf.a
...@@ -45,7 +30,7 @@ $(LIBBPF)-clean: ...@@ -45,7 +30,7 @@ $(LIBBPF)-clean:
$(call QUIET_CLEAN, libbpf) $(call QUIET_CLEAN, libbpf)
$(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(OUTPUT) clean >/dev/null $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(OUTPUT) clean >/dev/null
prefix = /usr/local prefix ?= /usr/local
bash_compdir ?= /usr/share/bash-completion/completions bash_compdir ?= /usr/share/bash-completion/completions
CC = gcc CC = gcc
...@@ -55,12 +40,15 @@ CFLAGS += -W -Wall -Wextra -Wno-unused-parameter -Wshadow ...@@ -55,12 +40,15 @@ CFLAGS += -W -Wall -Wextra -Wno-unused-parameter -Wshadow
CFLAGS += -D__EXPORTED_HEADERS__ -I$(srctree)/tools/include/uapi -I$(srctree)/tools/include -I$(srctree)/tools/lib/bpf -I$(srctree)/kernel/bpf/ CFLAGS += -D__EXPORTED_HEADERS__ -I$(srctree)/tools/include/uapi -I$(srctree)/tools/include -I$(srctree)/tools/lib/bpf -I$(srctree)/kernel/bpf/
LIBS = -lelf -lbfd -lopcodes $(LIBBPF) LIBS = -lelf -lbfd -lopcodes $(LIBBPF)
INSTALL ?= install
RM ?= rm -f
include $(wildcard *.d) include $(wildcard *.d)
all: $(OUTPUT)bpftool all: $(OUTPUT)bpftool
SRCS=$(wildcard *.c) SRCS = $(wildcard *.c)
OBJS=$(patsubst %.c,$(OUTPUT)%.o,$(SRCS)) $(OUTPUT)disasm.o OBJS = $(patsubst %.c,$(OUTPUT)%.o,$(SRCS)) $(OUTPUT)disasm.o
$(OUTPUT)disasm.o: $(srctree)/kernel/bpf/disasm.c $(OUTPUT)disasm.o: $(srctree)/kernel/bpf/disasm.c
$(QUIET_CC)$(COMPILE.c) -MMD -o $@ $< $(QUIET_CC)$(COMPILE.c) -MMD -o $@ $<
...@@ -73,21 +61,34 @@ $(OUTPUT)%.o: %.c ...@@ -73,21 +61,34 @@ $(OUTPUT)%.o: %.c
clean: $(LIBBPF)-clean clean: $(LIBBPF)-clean
$(call QUIET_CLEAN, bpftool) $(call QUIET_CLEAN, bpftool)
$(Q)rm -rf $(OUTPUT)bpftool $(OUTPUT)*.o $(OUTPUT)*.d $(Q)$(RM) $(OUTPUT)bpftool $(OUTPUT)*.o $(OUTPUT)*.d
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)
install: uninstall:
install -m 0755 -d $(prefix)/sbin $(call QUIET_UNINST, bpftool)
install $(OUTPUT)bpftool $(prefix)/sbin/bpftool $(Q)$(RM) $(DESTDIR)$(prefix)/sbin/bpftool
install -m 0755 -d $(bash_compdir) $(Q)$(RM) $(DESTDIR)$(bash_compdir)/bpftool
install -m 0644 bash-completion/bpftool $(bash_compdir)
doc: doc:
$(Q)$(MAKE) -C Documentation/ $(call descend,Documentation)
doc-clean:
$(call descend,Documentation,clean)
doc-install: doc-install:
$(Q)$(MAKE) -C Documentation/ install $(call descend,Documentation,install)
doc-uninstall:
$(call descend,Documentation,uninstall)
FORCE: FORCE:
.PHONY: all clean FORCE install doc doc-install .PHONY: all FORCE clean install uninstall
.PHONY: doc doc-clean doc-install doc-uninstall
.DEFAULT_GOAL := all .DEFAULT_GOAL := all
...@@ -99,5 +99,6 @@ ifneq ($(silent),1) ...@@ -99,5 +99,6 @@ ifneq ($(silent),1)
QUIET_CLEAN = @printf ' CLEAN %s\n' $1; QUIET_CLEAN = @printf ' CLEAN %s\n' $1;
QUIET_INSTALL = @printf ' INSTALL %s\n' $1; QUIET_INSTALL = @printf ' INSTALL %s\n' $1;
QUIET_UNINST = @printf ' UNINST %s\n' $1;
endif endif
endif endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment