-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
42 lines (31 loc) · 942 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 := g++
SRCDIR := src
TSTDIR := tests
OBJDIR := build
BINDIR := bin
MAIN := program/main.cpp
TESTER := program/tester.cpp
SRCEXT := cpp
SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT))
OBJECTS := $(patsubst $(SRCDIR)/%,$(OBJDIR)/%,$(SOURCES:.$(SRCEXT)=.o))
TSTSOURCES := $(shell find $(TSTDIR) -type f -name *.$(SRCEXT))
CFLAGS := -g -Wall -O3 -std=c++11
INC := -I include/ -I third_party/
$(OBJDIR)/%.o: $(SRCDIR)/%.$(SRCEXT)
@mkdir -p $(@D)
$(CC) $(CFLAGS) $(INC) -c -o $@ $<
main: $(OBJECTS)
@mkdir -p $(BINDIR)
$(CC) $(CFLAGS) $(INC) $(MAIN) $^ -o $(BINDIR)/main
tests: $(OBJECTS)
@mkdir -p $(BINDIR)
$(CC) $(CFLAGS) $(INC) $(TESTER) $(TSTSOURCES) $^ -o $(BINDIR)/tester
$(BINDIR)/tester
valgrind: main
valgrind --leak-check=full --track-origins=yes $(BINDIR)/main
all: main
run: main
$(BINDIR)/main
clean:
$(RM) -r $(OBJDIR)/* $(BINDIR)/*
.PHONY: clean coverage