From 66aaa7f2a690bb95e8cc011c52651a8356210485 Mon Sep 17 00:00:00 2001 From: William Findlay Date: Fri, 29 Oct 2021 12:53:00 -0400 Subject: [PATCH] makefile: add a makefile to the template --- Makefile | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7e30834 --- /dev/null +++ b/Makefile @@ -0,0 +1,44 @@ +CARGO = cargo +RUNNER = sudo -E + +RUN_ARGS = # User provided args could go here, or be specified at cmd line + +DEBUG = target/debug/{{project-name}} +RELEASE = target/release/{{project-name}} + +DEBUG_BPF = target/bpfel-unknown-none/debug/{{project-name}} +RELEASE_BPF = target/bpfel-unknown-none/release/{{project-name}} + +USER_SRCS = $(wildcard {{project-name}}-common/**/*) +COMMON_SRCS = $(wildcard {{project-name}}/**/*) +BPF_SRCS = $(wildcard {{project-name}}-ebpf/**/*) + +.PHONY: build +build: $(DEBUG) + +.PHONY: run +run: $(DEBUG) + $(RUNNER) ./$(DEBUG) --path $(DEBUG_BPF) $(RUN_ARGS) + +.PHONY: build-release +build-release: $(RELEASE) + +.PHONY: run-release +run-release: $(RELEASE) + $(RUNNER) ./$(RELEASE) --path $(RELEASE_BPF) $(RUN_ARGS) + +.PHONY: clean +clean: + $(CARGO) clean + +$(DEBUG): $(DEBUG_BPF) $(USER_SRCS) $(COMMON_SRCS) + $(CARGO) build + +$(DEBUG_BPF): $(BPF_SRCS) $(COMMON_SRCS) + $(CARGO) xtask build-ebpf + +$(RELEASE): $(RELEASE_BPF) $(USER_SRCS) $(COMMON_SRCS) + $(CARGO) build --release + +$(RELEASE_BPF): $(BPF_SRCS) $(COMMON_SRCS) + $(CARGO) xtask build-ebpf --release