X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2FMakefile;h=3fd601ffe20c96cee61c94c1ab9ec5e2a8aa2078;hp=eba72150b614a69de499436d1618bce74cad786b;hb=fde0b9e701a6bfac05e56f6bffdc29943be56120;hpb=797c960d2004eacbbd19c656f483f070130bb358 diff --git a/src/Makefile b/src/Makefile index eba72150..3fd601ff 100644 --- a/src/Makefile +++ b/src/Makefile @@ -20,11 +20,18 @@ ### Section 1. General Configuration ### ========================================================================== +### Establish the operating system name +UNAME = $(shell uname) + ### Executable name EXE = stockfish ### Installation dir definitions PREFIX = /usr/local +# Haiku has a non-standard filesystem layout +ifeq ($(UNAME),Haiku) + PREFIX=/boot/common +endif BINDIR = $(PREFIX)/bin ### Built-in benchmark for pgo-builds @@ -32,7 +39,7 @@ PGOBENCH = ./$(EXE) bench 32 1 10 default depth ### Object files OBJS = benchmark.o bitbase.o bitboard.o book.o endgame.o evaluate.o main.o \ - material.o misc.o move.o movegen.o movepick.o pawns.o position.o \ + material.o misc.o movegen.o movepick.o notation.o pawns.o position.o \ search.o thread.o timeman.o tt.o uci.o ucioption.o ### ========================================================================== @@ -192,6 +199,15 @@ ifeq ($(COMP),icc) profile_clean = icc-profile-clean endif +ifeq ($(COMP),clang) + comp=clang + CXX=clang++ + profile_prepare = gcc-profile-prepare + profile_make = gcc-profile-make + profile_use = gcc-profile-use + profile_clean = gcc-profile-clean +endif + ### 3.2 General compiler settings CXXFLAGS = -g -Wall -Wcast-qual -fno-exceptions -fno-rtti $(EXTRACXXFLAGS) @@ -207,6 +223,10 @@ ifeq ($(comp),icc) CXXFLAGS += -wd383,981,1418,1419,10187,10188,11505,11503 -Wcheck -Wabi -Wdeprecated -strict-ansi endif +ifeq ($(comp),clang) + CXXFLAGS += -ansi -pedantic -Wno-long-long -Wextra -Wshadow +endif + ifeq ($(os),osx) CXXFLAGS += -arch $(arch) endif @@ -216,7 +236,10 @@ LDFLAGS = $(EXTRALDFLAGS) ### On mingw use Windows threads, otherwise POSIX ifneq ($(comp),mingw) - LDFLAGS += -lpthread + # Haiku has pthreads in its libroot, so only link it in on other platforms + ifneq ($(UNAME),Haiku) + LDFLAGS += -lpthread + endif endif ifeq ($(os),osx) @@ -255,6 +278,20 @@ ifeq ($(optimize),yes) CXXFLAGS += -O3 endif endif + + ifeq ($(comp),clang) + ### -O4 requires a linker that supports LLVM's LTO + CXXFLAGS += -O3 + + ifeq ($(os),osx) + ifeq ($(arch),i386) + CXXFLAGS += -mdynamic-no-pic + endif + ifeq ($(arch),x86_64) + CXXFLAGS += -mdynamic-no-pic + endif + endif + endif endif ### 3.6. Bits @@ -329,6 +366,7 @@ help: @echo "gcc > Gnu compiler (default)" @echo "icc > Intel compiler" @echo "mingw > Gnu compiler with MinGW under Windows" + @echo "clang > LLVM Clang compiler" @echo "" @echo "Non-standard targets:" @echo "" @@ -415,7 +453,7 @@ config-sanity: @test "$(prefetch)" = "yes" || test "$(prefetch)" = "no" @test "$(bsfq)" = "yes" || test "$(bsfq)" = "no" @test "$(popcnt)" = "yes" || test "$(popcnt)" = "no" - @test "$(comp)" = "gcc" || test "$(comp)" = "icc" || test "$(comp)" = "mingw" + @test "$(comp)" = "gcc" || test "$(comp)" = "icc" || test "$(comp)" = "mingw" || test "$(comp)" = "clang" $(EXE): $(OBJS) $(CXX) -o $@ $(OBJS) $(LDFLAGS)