-
Notifications
You must be signed in to change notification settings - Fork 26
/
configure
executable file
·190 lines (164 loc) · 7.1 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
####################################################################
# configure for package gpuR
# Charles E. Determan Jr.
#
# Note - this assumes that when installing from environmental variables
# that the user wants the 64-bit install
CPPFLAGS="PKG_CPPFLAGS=-I../inst/include"
CXXFLAGS="PKG_CXXFLAGS="
LIBS="PKG_LIBS="
BUILD_LIB="BUILD_LIB="
if [ ! -z "OPENCL_FLAGS" ]; then
echo "OPENCL_FLAGS not set, using default -DCL_HPP_MINIMUM_OPENCL_VERSION=110 -DCL_USE_DEPRECATED_OPENCL_1_2_APIS -DCL_HPP_TARGET_OPENCL_VERSION=120"
CPPFLAGS="${CPPFLAGS} -DCL_HPP_MINIMUM_OPENCL_VERSION=110 -DCL_USE_DEPRECATED_OPENCL_1_2_APIS -DCL_HPP_TARGET_OPENCL_VERSION=120"
else
echo "Using OPENCL_FLAGS = " $OPENCL_FLAGS
fi
# check OS
case `uname` in
Darwin* )
echo "Darwin OS"
if [ ! -z "$OPENCL_LIB" ]; then
# custom paths
echo "Using OPENCL_LIB = " $OPENCL_LIB
LIBS="PKG_LIBS=-L$OPENCL_LIB -framework OpenCL -Wl,-rpath,$OPENCL_LIB"
if ${OPENCL_INC+"false"}; then
echo "OPENCL_INC not set, using default include directory"
OPENCL_INC=/System/Library/Frameworks/OpenCL.framework/Headers/
else
echo "Using OPENCL_INC = " $OPENCL_INC
fi
CPPFLAGS="${CPPFLAGS} -I'${OPENCL_INC}'"
elif [ ! -z "$CUDA_HOME" ]; then
# CUDA SDK
OPENCL_INC=$CUDA_HOME/include
CPPFLAGS="${CPPFLAGS} -I'${OPENCL_INC}'"
LIBS="PKG_LIBS=-L$CUDA_HOME/lib64 -framework OpenCL -Wl,-rpath,$CUDA_HOME/lib64"
elif [ ! -z "$AMDAPPSDKROOT" ]; then
# AMD SDK
OPENCL_INC=$AMDAPPSDKROOT/include
CPPFLAGS="${CPPFLAGS} -I'${OPENCL_INC}'"
LIBS="PKG_LIBS=-L$AMDAPPSDKROOT/lib/x86_64 -framework OpenCL -Wl,-rpath,$AMDAPPSDKROOT/lib/x86_64"
elif [ ! -z "$INTELOCLSDKROOT" ]; then
# Intel SDK
echo "using INTELOCLSDKROOT"
OPENCL_INC=$INTELOCLSDKROOT/include
CPPFLAGS="${CPPFLAGS} -I'${OPENCL_INC}'"
LIBS="PKG_LIBS=-L$INTELOCLSDKROOT/lib/x64 -framework -Wl,-rpath,$INTELOCLSDKROOT/lib/x64"
else
echo "OPENCL_LIB not set, trying default lib location"
LIBS="PKG_LIBS=-framework OpenCL"
#BUILD_LIB="BUILD_LIB=../inst/include/loader/libOpenCL.a"
echo "Checking OpenCL C++ API"
if ${OPENCL_INC+"false"}; then
echo "OPENCL_INC not set, using default include directory"
OPENCL_INC=/System/Library/Frameworks/OpenCL.framework/Headers/
else
echo "Using OPENCL_INC = " $OPENCL_INC
fi
fi
if test -e "$OPENCL_INC/cl2.hpp"; then
CPPFLAGS="${CPPFLAGS} -I$OPENCL_INC -DHAVE_CL_CL2_HPP"
echo "cl2.hpp header exists"
else
if test -e "$OPENCL_INC/cl.hpp"; then
CPPFLAGS="${CPPFLAGS} -I$OPENCL_INC"
echo "cl.hpp header exists"
fi
fi
;;
Linux* )
echo "Linux OS"
if [ ! -z "$OPENCL_LIB" ]; then
# custom paths
echo "Using OPENCL_LIB =" $OPENCL_LIB
LIBS="PKG_LIBS=-L$OPENCL_LIB -lOpenCL -Wl,-rpath,$OPENCL_LIB"
if ${OPENCL_INC+"false"}; then
echo "OPENCL_INC not set, using default include directory /usr/include"
OPENCL_INC=/usr/include
else
echo "Using OPENCL_INC = " $OPENCL_INC
fi
CPPFLAGS="${CPPFLAGS} -I'${OPENCL_INC}'"
elif [ ! -z "$CUDA_HOME" ]; then
# CUDA SDK
echo "using CUDA_HOME"
OPENCL_INC=$CUDA_HOME/include
LIBS="PKG_LIBS=-L$CUDA_HOME/lib64 -lOpenCL -Wl,-rpath,$CUDA_HOME/lib64"
CPPFLAGS="${CPPFLAGS} -I'${OPENCL_INC}'"
elif [ ! -z "$AMDAPPSDKROOT" ]; then
# AMD SDK
echo "using AMDAPPSDKROOT"
OPENCL_INC=$AMDAPPSDKROOT/include
LIBS="PKG_LIBS=-L$AMDAPPSDKROOT/lib/x86_64 -lOpenCL -Wl,-rpath,$AMDAPPSDKROOT/lib/x86_64"
CPPFLAGS="${CPPFLAGS} -I'${OPENCL_INC}'"
elif [ ! -z "$INTELOCLSDKROOT" ]; then
# Intel SDK
echo "using INTELOCLSDKROOT"
OPENCL_INC=$INTELOCLSDKROOT/include
LIBS="PKG_LIBS=-L$INTELOCLSDKROOT/lib/x64 -lOpenCL -Wl,-rpath,$INTELOCLSDKROOT/lib/x64"
CPPFLAGS="${CPPFLAGS} -I'${OPENCL_INC}'"
else
# try searching for opencl library
# if fails, build library from scratch
if [ `ldconfig -p | grep 'libOpenCL\|lOpenCL' | wc -l` > 0 ]; then
echo "found OpenCL library"
LIBS="PKG_LIBS=-lOpenCL"
echo "Checking OpenCL C++ API"
if ${OPENCL_INC+"false"}; then
echo "OPENCL_INC not set, using default include directory /usr/include"
OPENCL_INC=/usr/include/
else
echo "Using OPENCL_INC = " $OPENCL_INC
fi
CPPFLAGS="${CPPFLAGS} -I'${OPENCL_INC}'"
else
echo "no OpenCL found"
# exit 1
# setting defaults to compile from source
echo "OPENCL_LIB not set, will be compiled from source"
LIBS="PKG_LIBS=-L../inst/include/loader -lOpenCL -pthread"
BUILD_LIB="BUILD_LIB=../inst/include/loader/libOpenCL.a"
echo "Checking OpenCL C++ API"
if ${OPENCL_INC+"false"}; then
echo "OPENCL_INC not set, using default include directory /usr/include"
OPENCL_INC=/usr/include/
else
echo "Using OPENCL_INC = " $OPENCL_INC
fi
CPPFLAGS="${CPPFLAGS} -I'${OPENCL_INC}'"
fi
fi
if test -e "$OPENCL_INC/CL/cl2.hpp"; then
CPPFLAGS="${CPPFLAGS} -DHAVE_CL_CL2_HPP"
echo "cl2.hpp header exists"
else
if test -e "$OPENCL_INC/CL/cl.hpp"; then
echo "cl.hpp header exists"
else
echo "No OpenCL C++ API found, will use the headers contained in the package"
CPPFLAGS="${CPPFLAGS} -I. -pthread"
fi
fi
;;
Solaris*)
echo "SOLARIS currently not supported"
;;
*)
echo "unknown: `uname`"
;;
esac
echo 'CXX_STD=CXX11' > src/Makevars
echo "${CPPFLAGS}" >> src/Makevars
echo "${CXXFLAGS}" >> src/Makevars
echo "${LIBS}" >> src/Makevars
echo "${BUILD_LIB}" >> src/Makevars
printf '\n$(SHLIB): $(BUILD_LIB)\n\n' >> src/Makevars
printf '../inst/include/loader/libOpenCL.a:\n' >> src/Makevars
printf '\tcd ../inst/include/loader/ && mkdir -p .$(R_ARCH) && $(MAKE) libOpenCL.a \\\n' >> src/Makevars
printf '\tCC="$(CC)" CFLAGS="$(ALL_CFLAGS)" AR="$(AR)" RM="$(RM)" \\\n' >> src/Makevars
printf '\tICD_OS=icd_linux\n' >> src/Makevars
echo ""
echo "*********** Generated Makevars file ***********"
cat src/Makevars
echo "***********************************************"