Lines 43-48
OBJS = benchmark.o bitbase.o bitboard.o book.o endgame.o evaluate.o main.o \
Link Here
|
43 |
material.o misc.o movegen.o movepick.o notation.o pawns.o position.o \ |
43 |
material.o misc.o movegen.o movepick.o notation.o pawns.o position.o \ |
44 |
search.o thread.o timeman.o tt.o uci.o ucioption.o |
44 |
search.o thread.o timeman.o tt.o uci.o ucioption.o |
45 |
|
45 |
|
|
|
46 |
# libraries |
47 |
LIBS += -lpthread |
48 |
|
46 |
### ========================================================================== |
49 |
### ========================================================================== |
47 |
### Section 2. High-level Configuration |
50 |
### Section 2. High-level Configuration |
48 |
### ========================================================================== |
51 |
### ========================================================================== |
Lines 50-57
OBJS = benchmark.o bitbase.o bitboard.o book.o endgame.o evaluate.o main.o \
Link Here
|
50 |
# flag --- Comp switch --- Description |
53 |
# flag --- Comp switch --- Description |
51 |
# ---------------------------------------------------------------------------- |
54 |
# ---------------------------------------------------------------------------- |
52 |
# |
55 |
# |
53 |
# debug = yes/no --- -DNDEBUG --- Enable/Disable debug mode |
|
|
54 |
# optimize = yes/no --- (-O3/-fast etc.) --- Enable/Disable optimizations |
55 |
# arch = (name) --- (-arch) --- Target architecture |
56 |
# arch = (name) --- (-arch) --- Target architecture |
56 |
# os = (name) --- --- Target operating system |
57 |
# os = (name) --- --- Target operating system |
57 |
# bits = 64/32 --- -DIS_64BIT --- 64-/32-bit operating system |
58 |
# bits = 64/32 --- -DIS_64BIT --- 64-/32-bit operating system |
Lines 65-73
OBJS = benchmark.o bitbase.o bitboard.o book.o endgame.o evaluate.o main.o \
Link Here
|
65 |
# or modifying existing flags, you have to make sure there are no extra spaces |
66 |
# or modifying existing flags, you have to make sure there are no extra spaces |
66 |
# at the end of the line for flag values. |
67 |
# at the end of the line for flag values. |
67 |
|
68 |
|
68 |
### 2.1. General |
|
|
69 |
debug = no |
70 |
optimize = yes |
71 |
|
69 |
|
72 |
### 2.2 Architecture specific |
70 |
### 2.2 Architecture specific |
73 |
|
71 |
|
Lines 200-344
endif
Link Here
|
200 |
### Section 3. Low-level configuration |
198 |
### Section 3. Low-level configuration |
201 |
### ========================================================================== |
199 |
### ========================================================================== |
202 |
|
200 |
|
203 |
### 3.1 Selecting compiler (default = gcc) |
|
|
204 |
ifeq ($(COMP),) |
205 |
COMP=gcc |
206 |
endif |
207 |
|
208 |
ifeq ($(COMP),mingw) |
209 |
comp=mingw |
210 |
CXX=g++ |
211 |
profile_prepare = gcc-profile-prepare |
212 |
profile_make = gcc-profile-make |
213 |
profile_use = gcc-profile-use |
214 |
profile_clean = gcc-profile-clean |
215 |
endif |
216 |
|
217 |
ifeq ($(COMP),gcc) |
218 |
comp=gcc |
219 |
CXX=g++ |
220 |
profile_prepare = gcc-profile-prepare |
221 |
profile_make = gcc-profile-make |
222 |
profile_use = gcc-profile-use |
223 |
profile_clean = gcc-profile-clean |
224 |
endif |
225 |
|
226 |
ifeq ($(COMP),icc) |
227 |
comp=icc |
228 |
CXX=icpc |
229 |
profile_prepare = icc-profile-prepare |
230 |
profile_make = icc-profile-make |
231 |
profile_use = icc-profile-use |
232 |
profile_clean = icc-profile-clean |
233 |
endif |
234 |
|
235 |
ifeq ($(COMP),clang) |
236 |
comp=clang |
237 |
CXX=clang++ |
238 |
profile_prepare = gcc-profile-prepare |
239 |
profile_make = gcc-profile-make |
240 |
profile_use = gcc-profile-use |
241 |
profile_clean = gcc-profile-clean |
242 |
endif |
243 |
|
244 |
### 3.2 General compiler settings |
245 |
CXXFLAGS = -Wall -Wcast-qual -fno-exceptions -fno-rtti $(EXTRACXXFLAGS) |
246 |
|
247 |
ifeq ($(comp),gcc) |
248 |
CXXFLAGS += -ansi -pedantic -Wno-long-long -Wextra -Wshadow |
249 |
endif |
250 |
|
251 |
ifeq ($(comp),mingw) |
252 |
CXXFLAGS += -Wextra -Wshadow |
253 |
endif |
254 |
|
255 |
ifeq ($(comp),icc) |
256 |
CXXFLAGS += -diag-disable 1476,10120 -Wcheck -Wabi -Wdeprecated -strict-ansi |
257 |
endif |
258 |
|
259 |
ifeq ($(comp),clang) |
260 |
CXXFLAGS += -ansi -pedantic -Wno-long-long -Wextra -Wshadow |
261 |
endif |
262 |
|
263 |
ifeq ($(os),osx) |
264 |
CXXFLAGS += -arch $(arch) -mmacosx-version-min=10.0 |
265 |
endif |
266 |
|
267 |
### 3.3 General linker settings |
268 |
LDFLAGS = $(EXTRALDFLAGS) |
269 |
|
270 |
ifeq ($(comp),mingw) |
271 |
LDFLAGS += -static-libstdc++ -static-libgcc |
272 |
endif |
273 |
|
274 |
### On mingw use Windows threads, otherwise POSIX |
275 |
ifneq ($(comp),mingw) |
276 |
# On Android Bionic's C library comes with its own pthread implementation bundled in |
277 |
ifneq ($(arch),armv7) |
278 |
# Haiku has pthreads in its libroot, so only link it in on other platforms |
279 |
ifneq ($(UNAME),Haiku) |
280 |
LDFLAGS += -lpthread |
281 |
endif |
282 |
endif |
283 |
endif |
284 |
|
285 |
ifeq ($(os),osx) |
286 |
LDFLAGS += -arch $(arch) -mmacosx-version-min=10.0 |
287 |
endif |
288 |
|
289 |
### 3.4 Debugging |
290 |
ifeq ($(debug),no) |
291 |
CXXFLAGS += -DNDEBUG |
292 |
else |
293 |
CXXFLAGS += -g |
294 |
endif |
295 |
|
296 |
### 3.5 Optimization |
297 |
ifeq ($(optimize),yes) |
298 |
|
299 |
ifeq ($(comp),gcc) |
300 |
CXXFLAGS += -O3 |
301 |
|
302 |
ifeq ($(os),osx) |
303 |
ifeq ($(arch),i386) |
304 |
CXXFLAGS += -mdynamic-no-pic |
305 |
endif |
306 |
ifeq ($(arch),x86_64) |
307 |
CXXFLAGS += -mdynamic-no-pic |
308 |
endif |
309 |
endif |
310 |
|
311 |
ifeq ($(arch),armv7) |
312 |
CXXFLAGS += -fno-gcse -mthumb -march=armv7-a -mfloat-abi=softfp |
313 |
endif |
314 |
endif |
315 |
|
316 |
ifeq ($(comp),mingw) |
317 |
CXXFLAGS += -O3 |
318 |
endif |
319 |
|
320 |
ifeq ($(comp),icc) |
321 |
ifeq ($(os),osx) |
322 |
CXXFLAGS += -fast -mdynamic-no-pic |
323 |
else |
324 |
CXXFLAGS += -fast |
325 |
endif |
326 |
endif |
327 |
|
328 |
ifeq ($(comp),clang) |
329 |
### -O4 requires a linker that supports LLVM's LTO |
330 |
CXXFLAGS += -O3 |
331 |
|
332 |
ifeq ($(os),osx) |
333 |
ifeq ($(arch),i386) |
334 |
CXXFLAGS += -mdynamic-no-pic |
335 |
endif |
336 |
ifeq ($(arch),x86_64) |
337 |
CXXFLAGS += -mdynamic-no-pic |
338 |
endif |
339 |
endif |
340 |
endif |
341 |
endif |
342 |
|
201 |
|
343 |
### 3.6. Bits |
202 |
### 3.6. Bits |
344 |
ifeq ($(bits),64) |
203 |
ifeq ($(bits),64) |
Lines 365-385
ifeq ($(popcnt),yes)
Link Here
|
365 |
CXXFLAGS += -msse3 -DUSE_POPCNT |
224 |
CXXFLAGS += -msse3 -DUSE_POPCNT |
366 |
endif |
225 |
endif |
367 |
|
226 |
|
368 |
### 3.10 Link Time Optimization, it works since gcc 4.5 but not on mingw. |
|
|
369 |
### This is a mix of compile and link time options because the lto link phase |
370 |
### needs access to the optimization flags. |
371 |
ifeq ($(comp),gcc) |
372 |
ifeq ($(optimize),yes) |
373 |
ifeq ($(debug),no) |
374 |
GCC_MAJOR := `$(CXX) -dumpversion | cut -f1 -d.` |
375 |
GCC_MINOR := `$(CXX) -dumpversion | cut -f2 -d.` |
376 |
ifeq (1,$(shell expr \( $(GCC_MAJOR) \> 4 \) \| \( $(GCC_MAJOR) \= 4 \& $(GCC_MINOR) \>= 5 \))) |
377 |
CXXFLAGS += -flto |
378 |
LDFLAGS += $(CXXFLAGS) |
379 |
endif |
380 |
endif |
381 |
endif |
382 |
endif |
383 |
|
227 |
|
384 |
### ========================================================================== |
228 |
### ========================================================================== |
385 |
### Section 4. Public targets |
229 |
### Section 4. Public targets |
Lines 397-403
help:
Link Here
|
397 |
@echo "signature-build > Standard build with embedded signature" |
241 |
@echo "signature-build > Standard build with embedded signature" |
398 |
@echo "profile-build > PGO build" |
242 |
@echo "profile-build > PGO build" |
399 |
@echo "signature-profile-build > PGO build with embedded signature" |
243 |
@echo "signature-profile-build > PGO build with embedded signature" |
400 |
@echo "strip > Strip executable" |
|
|
401 |
@echo "install > Install executable" |
244 |
@echo "install > Install executable" |
402 |
@echo "clean > Clean up" |
245 |
@echo "clean > Clean up" |
403 |
@echo "" |
246 |
@echo "" |
Lines 470-482
signature-build: build embed-signature
Link Here
|
470 |
|
313 |
|
471 |
signature-profile-build: build embed-signature profile-build |
314 |
signature-profile-build: build embed-signature profile-build |
472 |
|
315 |
|
473 |
strip: |
|
|
474 |
strip $(EXE) |
475 |
|
476 |
install: |
316 |
install: |
477 |
-mkdir -p -m 755 $(BINDIR) |
317 |
-mkdir -p -m 755 $(BINDIR) |
478 |
-cp $(EXE) $(BINDIR) |
318 |
-cp $(EXE) $(BINDIR) |
479 |
-strip $(BINDIR)/$(EXE) |
|
|
480 |
|
319 |
|
481 |
clean: |
320 |
clean: |
482 |
$(RM) $(EXE) $(EXE).exe *.o .depend *~ core bench.txt *.gcda |
321 |
$(RM) $(EXE) $(EXE).exe *.o .depend *~ core bench.txt *.gcda |
Lines 493-500
all: $(EXE) .depend
Link Here
|
493 |
config-sanity: |
332 |
config-sanity: |
494 |
@echo "" |
333 |
@echo "" |
495 |
@echo "Config:" |
334 |
@echo "Config:" |
496 |
@echo "debug: '$(debug)'" |
|
|
497 |
@echo "optimize: '$(optimize)'" |
498 |
@echo "arch: '$(arch)'" |
335 |
@echo "arch: '$(arch)'" |
499 |
@echo "os: '$(os)'" |
336 |
@echo "os: '$(os)'" |
500 |
@echo "bits: '$(bits)'" |
337 |
@echo "bits: '$(bits)'" |
Lines 508-567
config-sanity:
Link Here
|
508 |
@echo "CXXFLAGS: $(CXXFLAGS)" |
345 |
@echo "CXXFLAGS: $(CXXFLAGS)" |
509 |
@echo "LDFLAGS: $(LDFLAGS)" |
346 |
@echo "LDFLAGS: $(LDFLAGS)" |
510 |
@echo "" |
347 |
@echo "" |
511 |
@echo "Testing config sanity. If this fails, try 'make help' ..." |
|
|
512 |
@echo "" |
513 |
@test "$(debug)" = "yes" || test "$(debug)" = "no" |
514 |
@test "$(optimize)" = "yes" || test "$(optimize)" = "no" |
515 |
@test "$(arch)" = "any" || test "$(arch)" = "x86_64" || test "$(arch)" = "i386" || \ |
516 |
test "$(arch)" = "ppc64" || test "$(arch)" = "ppc" || test "$(arch)" = "armv7" |
517 |
@test "$(os)" = "any" || test "$(os)" = "osx" |
518 |
@test "$(bits)" = "32" || test "$(bits)" = "64" |
519 |
@test "$(prefetch)" = "yes" || test "$(prefetch)" = "no" |
520 |
@test "$(bsfq)" = "yes" || test "$(bsfq)" = "no" |
521 |
@test "$(popcnt)" = "yes" || test "$(popcnt)" = "no" |
522 |
@test "$(sse)" = "yes" || test "$(sse)" = "no" |
523 |
@test "$(comp)" = "gcc" || test "$(comp)" = "icc" || test "$(comp)" = "mingw" || test "$(comp)" = "clang" |
524 |
|
348 |
|
525 |
$(EXE): $(OBJS) |
349 |
$(EXE): $(OBJS) |
526 |
$(CXX) -o $@ $(OBJS) $(LDFLAGS) |
350 |
$(CXX) $(CXXFLAGS) -o $@ $(OBJS) $(LDFLAGS) $(LIBS) |
527 |
|
|
|
528 |
gcc-profile-prepare: |
529 |
$(MAKE) ARCH=$(ARCH) COMP=$(COMP) gcc-profile-clean |
530 |
|
531 |
gcc-profile-make: |
532 |
$(MAKE) ARCH=$(ARCH) COMP=$(COMP) \ |
533 |
EXTRACXXFLAGS='-fprofile-generate' \ |
534 |
EXTRALDFLAGS='-lgcov' \ |
535 |
all |
536 |
|
537 |
gcc-profile-use: |
538 |
$(MAKE) ARCH=$(ARCH) COMP=$(COMP) \ |
539 |
EXTRACXXFLAGS='-fprofile-use' \ |
540 |
EXTRALDFLAGS='-lgcov' \ |
541 |
all |
542 |
|
543 |
gcc-profile-clean: |
544 |
@rm -rf *.gcda *.gcno bench.txt |
545 |
|
546 |
icc-profile-prepare: |
547 |
$(MAKE) ARCH=$(ARCH) COMP=$(COMP) icc-profile-clean |
548 |
@mkdir profdir |
549 |
|
550 |
icc-profile-make: |
551 |
$(MAKE) ARCH=$(ARCH) COMP=$(COMP) \ |
552 |
EXTRACXXFLAGS='-prof-gen=srcpos -prof_dir ./profdir' \ |
553 |
all |
554 |
|
555 |
icc-profile-use: |
556 |
$(MAKE) ARCH=$(ARCH) COMP=$(COMP) \ |
557 |
EXTRACXXFLAGS='-prof_use -prof_dir ./profdir' \ |
558 |
all |
559 |
|
560 |
icc-profile-clean: |
561 |
@rm -rf profdir bench.txt |
562 |
|
351 |
|
563 |
.depend: |
352 |
.depend: |
564 |
-@$(CXX) $(DEPENDFLAGS) -MM $(OBJS:.o=.cpp) > $@ 2> /dev/null |
353 |
-@$(CXX) $(CXXFLAGS) $(DEPENDFLAGS) -MM $(OBJS:.o=.cpp) > $@ 2> /dev/null |
565 |
|
354 |
|
566 |
-include .depend |
355 |
-include .depend |
567 |
|
356 |
|