增加 centos 7 构建

This commit is contained in:
2024-10-29 14:30:39 +08:00
parent 782debcd74
commit 15ec840544
4 changed files with 53 additions and 2 deletions

View File

@@ -2,16 +2,61 @@ CROSS_COMPILE ?=
CC := $(CROSS_COMPILE)gcc
STRIP := $(CROSS_COMPILE)strip
CFLAGS += -g -Wall -Iip2region
LIBS =
LIBS = -static
BIN := denyip
# 检测操作系统并设置相应的变量
OS := $(shell if cat /etc/issue | grep -i 'ubuntu' >/dev/null 2>&1; then \
echo ubuntu; \
elif test -f /etc/debian_version; then \
echo debian; \
elif test -f /etc/centos-release; then \
echo centos; \
else \
echo unsupported; \
fi)
OS_VER := $(shell if [ "$(OS)" = "ubuntu" ]; then \
cat /etc/issue | head -n1 | awk '{print $$2}'; \
elif [ "$(OS)" = "debian" ]; then \
cat /etc/debian_version; \
elif [ "$(OS)" = "centos" ]; then \
cat /etc/centos-release | grep -o -E '[0-9.]{3,}' 2>/dev/null; \
else \
echo "N/A"; \
fi)
KERNEL := $(shell uname -sr)
ARCH := $(shell uname -m)
# 使用shell命令获取库的链接选项
LIBPCAP := $(shell pkg-config --libs --static libpcap)
ifeq ($(OS), centos)
LIBPCAP := /usr/lib64/libpcap.so
LIBS =
else
LIBPCAP := $(shell pkg-config --libs --static libpcap)
endif
LIBCAP := $(shell pkg-config --libs --static libcap)
LIBIPSET := $(shell pkg-config --libs --static libipset)
all: $(BIN) # 默认目标
# 系统信息打印目标
info:
@echo "Operating System: $(OS)"
@echo "OS Version: $(OS_VER)"
@echo "Kernel Version: $(KERNEL)"
@echo "Architecture: $(ARCH)"
@echo "Compiler: $(CC)"
@echo "CFLAGS: $(CFLAGS)"
@echo "Libraries: $(LIBS)"
@echo "LIBPCAP: $(LIBPCAP)"
@echo "LIBCAP: $(LIBCAP)"
@echo "LIBIPSET: $(LIBIPSET)"
ipquery: # Go 构建目标
cd IP_region_query && CGO_ENABLED=0 go build -ldflags '-w -s'

View File

@@ -23,6 +23,12 @@ sudo apt update
sudo apt install build-essential golang libpcap-dev libcap-dev libsystemd-dev
```
在 Centos 7 系统上安装所需的开发工具和库:
```bash
yum install ipset-devel libattr-devel libpcap-devel libcap-devel
```
### 下载项目
克隆项目仓库:

BIN
cap.o

Binary file not shown.

BIN
denyip

Binary file not shown.