forked from wdv4758h/data-race-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.mk
157 lines (143 loc) · 3.15 KB
/
common.mk
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
PLATFORM=$(shell uname -s | sed -e "s/CYGWIN.*/Windows/" | sed -e "s/Darwin/Mac/")
BITNESS=$(shell uname -m | sed -e "s/i.86/32/;s/x86_64/64/;s/amd64/64/;s/arm.*/arm/")
MAJOR_V=$(shell uname -r | sed -e "s/\([0-9]*\)\..*/\1/")
ifeq ($(PLATFORM)$(BITNESS), Linux64)
default: l64 l32
endif
ifeq ($(PLATFORM)$(BITNESS), Linux32)
default: l32
endif
ifeq ($(PLATFORM)$(BITNESS), Windows32)
default: w
endif
ifeq ($(PLATFORM), Mac)
ifeq ($(MAJOR_V), 9)
default: m32
endif
ifeq ($(MAJOR_V), 10)
default: m64 m32
endif
ifeq ($(MAJOR_V), 11)
default: m64 m32
endif
DARWIN_VERSION=darwin_$(MAJOR_V)
endif
dummy:
@echo "Can't determine default configuration!"
@echo "For 64-bit Linux build: make l64"
@echo "For 32-bit Linux build: make l32"
@echo "For mixed Linux build: make l"
@echo "For 64-bit Mac build: make m64"
@echo "For 32-bit Mac build: make m32"
@echo "For mixed Mac build: make m"
@echo "For ARM Linux build: make la"
@exit 1
# This should go after the platform/bitness detection code, otherwise
# we'll have a wrong default target from gtest...
.PHONY: all
all:
# OS-specific file name suffixes and command line flags
ifeq ($(OS), linux)
CXX=g++
CC=gcc
LD=g++
LTLD=g++
SO=so
OBJ=o
EXE=
O=-o
LINKO=-o
else ifeq ($(OS), darwin)
CXX=g++
CC=gcc
LD=g++
ifeq ($(ARCH), x86)
LTLD=$(VALGRIND_ROOT)/coregrind/link_tool_exe_darwin 0x38000000 g++
endif
ifeq ($(ARCH), amd64)
LTLD=$(VALGRIND_ROOT)/coregrind/link_tool_exe_darwin 0x138000000 g++
endif
SO=so
OBJ=o
EXE=
O=-o
LINKO=-Wl,-o,
else ifeq ($(OS), windows)
CXX=cl -nologo
CC=cl -nologo
LD=link -nologo
SO=dll
OBJ=obj
EXE=.exe
O=-Fo
LINKO=-out:
LDOPT=-debug -incremental:no
else
OS=UNKNOWN_OS
endif
# STATICFLAGS
ifeq ($(STATIC), 1)
S=-static
STATICFLAGS=-static
else
S=
STATICFLAGS=
endif
# ARCHFLAGS
ifeq ($(OS), windows)
ARCHFLAGS=
else
ifeq ($(ARCH), x86)
ARCHFLAGS=-m32
else ifeq ($(ARCH), amd64)
ARCHFLAGS=-m64
else
ARCH=UNKNOWN_ARCH
endif
endif
# OPTFLAGS
ifeq ($(OS), windows)
ifeq ($(OPT), 1)
OX=O1
OPTFLAGS=-Zi -MT -O1 -Ob0
else
OX=O0
OPTFLAGS=-Zi -MTd -Od
endif
else
ifeq ($(OPT), 1)
OX=O1
OPTFLAGS=-g -O1 -fno-inline -fno-omit-frame-pointer -fno-builtin
else
OX=O0
OPTFLAGS=-g -O0
endif
endif
# GTEST_*
GTEST_ROOT=$(SVN_ROOT)/third_party/googletest
GTEST_CXXFLAGS=$(CXXFLAGS) $(ARCHFLAGS)
GTEST_MAKE_DIR=$(GTEST_ROOT)/make-$(OS)-$(ARCH)$(EXTRA_BUILD_SUFFIX)
ifeq ($(OS), windows)
ifeq ($(OPT), 1)
GTEST_LIB=$(GTEST_MAKE_DIR)/gtest.lib
else
GTEST_LIB=$(GTEST_MAKE_DIR)/gtestd.lib
endif
else
GTEST_LIB=$(GTEST_MAKE_DIR)/gtest_main.a
endif
ifeq ($(OS), windows)
# TODO(timurrrr): should be possible to unify this with the non-Windows part.
$(GTEST_LIB):
mkdir -p $(GTEST_MAKE_DIR)
$(CXX) $(CXXFLAGS) -c $O$(GTEST_LIB).$(OBJ) -I$(GTEST_ROOT)/include -I$(GTEST_ROOT) $(GTEST_ROOT)/src/gtest-all.cc
lib -nologo -OUT:$(GTEST_LIB) $(GTEST_LIB).$(OBJ)
else
$(GTEST_LIB):
mkdir -p $(GTEST_MAKE_DIR) && \
cd $(GTEST_MAKE_DIR) && \
$(MAKE) -f ../make/Makefile gtest_main.a CXXFLAGS="$(GTEST_CXXFLAGS)" LDFLAGS=$(GTEST_LDFLAGS)
endif
.PHONY: GTEST_CLEAN
GTEST_CLEAN:
rm -rf ${GTEST_ROOT}/make-*