-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
45 lines (36 loc) · 881 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
LLC ?= llc
CLANG ?= clang
CC := gcc
OUT ?= .
SRC ?= src
SOURCES ?= $(wildcard $(SRC)/*.c)
OBJECTS := $(patsubst $(SRC)/%.c, $(OUT)/%.o, $(SOURCES))
CFLAGS ?= -Iinclude/
LIBS = -lbpf -lelf
all: llvm-check $(OBJECTS)
.PHONY: clean $(CLANG) $(LLC)
clean:
rm -f $(OBJECTS)
rm -f *.ll
rm -f *~
llvm-check: $(CLANG) $(LLC)
@for TOOL in $^ ; do \
if [ ! $$(command -v $${TOOL} 2>/dev/null) ]; then \
echo "*** ERROR: Cannot find tool $${TOOL}" ;\
exit 1; \
else true; fi; \
done
$(OUT)/%.o: $(SRC)/%.c
$(CLANG) -S \
-D __BPF_TRACING__ \
$(CFLAGS) \
-Wall \
-Winline \
-Wno-unused-value \
-Wno-pointer-sign \
-Wno-compare-distinct-pointer-types \
-Werror \
-target bpf \
-O2 -emit-llvm -c -g -o ${@:.o=.ll} $<
$(LLC) -march=bpf -filetype=obj -o $@ ${@:.o=.ll}