-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
39 lines (29 loc) · 687 Bytes
/
Copy pathmakefile
File metadata and controls
39 lines (29 loc) · 687 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
39
# Compiler
CC = gcc
# Compiler flags
CFLAGS = -pthread -lm
# Executable names
SERVER = server
CLIENT = client
# Source files
SERVER_SRC = server.c
CLIENT_SRC = client.c
# Object files
SERVER_OBJ = $(SERVER_SRC:.c=.o)
CLIENT_OBJ = $(CLIENT_SRC:.c=.o)
# Default target
all: $(SERVER) $(CLIENT)
# Compile server
$(SERVER): $(SERVER_OBJ)
$(CC) $(SERVER_OBJ) -o $(SERVER) $(CFLAGS)
# Compile client
$(CLIENT): $(CLIENT_OBJ)
$(CC) $(CLIENT_OBJ) -o $(CLIENT) $(CFLAGS)
# Compile .c files into .o files
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
# Clean up object files and executables
clean:
rm -f $(SERVER) $(CLIENT) $(SERVER_OBJ) $(CLIENT_OBJ)
# Rebuild everything
rebuild: clean all