Skip to content

Commit

Permalink
Change libbpf install_headers DESTDIR to "build" and cleanup
Browse files Browse the repository at this point in the history
The libbpf headers got installed into ../libbpf/src/root via
invoking make install_headers with DESTDIR=root.

This patch change the clean target to also cleanup this DESTDIR,
but LIBBPF_DIR is supplied by Makefile that include common.mk,
and rm command could be expanded to /root, if Makefile didn't
define this, which is too high risk. Thus, change the DESTDIR
name to "build" before, changing clean target.

I don't think this solves the issue #72, but it helps avoid
stale files in this DESTDIR.

Signed-off-by: Jesper Dangaard Brouer <[email protected]>
  • Loading branch information
netoptimizer committed Sep 6, 2019
1 parent dbd66f1 commit 064365f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)

LESSONS = $(wildcard basic*) $(wildcard packet*) $(wildcard tracing??-*)
# LESSONS += advanced03-AF_XDP
LESSONS_CLEAN = $(addsuffix _clean,$(LESSONS))

.PHONY: clean $(LESSONS) $(LESSONS_CLEAN)
Expand Down
2 changes: 1 addition & 1 deletion common/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ all: common_params.o common_user_bpf_xdp.o common_libbpf.o
CFLAGS := -g -Wall

LIBBPF_DIR = ../libbpf/src/
CFLAGS += -I$(LIBBPF_DIR)/root/usr/include/ -I../headers
CFLAGS += -I$(LIBBPF_DIR)/build/usr/include/ -I../headers
# TODO: Do we need to make libbpf from this make file too?

common_params.o: common_params.c common_params.h
Expand Down
5 changes: 3 additions & 2 deletions common/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ EXTRA_DEPS +=
# BPF-prog kern and userspace shares struct via header file:
KERN_USER_H ?= $(wildcard common_kern_user.h)

CFLAGS ?= -I$(LIBBPF_DIR)/root/usr/include/ -g
CFLAGS ?= -I$(LIBBPF_DIR)/build/usr/include/ -g
# Extra include for Ubuntu issue #44
CFLAGS += -I/usr/include/x86_64-linux-gnu
CFLAGS += -I../headers/
Expand All @@ -51,6 +51,7 @@ all: llvm-check $(USER_TARGETS) $(XDP_OBJ) $(COPY_LOADER) $(COPY_STATS)
.PHONY: clean $(CLANG) $(LLC)

clean:
rm -rf $(LIBBPF_DIR)/build
$(MAKE) -C $(LIBBPF_DIR) clean
$(MAKE) -C $(COMMON_DIR) clean
rm -f $(USER_TARGETS) $(XDP_OBJ) $(USER_OBJ) $(COPY_LOADER) $(COPY_STATS)
Expand Down Expand Up @@ -89,7 +90,7 @@ $(OBJECT_LIBBPF):
exit 1; \
else \
cd $(LIBBPF_DIR) && $(MAKE) all; \
mkdir -p root; DESTDIR=root $(MAKE) install_headers; \
mkdir -p build; DESTDIR=build $(MAKE) install_headers; \
fi

# Create dependency: detect if C-file change and touch H-file, to trigger
Expand Down

0 comments on commit 064365f

Please sign in to comment.