-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
74 lines (64 loc) · 1.9 KB
/
Makefile
File metadata and controls
74 lines (64 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Makefile for HTTP Server Project
# Variables
SRC_DIR = src
BUILD_DIR = build
JAVA_FILES = $(shell find $(SRC_DIR) -name "*.java")
MAIN_CLASS = Main
# Colors for output
GREEN = \033[0;32m
YELLOW = \033[1;33m
NC = \033[0m # No Color
# Default target
.PHONY: all
all: clean build run
# Clean build directory
.PHONY: clean
clean:
@echo "$(YELLOW)Cleaning build directory...$(NC)"
@rm -rf $(BUILD_DIR)/*
@echo "$(GREEN)✓ Clean complete$(NC)"
# Compile Java files
.PHONY: compile
compile:
@echo "$(YELLOW)Compiling Java files...$(NC)"
@mkdir -p $(BUILD_DIR)
@javac -d $(BUILD_DIR) $(JAVA_FILES)
@echo "$(GREEN)✓ Compilation complete$(NC)"
# Copy resources
.PHONY: copy
copy:
@echo "$(YELLOW)Copying resources...$(NC)"
@cp -r $(SRC_DIR)/www $(BUILD_DIR)/ 2>/dev/null || true
@cp -r cgi-bin $(BUILD_DIR)/ 2>/dev/null || true
@cp $(SRC_DIR)/config.json $(BUILD_DIR)/ 2>/dev/null || true
@mkdir -p $(BUILD_DIR)/uploads
@echo "$(GREEN)✓ Resources copied$(NC)"
# Build (compile + copy)
.PHONY: build
build: compile copy
@echo "$(GREEN)✓ Build complete$(NC)"
# Run server
.PHONY: run
run:
@echo "$(GREEN)Starting server...$(NC)"
@cd $(BUILD_DIR) && java $(MAIN_CLASS)
# Quick rebuild and run (no clean)
.PHONY: quick
quick: build run
# Show help
.PHONY: help
help:
@echo "$(GREEN)========================================$(NC)"
@echo "$(GREEN) HTTP Server Makefile$(NC)"
@echo "$(GREEN)========================================$(NC)"
@echo ""
@echo " make - Clean, build, and run (default)"
@echo " make clean - Clean build directory"
@echo " make build - Compile and copy resources"
@echo " make compile - Compile Java files only"
@echo " make copy - Copy resources only"
@echo " make run - Run the server"
@echo " make quick - Build and run (no clean)"
@echo " make help - Show this help"
@echo ""
@echo "$(GREEN)========================================$(NC)"