-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild-omm
executable file
·244 lines (213 loc) · 5.84 KB
/
build-omm
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
#!/bin/sh
# Set number of processors for parallel builds (make -j)
make_nprocs="8"
# Set external dependencies if necessary
if test ! -n "${LINALG_INCLUDES}"; then
LINALG_INCLUDES=""
export LINALG_INCLUDES
fi
if test ! -n "${LINALG_LIBS}"; then
LINALG_LIBS="-lscalapack -lopenblas"
export LINALG_LIBS
fi
# ------------------------------------ #
# Check that we are in an omm-bundle source tree
if test ! -s "pspBLAS/src/pspBLAS.F90" -o \
! -s "MatrixSwitch/src/MatrixSwitch.F90" -o \
! -s "libOMM/src/omm.F90"; then
echo "Error: this is not an omm-bundle source tree" >&2
exit 1
fi
# ------------------------------------ #
# Set install dirs
psp_prefix="${PWD}/build_pspBLAS"
msw_prefix="${PWD}/build_MatrixSwitch"
omm_prefix="${PWD}/build_libOMM"
# Set build dirs
root_builddir="${PWD}/tmp-objs"
psp_builddir="${root_builddir}/pspBLAS"
msw_builddir="${root_builddir}/MatrixSwitch"
omm_builddir="${root_builddir}/libOMM"
# Set source dirs
psp_srcdir="${PWD}/pspBLAS"
msw_srcdir="${PWD}/MatrixSwitch"
omm_srcdir="${PWD}/libOMM"
# ------------------------------------ #
# Usage
script_name=`basename "${0}"`
if test "${#}" = 0; then
cat <<EOF
Usage: ${script_name} command [command ...]
This script will install libraries under the following paths:
* pspBLAS -> ${psp_prefix}
* MatrixSwitch -> ${msw_prefix}
* libOMM -> ${omm_prefix}
Commands can be:
* all : build all libraries
* <lib> : build library <lib> (pspblas, matrixswitch, and/or libomm)
* check : run test suites before installing libraries
* clean : remove temporary build directories (other commands are ignored)
* wipe : remove both build and install directories (other commands are ignored)
EOF
exit 0
fi
# ------------------------------------ #
# Process command-line options
tasks=""
cfg_opts=""
bld_psp="no"
bld_msw="no"
bld_omm="no"
cfg_psp=""
cfg_msw="--enable-conv"
cfg_omm=""
cln_bld="no"
cln_ins="no"
run_chk="no"
while test "${#}" -gt 0; do
cmd="${1}"
shift
case "${cmd}" in
all)
bld_psp="yes"
bld_msw="yes"
bld_omm="yes"
;;
check)
run_chk="yes"
;;
clean)
cln_bld="yes"
;;
[Ll]ib[Oo][Mm][Mm])
bld_omm="yes"
;;
[Mm]atrix[Ss]witch)
bld_msw="yes"
;;
[Pp]sp[Bb][Ll][Aa][Ss])
bld_psp="yes"
;;
wipe)
cln_bld="yes"
cln_ins="yes"
;;
*)
echo "${script_name}: Error: unknown command '${cmd}'" >&2
exit 1
;;
esac
done
# ------------------------------------ #
# Do we want to clean the source tree?
if test "${cln_bld}" = "yes"; then
cln_ret="0"
test -d "${root_builddir}" && chmod -R u+w "${root_builddir}"
rm -rf "${root_builddir}"
if test "${cln_ins}" = "yes"; then
for tmpdir in "${psp_prefix}" "${msw_prefix}" "${omm_prefix}"; do
cln_internal=`echo "${tmpdir}" | grep "${PWD}"`
if test "${cln_internal}" = ""; then
echo "${script_name}: Cowardly refusing to remove external directory:" >&2
echo " ${tmpdir}" >&2
cln_ret="10"
else
if test -d "${tmpdir}"; then
chmod -R u+w "${tmpdir}"
rm -r "${tmpdir}"
cln_ret="${?}"
if test "${cln_ret}" != "0"; then
echo "${script_name}: Error: could not remove directory:" >&2
echo " ${tmpdir}" >&2
fi
fi
fi
test "${cln_ret}" = "0" || break
done
fi
test "${cln_ret}" = "0" || \
echo "${script_name}: Error: could not clean the source tree" >&2
exit "${cln_ret}"
fi
# ------------------------------------ #
# Set build parameters
test -n "${CC}" || CC="mpicc"
test -n "${FC}" || FC="mpifort"
export CC FC
# Stop at first error
set -e
# ------------------------------------ #
# Build pspBLAS
if test "${bld_psp}" = "yes"; then
if test -e "${psp_prefix}"; then
echo "${script_name}: Error: pspBLAS install directory already exists" >&2
exit 2
fi
mkdir -p "${psp_builddir}"
cd "${psp_builddir}"
"${psp_srcdir}/configure" \
--srcdir="${psp_srcdir}" \
--prefix="${psp_prefix}" \
${cfg_psp}
sleep 3
make -j${make_nprocs}
if test "${run_chk}" = "yes"; then
make -j${make_nprocs} check
fi
make -j${make_nprocs} install
fi
# ------------------------------------ #
# Build MatrixSwitch
if test "${bld_msw}" = "yes"; then
if test -e "${msw_prefix}"; then
echo "${script_name}: Error: MatrixSwitch install directory already exists" >&2
exit 2
fi
if test ! -d "${psp_prefix}"; then
echo "${script_name}: Error: MatrixSwitch requires pspBLAS" >&2
exit 3
fi
mkdir -p "${msw_builddir}"
cd "${msw_builddir}"
"${msw_srcdir}/configure" \
--srcdir="${msw_srcdir}" \
--prefix="${msw_prefix}" \
--with-psp="${psp_prefix}" \
${cfg_msw}
sleep 3
make -j${make_nprocs}
if test "${run_chk}" = "yes"; then
make -j${make_nprocs} check
fi
make -j${make_nprocs} install
fi
# ------------------------------------ #
# Build libOMM
if test "${bld_omm}" = "yes"; then
if test -e "${omm_prefix}"; then
echo "${script_name}: Error: libOMM install directory already exists" >&2
exit 2
fi
if test ! -d "${psp_prefix}"; then
echo "${script_name}: Error: libOMM requires pspBLAS" >&2
exit 3
fi
if test ! -d "${msw_prefix}"; then
echo "${script_name}: Error: libOMM requires MatrixSwitch" >&2
exit 3
fi
mkdir -p "${omm_builddir}"
cd "${omm_builddir}"
"${omm_srcdir}/configure" \
--srcdir="${omm_srcdir}" \
--prefix="${omm_prefix}" \
--with-psp="${psp_prefix}" \
--with-msw="${msw_prefix}" \
${cfg_omm}
sleep 3
make -j${make_nprocs}
if test "${run_chk}" = "yes"; then
make -j${make_nprocs} check
fi
make -j${make_nprocs} install
fi