forked from kthohr/mcmc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·170 lines (138 loc) · 4.78 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
#!/bin/bash
## MCMC config script
# inputs
while getopts b:cm:o:p option; do
case "${option}" in
b) MCMC_BUILD=${OPTARG};;
c) MCMC_COVERAGE="y";;
m) MCMC_MATRIX_OPS=${OPTARG};;
o) MCMC_OPT=${OPTARG};;
p) MCMC_PARALLEL="y";;
esac
done
if [ -z ${CC+x} ]; then
CC=gcc
fi
if [ -z ${CXX+x} ]; then
CXX=g++
fi
if [ -z ${FC+x} ]; then
FC=gfortran
fi
if [[ !(-z ${KEITH_DEV_SETTINGS+x}) ]]; then
CC=gcc-mp-7
CXX=g++-mp-7
FC=gfortran-mp-7
fi
# compiler checks
IS_DARWIN=$($CXX -dumpmachine 2>&1 | grep -i -c "darwin")
APPLE_COMPILER=$($CXX --version 2>&1 | grep -i -c -E 'apple llvm')
IS_FAST_OPT=0
# announcements
echo ""
if [[ "${MCMC_BUILD}" == "dev" ]]; then
echo "MCMC: dev version"
fi
if [[ "${MCMC_COVERAGE}" == "y" ]]; then
echo "MCMC: coverage build"
fi
# get working directory
WDIR=${PWD}
# look for Armadillo
if [ -z ${ARMA_INCLUDE_PATH+x} ]; then
echo ""
if [ -f ${WDIR}/include/armadillo ]; then
ARMA_INCLUDE_PATH="./include"
elif [ -f /usr/include/armadillo ]; then
ARMA_INCLUDE_PATH="/usr/include"
elif [ -f /usr/local/include/armadillo ]; then
ARMA_INCLUDE_PATH="/usr/local/include"
elif [ -f /opt/include/armadillo ]; then
ARMA_INCLUDE_PATH="/opt/include"
elif [ -f /opt/local/include/armadillo ]; then
ARMA_INCLUDE_PATH="/opt/local/include"
else
echo "MCMC: cannot find armadillo files. Cloning from GitHub"
echo ""
mkdir ${WDIR}/arma_tmp
git clone -b unstable --single-branch https://github.com/conradsnicta/armadillo-code ${WDIR}/arma_tmp
mv ${WDIR}/arma_tmp/include/* ${WDIR}/include
rm -rf ${WDIR}/arma_tmp
ARMA_INCLUDE_PATH="./include"
echo ""
fi
fi
echo "MCMC: ARMA_INCLUDE_PATH set to ${ARMA_INCLUDE_PATH}"
# set build and optimization flags
if [[ "${MCMC_COVERAGE}" == "y" ]]; then
MCMC_OPT_FLAGS="-g -O0 -Wall --coverage -fno-inline -fno-inline-small-functions -fno-default-inline"
else
if [[ "${MCMC_OPT}" == "fast" ]]; then
echo "MCMC: experimental optimization; use of NaN or +/-Inf not recognized"
IS_FAST_OPT=1
MCMC_OPT_FLAGS="-Ofast -march=native -DARMA_NO_DEBUG"
elif [[ "${MCMC_OPT}" == "native" ]]; then
IS_FAST_OPT=1
MCMC_OPT_FLAGS="-O3 -march=native -DARMA_NO_DEBUG"
else
MCMC_OPT_FLAGS="-O3"
fi
if [[ "${MCMC_PARALLEL}" == "y" ]]; then
echo "MCMC: using OpenMP"
MCMC_OPT_FLAGS="${MCMC_OPT_FLAGS} -fopenmp -DMCMC_USE_OMP"
fi
fi
MCMC_WARN_FLAGS="-Wall"
# shared library name and install path
MCMC_SHLIB_NAME="libmcmc.so"
if [[ !("${MCMC_BUILD}" == "dev") ]]; then
if [ -z ${MCMC_INSTALL_PATH+x} ]; then
MCMC_INSTALL_PATH="/usr/local"
fi
echo ""
echo "MCMC: install path set to ${MCMC_INSTALL_PATH}"
fi
if [[ $OSTYPE == darwin* ]] ; then
if [[ "${MCMC_BUILD}" == "dev" ]]; then
MCMC_SHLIB_FLAGS="-dynamiclib -install_name ${WDIR}/${MCMC_SHLIB_NAME} -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress"
else
MCMC_SHLIB_FLAGS="-dynamiclib -install_name ${MCMC_INSTALL_PATH}/lib/${MCMC_SHLIB_NAME} -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress"
fi
MCMC_BLAS_LAPACK="-framework Accelerate"
elif [[ $OSTYPE == *linux* ]] ; then
MCMC_OPT_FLAGS="-fPIC ${MCMC_OPT_FLAGS}"
if [[ "${MCMC_BUILD}" == "dev" ]]; then
MCMC_SHLIB_FLAGS="-fPIC -shared -L${WDIR} -Wl,-Bsymbolic-functions -Wl,-z,relro "
else
MCMC_SHLIB_FLAGS="-fPIC -shared -L${MCMC_INSTALL_PATH}/lib -Wl,-Bsymbolic-functions -Wl,-z,relro"
fi
MCMC_BLAS_LAPACK="-lblas -llapack"
else
MCMC_BLAS_LAPACK="-lblas -llapack"
fi
if [[ !(-z ${MCMC_MATRIX_OPS+x}) ]]; then
MCMC_BLAS_LAPACK="${MCMC_MATRIX_OPS}"
echo ""
echo "MCMC: BLAS and Lapack libraries set to ${MCMC_BLAS_LAPACK}"
fi
if [[ "${MCMC_COVERAGE}" == "y" ]]; then
MCMC_SHLIB_FLAGS="--coverage ${MCMC_SHLIB_FLAGS}"
else
MCMC_SHLIB_FLAGS="${MCMC_OPT_FLAGS} ${MCMC_SHLIB_FLAGS}"
fi
if [ "$IS_FAST_OPT" -eq "1" ] && [ "$IS_DARWIN" -eq "1" ] && [ "$APPLE_COMPILER" -eq "0" ]; then
echo ""
echo "MCMC: To enable AVX features, your compiler will use the Apple LLVM assembler"
MCMC_OPT_FLAGS="-Wa,-q ${MCMC_OPT_FLAGS}"
fi
sed -e "s|@CC@|${CC}|" \
-e "s|@CXX@|${CXX}|" \
-e "s|@FC@|${FC}|" \
-e "s|@ARMA_INCLUDE_PATH@|${ARMA_INCLUDE_PATH}|" \
-e "s|@MCMC_BLAS_LAPACK@|${MCMC_BLAS_LAPACK}|" \
-e "s|@MCMC_WARN_FLAGS@|${MCMC_WARN_FLAGS}|" \
-e "s|@MCMC_OPT_FLAGS@|${MCMC_OPT_FLAGS}|" \
-e "s|@MCMC_SHLIB_NAME@|${MCMC_SHLIB_NAME}|" \
-e "s|@MCMC_SHLIB_FLAGS@|${MCMC_SHLIB_FLAGS}|" \
-e "s|@MCMC_INSTALL_PATH@|${MCMC_INSTALL_PATH}|" \
Makefile.in > Makefile