-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·58 lines (51 loc) · 1.83 KB
/
configure
File metadata and controls
executable file
·58 lines (51 loc) · 1.83 KB
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
#!/bin/sh
# Configure script for coexpr package
# Detects OpenMP support and configures Makevars accordingly
# Get R configuration
: ${R_HOME=`R RHOME`}
if test -z "${R_HOME}"; then
echo "Could not determine R_HOME"
exit 1
fi
CC=`"${R_HOME}/bin/R" CMD config CC`
CFLAGS=`"${R_HOME}/bin/R" CMD config CFLAGS`
CXX=`"${R_HOME}/bin/R" CMD config CXX`
CXXFLAGS=`"${R_HOME}/bin/R" CMD config CXXFLAGS`
SHLIB_OPENMP_CXXFLAGS=`"${R_HOME}/bin/R" CMD config SHLIB_OPENMP_CXXFLAGS`
# Check for OpenMP support
OPENMP_CXXFLAGS=""
OPENMP_LIBS=""
EXTRA_CXXFLAGS=""
echo "Checking for OpenMP support..."
# macOS with Homebrew libomp
if [ "$(uname -s)" = "Darwin" ]; then
LIBOMP_PATH="/opt/homebrew/opt/libomp"
if [ -f "${LIBOMP_PATH}/lib/libomp.dylib" ]; then
echo " Found Homebrew libomp at ${LIBOMP_PATH}"
OPENMP_CXXFLAGS="-fopenmp -I${LIBOMP_PATH}/include"
# Use explicit path to override R's bundled libomp
OPENMP_LIBS="-L${LIBOMP_PATH}/lib -Wl,-rpath,${LIBOMP_PATH}/lib ${LIBOMP_PATH}/lib/libomp.dylib"
elif [ -n "${SHLIB_OPENMP_CXXFLAGS}" ]; then
echo " Using R's OpenMP flags: ${SHLIB_OPENMP_CXXFLAGS}"
OPENMP_CXXFLAGS="${SHLIB_OPENMP_CXXFLAGS}"
OPENMP_LIBS="${SHLIB_OPENMP_CXXFLAGS}"
else
echo " OpenMP not found, building without parallel support"
fi
else
# Linux and other systems
if [ -n "${SHLIB_OPENMP_CXXFLAGS}" ]; then
echo " Using R's OpenMP flags: ${SHLIB_OPENMP_CXXFLAGS}"
OPENMP_CXXFLAGS="${SHLIB_OPENMP_CXXFLAGS}"
OPENMP_LIBS="${SHLIB_OPENMP_CXXFLAGS}"
else
echo " OpenMP not found, building without parallel support"
fi
fi
# Write Makevars
echo "Creating src/Makevars..."
sed -e "s|@OPENMP_CXXFLAGS@|${OPENMP_CXXFLAGS}|g" \
-e "s|@OPENMP_LIBS@|${OPENMP_LIBS}|g" \
-e "s|@EXTRA_CXXFLAGS@|${EXTRA_CXXFLAGS}|g" \
src/Makevars.in > src/Makevars
echo "Configuration complete."