-
Notifications
You must be signed in to change notification settings - Fork 104
/
Copy pathMakefile
49 lines (40 loc) · 1.45 KB
/
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
46
47
48
49
APPS = hello
.PHONY: all
all: $(APPS)
KERN_SOURCES = ${APPS:=_kern.c}
USER_SOURCES = ${APPS:=_user.c}
USER_SOURCES += trace_helpers.c
KERN_OBJECTS = ${KERN_SOURCES:.c=.o}
USER_OBJECTS = ${USER_SOURCES:.c=.o}
USER_LIBS += trace_helpers.o
KERNEL_SOURCE ?= /usr/src/$(shell uname -r)
KERNEL_INCLUDES := -I$(KERNEL_SOURCE)/tools/lib/
KERNEL_INCLUDES += -I$(KERNEL_SOURCE)/arch/x86/include
KERNEL_INCLUDES += -I$(KERNEL_SOURCE)/arch/x86/include/generated/uapi
KERNEL_INCLUDES += -I$(KERNEL_SOURCE)/arch/x86/include/generated
KERNEL_INCLUDES += -I$(KERNEL_SOURCE)/arch/x86/include/uapi
KERNEL_INCLUDES += -I$(KERNEL_SOURCE)/include/uapi
KERNEL_INCLUDES += -I$(KERNEL_SOURCE)/include/generated/uapi
KERNEL_INCLUDES += -I$(KERNEL_SOURCE)/include/linux/kconfig.h
KERNEL_INCLUDES += -I$(KERNEL_SOURCE)/include
LIBBPF = -L$(KERNEL_SOURCE)/tools/lib/bpf/
$(APPS): %: %_kern.o %_user.o $(USER_LIBS)
clang -Wall -O2 -g $@_user.o $(USER_LIBS) -static $(LIBBPF) -lbpf -lelf -lz -o $@
$(USER_OBJECTS): %.o: %.c
clang -g -O2 -Wall -I . -c $< -o $@
$(KERN_OBJECTS): %.o: %.c
clang -g -O2 \
-target bpf \
-c $< -o $@ \
-D__TARGET_ARCH_x86 \
-D__KERNEL__ -D__ASM_SYSREG_H \
-Wno-unused-value -Wno-pointer-sign \
-Wno-compare-distinct-pointer-types \
-Wno-gnu-variable-sized-type-not-at-end \
-Wno-address-of-packed-member -Wno-tautological-compare \
-Wno-unknown-warning-option \
$(KERNEL_INCLUDES)
format:
VERSION_CONTROL=none indent -linux *.h *.c
clean:
rm -rf $(APPS) *.o