cocoon/Makefile
xfy911 5adf5e0581 fix(build): 修复 Range 解析嵌套问题 + 补充 errno 头文件 + 链接 zlib
- http.c: 修复 Range 请求解析被错误嵌套在 accept-encoding 分支的 bug
- static.c: 补充缺失的 <errno.h> 和 <zlib.h> 头文件,修复编译失败
- Makefile: 添加 -lz 链接参数,支持 gzip 压缩功能
2026-06-03 18:18:33 +08:00

67 lines
1.3 KiB
Makefile
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Cocoon - 基于 coco 协程库的静态资源 Web 服务器
# coco 库路径(默认使用 submodule可覆盖
COCO_DIR ?= coco
COCO_INCLUDE ?= $(COCO_DIR)/include
COCO_LIB ?= $(COCO_DIR)/build
CC = gcc
CFLAGS = -Wall -Wextra -O2 -std=c11 -I$(COCO_INCLUDE)
LDFLAGS = -L$(COCO_LIB) -lcoco -lpthread -lm -luring -lz
# 调试模式
DEBUG ?= 0
ifeq ($(DEBUG),1)
CFLAGS += -g -O0 -DCOCOON_DEBUG
endif
# 安装路径
PREFIX ?= /usr/local
BINDIR = $(PREFIX)/bin
# 源文件
SRCS = main.c server.c http.c static.c log.c
OBJS = $(SRCS:.c=.o)
TARGET = cocoon
# 默认目标
all: $(TARGET)
# 链接
$(TARGET): $(OBJS)
$(CC) $(OBJS) -o $@ $(LDFLAGS)
# 构建 coco 依赖(如果 submodule 已初始化)
deps:
@if [ ! -d "$(COCO_DIR)/build" ]; then \
echo "[Cocoon] 构建 coco 依赖..."; \
cd $(COCO_DIR) && mkdir -p build && cd build && cmake .. && $(MAKE); \
else \
echo "[Cocoon] coco 已构建,跳过"; \
fi
# 完整构建(先构建依赖,再构建项目)
build-all: deps $(TARGET)
# 编译规则
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
# 安装
install: $(TARGET)
install -d $(BINDIR)
install -m 755 $(TARGET) $(BINDIR)/
# 卸载
uninstall:
rm -f $(BINDIR)/$(TARGET)
# 清理
clean:
rm -f $(OBJS) $(TARGET)
# 重新构建
rebuild: clean all
.PHONY: all clean install uninstall rebuild deps build-all