-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
74 lines (62 loc) · 2.07 KB
/
Copy pathMakefile
File metadata and controls
74 lines (62 loc) · 2.07 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
# this makefile was generated using an LLM.
CC = gcc
CFLAGS = -I./include -Wall -Wextra -g -pthread
LDFLAGS = -lpthread
# Directories and Files
BIN = bin
SRC = src
APPS = apps
TESTS = tests
# Source Groups
COMMON_SRC = $(SRC)/IPBparser.c $(SRC)/IPBnetwork.c $(SRC)/IPBtypes.c
SERVER_SRC = $(APPS)/serverMain.c $(COMMON_SRC) $(SRC)/IPBserverData.c
CLIENT_SRC = $(APPS)/clientMain.c $(COMMON_SRC) $(SRC)/IPBclientAPI.c
TEST_SRC = $(TESTS)/IPBtests.c $(COMMON_SRC) $(SRC)/IPBclientAPI.c
.PHONY: all clean run-tests
# Default Target
all: $(BIN)/server $(BIN)/client
# Ensure bin directory exists
$(BIN):
mkdir -p $(BIN)
# Build Targets
$(BIN)/server: $(SERVER_SRC) | $(BIN)
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)
@echo "✓ Built Server"
$(BIN)/client: $(CLIENT_SRC) | $(BIN)
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)
@echo "✓ Built Client"
$(BIN)/tests: $(TEST_SRC) | $(BIN)
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)
@echo "✓ Built Tests"
# Integrated Test Runner (No script needed)
run-tests: $(BIN)/server $(BIN)/tests
@echo "--- Setting up Environment ---"
@fuser -k 9000/tcp > /dev/null 2>&1 || true
@rm -f server.log
@echo "--- Starting Server (Background) ---"
@./$(BIN)/server -v 9000 > server.log 2>&1 & echo $$! > server.pid
@sleep 1
@echo "--- Running Test Suite ---"
@if ./$(BIN)/tests; then \
echo "SUCCESS: All tests passed."; \
kill `cat server.pid` 2>/dev/null; \
rm -f server.pid server.log; \
else \
echo "FAILURE: Tests failed. Server Log:"; \
echo "----------------------------------"; \
cat server.log; \
echo "----------------------------------"; \
kill `cat server.pid` 2>/dev/null; \
rm -f server.pid; \
exit 1; \
fi
clean:
rm -rf $(BIN) server.log server.pid
@echo "✓ Cleaned"
help:
@echo "IPB Project Makefile"
@echo "===================="
@echo "make Build server and client"
@echo "make run-tests Build and run the full test suite (auto-starts server)"
@echo "make clean Remove build artifacts and logs"
@echo "make help Show this help message"