forked from duncantl/RCUDA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.in
111 lines (84 loc) · 2.49 KB
/
configure.in
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
AC_INIT(src/RCUDA.h)
# find the cuda.h file.
# Find nvcc
if test -z "$CUDA_DIR" ; then
if test -r "/usr/local/cuda" ; then
CUDA_DIR=/usr/local/cuda
elif test -r "/usr/local/cuda-5.0" ; then
CUDA_DIR=/usr/local/cuda-5.0
else
echo "the CUDA development files are not in the typical locations."
echo "Please rerun having set the environment variable CUDA_DIR to"
echo "the path of the directory that contains both the include/ and lib/ directories"
echo "of the CUDA installation"
if test -z "$FORCE" ; then
exit 1
fi
fi
fi
if test -z "$CUDA_INC_DIR" ; then
CUDA_INC_DIR=${CUDA_DIR}/include
fi
if test -z "$CUDA_LIB_DIR" ; then
if test -e ${CUDA_DIR}/lib64 ; then
CUDA_LIB_DIR=${CUDA_DIR}/lib64
else
CUDA_LIB_DIR=${CUDA_DIR}/lib
fi
fi
export PATH=$CUDA_DIR/bin:$PATH
AC_PATH_PROGS(NVCC_BIN, nvcc)
CPPFLAGS="-I${CUDA_INC_DIR} $CPPFLAGS"
AC_CHECK_HEADER(cuda.h, FOUND_CUDA_H=1)
#AC_TRY_COMPILE([
##include <cuda.h>
##include <cuda_runtime_api.h>
#])
LDFLAGS="-L${CUDA_LIB_DIR} ${LDFLAGS}"
LIBS="-lcuda -lcudart ${LIBS}"
AC_TRY_LINK([
#include <cuda.h>
#include <cuda_runtime_api.h>
],
[
int ver;
cudaDriverGetVersion(&ver);
cudaRuntimeGetVersion(&ver);
], echo "linking okay", [echo "cannot link with libcuda" ; if test -z "$FORCE" ; then exit 1 ; fi])
# For OSX 10.11. Need to specify this for linking so we can find the library at run/load time.
OS=`uname`
if test "$OS" = "Darwin" ; then
RPATH="-Wl,-rpath,/usr/local/cuda/lib"
fi
echo "Creating checkSDKVersion with $CPPFLAGS $LDFLAGS $LIBS"
$CC -o checkSDKVersion checkSDKVersion.c $CPPFLAGS $LDFLAGS $LIBS $RPATH
./checkSDKVersion
if ! test $? = 0 ; then
echo "You appear to have an older CUDA SDK. We require CUDA SDK 5.0 or higher"
if test -z "$FORCE" ; then
exit 2
fi
fi
echo "CUDA_INC_DIR = $CUDA_INC_DIR"
echo "CUDA_LIB_DIR = $CUDA_LIB_DIR"
echo "nvcc = $NVCC_BIN"
echo "Computing CUDA run-time version"
$CC -o cudaVersion -I$CUDA_INC_DIR cudaVersion.c -L$CUDA_LIB_DIR -lcuda -lcudart $RPATH
CUDA_VERSION=`cudaVersion`
AC_SUBST(CUDA_VERSION)
AC_SUBST(CUDA_INC_DIR)
AC_SUBST(CUDA_LIB_DIR)
AC_SUBST(CUDA_DIR)
AC_SUBST(NVCC_BIN)
AC_SUBST(RPATH)
AC_OUTPUT(src/Makevars R/nvcc.R)
#chmod -w R/nvcc.R
echo "Computing size of CUDA structures"
echo "Compiling sizeofs"
${NVCC_BIN} -o sizeofs sizeofs.cu
if test $? = 0; then
echo "Running sizeofs"
./sizeofs > R/StructSizes.R
else
echo "Problems compiling sizeofs.cu. Continuing with installation, but there may be problems!"
fi