c-router-emulator/router/Makefile

36 lines
672 B
Makefile
Raw Normal View History

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