-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
52 lines (37 loc) · 992 Bytes
/
Makefile
File metadata and controls
52 lines (37 loc) · 992 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
40
41
42
43
44
45
46
47
48
49
50
51
52
UNAME = $(shell uname -s)
CC = gcc
CFLAGS = -std=c11 -g -Wall
CFLAGS += -Isrc/ -Ilib/curl/include
CFLAGS += -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700
LDFLAGS = -g
ifeq ($(UNAME), Linux)
LDFLAGS += -ldl -lpthread
endif
OUT=mtwwwd
ENV = .env
WEB_PATH = $(shell grep "WEB_PATH" $(ENV) | cut -d '=' -f2)
PORT = $(shell grep "PORT" $(ENV) | cut -d '=' -f2)
N_THREADS = $(shell grep "N_THREADS" $(ENV) | cut -d '=' -f2)
N_BUFFS = $(shell grep "N_BUFFS" $(ENV) | cut -d '=' -f2)
SRC = $(wildcard src/*.c) $(wildcard src/**/*.c) $(wildcard src/**/**/*.c)
OBJ = $(SRC:.c=.o)
BIN = bin
.POSIX: all clean
.PHONY: all clean
all: dirs compile
dirs:
mkdir -p ./$(BIN)
run: all
$(BIN)/$(OUT) $(WEB_PATH) $(PORT) $(N_THREADS) $(N_BUFFS)
valgrind: all
valgrind\
--track-origins=yes\
--leak-check=full\
--leak-resolution=high\
--show-leak-kinds=all $(MAKE) run
compile: $(OBJ)
$(CC) -o $(BIN)/$(OUT) $^ $(LDFLAGS)
%.o: %.c
$(CC) -o $@ -c $< $(CFLAGS)
clean:
rm -rf $(BIN) $(OBJ)