-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
81 lines (61 loc) · 2.01 KB
/
Makefile
File metadata and controls
81 lines (61 loc) · 2.01 KB
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
CXX = g++
PLATFORM_LDFLAGS = -lpthread
PLATFORM_CXXFLAGS = -std=c++11
PROFILING_FLAGS=-pg
OPT=
# DEBUG_LEVEL can have two values:
# * DEBUG_LEVEL=2; this is the ultimate debug mode. It will compile benchmark
# without any optimizations. To compile with level 2, issue `make dbg`
# * DEBUG_LEVEL=0; this is the debug level we use for release. If you're
# running benchmark in production you most definitely want to compile benchmark
# with debug level 0. To compile with level 0, run `make`,
# Set the default DEBUG_LEVEL to 0
DEBUG_LEVEL?=0
ifneq ($(MAKECMDGOALS),dbg)
DEBUG_LEVEL=2
endif
# compile with -O2 if debug level is not 2
ifeq ($(DEBUG_LEVEL), 2)
OPT += -O2 -fno-omit-frame-pointer
# if we're compiling for release, compile without debug code (-DNDEBUG) and
# don't treat warnings as errors
OPT += -DNDEBUG
DISABLE_WARNING_AS_ERROR=1
# Skip for archs that don't support -momit-leaf-frame-pointer
ifeq (,$(shell $(CXX) -fsyntax-only -momit-leaf-frame-pointer -xc /dev/null 2>&1))
OPT += -momit-leaf-frame-pointer
endif
else
$(warning Warning: Compiling in debug mode. Don't use the resulting binary in production)
OPT += $(PROFILING_FLAGS)
DEBUG_SUFFIX = "_debug"
endif
ROOT_PATH = $(CURDIR)
INCLUDE_PATH = -I./
ifeq ($(OBJDIR),)
OBJDIR=$(CURDIR)/build
endif
WARNING_FLAGS = # -W -Wextra -Wall
# WARNING_FLAGS = -W -Wextra -Wall -Wsign-compare \
# -Wno-unused-parameter -Woverloaded-virtual \
# -Wnon-virtual-dtor -Wno-missing-field-initializers
ifndef DISABLE_WARNING_AS_ERROR
WARNING_FLAGS += -Werror
endif
CXXFLAGS += $(WARNING_FLAGS) $(INCLUDE_PATH) $(PLATFORM_CXXFLAGS) $(PLATFORM_LDFLAGS) $(OPT)
SRC_FILES = $(wildcard *.cpp)
OBJECTS = $(notdir $(patsubst %.cpp,%.out,$(SRC_FILES)))
OBJ = $(foreach file, $(OBJECTS), $(OBJDIR)/$(file))
dummy := $(shell mkdir -p $(OBJDIR))
.PHONY: all
all : setup $(OBJ)
dbg: setup $(OBJ)
setup:
@echo "Building $(OBJ)"
mkdir -p $(OBJDIR)
$(OBJ): $(OBJDIR)/%.out : %.cpp
$(CXX) $(CXXFLAGS) -o $@ $<
.PHONY: clean all
clean:
-rm -f $(OBJDIR)/*
-rmdir $(OBJDIR)