Skip to content

Commit

Permalink
Merge pull request #1185 from ariel-anieli/makefile-ebpf
Browse files Browse the repository at this point in the history
ebpf_prog/Makefile: temp files are now handled by a pattern rule
  • Loading branch information
gustavo-iniguez-goya authored Sep 10, 2024
2 parents 2e90f38 + cfd267a commit 8bb1d44
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions ebpf_prog/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
KERNEL_DIR ?= /lib/modules/$(shell uname -r)/source
KERNEL_HEADERS ?= /usr/src/linux-headers-$(shell uname -r)/
CLANG ?= clang
CC = clang
LLC ?= llc
LLVM_STRIP ?= llvm-strip -g
ARCH ?= $(shell uname -m)
Expand All @@ -27,8 +27,9 @@ ifeq ($(ARCH),arm)
EXTRA_FLAGS = "-D__LINUX_ARM_ARCH__=7"
endif

BIN := opensnitch.o opensnitch-procs.o opensnitch-dns.o
CLANG_FLAGS = -I. \
SRC := $(wildcard *.c)
BIN := $(SRC:.c=.o)
CFLAGS = -I. \
-I$(KERNEL_HEADERS)/arch/$(ARCH)/include/generated/ \
-I$(KERNEL_HEADERS)/include \
-include $(KERNEL_DIR)/include/linux/kconfig.h \
Expand All @@ -54,10 +55,13 @@ CLANG_FLAGS = -I. \

all: $(BIN)

%.o: %.c
$(CLANG) $(CLANG_FLAGS) -c $< -o $@.partial
$(LLC) -march=bpf -mcpu=generic -filetype=obj -o $@ $@.partial
rm -f $@.partial
%.bc: %.c
$(CC) $(CFLAGS) -c $<

%.o: %.bc
$(LLC) -march=bpf -mcpu=generic -filetype=obj -o $@ $<

clean:
rm -f *.o *.partial
rm -f $(BIN)

.SUFFIXES:

0 comments on commit 8bb1d44

Please sign in to comment.