-
Notifications
You must be signed in to change notification settings - Fork 15
/
configure.ac
114 lines (102 loc) · 3.21 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
# require at least autoconf 2.69
AC_PREREQ([2.69])
# Process this file with autoconf to produce a configure script.
AC_INIT([seededlda],[1.4.0])
# Ensure C++ is set up as R expects
: ${R_HOME=`R RHOME`}
if test -z "${R_HOME}"; then
AC_MSG_ERROR([Could not determine R_HOME.])
fi
CXX=`"${R_HOME}/bin/R" CMD config CXX`
CXXFLAGS=`"${R_HOME}/bin/R" CMD config CXXFLAGS`
CXXFLAGS="${CXXFLAGS} -g0" # Disable debug information
CPPFLAGS=`"${R_HOME}/bin/R" CMD config CPPFLAGS`
LDFLAGS=`"${R_HOME}/bin/R" CMD config LDFLAGS`
AC_LANG(C++)
AC_REQUIRE_CPP
AC_PROG_CC
AC_PROG_CXX
# Default to no Intel TBB
TBBFLAGS=
TBBLIBS=
# Configure argument to avoid TBB
WITH_TBB="yes"
AC_ARG_ENABLE([tbb], [AS_HELP_STRING([--enable-tbb],["to choose to disable Intel TBB even if installed, use --disable-tbb"])],
[if test "${enableval}" = no; then
want_tbb=no
elif test "${enableval}" = yes; then
want_tbb=yes
else
want_tbb=yes
fi],
[want_tbb=yes])
if test "$want_tbb" = no ; then
AC_MSG_NOTICE([Intel TBB detection disabled])
else
# If tbb/tbb.h and libtbb are found, define TBB and add -ltbb
AC_MSG_CHECKING([Intel TBB existence:])
TBB_EXISTS=no
pkg-config --exists tbb >/dev/null 2>&1
SH_TBB_EXISTS=`echo $?`
if test ${SH_TBB_EXISTS} = 0 ; then
TBB_EXISTS=yes
AC_MSG_RESULT(yes)
else
if test ${SH_TBB_EXISTS} = 1 ; then
TBB_EXISTS=no
AC_MSG_RESULT(no)
AC_MSG_WARN([Intel TBB not installed; install TBB devel package for parallel processing or update PKG_CONFIG_PATH environment variable])
else
TBB_EXISTS=no
AC_MSG_RESULT(no)
AC_MSG_WARN([pkg-config not found; install pkg-config to auto-detect Intel TBB; assumed absent])
fi
fi
if test ${TBB_EXISTS} = yes ; then
AC_SUBST(TBBFLAGS, ["-DTBB $(pkg-config --cflags tbb)"])
AC_SUBST(TBBLIBS, ["$(pkg-config --libs tbb)"])
AC_MSG_CHECKING([tbb available for compiling and linking:])
[cat > libtbb_test.cpp <<_EOCONF
#include <tbb/tbb.h>
int main() {
int H = 1000;
tbb::concurrent_vector<bool> v(H, false);
tbb::parallel_for(tbb::blocked_range<int>(0, H), [&](tbb::blocked_range<int> r) {
for (int h = r.begin(); h < r.end(); ++h) {
v[h] = true;
}
});
if (std::find(v.begin(), v.end(), false) == v.end()) { // all true
return 0;
} else {
return 1;
}
}
_EOCONF]
${CXX} ${CXXFLAGS} ${TBBFLAGS} -o libtbb_test libtbb_test.cpp ${TBBLIBS} 2> errors.txt
if test `echo $?` -ne 0 ; then
AC_MSG_RESULT(no)
AC_MSG_WARN([parallel computing is disabled because the Intel TBB devel package is absent])
AC_SUBST(TBBFLAGS, [""])
AC_SUBST(TBBLIBS, [""])
else
./libtbb_test >/dev/null 2>&1
if test `echo $?` -ne 0 ; then
AC_MSG_RESULT(no)
AC_MSG_WARN([parallel computing is disabled because Intel TBB did not load])
AC_SUBST(TBBFLAGS, [""])
AC_SUBST(TBBLIBS, [""])
else
AC_MSG_RESULT(yes)
fi
fi
rm -f libtbb_test.cpp libtbb_test errors.txt
fi
fi
# Now substitute these variables in src/Makevars.in to create src/Makevars
AC_SUBST(TBB_CFLAGS, ${TBBFLAGS})
AC_SUBST(TBB_LIBS, ${TBBLIBS})
AC_MSG_NOTICE([Package CPP flags: ${TBB_CFLAGS}])
AC_MSG_NOTICE([Package LIBS: ${TBB_LIBS}])
AC_CONFIG_FILES([src/Makevars])
AC_OUTPUT