From 064365f77c85e7c5a1e55d91f4fd2c8b6e7a1521 Mon Sep 17 00:00:00 2001 From: Jesper Dangaard Brouer Date: Fri, 6 Sep 2019 17:00:42 +0200 Subject: [PATCH] Change libbpf install_headers DESTDIR to "build" and cleanup 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 --- Makefile | 1 + common/Makefile | 2 +- common/common.mk | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index cf266aff..60b34dab 100644 --- a/Makefile +++ b/Makefile @@ -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) diff --git a/common/Makefile b/common/Makefile index daf6fac2..e2621bf1 100644 --- a/common/Makefile +++ b/common/Makefile @@ -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 diff --git a/common/common.mk b/common/common.mk index 6848676c..a4765e4b 100644 --- a/common/common.mk +++ b/common/common.mk @@ -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/ @@ -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) @@ -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