-
Notifications
You must be signed in to change notification settings - Fork 8
/
configure
executable file
·190 lines (150 loc) · 5.71 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
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#!/bin/sh
echo ====== configuring symengine R package ======
# Check working directory
if [ ! -f ./DESCRIPTION ]; then
echo Running in wrong directory `pwd`
exit 1
fi
echo == current working directory
echo `pwd`
# Check sh
echo == $SHELL
#$SHELL --version
# Check cmake
echo == cmake:
which cmake
if [ $? -ne 0 ]; then
echo "cmake is not in PATH, try looking for /Applications/CMake.app/Contents/bin/cmake"
## This is the cmake path on MacOS if installed via dmg, which is also used
## on CRAN's Mac builder.
CMAKE_BIN="/Applications/CMake.app/Contents/bin/cmake"
which $CMAKE_BIN
if [ $? -ne 0 ]; then
echo >&2 "cmake can not be found"
exit 1
fi
else
CMAKE_BIN="cmake"
fi
$CMAKE_BIN --version
## Setting some environment variables
: ${R_HOME=`R RHOME`}
if test -z "${R_HOME}"; then
echo >&2 "could not determine R_HOME"
exit 1
else
echo == R_HOME
echo $R_HOME
fi
echo == getting R config variables
R_CC=`"${R_HOME}/bin/R" CMD config CC` ; echo R_CC="$R_CC"
R_CFLAGS=`"${R_HOME}/bin/R" CMD config CFLAGS` ; echo R_CFLAGS="$R_CFLAGS"
R_CPICFLAGS=`"${R_HOME}/bin/R" CMD config CPICFLAGS` ; echo R_CPICFLAGS="$R_CPICFLAGS"
R_CXX=`"${R_HOME}/bin/R" CMD config CXX` ; echo R_CXX="$R_CXX"
R_CXXFLAGS=`"${R_HOME}/bin/R" CMD config CXXFLAGS` ; echo R_CXXFLAGS="$R_CXXFLAGS"
R_CXXPICFLAGS=`"${R_HOME}/bin/R" CMD config CXXPICFLAGS` ; echo R_CXXPICFLAGS="$R_CXXPICFLAGS"
R_CPPFLAGS=`"${R_HOME}/bin/R" CMD config CPPFLAGS` ; echo R_CPPFLAGS="$R_CPPFLAGS"
R_LDFLAGS=`"${R_HOME}/bin/R" CMD config LDFLAGS` ; echo R_LDFLAGS="$R_LDFLAGS"
if test -z "$R_CXX"; then
echo >&2 "could not detect C++ compiler with R CMD config"
fi
echo == setting environment variables for cmake
CC="$R_CC" ; echo setting CC="$CC" ; export CC
CXX="$R_CXX" ; echo setting CXX="$CXX" ; export CXX
echo == translating to cmake variables
CMAKE_C_FLAGS="$R_CFLAGS $R_CPICFLAGS" ; echo setting CMAKE_C_FLAGS="$CMAKE_C_FLAGS"
CMAKE_CXX_FLAGS="$R_CXXFLAGS $R_CXXPICFLAGS" ; echo setting CMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS"
CMAKE_INCLUDE_PATH=`"${R_HOME}/bin/Rscript" ./tools/translate_to_cmake_flags.R CMAKE_INCLUDE_PATH "$R_CPPFLAGS"` ; echo setting CMAKE_INCLUDE_PATH="$CMAKE_INCLUDE_PATH"
CMAKE_LIBRARY_PATH=`"${R_HOME}/bin/Rscript" ./tools/translate_to_cmake_flags.R CMAKE_LIBRARY_PATH "$R_LDFLAGS"` ; echo setting CMAKE_LIBRARY_PATH="$CMAKE_LIBRARY_PATH"
## Use ./tools/SYMENGINE_BUNDLED file as indicator so that
## this won't run on CRAN machine.
if [ ! -f ./tools/SYMENGINE_BUNDLED ]; then
echo ====== bundling SymEngine source
./tools/bundle_symengine_source.sh
if [ $? -ne 0 ]; then
echo "./tools/bundle_symengine_source.sh exited with non-zero status"
exit 1
fi
fi
echo ====== Unpacking src/upstream.tar
cd src/
tar xf upstream.tar
cd ..
AR=`"${R_HOME}/bin/R" CMD config AR`
AR=`which $AR`
RANLIB=`"${R_HOME}/bin/R" CMD config RANLIB`
RANLIB=`which $RANLIB`
## If SymEngine_DIR environment variable is not set, use src/upstream
if [ -z "$SymEngine_DIR" ]; then
echo ====== running cmake
PKG_DIR=`pwd`
cd src/upstream
set -x
$CMAKE_BIN \
-DCMAKE_AR=$AR \
-DCMAKE_RANLIB=$RANLIB \
\
-DCMAKE_C_FLAGS="$CMAKE_C_FLAGS" \
-DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS" \
-DCMAKE_INCLUDE_PATH="$CMAKE_INCLUDE_PATH" \
-DCMAKE_LIBRARY_PATH="$CMAKE_LIBRARY_PATH" \
\
-DCMAKE_BUILD_TYPE=Release \
-DWITH_BFD=no \
-DWITH_SYMENGINE_ASSERT=no \
-DWITH_ECM=no \
-DWITH_PRIMESIEVE=no \
-DWITH_FLINT=no \
-DWITH_ARB=no \
-DWITH_TCMALLOC=no \
-DWITH_OPENMP=no \
-DWITH_PIRANHA=no \
-DWITH_LLVM=no \
-DWITH_MPFR=yes \
-DWITH_MPC=no \
-DINTEGER_CLASS=gmp \
-DBUILD_TESTS=no \
-DBUILD_BENCHMARKS=no \
-DBUILD_SHARED_LIBS=no \
-DWITH_COTIRE=no \
.
if [ $? -ne 0 ]; then
exit 1
fi
set +x
cd $PKG_DIR
SymEngine_DIR="$PKG_DIR"/src/upstream
echo == setting SymEngine_DIR
echo $SymEngine_DIR
DO_UPSTREAM="do_upstream"
else
# if SymEngine_DIR exists
DO_UPSTREAM=
fi
echo == config PKG_LIBS and PKG_CPPFLAGS for Makevars
## Running cmake --find-package under src/
cd src
PKG_LIBS_VALUE=`SymEngine_DIR="$SymEngine_DIR" $CMAKE_BIN --find-package -DNAME=SymEngine -DCOMPILER_ID=GNU -DLANGUAGE=CXX -DMODE=LINK`
status_PKG_LIBS=$?
PKG_CPPFLAGS_VALUE=`SymEngine_DIR="$SymEngine_DIR" $CMAKE_BIN --find-package -DNAME=SymEngine -DCOMPILER_ID=GNU -DLANGUAGE=CXX -DMODE=COMPILE`
status_PKG_CPPFLAGS=$?
cd ..
echo set PKG_LIBS=$PKG_LIBS_VALUE
echo set PKG_CPPFLAGS=$PKG_CPPFLAGS_VALUE
if [ "$status_PKG_LIBS" -ne 0 ]; then
echo >&2 "generating PKG_LIBS failed with 'cmake --find-package', new reset using fallback value"
PKG_LIBS_VALUE="-Lupstream/symengine -lsymengine -lmpfr -lgmp"
echo reset PKG_LIBS=$PKG_LIBS_VALUE
fi
if [ "$status_PKG_CPPFLAGS" -ne 0 ]; then
echo >&2 "generating PKG_CPPFLAGS failed with 'cmake --find-package', new reset using fallback value"
PKG_CPPFLAGS_VALUE="-Iupstream"
echo reset PKG_CPPFLAGS=$PKG_CPPFLAGS_VALUE
fi
echo == generating src/Makevars
cat src/Makevars.in | \
sed "s*@@@PKG_LIBS@@@*$PKG_LIBS_VALUE*g" | \
sed "s*@@@PKG_CPPFLAGS@@@*$PKG_CPPFLAGS_VALUE*g" | \
sed "s*@@@DO_UPSTREAM@@@*$DO_UPSTREAM*g" \
> src/Makevars
echo ====== configuring symengine R package DONE ======