-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
59 lines (44 loc) · 1.16 KB
/
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
PROJECT = vector
BUILD = g++
MAKEDIR = mkdir
REMOVE = rm -rf
OUT_DIR = bin
OUTPUT = ./$(OUT_DIR)/$(PROJECT)
DBGFLAGS = -g
CFLAGS = -flto -std=c++14
#-I.\include
LDFLAGS = -flto
#-L. -l:pdcurses.a -s
EXCLUDE = catch.cpp
TARGETS = main.cpp tests.cpp benchmarks.cpp
ALLSRCS = $(wildcard *.cpp)
SOURCES = $(filter-out $(TARGETS) $(EXCLUDE),$(ALLSRCS))
OBJECTS = $(SOURCES:.cpp=.o)
.SECONDEXPANSION:
.PHONY: all cov test bench debug build list clean
all: build clean
list:
@printf "Targets: $(TARGETS)\nSources: $(SOURCES)\nObjects: $(OBJECTS)\n"
# cov: CFLAGS = -fprofile-arcs -ftest-coverage
# cov: LDFLAGS += -fprofile-arcs -ftest-coverage
cov: CFLAGS = -O0 -g -coverage -fno-inline
cov: LDFLAGS += -coverage
cov: test
@$(OUTPUT)
@gcov tests.cpp > "coverage.txt"
# test: CFLAGS += $(DBGFLAGS)
test: SOURCES += catch.cpp
test: $(OUT_DIR) catch.o tests
debug: CFLAGS += $(DBGFLAGS)
debug: build
build: $(OUT_DIR) main
bench: $(OUT_DIR) benchmarks
$(OUT_DIR):
$(MAKEDIR) $(OUT_DIR)
$(TARGETS:.cpp=): $(OBJECTS) $$(@).o
$(BUILD) -o $(OUTPUT) $(OBJECTS) $(@).o $(LDFLAGS)
# $(BUILD) -o $@ $^ $(LDFLAGS)
%.o: %.cpp
$(BUILD) -o $@ -c $< $(CFLAGS)
clean:
$(REMOVE) *.o *.gc*