-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
64 lines (46 loc) · 1.54 KB
/
Copy pathMakefile
File metadata and controls
64 lines (46 loc) · 1.54 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
# Callum Gran 2023
# See LICENSE for license info
OBJDIR = .obj
SRC = src
DIRS := $(shell find $(SRC) -type d -not -wholename "src/client")
SRCS := $(shell find $(SRC) -type f -name "*.c" -not -wholename "src/client/*")
OBJS := $(SRCS:%.c=$(OBJDIR)/%.o)
CFLAGS = -Iinclude -Wall -Wextra -Wshadow -std=c11 -g -D_POSIX_C_SOURCE=200809L
CFLAGS += -DLOGGING
LDFLAGS = -pthread
LDLIBS = -lm -lssl -lcrypto
.PHONY: format clean tags bear $(OBJDIR)
TARGET = server
TARGET-FUZZ = server-fuzz
CLIENT = client
all: $(TARGET)
$(OBJDIR)/%.o: %.c Makefile | $(OBJDIR)
@echo [CC] $@
@$(CC) -c $(CFLAGS) $< -o $@
$(TARGET): $(OBJS)
@echo [LD] $@
@$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
$(TARGET-FUZZ): $(OBJS)
@echo [LD] $@
@$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
$(OBJDIR):
$(foreach dir, $(DIRS), $(shell mkdir -p $(OBJDIR)/$(dir)))
debug: CFLAGS += -g -DDEBUG
debug: $(TARGET)
server-asan: CFLAGS += -fsanitize=address -fsanitize=undefined
server-asan: LDFLAGS += -fsanitize=address -fsanitize=undefined
server-asan: $(TARGET-FUZZ)
LDLIBS += -lreadline
client:
$(CC) $(CFLAGS) -o $(CLIENT) src/client/client_impl.c src/lib/env_parser.c src/lib/queue.c src/lib/threadpool.c src/chatp2p/client.c src/chatp2p/address_book.c src/chatp2p/chat_msg.c src/encrypt/encrypt.c src/chatp2p/error.c $(LDLIBS)
client-asan: CFLAGS += -fsanitize=address -fsanitize=undefined
client-asan: LDFLAGS += -fsanitize=address -fsanitize=undefined
client-asan: client
clean:
rm -rf $(OBJDIR) $(TARGET) $(CLIENT) $(TARGET-FUZZ)
tags:
@ctags -R
bear:
@bear -- make
format:
python format.py