summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorEvan Shelhamer <shelhamer@imaginarynumber.net>2014-04-08 15:41:29 -0700
committerEvan Shelhamer <shelhamer@imaginarynumber.net>2014-04-08 15:45:00 -0700
commit8fc0e4bbe666f2c68f0f7f6ae4c7237675016114 (patch)
tree670a9edcf728a7a8be8c769b96330f907805977e /Makefile
parent8f1f3d29385f343c062ffa092833f1cfa730b603 (diff)
downloadcaffe-8fc0e4bbe666f2c68f0f7f6ae4c7237675016114.tar.gz
caffe-8fc0e4bbe666f2c68f0f7f6ae4c7237675016114.tar.bz2
caffe-8fc0e4bbe666f2c68f0f7f6ae4c7237675016114.zip
auto-configure linux/osx build differences
- set cxx as needed (clang++ on os x) - set stdlib flag for os x 10.9 (CUDA libc++ workaround) - link ATLAS properly for non-MKL installation whether linux or os x
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile46
1 files changed, 40 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index 71b19b02..26dcac50 100644
--- a/Makefile
+++ b/Makefile
@@ -142,6 +142,33 @@ ALL_BUILD_DIRS := $(sort \
$(PROTO_BUILD_DIR) $(PROTO_BUILD_INCLUDE_DIR) $(PY_PROTO_BUILD_DIR) \
$(DISTRIBUTE_SUBDIRS))
+##############################
+# Configure build
+##############################
+
+# Determine platform
+UNAME := $(shell uname -s)
+ifeq ($(UNAME), Linux)
+ LINUX := 1
+else ifeq ($(UNAME), Darwin)
+ OSX := 1
+endif
+
+ifeq ($(LINUX), 1)
+ CXX := /usr/bin/g++
+endif
+
+# OS X:
+# clang++ instead of g++
+# libstdc++ instead of libc++ for CUDA compatibility on 10.9
+ifeq ($(OSX), 1)
+ CXX := /usr/bin/clang++
+ ifneq ($(findstring $(shell sw_vers -productVersion), 10.9),)
+ CXXFLAGS += -stdlib=libstdc++
+ endif
+endif
+
+# Debugging
DEBUG ?= 0
ifeq ($(DEBUG), 1)
COMMON_FLAGS := -DDEBUG -g -O0
@@ -149,15 +176,22 @@ else
COMMON_FLAGS := -DNDEBUG -O2
endif
-# MKL switch (default = non-MKL)
+# MKL switch (default = non-MKL = ATLAS)
USE_MKL ?= 0
ifeq ($(USE_MKL), 1)
- LIBRARIES += mkl_rt
- COMMON_FLAGS += -DUSE_MKL
- INCLUDE_DIRS += $(MKL_INCLUDE_DIR)
- LIBRARY_DIRS += $(MKL_LIB_DIR)
+ LIBRARIES += mkl_rt
+ COMMON_FLAGS += -DUSE_MKL
+ INCLUDE_DIRS += $(MKL_INCLUDE_DIR)
+ LIBRARY_DIRS += $(MKL_LIB_DIR)
else
- LIBRARIES += cblas atlas
+ ifeq ($(LINUX), 1)
+ # Linux simply has cblas and atlas
+ LIBRARIES += cblas atlas
+ else ifeq ($(OSX), 1)
+ # OS X packages atlas as the vecLib framework
+ LIBRARIES += cblas
+ LDFLAGS += -framework vecLib
+ endif
endif
COMMON_FLAGS += $(foreach includedir,$(INCLUDE_DIRS),-I$(includedir))