-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
68 lines (45 loc) · 1.75 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
include vars.make
GCHECK_INCLUDE_DIR:=$(GCHECK_INCLUDE_DIR)/gcheck
GCHECK_SOURCES=gcheck.cpp user_object.cpp redirectors.cpp json.cpp console_writer.cpp argument.cpp stringify.cpp shared_allocator.cpp multiprocessing.cpp customtest.cpp
GCHECK_OBJECTS=$(GCHECK_SOURCES:cpp=o)
SOURCES=$(GCHECK_SOURCES:%=src/%)
HEADERS=$(GCHECK_HEADERS:%=$(GCHECK_INCLUDE_DIR)/%) src/console_writer.h
OBJECTS:=$(GCHECK_OBJECTS:%=build/%)
PIC_OBJECTS:=$(OBJECTS:o=pic.o)
LIBNAME=$(GCHECK_LIB_NAME)
CXXFLAGS = -std=c++17 -Wall -Wextra -pedantic -I$(GCHECK_INCLUDE_DIR) -Isrc
ifeq ($(OS),Windows_NT)
RM=del /f /q
FixPath = $(subst /,\,$1)
else
RM=rm -f
FixPath = $1
endif
.PHONY: clean static shared debug set-debug set-construct with-construct debug-construct
static: $(GCHECK_LIB_DIR)/$(LIBNAME)
shared: $(GCHECK_LIB_DIR)/$(GCHECK_SHARED_LIB_NAME)
with-construct: | set-construct $(GCHECK_LIB_DIR)/$(LIBNAME)
debug-construct: | set-debug with-construct
debug: | set-debug $(GCHECK_LIB_DIR)/$(LIBNAME)
set-construct:
$(eval CPPFLAGS += -DGCHECK_CONSTRUCT_DATA)
set-debug:
$(eval CXXFLAGS += -g)
build/%.o : src/%.cpp $(HEADERS) | build
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
build/%.pic.o : src/%.cpp $(HEADERS) | build
$(CXX) -fPIC $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
$(GCHECK_LIB_DIR)/$(LIBNAME): | $(OBJECTS) $(GCHECK_LIB_DIR)
ar rcs $(call FixPath, $@ $(OBJECTS))
$(GCHECK_LIB_DIR)/$(GCHECK_SHARED_LIB_NAME): $(PIC_OBJECTS) | $(GCHECK_LIB_DIR)
$(CXX) -shared $(CPPFLAGS) $(CXXFLAGS) $(PIC_OBJECTS) -o $@
get-report: $(EXECUTABLE)
$(call FixPath, ./$(EXECUTABLE)) --json 2>&1
clean:
$(RM) $(call FixPath, build/* $(GCHECK_LIB_DIR)/* $(EXECUTABLE) output.html report.json)
clean-all: clean
$(MAKE) -C tests clean
build:
mkdir build
$(GCHECK_LIB_DIR):
mkdir $(GCHECK_LIB_DIR)