-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·52 lines (47 loc) · 1.9 KB
/
Copy pathconfigure
File metadata and controls
executable file
·52 lines (47 loc) · 1.9 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
#!/bin/sh
# configure -- AutoSpectralRcpp
#
# Detects Homebrew libomp on macOS and writes src/Makevars from src/Makevars.in.
# On Linux, OpenMP is handled natively by GCC and no detection is needed.
# On Windows, configure is not run -- src/Makevars.win is used directly.
#
# This script never installs software. If libomp is absent on macOS, the
# package builds without OpenMP (single-threaded C++ only). To enable OpenMP:
# brew install libomp
OPENMP_CPPFLAGS=""
OPENMP_LIBS=""
FLIBS_LINE=""
if [ "$(uname)" = "Darwin" ]; then
for HOMEBREW_PREFIX in /opt/homebrew /usr/local; do
LIBOMP_DIR="${HOMEBREW_PREFIX}/opt/libomp"
if [ -d "${LIBOMP_DIR}" ]; then
OPENMP_CPPFLAGS="-Xpreprocessor -fopenmp -I${LIBOMP_DIR}/include"
OPENMP_LIBS="-L${LIBOMP_DIR}/lib -lomp"
echo "configure: found libomp at ${LIBOMP_DIR}, enabling OpenMP"
break
fi
done
if [ -z "${OPENMP_LIBS}" ]; then
if [ -t 1 ]; then
echo "configure: libomp not found -- building without OpenMP (single-threaded C++ only)"
echo "configure: to enable OpenMP, run: brew install libomp"
echo "configure: then reinstall the package"
else
echo "configure: libomp not found and session is non-interactive -- cannot auto-install"
echo "configure: to enable OpenMP, open a terminal and run: brew install libomp"
echo "configure: then reinstall the package"
echo "configure: building without OpenMP (single-threaded C++ only) for now"
fi
echo "configure: note -- keep n_threads conservative to avoid conflict with Accelerate BLAS"
fi
else
# Linux: gfortran is expected to be present; include $(FLIBS) as normal
# OpenMP is handled natively by GCC via $(SHLIB_OPENMP_CXXFLAGS)
FLIBS_LINE='$(FLIBS)'
fi
sed \
-e "s|@OPENMP_CPPFLAGS@|${OPENMP_CPPFLAGS}|g" \
-e "s|@OPENMP_LIBS@|${OPENMP_LIBS}|g" \
-e "s|@FLIBS_LINE@|${FLIBS_LINE}|g" \
src/Makevars.in > src/Makevars
exit 0