-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·46 lines (40 loc) · 1.41 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
39
40
41
42
43
44
45
46
#!/bin/sh
# We make sure that the R and Armadillo bindings are compatible (i.e., messages)
# this is why we add the R and cpp11 path
CPP11_INCLUDE_PATH=`${R_HOME}/bin/Rscript -e "cat(system.file('include', package = 'cpp11'))"`
INST_INCLUDE_PATH="./inst/include"
# Check if CPP11_INCLUDE_PATH is empty
if [ -z "$CPP11_INCLUDE_PATH" ]; then
echo "Error: cpp11 include path is empty. Please ensure the cpp11 package is installed."
exit 1
fi
PKG_CPPFLAGS="-I${INST_INCLUDE_PATH} -I${CPP11_INCLUDE_PATH}"
# Debugging: Print the values of the variables
echo "=================================="
echo " Compiler Configuration Variables "
echo " "
echo "CPP11_INCLUDE_PATH: ${CPP11_INCLUDE_PATH}"
echo "INST_INCLUDE_PATH: ${INST_INCLUDE_PATH}"
echo "PKG_CPPFLAGS: ${PKG_CPPFLAGS}"
# Create a temporary C++ file to test the compatibility with Armadillo
cat <<EOF> conftest.cpp
#include <armadillo.hpp>
using namespace arma;
int main() {
Mat<int> A(2, 2, fill::ones);
return 0;
}
EOF
# Test Armadillo using R CMD SHLIB
echo "==================================="
echo " Testing minimal Armadillo example "
echo " "
if ! PKG_CPPFLAGS="${PKG_CPPFLAGS}" "${R_HOME}/bin/R" CMD SHLIB conftest.cpp
then
echo "Armadillo is not compatible with the C++ compiler used by R."
rm -f conftest.cpp conftest.o conftest.so
exit 1
else
echo "Armadillo is compatible with the C++ compiler used by R."
rm -f conftest.cpp conftest.o conftest.so
fi