44 lines
926 B
Makefile
44 lines
926 B
Makefile
# Makefile for Web Server
|
||
|
||
CC = gcc
|
||
CFLAGS = -Wall -Wextra -std=c99
|
||
TARGET = webserver
|
||
SOURCE = webserver.c
|
||
|
||
# 默认目标
|
||
all: $(TARGET)
|
||
|
||
# 编译web服务器
|
||
$(TARGET): $(SOURCE)
|
||
$(CC) $(CFLAGS) -o $(TARGET) $(SOURCE)
|
||
|
||
# 创建webroot目录和示例文件
|
||
setup:
|
||
mkdir -p webroot
|
||
@echo "Creating webroot directory and copying index.html..."
|
||
|
||
# 运行服务器
|
||
run: $(TARGET)
|
||
./$(TARGET)
|
||
|
||
# 清理编译文件
|
||
clean:
|
||
rm -f $(TARGET)
|
||
rm -f webserver.log
|
||
|
||
# 完全清理(包括webroot目录)
|
||
distclean: clean
|
||
rm -rf webroot
|
||
|
||
# 帮助信息
|
||
help:
|
||
@echo "Available targets:"
|
||
@echo " all - Compile the web server"
|
||
@echo " setup - Create webroot directory"
|
||
@echo " run - Compile and run the server"
|
||
@echo " clean - Remove compiled files and logs"
|
||
@echo " distclean- Remove everything including webroot"
|
||
@echo " help - Show this help message"
|
||
|
||
.PHONY: all setup run clean distclean help
|