2023-09-19 11:34:11 +08:00
|
|
|
# 定义路径变量
|
|
|
|
SRC_DIR = ./
|
2023-09-20 16:40:52 +08:00
|
|
|
OBJ_DIR = ./objs
|
2023-09-19 11:34:11 +08:00
|
|
|
BIN_DIR = ./
|
|
|
|
|
2023-09-20 16:13:41 +08:00
|
|
|
|
|
|
|
# CFLAGS = -Wall -Wextra -Werror
|
2023-09-19 11:34:11 +08:00
|
|
|
# 定义编译器
|
|
|
|
CC = gcc
|
|
|
|
# 定义目标文件
|
2023-09-20 16:13:41 +08:00
|
|
|
TARGET = $(BIN_DIR)/router
|
2023-09-19 11:34:11 +08:00
|
|
|
# 定义源文件
|
|
|
|
SRCS = $(wildcard $(SRC_DIR)/*.c)
|
2023-09-20 16:13:41 +08:00
|
|
|
# OBJS = $(OBJ_DIR)/t1.o $(OBJ_DIR)/get_interface.o
|
|
|
|
OBJS = $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(SRCS))
|
2023-09-19 11:34:11 +08:00
|
|
|
|
|
|
|
# 编译规则
|
|
|
|
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
|
|
|
|
$(CC) -c $< -o $@
|
|
|
|
|
|
|
|
# 链接规则
|
|
|
|
$(TARGET): $(OBJS)
|
2023-09-21 09:51:03 +08:00
|
|
|
$(CC) $^ -o $@ -lpcap -lpthread -lmysqlclient -lnet
|
2023-09-19 11:34:11 +08:00
|
|
|
|
|
|
|
# 默认构建目标
|
|
|
|
all: $(TARGET)
|
|
|
|
|
|
|
|
# 创建目录
|
|
|
|
$(shell mkdir -p $(OBJ_DIR) $(BIN_DIR))
|
|
|
|
|
|
|
|
# 清理规则
|
|
|
|
clean:
|
|
|
|
rm -rf $(OBJ_DIR)/*.o $(TARGET)
|
|
|
|
|
|
|
|
# 伪目标
|
|
|
|
.PHONY: all clean
|