forked from simulationcraft/simc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
246 lines (203 loc) · 6.58 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
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# ==========================================================================
# Dedmonwakeen's Raid DPS/TPS Simulator.
# Send questions to [email protected]
# ==========================================================================
# To build on Unix/Mac/Windows: make
# To build debuggable executable, add OPTS=-g to cmd-line invocation
# By default, 32-bit binary is built. To build a 64-bit binary, add BITS=64 to the cmd-line invocation
# Override MODULE on the cmd-line invocation if you want to build a custom named executable, e.g. 'simc64'
# Override OBJ_DIR if you want your object files built somewhere other than the local directory
FLAVOR =
DESTDIR =
PREFIX ?= ..
# Build base directory
BASE_DIR = $(DESTDIR)$(PREFIX)
# Base "shared data" search path. For the command line client, profiles are
# searched from $PREFIX, or $PREFIX/share/SimulationCraft if $PREFIX is not the
# default ("..")
SHARED_DATA = $(PREFIX)
# Base installation path for the command line client binary, by default "..",
# if $DESTDIR or $PREFIX is given, set to $DESTDIR$PREFIX/bin.
BIN_INSTALL_PATH = $(PREFIX)
# Installation path for the shared files. By default it's not used; if $PREFIX
# is set to something else than "..", set to
# $DESTDIR$PREFIX/share/SimulationCraft
SHARE_INSTALL_PATH =
ifneq (${PREFIX},..)
ORG_NAME = SimulationCraft
APP_NAME = SimulationCraft
SHARED_DATA = $(PREFIX)/share/$(ORG_NAME)/$(APP_NAME)
BIN_INSTALL_PATH = $(BASE_DIR)/bin
SHARE_INSTALL_PATH = $(BASE_DIR)/share/$(ORG_NAME)/$(APP_NAME)
endif
ifeq (${OS},Windows_NT)
OS = WINDOWS
endif
ifeq (${OS},)
ifdef SystemRoot
OS = WINDOWS
else
OS = UNIX
FLAVOR = $(shell uname)
endif
endif
MKDIR = mkdir
CXX = g++
CPP_FLAGS = -Wall -Wextra -Woverloaded-virtual -W -I. -DSC_SHARED_DATA=\"$(SHARED_DATA)\" --std=c++0x -O3
OPTS =
LINK_LIBS =
# Include build setting from user configuration file
-include ../build.conf
# Enable SSE2
DUMPMACHINE =$(shell $(CXX) -dumpmachine)
# SSE2 is explicitly disabled for 32bit MINGW.
ifeq ($(findstring i686-w64-mingw32,${DUMPMACHINE}),)
OPTS += -msse2 -mfpmath=sse
endif
# OSX
ifeq (${FLAVOR},Darwin)
ifeq (${OPENSSL},)
LINK_LIBS += -framework Security -framework CoreFoundation
endif
# OSX Clang 7.0 started complaining about inconsistent missing override specifiers, but the
# detection seems to not be 100% accurate. Disable for now.
COMPILER_STR := $(shell ${CXX} -v 2>&1)
ifneq ($(findstring clang,${COMPILER_STR}),)
# OS X clang spits out a substring "clang-x.y.z" on the first line of the version output, where x is
# the major version. Not all clang frontends report versions like this, but it should work for OS X.
COMPILER_VERSION := $(shell echo "${COMPILER_STR}" | grep clang | sed -Ee 's/.+clang-([0-9]+).+/\1/g')
ifeq ($(shell expr ${COMPILER_VERSION} \>= 700),1)
CPP_FLAGS += -Wno-inconsistent-missing-override
endif
endif
endif
ifneq (${DEBUG},)
CPP_FLAGS += -g
endif
ifneq (${EVENT_QUEUE_DEBUG},)
CPP_FLAGS += -DEVENT_QUEUE_DEBUG
endif
ifneq (${NO_DEBUG},)
CPP_FLAGS += -DNDEBUG
endif
ifneq (${C++14},)
CPP_FLAGS += --std=c++1y
endif
ifneq (${c++0x},)
CPP_FLAGS += --std=c++0x
endif
ifneq (${C++03},)
CPP_FLAGS += --std=c++03
endif
ifneq (${LTO},)
OPTS += -flto
endif
ifneq (${MARCH_NATIVE},)
OPTS += -march=native
endif
ifneq (${FFAST-MATH},)
OPTS += -ffast-math
endif
ifeq (32,${BITS})
OPTS += -m32
endif
ifeq (64,${BITS})
OPTS += -m64
endif
ifneq (${SC_DEFAULT_APIKEY},)
CPP_FLAGS += -DSC_DEFAULT_APIKEY=\"${SC_DEFAULT_APIKEY}\"
endif
ifneq (${OPENSSL},)
ifneq (${OPENSSL_PATH},)
CPP_FLAGS += -I${OPENSSL_PATH}/include
LINK_LIBS += -L${OPENSSL_PATH}/lib
endif
OPTS += -DSC_USE_OPENSSL
ifeq (WINDOWS,${OS})
LINK_LIBS += -lssleay32
else
LINK_LIBS += -lssl
endif
endif
# Any UNIX platform
ifeq (UNIX,${OS})
LINK_LIBS += -lpthread
AR = ar
COPY = cp
REMOVE = rm -f
PATHSEP = /
endif
# Windows platform with MinGW32
ifeq (WINDOWS,${OS})
MODULE_EXT = .exe
CPP_FLAGS += -DUNICODE
LINK_LIBS += -lws2_32 -lwininet
ifeq (${NO_STATIC},)
LINK_FLAGS += -static
endif
COPY = copy
REMOVE = del /f
PATHSEP = \\
AR = ar
endif
MODULE = simc$(MODULE_EXT)
include ../source_files/engine_make
include ../source_files/engine_main_make
SRC_H := $(filter %.h, $(SRC)) $(filter %.hh, $(SRC)) $(filter %.hpp, $(SRC)) $(filter %.inc, $(SRC))
SRC_CPP := $(filter %.cpp, $(SRC))
OBJ_DIR = .
OBJ_EXT = o
SRC_OBJ := $(SRC_CPP:%.cpp=$(OBJ_DIR)$(PATHSEP)%.$(OBJ_EXT))
.PHONY: all mostlyclean clean
all: $(MODULE)
debug:OPTS += -g -fno-omit-frame-pointer -O0
debug: $(MODULE)
release:CPP_FLAGS += -DNDEBUG
release: $(MODULE)
optimized:CPP_FLAGS += -DNDEBUG
optimized:OPTS += -march=native -ffast-math -fomit-frame-pointer
optimized: $(MODULE)
install: all
ifneq (${PREFIX},..)
$(MKDIR) -p $(BIN_INSTALL_PATH)
endif
$(COPY) $(MODULE) $(BIN_INSTALL_PATH)
ifneq (${PREFIX},..)
$(MKDIR) -p $(SHARE_INSTALL_PATH)
$(COPY) -r $(wildcard ../profiles/*) $(SHARE_INSTALL_PATH)
endif
$(MODULE): $(SRC_OBJ)
-@echo [$(MODULE)] Linking $@
@$(CXX) $(OPTS) $(LINK_FLAGS) $^ $(LINK_LIBS) -o $@
$(OBJ_DIR)$(PATHSEP)%.$(OBJ_EXT): %.cpp $(SRC_H)
-@echo [$(MODULE)] Compiling $(notdir $<)
@$(CXX) $(CPP_FLAGS) $(OPTS) -c $< -o $@
%.s: %.cpp $(SRC_H)
-@echo [$(MODULE)] Compiling $(notdir $<)
$(CXX) $(CPP_FLAGS) $(OPTS) -S $< -o $@
# cleanup targets
mostlyclean:
-@echo [$(MODULE)] Cleaning intermediate files
@$(REMOVE) $(SRC_OBJ)
clean: mostlyclean
-@echo [$(MODULE)] Cleaning target files
@$(REMOVE) $(MODULE) sc_http$(MODULE_EXT)
# Unit Tests
sc_http$(MODULE_EXT): interfaces$(PATHSEP)sc_http.cpp util$(PATHSEP)sc_io.cpp sc_thread.cpp sc_util.cpp
-@echo [$@] Linking
$(CXX) $(CPP_FLAGS) -std=c++0x -DUNIT_TEST $(OPTS) $(LINK_FLAGS) $^ $(LINK_LIBS) -o $@
rng$(MODULE_EXT): util$(PATHSEP)rng.cpp
-@echo [$@] Linking
$(CXX) $(CPP_FLAGS) -DUNIT_TEST $(OPTS) $(LINK_FLAGS) $^ $(LINK_LIBS) -o $@
timeline$(MODULE_EXT): util$(PATHSEP)timeline.hpp util$(PATHSEP)timeline.cpp
-@echo [$@] Linking
$(CXX) $(CPP_FLAGS) -std=c++0x -DUNIT_TEST $(OPTS) $(LINK_FLAGS) $^ $(LINK_LIBS) -o $@
sample_data$(MODULE_EXT): util$(PATHSEP)sample_data.hpp util$(PATHSEP)sample_data.cpp
-@echo [$@] Linking
$(CXX) $(CPP_FLAGS) -std=c++0x -DUNIT_TEST $(OPTS) $(LINK_FLAGS) $^ $(LINK_LIBS) -o $@
sc_expressions$(MODULE_EXT): sim$(PATHSEP)sc_expressions.cpp sc_util.cpp
-@echo [$@] Linking
$(CXX) $(CPP_FLAGS) -DUNIT_TEST $(OPTS) $(LINK_FLAGS) $^ $(LINK_LIBS) -o $@
# Deprecated targets
unix windows mac:
$(error unix/windows/mac are no longer a valid targets, please read the docs at the top of Makefile)