-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
38 lines (29 loc) · 845 Bytes
/
makefile
File metadata and controls
38 lines (29 loc) · 845 Bytes
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
# Compiler and flags
CXX = g++
CXXFLAGS = -std=c++17 -pthread -Wall -Iinclude
LDFLAGS = -pthread
# Source files
SERVER_SRC = src/main.cpp src/Server.cpp
CLIENT_SRC = client.cpp
# Object files (auto-generated from source files)
SERVER_OBJ = $(SERVER_SRC:.cpp=.o)
CLIENT_OBJ = $(CLIENT_SRC:.cpp=.o)
# Executable names
SERVER_EXE = server
CLIENT_EXE = client
# Default target: build all
all: $(SERVER_EXE) $(CLIENT_EXE)
# Rule to build the server
$(SERVER_EXE): $(SERVER_OBJ)
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
# Rule to build the client
$(CLIENT_EXE): $(CLIENT_OBJ)
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
# Generic rule to compile .cpp files into .o object files
%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
# Clean up build files
clean:
rm -f $(SERVER_EXE) $(CLIENT_EXE) $(SERVER_OBJ) $(CLIENT_OBJ)
# Phony targets
.PHONY: all clean