@@ -18,7 +18,6 @@ include $(ROOT)/script/arch.mk
1818
1919HEADERS := $(if $(KERNEL ) ,$(KERNEL ) ,/lib/modules/$(shell uname -r) /build/)
2020NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC ) -print-file-name=include)
21- BTF := $(if $(VMLINUX ) ,$(VMLINUX ) ,/sys/kernel/btf/vmlinux)
2221export HEADERS
2322
2423USERINCLUDE := \
@@ -42,28 +41,20 @@ KERNEL_CFLAGS += $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
4241 -Wno-unknown-warning-option -Wno-frame-address
4342
4443cmd_download = @if [ ! -f $(1 ) ]; then wget -O $(1 ) $(REMOTE_ROOT ) /$(2 ) ; fi
45- cmd_exist = $(if $(wildcard $(1 ) ) ,$(2 ) ,$(3 ) )
46- cmd_or_exist = $(call cmd_exist,$(1 ) ,$(1 ) ,$(2 ) )
47- ifeq ("$(wildcard $(HEADERS ) )$(wildcard $(BTF ) ) ","")
48- $(error BTF is not found in your system, please install kernel headers)
49- endif
5044
51- ifeq ( $( if $( KERNEL ) , $( wildcard $( KERNEL ) ) ,"pass") ,)
52- $(error kernel path not exist )
45+ ifdef KERN_VER
46+ CFLAGS += -DKERN_VER=$(KERN_VER )
5347endif
5448
55- ifeq ($(if $(VMLINUX ) ,$(wildcard $(VMLINUX ) ) ,"pass") ,)
56- $(error vmlinux path not exist)
49+ ifdef COMPAT
50+ ifeq ($(wildcard $(HEADERS ) ) ,)
51+ $(error kernel headers not exist in COMPAT mdoe, please install it)
5752endif
58-
59- # preferred to compile from kernel headers, then BTF
60- mode := $(if $(VMLINUX ) ,'btf',$(call cmd_exist,$(HEADERS ) ,'kernel','btf') )
61- ifeq ($(mode ) ,'btf')
62- kheaders_cmd := ln -s vmlinux.h kheaders.h
63- kheaders_dep := vmlinux.h
64- else
6553 kheaders_cmd := ln -s vmlinux_header.h kheaders.h
54+ CFLAGS += -DCOMPAT_MODE
6655 BPF_CFLAGS += $(KERNEL_CFLAGS)
56+ else
57+ kheaders_cmd := ln -s ../shared/bpf/vmlinux.h kheaders.h
6758endif
6859
6960ifndef BPFTOOL
7465endif
7566endif
7667
77- vmlinux.h :
78- $(BPFTOOL ) btf dump file $(BTF ) format c > vmlinux.h
79-
80- kheaders.h : $(kheaders_dep )
68+ kheaders.h :
8169 $(call kheaders_cmd)
8270
83- progs/% .o : progs/% .c kheaders.h
71+ progs/% .o : progs/% .c $( BPF_EXTRA_DEP )
8472 clang -O2 -c -g -S -Wall -Wno-pointer-sign -Wno-unused-value \
8573 -Wno-incompatible-pointer-types-discards-qualifiers \
8674 -fno-asynchronous-unwind-tables \
0 commit comments