~kiwec/ke

ref: 842396976984e3cbd83251296dd90a46b9d53b3c ke/Makefile -rw-r--r-- 1.2 KiB
84239697 — Wolf Clément Downgrade to C++17, avoid stdlib 3 years ago
                                                                                
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
SRC      = $(wildcard src/*.cc)
OBJ      = $(SRC:.cc=.o)
DEP      = $(OBJ:.o=.d)
TESTS    = $(wildcard test/*.cc)
TOBJ     = $(TESTS:.cc=.o)
TDEP     = $(TOBJ:.o=.d)
CXX      = clang
CXXFLAGS = -std=c++17
LDFLAGS  = -ltermbox -lstdc++ -lm
TARGET   = ke
TESTTGT  = ke-tests

$(TARGET): $(OBJ)
	$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)

$(TESTTGT): CXXFLAGS += -g
$(TESTTGT): LDFLAGS += -O0
$(TESTTGT): $(filter-out src/main.o, $(OBJ)) $(TOBJ)
	$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)

-include $(DEP)
-include $(TDEP)

%.d: %.cc
	@$(CXX) $(CXXFLAGS) $< -MM -MT $(@:.d=.o) >$@

.PHONY: clean
clean:
	rm -f $(OBJ) $(DEP) $(TARGET) $(TESTTGT) ".ke.profdata" ".ke.profraw"

.PHONY: coverage
coverage: CXXFLAGS += -fprofile-instr-generate -fcoverage-mapping
coverage: LDFLAGS += -fprofile-instr-generate -fcoverage-mapping
coverage: clean $(TESTTGT)
	LLVM_PROFILE_FILE=".ke.profraw" ./$(TESTTGT)
	llvm-profdata merge -sparse ".ke.profraw" -o ".ke.profdata"
	llvm-cov show $(TESTTGT) -instr-profile=".ke.profdata"

.PHONY: debug
debug: CXXFLAGS += -Wall -Wextra -g
debug: LDFLAGS += -O0
debug: $(TARGET)

.PHONY: tests
tests: $(TESTTGT)
	./$(TESTTGT)

.PHONY: install
install: $(TARGET)
	install $(TARGET) /usr/bin/$(TARGET)