-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
97 lines (69 loc) · 1.96 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
##
# @file Makefile
# @author Conlan Wesson
##
FUNGESRC := $(shell find src/ -name \*.cpp)
SRCS := third_party/bigint/src/bigint.cpp $(FUNGESRC)
OBJS := $(addsuffix .o,$(addprefix bin/,$(basename $(SRCS))))
DEPS := $(OBJS:%.o=%.d)
EXEC := bin/funge
INCLUDES := $(addprefix -I,$(shell find src/ -type d -name include)) -I third_party/bigint/include
CPP := g++
CPPARGS := $(INCLUDES) -g -Wall -Wextra -Werror -std=c++2a
LINTARGS := $(INCLUDES) --enable=all --std=c++20
LD := g++
LDARGS := -pthread
.PHONY: all clean realclean build funge test lint doc man ut unittest cpputest smoketest
GCOV ?= 0
ifneq ($(GCOV),0)
CPPARGS += -fprofile-arcs -ftest-coverage
LDARGS += -fprofile-arcs -ftest-coverage
endif
all: test
build: funge
funge: $(EXEC)
$(EXEC): $(OBJS)
@echo "LD " $(subst bin/,,$@)
@$(LD) $(LDARGS) -o $@ $^
bin/%.o: %.cpp
@mkdir -p $(dir $@)
@echo "CPP " $(subst src/,,$<)
@$(CPP) $(CPPARGS) -MMD -o $@ -c $<
-include $(DEPS)
test: ut smoketest
smoketest: $(EXEC)
@./test/smoketest.sh
lint:
@cppcheck $(LINTARGS) $(FUNGESRC)
doc: man
@echo "DOX "
@doxygen Doxyfile
man: bin/funge.1
bin/funge.1: doc/man.md
@mkdir -p $(dir $@)
@echo "MAN "
@pandoc $< -s -t man -o $@
CPPUTESTLIB := test/cpputest/src/CppUTest/libCppUTest.a test/cpputest/src/CppUTestExt/libCppUTestExt.a
UTCPPARGS := -I src/include -I test/cpputest/include -lpthread -Wall -Wextra -Werror -std=c++2a --include test/ut/new_macros.h
UTSRCS := $(shell find test/ut/ -name \*.cpp) src/Field.cpp src/StackStack.cpp src/Stack.cpp src/Vector.cpp src/VectorRange.cpp
UTBIN := bin/unittest
ut: unittest
unittest: $(UTBIN)
$(UTBIN): $(UTSRCS) $(CPPUTESTLIB)
@mkdir -p $(dir $@)
@echo "LD " $@
@$(CPP) $(UTCPPARGS) -o $@ $^
@$(UTBIN) -c -v -ojunit
cpputest: $(CPPUTESTLIB)
$(CPPUTESTLIB):
cd test/cpputest; cmake .
make -C test/cpputest
.NOTPARALLEL:
clean:
@echo CLEAN bin/
@rm -f $(OBJS) $(DEPS)
make -C test/cpputest clean
realclean: clean
@echo REALCLEAN
@rm -rf bin/
@rm -rf doc/html/