$(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
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))
-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_35,code=sm_35
-# MKL switch: set to 1 for MKL
+# MKL switch:
+# 0 for ATLAS BLAS (default)
+# 1 for MKL BLAS
USE_MKL := 0
# MKL directory contains include/ and lib/ directions that we need.
MKL_DIR := /opt/intel/mkl
# NOTE: this is required only if you will compile the python interface.
# We need to be able to find Python.h and numpy/arrayobject.h.
PYTHON_INCLUDES := /usr/include/python2.7 \
- /usr/local/lib/python2.7/dist-packages/numpy/core/include
+ /usr/local/lib/python2.7/dist-packages/numpy/core/include
# Anaconda Python distribution is quite popular. Include path:
# PYTHON_INCLUDES := $(HOME)/anaconda/include \
- # $(HOME)/anaconda/include/python2.7 \
- # $(HOME)/anaconda/lib/python2.7/site-packages/numpy/core/include
+ # $(HOME)/anaconda/include/python2.7 \
+ # $(HOME)/anaconda/lib/python2.7/site-packages/numpy/core/include
# We need to be able to find libpythonX.X.so or .dylib.
PYTHON_LIB := /usr/local/lib
# PYTHON_LIB := $(HOME)/anaconda/lib
-CXX := /usr/bin/g++
-# For OS X, use clang++.
-# CXX := /usr/bin/clang++
-# For OS X 10.9, use libstdc++ instead of libc++ for CUDA compatibility.
-# CXXFLAGS := -stdlib=libstdc++
-
# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDES) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/lib /usr/local/lib
MKL_DIR := /opt/intel/mkl # only needed for MKL
PYTHON_INCLUDES := /path/to/anaconda/include /path/to/anaconda/include/python2.7 /path/to/anaconda/lib/python2.7/site-packages/numpy/core/include
PYTHON_LIB := /path/to/anaconda/lib
- CXX=/usr/bin/clang++
Don't forget to set `PATH` and `LD_LIBRARY_PATH`: