-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathconfigure
executable file
·38 lines (35 loc) · 1.89 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
#!/bin/sh
CC=`${R_HOME}/bin/R CMD config CC`
CFLAGS=`${R_HOME}/bin/R CMD config CFLAGS`
printf "#include <omp.h>\nint main () { return omp_get_num_threads(); }" | ${CC} ${CFLAGS} -fopenmp -xc ->/dev/null 2>&1 || R_NO_OPENMP=1;
rm a.out >/dev/null 2>&1
if [ "$R_NO_OPENMP" = "1" ]; then
printf "#include <omp.h>\nint main () { return omp_get_num_threads(); }" | ${CC} ${CFLAGS} -Xpreprocessor -fopenmp -lomp -xc ->/dev/null 2>&1 || R_NO_OPENMP=2;
rm a.out >/dev/null 2>&1
if [ "$R_NO_OPENMP" = "2" ]; then
if [ "`uname`" = "Linux" ] ;then
echo "*** On Linux and OpenMP not supported!"
sed -e "s|@openmp_cflags@||g; s|@openmp_libslags@||g; s|@realtime_libslags@|-lrt|g;" src/Makevars.in > src/Makevars
else
echo "*** Not on Linux and OpenMP not supported!"
sed -e "s|@openmp_cflags@||g; s|@openmp_libslags@||g; s|@realtime_libslags@||g;" src/Makevars.in > src/Makevars
fi
else
echo "*** OpenMP supported (-Xpreprocessor)!"
sed -e "s|@openmp_cflags@|-Xpreprocessor -fopenmp|g; s|@openmp_libslags@|-lomp|g; s|@realtime_libslags@||g;" src/Makevars.in > src/Makevars
fi
else
if [ "`uname`" = "Darwin" ] ;then
if gcc --version | grep -i "gcc" > /dev/null; then
echo "*** On Darwin and GCC OpenMP supported!"
sed -e "s|@openmp_cflags@|-Xpreprocessor -fopenmp|g; s|@openmp_libslags@|-lgomp|g; s|@realtime_libslags@||g;" src/Makevars.in > src/Makevars
elif clang --version | grep -i "clang" > /dev/null; then
echo "*** On Darwin and CLANG OpenMP supported!"
sed -e "s|@openmp_cflags@|-Xpreprocessor -fopenmp|g; s|@openmp_libslags@|-lomp|g; s|@realtime_libslags@||g;" src/Makevars.in > src/Makevars
fi
else
echo "*** On Linux and OpenMP supported!"
sed -e "s|@openmp_cflags@|\$(SHLIB_OPENMP_CFLAGS)|g; s|@openmp_libslags@|\$(SHLIB_OPENMP_CFLAGS)|g; s|@realtime_libslags@|-lrt|g;" src/Makevars.in > src/Makevars
fi
fi
exit 0