-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
44 lines (34 loc) · 1.25 KB
/
Makefile
File metadata and controls
44 lines (34 loc) · 1.25 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
# Define the compiler and compiler flags
CC = gcc
CFLAGS = -Wall -Wextra -std=c11
# Define the special library paths for OpenSSL
OPENSSL_INCLUDE = -I$(shell brew --prefix openssl)/include
OPENSSL_LIB = -L$(shell brew --prefix openssl)/lib
# Define the name of the final executables
SERVER_TARGET = server
CLIENT_TARGET = client
# Source files
SERVER_SRC = server.c
CLIENT_SRC = client.c
SHAM_SRC = sham.c
SHAM_HEADER = sham.h
# Object files
SERVER_OBJ = $(SERVER_SRC:.c=.o)
CLIENT_OBJ = $(CLIENT_SRC:.c=.o)
SHAM_OBJ = $(SHAM_SRC:.c=.o)
# The main rule to build all targets
all: $(SERVER_TARGET) $(CLIENT_TARGET)
# Rule to build the server executable
$(SERVER_TARGET): $(SERVER_OBJ) $(SHAM_OBJ)
$(CC) $(CFLAGS) $(OPENSSL_INCLUDE) $(OPENSSL_LIB) $(SERVER_OBJ) $(SHAM_OBJ) -o $@ -lcrypto
# Rule to build the client executable
$(CLIENT_TARGET): $(CLIENT_OBJ) $(SHAM_OBJ)
$(CC) $(CFLAGS) $(OPENSSL_INCLUDE) $(OPENSSL_LIB) $(CLIENT_OBJ) $(SHAM_OBJ) -o $@ -lcrypto
# Rule for compiling .c files into .o files
# This will handle server.c, client.c, and sham.c
%.o: %.c $(SHAM_HEADER)
$(CC) $(CFLAGS) $(OPENSSL_INCLUDE) -c $< -o $@
# A clean rule to remove generated files
.PHONY: clean all
clean:
rm -f $(SERVER_OBJ) $(CLIENT_OBJ) $(SHAM_OBJ) $(SERVER_TARGET) $(CLIENT_TARGET)