• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# SPDX-License-Identifier: GPL-2.0
2CFLAGS += -D_FILE_OFFSET_BITS=64 -Wall -Werror -I../.. -I../../../../.. -I../../../../include
3LDLIBS := -lpthread -lelf
4TEST_GEN_PROGS := fuse_test fuse_daemon
5TEST_GEN_FILES := \
6	test_bpf.bpf \
7	fd_bpf.bpf \
8	fd.sh \
9
10EXTRA_CLEAN := *.bpf
11BPF_FLAGS = -Wall -Werror -O2 -g -emit-llvm \
12	    -I ../../../../../include \
13	    -idirafter /usr/lib/gcc/x86_64-linux-gnu/10/include \
14	    -idirafter /usr/local/include \
15	    -idirafter /usr/include/x86_64-linux-gnu \
16	    -idirafter /usr/include \
17
18include ../../lib.mk
19
20# Put after include ../../lib.mk since that changes $(TEST_GEN_PROGS)
21# Otherwise you get multiple targets, this becomes the default, and it's a mess
22EXTRA_SOURCES := bpf_loader.c
23$(TEST_GEN_PROGS) : $(EXTRA_SOURCES)
24
25$(OUTPUT)/%.ir: %.c
26	clang $(BPF_FLAGS) -c $< -o $@
27
28$(OUTPUT)/%.bpf: $(OUTPUT)/%.ir
29	llc -march=bpf -filetype=obj -o $@ $<
30
31$(OUTPUT)/fd.sh: fd.txt
32	cp $< $@
33	chmod 755 $@
34
35