forked from dselivanov/rsparse
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigure.ac
145 lines (126 loc) · 4.77 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
AC_PREREQ([2.69])
AC_INIT(DESCRIPTION)
dnl Determine R_HOME.
: ${R_HOME=`R RHOME`}
if test -z "${R_HOME}"; then
AC_MSG_ERROR([could not determine R_HOME])
fi
# Obtain from R.
R_SCMD="${R_HOME}/bin/R CMD config"
BLAS_LIBS=`${R_SCMD} BLAS_LIBS`
LAPACK_LIBS=`${R_SCMD} LAPACK_LIBS`
FLOAT_LIBS=`${R_HOME}/bin/Rscript -e "float:::ldflags()"`
# Check tools.
AC_CHECK_PROG([echo_ok], [echo], [yes], [no], ,)
AC_CHECK_PROG([grep_ok], [grep], [yes], [no], ,)
#------------------------------------------------------
# borrowed from https://github.com/wrathematics/float
#------------------------------------------------------
### Check for single precision BLAS/LAPACK symbols. These can be present/absent
### in almost any imaginable combination. For example, OpenBLAS (and others?)
### ship LAPACK symbols in the blas.[so|dylib|dll] file.
# Check Rblas.
if test -f "${FLOAT_LIBS}" ; then
HAVESBLAS="yes"
HAVESLAPACK="yes"
else
if test "X${echo_ok}" = "Xyes" -a "X${grep_ok}" = "Xyes"; then
useRblas=`echo ${BLAS_LIBS} | grep "\-lRblas"`
if test "X${useRblas}" = "X"; then
AC_CHECK_LIB(blas, [sgemm_], [HAVESBLAS=yes], [HAVESBLAS=no])
AC_CHECK_LIB(blas, [sgetrf_], [HAVESLAPACK=yes], [HAVESLAPACK=no])
else
LDFLAGS_OLD="${LDFLAGS}"
LDFLAGS="${LDFLAGS} ${BLAS_LIBS}"
AC_CHECK_LIB(Rblas, [sgemm_], [HAVESBLAS=yes], [HAVESBLAS=no])
AC_CHECK_LIB(Rblas, [sgetrf_], [HAVESLAPACK=yes], [HAVESLAPACK=no])
LDFLAGS="${LDFLAGS_OLD}" # WCC: do you need a "if-else-fi" to check?
fi
else
HAVESBLAS="no"
fi
fi
# Check for single precision LAPACK symbols.
if test "X${HAVESLAPACK}" = "X" -o "X${HAVESLAPACK}" = "Xno"; then
if test "X${echo_ok}" = "Xyes" -a "X${grep_ok}" = "Xyes"; then
useRlapack=`echo ${LAPACK_LIBS} | grep "\-lRlapack"`
if test "X${useRlapack}" = "X"; then
AC_CHECK_LIB(lapack, [sgetrf_], [HAVESLAPACK=yes], [HAVESLAPACK=no])
else
LDFLAGS_OLD="${LDFLAGS}"
LDFLAGS="${LDFLAGS} ${LAPACK_LIBS}"
AC_CHECK_LIB(Rlapack, [sgetrf_], [HAVESLAPACK=yes], [HAVESLAPACK=no])
LDFLAGS="${LDFLAGS_OLD}"
fi
else
HAVESLAPACK="no"
fi
fi
# Set additional object files and messages
ARMA_BLAS=""
SINGLE_PRECISION_BLAS_AVAILABLE="FALSE"
if test "X${HAVESBLAS}" = "Xno"; then
echo "* NOTE: defining ARMA_DONT_USE_BLAS"
echo "* WARNING: using Armadillo reference BLAS implementation"
ARMA_BLAS="${ARMA_BLAS} -DARMA_DONT_USE_BLAS"
else
echo "* NOTE: using system-wide BLAS"
SINGLE_PRECISION_BLAS_AVAILABLE="TRUE"
fi
# Set additional object files and messages
SINGLE_PRECISION_LAPACK_AVAILABLE="FALSE"
DSINGLE_PRECISION_LAPACK_AVAILABLE=""
if test "X${HAVESLAPACK}" = "Xyes"; then
echo "* NOTE: using system-wide LAPACK"
SINGLE_PRECISION_LAPACK_AVAILABLE="TRUE"
DSINGLE_PRECISION_LAPACK_AVAILABLE="-DSINGLE_PRECISION_LAPACK_AVAILABLE"
else
echo "* WARNING: single precision LAPACK is not available"
fi
#------------------------------------------------------
# borrowed from https://github.com/zhangh12/ARTP2/blob/88597ea2c81119821feaed218142372178aaf430/configure.ac
#------------------------------------------------------
CXX1X=`"${R_HOME}/bin/R" CMD config CXX1X`
CXX1XSTD=`"${R_HOME}/bin/R" CMD config CXX1XSTD`
CXX="${CXX1X} ${CXX1XSTD}"
CXXFLAGS=`"${R_HOME}/bin/R" CMD config CXX1XFLAGS`
AC_LANG(C++)
dnl this the meat of R's m4/openmp.m4
OPENMP_[]_AC_LANG_PREFIX[]FLAGS=
AC_ARG_ENABLE([openmp],
[AS_HELP_STRING([--disable-openmp], [do not use OpenMP])])
if test "$enable_openmp" != no; then
AC_CACHE_CHECK([for $[]_AC_CC[] option to support OpenMP],
[ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp],
[AC_LINK_IFELSE([_AC_LANG_OPENMP],
[ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp='none needed'],
[ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp='unsupported'
for ac_option in -fopenmp -xopenmp -qopenmp \
-openmp -mp -omp -qsmp=omp -homp \
-fopenmp=libomp \
-Popenmp --openmp; do
ac_save_[]_AC_LANG_PREFIX[]FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $ac_option"
AC_LINK_IFELSE([_AC_LANG_OPENMP],
[ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp=$ac_option])
_AC_LANG_PREFIX[]FLAGS=$ac_save_[]_AC_LANG_PREFIX[]FLAGS
if test "$ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp" != unsupported; then
break
fi
done])])
case $ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp in #(
"none needed" | unsupported)
;; #(
*)
OPENMP_[]_AC_LANG_PREFIX[]FLAGS=$ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp ;;
esac
fi
#------------------------------------------------------
AC_SUBST(OPENMP_CXXFLAGS)
AC_SUBST(ARMA_BLAS)
AC_SUBST(DSINGLE_PRECISION_LAPACK_AVAILABLE)
AC_SUBST(FLOAT_LIBS)
AC_OUTPUT(src/Makevars)
AC_SUBST(SINGLE_PRECISION_LAPACK_AVAILABLE)
AC_SUBST(SINGLE_PRECISION_BLAS_AVAILABLE)
AC_OUTPUT([R/configure.R])