-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
42 lines (33 loc) · 905 Bytes
/
Makefile
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
CC = gcc
#### Check for memory leaks (at exit) ####
# $ leaks --list --atExit -- ./bin/program
#### Check for leaks (at runtime) ####
# $ export MallocStackLogging=1
# Set breakpoint in debugger
# Run debugger
# $ ps aux | grep "bin/program"
# $ leaks <proccess_id>
# Step though debugger and check for leaks each step
# $ export MallocStackLogging=0
CFLAGS = -g -Wall -Werror -I include/
LDFLAGS = -lcurl -lcjson
SRC = ./src
OBJ = ./obj
HEADER = include/
BIN_DIR = ./bin
SRCS = $(wildcard $(SRC)/*.c $(SRC)/*/*.c)
OBJS = $(patsubst $(SRC)/%.c, $(OBJ)/%.o, $(SRCS))
HDRS = $(wildcard $(HEADER)/*.h $(HEADER)/*.c)
BIN = $(addprefix $(BIN_DIR)/, program)
all: $(BIN)
$(OBJ):
mkdir -p $(BIN_DIR)
mkdir -p $@
$(BIN): $(OBJS) $(OBJ)
$(CC) $(CFLAGS) $(OBJS) -o $@ $(LDFLAGS)
$(OBJ)/%.o: $(SRC)/%.c $(OBJ)
mkdir -p $(@D)
$(CC) $(CFLAGS) -c $< -o $@
clean:
$(RM) -r $(OBJ)/*
$(RM) -r $(BIN_DIR)/*