-
Notifications
You must be signed in to change notification settings - Fork 133
/
configure.in
executable file
·218 lines (177 loc) · 6.28 KB
/
configure.in
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#!/bin/bash
## OptimLib config script for tests
function print_help
{
echo "" ;
echo -e "\x1B[32mOptimLib Test Configuration Options:\033[0m" >&2 ;
echo " -c Coverage build" ;
echo " -d Development build" ;
echo " -g Debugging build (optimization flags set to -O0 -g)" ;
echo " -h Print help" ;
echo " -i OptimLib install path (default: build directory)" ;
echo " Example: /usr/local" ;
echo " -l Choice of linear algebra library" ;
echo " Examples: -l arma, or -l eigen" ;
echo " -m Specify the BLAS and Lapack libraries to link against" ;
echo " Examples: -m \"-lopenblas\" or -m \"-framework Accelerate\"" ;
echo " -o Compiler optimization options; defaults to:" ;
echo " -O3 -march=native -ffp-contract=fast -DARMA_NO_DEBUG" ;
echo "" ;
}
while getopts hcdgi:l:m:o:p option; do
case "${option}" in
h) print_help; exit 2;;
c) OPTIM_COVERAGE_BUILD="y";;
d) OPTIM_DEV_BUILD="y";;
g) OPTIM_DEBUG_BUILD="y";;
i) OPTIM_INSTALL_PATH=${OPTARG};;
l) OPTIM_LINEAR_ALG_LIB=${OPTARG};;
m) OPTIM_MATRIX_OPS=${OPTARG};;
o) OPTIM_OPT=${OPTARG};;
?) print_help; exit 2;;
esac
done
if [ -z ${CXX+x} ]; then
CXX=g++
fi
#
echo ""
echo -e "\x1B[32mOptimLib Test Configuration...\033[0m" >&2 ;
echo ""
# compiler checks
IS_DARWIN=$($CXX -dumpmachine 2>&1 | grep -i -c "darwin")
GCC_COMPILER=$($CXX --version 2>&1 | grep -i -c -E "gcc")
CLANG_COMPILER=$($CXX --version 2>&1 | grep -i -c -E "clang")
APPLE_COMPILER=$($CXX --version 2>&1 | grep -i -c -E 'apple llvm')
# get working directory
WDIR=${PWD}
# look for Armadillo
if [[ "${OPTIM_LINEAR_ALG_LIB}" == "arma" ]]; then
if [ -z ${ARMA_INCLUDE_PATH+x} ]; then
declare -a ARMA_DIRS=("${WDIR}/../../include" "/usr/include" "/usr/local/include" "/opt/include" "/opt/local/include")
ARMA_INCLUDE_PATH=
for i in "${ARMA_DIRS[@]}"; do
if [ -f "$i"/armadillo ]; then
ARMA_INCLUDE_PATH="$i"
break
fi
done
if [[ $ARMA_INCLUDE_PATH == "" ]]; then
echo -e " \x1B[31m- error: cannot find the Armadillo library header files. Exiting.\033[0m" >&2 ;
echo ""
exit 1
fi
fi
OPTIM_MATLIB_FLAGS="-DOPTIM_ENABLE_ARMA_WRAPPERS -DARMA_NO_DEBUG"
OPTIM_MATLIB_INCLUDE_PATH=$ARMA_INCLUDE_PATH
elif [[ "${OPTIM_LINEAR_ALG_LIB}" == "blaze" ]]; then
# OPTIM_MATLIB_FLAGS="-DOPTIM_ENABLE_BLAZE_WRAPPERS"
# OPTIM_MATLIB_INCLUDE_PATH=$BLAZE_INCLUDE_PATH
# CXX_STD="-std=c++14"
echo -e " \x1B[31m- error: Blaze not yet supported. Exiting.\033[0m" >&2 ;
echo ""
exit 1
elif [[ "${OPTIM_LINEAR_ALG_LIB}" == "eigen" ]]; then
OPTIM_MATLIB_FLAGS="-DOPTIM_ENABLE_EIGEN_WRAPPERS"
OPTIM_MATLIB_INCLUDE_PATH=$EIGEN_INCLUDE_PATH
else
echo -e " \x1B[31m- error: unrecognized linear algebra library.\033[0m" >&2 ;
echo ""
exit 1
fi
# set build and optimization flags
if [[ "${OPTIM_COVERAGE_BUILD}" == "y" ]]; then
if [ "$GCC_COMPILER" -eq "1" ]; then
OPTIM_OPT_FLAGS="-g -O0 --coverage -fno-inline -fno-inline-small-functions -fno-default-inline"
else # clang:
OPTIM_OPT_FLAGS="-g -O0 --coverage -fno-inline"
fi
elif [[ "${OPTIM_DEBUG_BUILD}" == "y" ]]; then
OPTIM_OPT_FLAGS="-g -O0"
else
if [[ "${OPTIM_OPT}" == "" ]]; then
OPTIM_OPT_FLAGS="-O3 -march=native -ffp-contract=fast"
else
OPTIM_OPT_FLAGS="${OPTIM_OPT}"
fi
if [[ "${OPTIM_PARALLEL}" == "y" ]]; then
OPTIM_OPT_FLAGS="${OPTIM_OPT_FLAGS} -fopenmp"
fi
fi
OPTIM_WARN_FLAGS="-Wall"
# shared library name and install path
OPTIM_SHLIB_NAME="optim"
#
if [[ "${OPTIM_INSTALL_PATH}" == "" ]]; then
cd ../..
OPTIM_INSTALL_PATH=${PWD}
OPTIM_INSTALL_INCLUDE_PATH=${PWD}/include
OPTIM_INSTALL_LIB_PATH=${PWD}
cd ${WDIR}
else
OPTIM_INSTALL_INCLUDE_PATH="${OPTIM_INSTALL_PATH}/include"
OPTIM_INSTALL_LIB_PATH="${OPTIM_INSTALL_PATH}/lib"
fi
# BLAS and LAPACK settings
if [[ !(-z ${OPTIM_MATRIX_OPS+x}) ]]; then
OPTIM_BLAS_LAPACK="${OPTIM_MATRIX_OPS}"
else
if [[ $OSTYPE == darwin* ]] ; then
OPTIM_BLAS_LAPACK="-framework Accelerate"
else
OPTIM_BLAS_LAPACK="-lblas -llapack"
fi
fi
# final optimization checks
if [ "$IS_DARWIN" -eq "1" ] && [ "$GCC_COMPILER" -eq "1" ]; then
OPTIM_OPT_FLAGS="-Wa,-q ${OPTIM_OPT_FLAGS}"
fi
#
# final print:
echo " - OS: ${OSTYPE}"
echo " - C++ compiler: ${CXX}"
if [[ "${OPTIM_DEV_BUILD}" == "y" ]]; then
echo " - Build version: development"
elif [[ "${OPTIM_COVERAGE_BUILD}" == "y" ]]; then
echo " - Build version: coverage"
elif [[ "${OPTIM_DEBUG_BUILD}" == "y" ]]; then
echo " - Build version: debug"
else
echo " - Build version: release"
fi
echo ""
echo " - OPTIM_LINEAR_ALG_LIB set to: ${OPTIM_LINEAR_ALG_LIB}"
echo " - OPTIM_MATLIB_INCLUDE_PATH set to:"
echo " ${OPTIM_MATLIB_INCLUDE_PATH}"
echo " - BLAS and Lapack libraries set to:"
echo " ${OPTIM_BLAS_LAPACK}"
echo ""
echo " - optimization flags:"
echo " ${OPTIM_OPT_FLAGS}"
echo ""
echo " - OptimLib install path:"
echo " ${OPTIM_INSTALL_PATH}"
echo ""
echo " - Additional notes:"
if [ "$APPLE_COMPILER" -eq "1" ] && [[ "${OPTIM_PARALLEL}" == "y" ]]; then
echo -e " \x1B[31m- You have enabled OpenMP, but your C++ compiler does not\033[0m" >&2 ;
echo -e " \x1B[31m support this feature!\033[0m" >&2 ;
fi
if [ "$IS_DARWIN" -eq "1" ] && [ "$GCC_COMPILER" -eq "1" ]; then
echo " - To enable AVX features, your compiler will use the Apple LLVM"
echo " assembler"
fi
echo ""
echo -e "\x1B[32mConfiguration completed. Creating Makefile... \c\033[0m" >&2 ;
sed -e "s|@CXX@|${CXX}|" \
-e "s|@OPTIM_MATLIB_FLAGS@|${OPTIM_MATLIB_FLAGS}|" \
-e "s|@OPTIM_MATLIB_INCLUDE_PATH@|${OPTIM_MATLIB_INCLUDE_PATH}|" \
-e "s|@OPTIM_BLAS_LAPACK@|${OPTIM_BLAS_LAPACK}|" \
-e "s|@OPTIM_WARN_FLAGS@|${OPTIM_WARN_FLAGS}|" \
-e "s|@OPTIM_OPT_FLAGS@|${OPTIM_OPT_FLAGS}|" \
-e "s|@OPTIM_SHLIB_NAME@|${OPTIM_SHLIB_NAME}|" \
-e "s|@OPTIM_INCLUDE_PATH@|${OPTIM_INSTALL_INCLUDE_PATH}|" \
-e "s|@OPTIM_INSTALL_PATH@|${OPTIM_INSTALL_LIB_PATH}|" \
Makefile.in > Makefile
echo -e "\x1B[32mdone.\033[0m" >&2 ;
echo ""