From 22b64127d7acc9c255b007e120e2a721f4e136d2 Mon Sep 17 00:00:00 2001
From: Jianwen WEI <weijianwen@gmail.com>
Date: Fri, 18 Aug 2017 23:32:16 +0800
Subject: [PATCH] Enable customize CUB MSHADOW PSLITE CUDA paths.

---
 Makefile | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index c71cb13..a53d072 100644
--- a/Makefile
+++ b/Makefile
@@ -14,6 +14,19 @@ ifndef DMLC_CORE
 	DMLC_CORE = $(ROOTDIR)/dmlc-core
 endif
 
+ifndef MSHADOW_PATH
+	MSHADOW_PATH = $(ROOTDIR)/mshadow
+endif
+ifneq ("$(wildcard $(MSHADOW_PATH)/include/mshadow/base.h)","")
+MSHADOW_INC = $(MSHADOW_PATH)/include
+else
+MSHADOW_INC = $(MSHADOW_PATH)
+endif
+
+ifndef PS_PATH
+	PS_PATH = $(ROOTDIR)/ps-lite
+endif
+
 ifndef NNVM_PATH
 	NNVM_PATH = $(ROOTDIR)/nnvm
 endif
@@ -32,7 +45,7 @@ ifeq ($(USE_MKL2017), 1)
 	export USE_MKLML = $(lastword $(RETURN_STRING))
 endif
 
-include mshadow/make/mshadow.mk
+include $(MSHADOW_PATH)/make/mshadow.mk
 include $(DMLC_CORE)/make/dmlc.mk
 
 # all tge possible warning tread
@@ -49,7 +62,7 @@ ifeq ($(DEBUG), 1)
 else
 	CFLAGS += -O3 -DNDEBUG=1
 endif
-CFLAGS += -I$(ROOTDIR)/mshadow/ -I$(ROOTDIR)/dmlc-core/include -fPIC -I$(NNVM_PATH)/include -Iinclude $(MSHADOW_CFLAGS)
+CFLAGS += -I$(MSHADOW_INC) -I$(DMLC_CORE)/include -fPIC -I$(NNVM_PATH)/include -Iinclude $(MSHADOW_CFLAGS)
 LDFLAGS = -pthread $(MSHADOW_LDFLAGS) $(DMLC_LDFLAGS)
 ifeq ($(DEBUG), 1)
 	NVCCFLAGS = -std=c++11 -Xcompiler -D_FORCE_INLINES -g -G -O0 -ccbin $(CXX) $(MSHADOW_NVCCFLAGS)
@@ -125,8 +138,11 @@ ifneq ($(USE_CUDA_PATH), NONE)
 	NVCC=$(USE_CUDA_PATH)/bin/nvcc
 endif
 
+ifndef CUB_INCLUDE
+	CUB_PATH = $(ROOTDIR)/cub
+endif
+
 # ps-lite
-PS_PATH=$(ROOTDIR)/ps-lite
 DEPS_PATH=$(shell pwd)/deps
 include $(PS_PATH)/make/ps.mk
 ifeq ($(USE_DIST_KVSTORE), 1)
@@ -181,11 +197,11 @@ else
 endif
 
 # all dep
-LIB_DEP += $(DMLC_CORE)/libdmlc.a $(NNVM_PATH)/lib/libnnvm.a
+LIB_DEP += $(DMLC_CORE)/lib/libdmlc.a $(NNVM_PATH)/lib/libnnvm.a
 ALL_DEP = $(OBJ) $(EXTRA_OBJ) $(PLUGIN_OBJ) $(LIB_DEP)
 
 ifeq ($(USE_CUDA), 1)
-	CFLAGS += -I$(ROOTDIR)/cub
+	CFLAGS += -I$(CUB_INCLUDE) -I$(USE_CUDA_PATH)/include -I$(CUDNN_PATH)/include
 	ALL_DEP += $(CUOBJ) $(EXTRA_CUOBJ) $(PLUGIN_CUOBJ)
 	LDFLAGS += -lcuda -lcufft
 	SCALA_PKG_PROFILE := $(SCALA_PKG_PROFILE)-gpu
-- 
1.8.3.1

