forked from nullsatz/gputools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
121 lines (106 loc) · 3.3 KB
/
configure.ac
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
AC_INIT([gputools], 1.2) dnl package name, version
AC_CONFIG_AUX_DIR([tools])
dnl Select an optional include path, from a configure option
dnl or from an environment variable.
AC_ARG_WITH([cuda-include],
AC_HELP_STRING([--with-cuda-include=INCLUDE_PATH],
[the location of CUDA header files]),
[cuda_include_path=$withval])
CUDA_CPPFLAGS="-I."
if test [ -n "${cuda_include_path}" ] ; then
CUDA_CPPFLAGS="-I. -I${cuda_include_path}"
else
if test [ -n "${CUDA_INCLUDE}" ] ; then
CUDA_CPPFLAGS="-I. -I${CUDA_INCLUDE}"
cuda_include_path="${CUDA_INCLUDE}"
else
if test [ -d "/usr/local/cuda/include" ] ; then
CUDA_CPPFLAGS="-I. -I/usr/local/cuda/include"
cuda_include_path="/usr/local/cuda/include"
fi
fi
fi
dnl ditto for a library path
AC_ARG_WITH([cuda-lib],
AC_HELP_STRING([--with-cuda-lib=LIB_PATH],
[the location of CUDA libraries]),
[cuda_lib_path=$withval])
if test [ -n "${cuda_lib_path}" ] ; then
LIBS="-L${cuda_lib_path} ${LIBS}"
else
if test [ -n "${CUDA_LIBS}" ] ; then
LIBS="-L${CUDA_LIBS} ${LIBS}"
cuda_lib_path="${CUDA_LIBS}"
else
if test [ -d "/usr/local/cuda/lib64" ] ; then
LIBS="-L/usr/local/cuda/lib64 ${LIBS}"
cuda_lib_path="/usr/local/cuda/lib64"
else
if test [ -d "/usr/local/cuda/lib" ] ; then
LIBS="-L/usr/local/cuda/lib ${LIBS}"
cuda_lib_path="/usr/local/cuda/lib"
fi
fi
fi
fi
dnl Now find the compiler and compiler flags to use
: ${R_HOME=`R RHOME`}
if test -z "${R_HOME}"; then
echo "could not determine R_HOME"
exit 1
fi
CXX=`"${R_HOME}/bin/R" CMD config CXX`
CPP=`"${R_HOME}/bin/R" CMD config CPP`
CXXFLAGS=`"${R_HOME}/bin/R" CMD config CXXFLAGS`
CPPFLAGS=`"${R_HOME}/bin/R" CMD config CPPFLAGS`
AC_PROG_CXX
AC_PROG_CPP
if test [ -n "${cuda_include_path}" ] ; then
OLD_CPPFLAGS=${CPPFLAGS}
CPPFLAGS="-I${cuda_include_path} ${CPPFLAGS}"
fi
AC_CHECK_HEADER([cuda.h], , [HAS_CUDA_H=no])
AC_CHECK_HEADER([nvrtc.h], , [HAS_NVRTC_H=no])
if test [ -n "${cuda_include_path}" ] ; then
CPPFLAGS=${OLD_CPPFLAGS}
fi
if test [ "${HAS_CUDA_H}" = no ] ; then
AC_MSG_ERROR("CUDA header cuda.h not found")
fi
if test [ "${HAS_NVRTC_H}" = no ] ; then
AC_MSG_ERROR("CUDA header nvrtc.h not found")
fi
if test [ -n "${cuda_lib_path}" ] ; then
OLD_LDFLAGS=${LDFLAGS}
LDFLAGS="-L${cuda_lib_path} ${LDFLAGS}"
fi
dnl search for a library containing a CUDA function
AC_SEARCH_LIBS([cuGetErrorName], [cuda], ,
AC_MSG_ERROR("no cuda driver library found"))
dnl search for a library containing a CUDA function
AC_SEARCH_LIBS([cudaMalloc], [cudart], ,
AC_MSG_ERROR("no cuda runtime api library found"))
dnl search for a library containing a CUDA function
AC_SEARCH_LIBS([nvrtcCreateProgram], [nvrtc], ,
AC_MSG_ERROR("no nvrtc library found"))
dnl search for a library containing a CUDA function
AC_SEARCH_LIBS([cublasSetMatrix], [cublas], ,
AC_MSG_ERROR("no cublas library found"))
if test [ -n "${cuda_lib_path}" ] ; then
LDFLAGS=${OLD_LDFLAGS}
AC_CANONICAL_HOST
case $host_os in
darwin* )
LIBS="${LIBS} -Wl,-rpath,${cuda_lib_path}"
;;
* )
LIBS="${LIBS} -Wl,-rpath=${cuda_lib_path}"
;;
esac
fi
dnl substitute CUDA_CPPFLAGS and LIBS
AC_SUBST(CUDA_CPPFLAGS)
AC_SUBST(LIBS)
dnl and do substitution in the src/Makevars.in
AC_CONFIG_FILES([src/Makevars])
AC_OUTPUT