代码拉取完成,页面将自动刷新
COMPONENT := $(ROOT)/component
COMMON_SHARED := $(ROOT)/shared/pkt_utils.c $(COMPONENT)/net_utils.c \
$(COMPONENT)/arg_parse.c $(COMPONENT)/sys_utils.c \
$(ROOT)/shared/bpf_utils.c
CFLAGS += -I./ -I$(ROOT)/shared/bpf/ -g
BPF_CFLAGS = $(CFLAGS) -Wno-unused-function \
-Wno-compare-distinct-pointer-types -Wuninitialized \
-D__TARGET_ARCH_$(SRCARCH) -DBPF_NO_PRESERVE_ACCESS_INDEX
ifeq ("$(shell pkg-config --print-requires-private libelf | grep libzstd)","libzstd")
LIBELF_ZSTD_FLAGS = -lzstd
endif
HOST_CFLAGS = \
-lbpf -lelf -lz $(LIBELF_ZSTD_FLAGS) -O2 -static $(CFLAGS) -Wall \
-Wno-deprecated-declarations -DVERSION=$(VERSION) \
-DRELEASE=$(RELEASE) \
-I$(ROOT)/shared/ -I$(ROOT)/component
CC := $(CROSS_COMPILE)gcc
include $(ROOT)/script/arch.mk
HEADERS := $(if $(KERNEL),$(KERNEL),/lib/modules/$(shell uname -r)/build/)
NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
export HEADERS
USERINCLUDE := \
-I$(HEADERS)/arch/$(SRCARCH)/include/uapi \
-I$(HEADERS)/arch/$(SRCARCH)/include/generated/uapi \
-I$(HEADERS)/include/uapi \
-I$(HEADERS)/include/generated/uapi \
-include $(HEADERS)/include/linux/kconfig.h \
-I/usr/include/
LINUXINCLUDE := \
-I$(HEADERS)/arch/$(SRCARCH)/include \
-I$(HEADERS)/arch/$(SRCARCH)/include/generated \
-I$(HEADERS)/include \
$(USERINCLUDE)
KERNEL_CFLAGS += $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
-D__KERNEL__ -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 -Wno-frame-address
ifdef KERN_VER
CFLAGS += -DKERN_VER=$(KERN_VER)
endif
ifdef NO_GLOBAL_DATA
CFLAGS += -DBPF_NO_GLOBAL_DATA
endif
ifdef DISABLE_IPV6
CFLAGS += -DNT_DISABLE_IPV6
endif
ifdef NO_BTF
ifeq ($(wildcard $(HEADERS)),)
$(error kernel headers not exist in COMPAT mode, please install it)
endif
kheaders_cmd := ln -s vmlinux_header.h kheaders.h
CFLAGS += -DNO_BTF
BPF_CFLAGS += $(KERNEL_CFLAGS)
else
kheaders_cmd := ln -s ../shared/bpf/vmlinux.h kheaders.h
BPF_CFLAGS += -target bpf
endif
ifdef INLINE
CFLAGS += -DINLINE_MODE
endif
ifdef INIT
CFLAGS += -D__F_INIT_EVENT
endif
ifdef OUTPUT_WHOLE
CFLAGS += -D__F_OUTPUT_WHOLE
endif
ifndef BPFTOOL
ifneq ("$(shell bpftool gen help 2>&1 | grep skeleton)","")
BPFTOOL := bpftool
else
ifeq ("$(shell uname -m)","x86_64")
BPFTOOL := $(ROOT)/script/bpftool-x86
endif
ifeq ("$(shell uname -m)","aarch64")
BPFTOOL := $(ROOT)/script/bpftool-arm
endif
ifeq ("$(shell uname -m)","loongarch64")
BPFTOOL := $(ROOT)/script/bpftool-loongarch
endif
endif
endif
ifdef BPF_DEBUG
CFLAGS += -DBPF_DEBUG
endif
kheaders.h:
$(call kheaders_cmd)
progs/%.o: progs/%.c $(BPF_EXTRA_DEP)
clang -O2 -c -S -Wall -fno-asynchronous-unwind-tables \
-Wno-incompatible-pointer-types-discards-qualifiers \
$< -emit-llvm -Wno-unknown-attributes $(BPF_CFLAGS) -Xclang \
-disable-llvm-passes -o - | \
opt -O2 -mtriple=bpf-pc-linux | \
llvm-dis | \
llc -march=bpf -filetype=obj -o $@
@readelf -S $@ | grep BTF > /dev/null || (rm $@ && exit 1)
%.skel.h: %.o
$(BPFTOOL) gen skeleton $< > $@ || (rm -r $@ && exit 1)
$(bpf_progs): %: %.skel.h
@:
bpf: $(bpf_progs) $(bpf_progs_ext)
$(progs): %: %.c bpf
@if [ -n "$(prog-$@)" ]; then \
echo $(CC) $(prog-$@) -o $@ $(HOST_CFLAGS); \
$(CC) $(prog-$@) -o $@ $(HOST_CFLAGS); \
else \
echo $(CC) $< -o $@ $(HOST_CFLAGS); \
$(CC) $< -o $@ $(HOST_CFLAGS); \
fi
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。