5 Star 0 Fork 0

lwh/webdisk_project

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Makefile 1.77 KB
一键复制 编辑 原始数据 按行查看 历史
lwh 提交于 2024-05-27 10:38 . 整合项目代码 目前存在bug lwh
#directory structure
INCLUDE_DIR := ./include
SERVER_DIR := ./server
CLIENT_DIR := ./client
BIN_DIR := ./bin
OBJ_DIR := ./obj
#phony target
.PHONY: all clean-obj clean-main clean-file rebuild debug
.DEFAULT_GOAL := all
# CC is compiler and compiler options
CC := gcc
CFLAGS := -Wall -g -O1 -I$(INCLUDE_DIR) -pthread -lmysqlclient
# Conditional logic to set FINAL and SRC_DIR
ifeq ($(FINAL),server)
SRC_DIR := $(SERVER_DIR)
TARGET := $(BIN_DIR)/server
else ifeq ($(FINAL),client)
SRC_DIR := $(CLIENT_DIR)
TARGET := $(BIN_DIR)/client
else
# This target will be the default if FINAL is not set
default:
$(error "FINAL must be 'server' or 'client'")
endif
# file preparation
SRCS := $(wildcard $(SRC_DIR)/*.c)
OBJS := $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(SRCS))
DEPS := $(OBJS)
# final target
MESSAGE := "Build Succeed!"
all: $(TARGET)
@echo $(MESSAGE)
#linking .o files
$(TARGET):$(DEPS)
$(CC) $(CFLAGS) $^ -o $@
#compiling to generate .o files
$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c
$(CC) $(CFLAGS) -c $< -o $@
#cleaning options
clean:
rm -f ./obj/*.o
rm -f ./bin/server
rm -f ./bin/client
clean-server:
rm -f ./bin/server
clean-client:
rm -f ./bin/client
clean-file:
rm -f $(BIN_DIR)/$(FN) $(OBJ_DIR)/$(FileName)
rebuild:
clean-$(FINAL) all
#debugging information
debug:
@echo "TARGET: $(TARGET)"
@echo "DEPS: $(DEPS)"
@echo "CFLAGS: $(CFLAGS)"
help:
@echo "Available targets:"
@echo " clean - clean all the build files"
@echo " clean-obj - clean object files"
@echo " clean-server - clean the server executable"
@echo " clean-client - clean the client executable"
@echo " clean-file - clean a specific file (specify FN=<filename>)"
@echo " rebuild - clean and rebuild the project"
@echo " debug - print Makefile variables for debugging"
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/li-cs-student/webdisk_project.git
[email protected]:li-cs-student/webdisk_project.git
li-cs-student
webdisk_project
webdisk_project
master

搜索帮助