]> git.sesse.net Git - stockfish/commitdiff
Add support for Mac clang compiler
authorAndy Duplain <trojanfoe@gmail.com>
Sun, 29 Apr 2012 09:14:50 +0000 (10:14 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 29 Apr 2012 10:47:02 +0000 (11:47 +0100)
Makefile modified to support the clang compiler under Mac.
This was tested using clang 4 under Mountain Lion, but should
also work fine under Lion and possibly under Snow Leopard.

It requires the 'Xcode 4.x Command Line Tools' to be installed.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/Makefile

index eba72150b614a69de499436d1618bce74cad786b..71aa7b30d195370738bcab3705f4385b7328b308 100644 (file)
@@ -192,6 +192,15 @@ ifeq ($(COMP),icc)
        profile_clean = icc-profile-clean
 endif
 
        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)
 
 ### 3.2 General compiler settings
 CXXFLAGS = -g -Wall -Wcast-qual -fno-exceptions -fno-rtti $(EXTRACXXFLAGS)
 
@@ -207,6 +216,10 @@ ifeq ($(comp),icc)
        CXXFLAGS += -wd383,981,1418,1419,10187,10188,11505,11503 -Wcheck -Wabi -Wdeprecated -strict-ansi
 endif
 
        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
 ifeq ($(os),osx)
        CXXFLAGS += -arch $(arch)
 endif
@@ -255,6 +268,19 @@ ifeq ($(optimize),yes)
                        CXXFLAGS += -O3
                endif
        endif
                        CXXFLAGS += -O3
                endif
        endif
+
+       ifeq ($(comp),clang)
+               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
 endif
 
 ### 3.6. Bits
@@ -329,6 +355,7 @@ help:
        @echo "gcc                  > Gnu compiler (default)"
        @echo "icc                  > Intel compiler"
        @echo "mingw                > Gnu compiler with MinGW under Windows"
        @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 ""
        @echo ""
        @echo "Non-standard targets:"
        @echo ""
@@ -415,7 +442,7 @@ config-sanity:
        @test "$(prefetch)" = "yes" || test "$(prefetch)" = "no"
        @test "$(bsfq)" = "yes" || test "$(bsfq)" = "no"
        @test "$(popcnt)" = "yes" || test "$(popcnt)" = "no"
        @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)
 
 $(EXE): $(OBJS)
        $(CXX) -o $@ $(OBJS) $(LDFLAGS)