-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigure.ac
80 lines (63 loc) · 2.25 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
AC_INIT([readmat],[0.0.0.9000])
# Find the compiler and compiler flags used by R.
: ${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`
CXXFLAGS=`"${R_HOME}/bin/R" CMD config CXXFLAGS`
# set original preprocessor flags
R_CPPFLAGS=`"${R_HOME}/bin/R" CMD config CPPFLAGS`
# check c++
AC_LANG(C++)
AC_PROG_CPP
# sources files
AC_CONFIG_SRCDIR([src/cpp11.cpp])
AC_CONFIG_HEADERS([src/config.hpp])
# check for matlab installation
AC_CHECK_PROG([matlab],[matlab],[yes],[no])
AM_CONDITIONAL([FOUND_MATLAB], [test "x$matlab" = xyes])
AM_COND_IF([FOUND_MATLAB],,[AC_MSG_WARN([A full Matlab installation is required.])])
# matlab root
MAT_ROOT=$(matlab -batch 'disp(matlabroot)')
# matlab shared libraries
MAT_LIBS=$(matlab -batch "disp(fullfile(matlabroot, 'bin', computer('arch')))")
# Rpath
RPATH="-Wl,-rpath,${MAT_LIBS}"
# the search path of a default Matlab install (tricking AS_SEARCH_*)
MAT_CPPFLAGS="-I${MAT_ROOT}/extern/include"
CPPFLAGS="${MAT_CPPFLAGS} ${R_CPPFLAGS}"
LDFLAGS="-L${MAT_LIBS} ${RPATH}"
# check for libraries
have_mat=no
AC_SEARCH_LIBS([matOpen], [mat], [have_mat=yes])
if test "x${have_mat}" = xyes; then
AC_CHECK_HEADERS([mat.h], [], [have_mat=yes])
fi
if test "x${have_mat}" = xno; then
AC_MSG_WARN([
------------------------------------------------------------------------
A full installation of Matlab is required.
If you believe Matlab is installed on your system but this script is
simply unable to find it, you can specify the include and lib paths
manually:
R CMD INSTALL ${PACKAGE_NAME} \\
--configure-vars='LIBS=-L/path/to/libs CPPFLAGS=-I/path/to/headers'
------------------------------------------------------------------------])
fi
if test "x${have_mat}" = xyes; then
# Write the flags into the src/Makevars file.
AC_SUBST([PKG_CPPFLAGS], ["${CPPFLAGS}"])
AC_SUBST([PKG_LIBS], ["-L${MAT_LIBS} ${ac_cv_search_matOpen} ${RPATH}"])
fi
AC_CONFIG_FILES([src/Makevars])
AC_OUTPUT
# print something nice
echo "
-----------------------------------------------------------
Configuration for ${PACKAGE_NAME} ${PACKAGE_VERSION}
cppflags: ${PKG_CPPFLAGS}
libs: ${PKG_LIBS}
-----------------------------------------------------------
"