-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
49 lines (40 loc) · 1011 Bytes
/
makefile
File metadata and controls
49 lines (40 loc) · 1011 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
NAME = dragonfail
CC = gcc
FLAGS = -std=c99 -pedantic -g
FLAGS+= -Wall -Wno-unused-parameter -Wextra -Werror=vla -Werror
VALGRIND = --show-leak-kinds=all --track-origins=yes --leak-check=full
BIND = bin
OBJD = obj
SRCD = src
EXPD = example
INCL = -I$(SRCD)
INCL+= -I$(EXPD)
SRCS = $(EXPD)/example.c
SRCS+= $(SRCD)/dragonfail.c
SRCS_OBJS := $(patsubst %.c,$(OBJD)/%.o,$(SRCS))
# aliases
.PHONY: final
final: $(BIND)/$(NAME)
# generic compiling command
$(OBJD)/%.o: %.c
@echo "building object $@"
@mkdir -p $(@D)
@$(CC) $(INCL) $(FLAGS) -c -o $@ $<
# final executable
$(BIND)/$(NAME): $(SRCS_OBJS) $(FINAL_OBJS)
@echo "compiling executable $@"
@mkdir -p $(@D)
@$(CC) -o $@ $^ $(LINK)
run:
@cd $(BIND) && ./$(NAME)
# tools
## valgrind memory leak detection
leak: $(BIND)/$(NAME)
@echo "# running valgrind"
rm -f valgrind.log
cd $(BIND) && valgrind $(VALGRIND) 2> ../valgrind.log ./$(NAME)
less valgrind.log
## repository cleaning
clean:
@echo "# cleaning"
rm -rf $(BIND) $(OBJD) valgrind.log