-
Notifications
You must be signed in to change notification settings - Fork 14
/
build_all
executable file
·385 lines (369 loc) · 12 KB
/
build_all
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
#!/bin/bash
#
# Build everything in the right order
#
# The args are passed to cmake
set -e
set -o pipefail
################################################################################
# Configuration
################################################################################
echo '*============================================================================*'
echo '| Configuration |'
echo '+----------------------------------------------------------------------------+'
echo '| |'
if [ $# -lt 1 ]
then
echo 'No build directory is specified, it is set to the default: '$PWD'/build'
BUILD=$PWD/build
else
BUILD=$1
fi
if [ $# -lt 2 ]
then
PREFIX=~/focus
echo 'No install directory is specified, therefore it is set to the directory: '$PREFIX
echo 'This means you install in-place'
else
PREFIX=$2
fi
# this is just a hiden argument for building the mac bundle
if [ $# -eq 3 ];
then
APPLE_BUNDLE=$3
else
APPLE_BUNDLE=OFF
fi
# Quick fix to enforce gnu-compilers on Macs
export CC=gcc
export CXX=g++
# And create build dirs here
SRC=$(pwd)
echo "The project structure is set as follows"
echo "The source dir is:"
echo $SRC
echo "The build dir is:"
echo $BUILD
echo "The install dir is:"
echo ${PREFIX}
# check if the build dir exists
if [ ! -e $BUILD ]; then
echo 'The build dir does not exist, therefore it will be created.'
mkdir -p $BUILD
fi
echo '*============================================================================*'
echo ''
echo ''
echo ''
echo ''
################################################################################
# Fortran
################################################################################
#APP=kernel/mrc
#echo '*============================================================================*'
#echo '| ' ${APP}
#echo '+----------------------------------------------------------------------------+'
#echo '| prepare |'
#echo cd ${SRC}/${APP} || { echo "failed to change to" ${SRC}/${APP} ; exit 1; }
#cd ${SRC}/${APP} || { echo "failed to change to" ${SRC}/${APP} ; exit 1; }
#echo 'workinkg directory: '
#pwd
#echo '+----------------------------------------------------------------------------+'
#echo '| autoconf |'
#echo autoconf || { echo "autoconf failed for" $APP ; exit 2; }
#autoconf || { echo "autoconf failed for" $APP ; exit 2; }
#echo '+----------------------------------------------------------------------------+'
#echo '| configure |'
#echo ./configure || { echo "Configure failed for" $APP ; exit 3; }
#./configure || { echo "Configure failed for" $APP ; exit 3; }
#echo ''
#echo '+----------------------------------------------------------------------------+'
#echo '| make |'
#make VERBOSE=1 -j1 || { echo "Build failed for $APP"; exit 4; }
#echo ''
#echo '+----------------------------------------------------------------------------+'
#echo '| make install |'
#make VERBOSE=1 -j1 install || { echo "Install failed for $APP"; read)
#echo '*============================================================================*'
#echo ''
#echo ''
#echo ''
#echo ''
#################################################################################
# Focus
################################################################################
APP=Focus
echo '*============================================================================*'
echo '| ' ${APP}
echo '+----------------------------------------------------------------------------+'
echo '| prepare |'
cd ${BUILD}
echo 'workinkg directory: '
pwd
echo '+----------------------------------------------------------------------------+'
echo '| configure |'
echo cmake -DCMAKE_INSTALL_PREFIX=${PREFIX} -DAPPLE_BUNDLE=${APPLE_BUNDLE} ${SRC} || { echo "Configure failed for" $APP ; exit 5; }
cmake -DCMAKE_INSTALL_PREFIX=${PREFIX} -DAPPLE_BUNDLE=${APPLE_BUNDLE} ${SRC} || { echo "Configure failed for" $APP ; exit 5; }
echo ''
echo '+----------------------------------------------------------------------------+'
echo '| make |'
make -j1 || { echo "Build failed for $APP"; exit 6; }
echo ''
echo '+----------------------------------------------------------------------------+'
echo '| make install |'
make -j1 install || { echo "Install failed for $APP"; exit 7; }
echo '*============================================================================*'
echo ''
echo ''
cd ${PREFIX}/bin
cd ${src}
echo ''
echo ''
################################################################################
# Replacing local "kernel" in installation site with link to svn-repository copy
################################################################################
S2='localuser'
S3='stahlber'
S4='dcigepc2'
if [ "$USER" == "$S2" ] || [ "$USER" == "$S3" ] || [ "$USER" == "$S4" ];
then
echo User = $USER
cd ${PREFIX}
ls -ld kernel
if [ -h kernel ];
then
echo "kernel link already existing."
else
echo "Moving executables into kernel/mrc/bin"
\cp -rf kernel/mrc/bin/* ${SRC}/kernel/mrc/bin
echo "Removing kernel directory in local ${PREFIX}"
\rm -rf kernel
fi
if [ ! -h kernel ];
then
echo "Replacing with link to svn-repository"
\ln -s ${SRC}/kernel .
ls -ld kernel
fi
#
cd scripts
#
ls -ld diffmaps
if [ -h diffmaps ];
then
echo "scripts/diffmaps link already existing."
else
echo "Removing diffmaps directory in local ${PREFIX}/scripts"
\rm -rf diffmaps
fi
if [ ! -h diffmaps ];
then
echo "Replacing with link to svn-repository"
\ln -s ${SRC}/scripts/diffmaps .
ls -ld diffmaps
fi
#
ls -ld image
if [ -h image ];
then
echo "scripts/image link already existing."
else
echo "Removing image directory in local ${PREFIX}/scripts"
\rm -rf image
fi
if [ ! -h image ];
then
echo "Replacing with link to svn-repository"
\ln -s ${SRC}/scripts/image .
ls -ld image
fi
#
ls -ld export
if [ -h export ];
then
echo "scripts/export link already existing."
else
echo "Removing export directory in local ${PREFIX}/scripts"
\rm -rf export
fi
if [ ! -h export ];
then
echo "Replacing with link to svn-repository"
\ln -s ${SRC}/scripts/export .
ls -ld export
fi
#
ls -ld merge
if [ -h merge ];
then
echo "scripts/merge link already existing."
else
echo "Removing merge directory in local ${PREFIX}/scripts"
\rm -rf merge
fi
if [ ! -h merge ];
then
echo "Replacing with link to svn-repository"
\ln -s ${SRC}/scripts/merge .
ls -ld merge
fi
#
ls -ld notifications
if [ -h notifications ];
then
echo "scripts/notifications link already existing."
else
echo "Removing notifications directory in local ${PREFIX}/scripts"
\rm -rf notifications
fi
if [ ! -h notifications ];
then
echo "Replacing with link to svn-repository"
\ln -s ${SRC}/scripts/notifications .
ls -ld notifications
fi
#
ls -ld dataset
if [ -h dataset ];
then
echo "scripts/dataset link already existing."
else
echo "Removing dataset directory in local ${PREFIX}/scripts"
\rm -rf dataset
fi
if [ ! -h dataset ];
then
echo "Replacing with link to svn-repository"
\ln -s ${SRC}/scripts/dataset .
ls -ld dataset
fi
#
ls -ld stats
if [ -h stats ];
then
echo "scripts/stats link already existing."
else
echo "Removing stats directory in local ${PREFIX}/scripts"
\rm -rf stats
fi
if [ ! -h stats ];
then
echo "Replacing with link to svn-repository"
\ln -s ${SRC}/scripts/stats .
ls -ld stats
fi
#
ls -ld singleparticle
if [ -h singleparticle ];
then
echo "scripts/singleparticle link already existing."
else
echo "Removing singleparticle directory in local ${PREFIX}/scripts"
\rm -rf singleparticle
fi
if [ ! -h singleparticle ];
then
echo "Replacing with link to svn-repository"
\ln -s ${SRC}/scripts/singleparticle .
ls -ld singleparticle
fi
#
ls -ld proc
if [ -h proc ];
then
echo "scripts/proc link already existing."
else
echo "Removing proc directory in local ${PREFIX}/scripts"
\rm -rf proc
fi
if [ ! -h proc ];
then
echo "Replacing with link to svn-repository"
\ln -s ${SRC}/scripts/proc .
ls -ld proc
fi
#
ls -ld project
if [ -h project ];
then
echo "scripts/project link already existing."
else
echo "Removing project directory in local ${PREFIX}/scripts"
\rm -rf project
fi
if [ ! -h project ];
then
echo "Replacing with link to svn-repository"
\ln -s ${SRC}/scripts/project .
ls -ld project
fi
#
# echo "done."
fi
echo "Checking environment files..."
if [ -e ~/.bashrc ];
then
envfile=~/.bashrc
if ! grep "# Added by FOCUS on" ${envfile} >& /dev/null ;
then
echo "Adding environment variables to ${envfile}"
echo -e "\n">> ${envfile}
echo "# Added by FOCUS on `date`:" >> ${envfile}
echo "# (makes standalone programs and Python modules available)" >> ${envfile}
echo "export FOCUS_ROOT=${PREFIX}" >> ${envfile}
echo "export PATH=\${FOCUS_ROOT}/bin:\${PATH}" >> ${envfile}
echo "export PATH=\${FOCUS_ROOT}/kernel/mrc/bin:\${PATH}" >> ${envfile}
echo "export PATH=\${FOCUS_ROOT}/scripts/proc:\${PATH}" >> ${envfile}
echo "export PYTHONPATH=\${FOCUS_ROOT}/scripts/proc:\${PYTHONPATH}" >> ${envfile}
fi
fi
if [ -e ~/.bash_profile ];
then
envfile=~/.bash_profile
if ! grep "# Added by FOCUS on" ${envfile} >& /dev/null ;
then
echo "Adding environment variables to ${envfile}"
echo -e "\n">> ${envfile}
echo "# Added by FOCUS on `date`:" >> ${envfile}
echo "# (makes standalone programs and Python modules available)" >> ${envfile}
echo "export FOCUS_ROOT=${PREFIX}" >> ${envfile}
echo "export PATH=\${FOCUS_ROOT}/bin:\${PATH}" >> ${envfile}
echo "export PATH=\${FOCUS_ROOT}/kernel/mrc/bin:\${PATH}" >> ${envfile}
echo "export PATH=\${FOCUS_ROOT}/scripts/proc:\${PATH}" >> ${envfile}
echo "export PYTHONPATH=\${FOCUS_ROOT}/scripts/proc:\${PYTHONPATH}" >> ${envfile}
fi
fi
if [ -e ~/.profile ];
then
envfile=~/.profile
if ! grep "# Added by FOCUS on" ${envfile} >& /dev/null ;
then
echo "Adding environment variables to ${envfile}"
echo -e "\n">> ${envfile}
echo "# Added by FOCUS on `date`:" >> ${envfile}
echo "# (makes standalone programs and Python modules available)" >> ${envfile}
echo "export FOCUS_ROOT=${PREFIX}" >> ${envfile}
echo "export PATH=\${FOCUS_ROOT}/bin:\${PATH}" >> ${envfile}
echo "export PATH=\${FOCUS_ROOT}/kernel/mrc/bin:\${PATH}" >> ${envfile}
echo "export PATH=\${FOCUS_ROOT}/scripts/proc:\${PATH}" >> ${envfile}
echo "export PYTHONPATH=\${FOCUS_ROOT}/scripts/proc:\${PYTHONPATH}" >> ${envfile}
fi
fi
if [ -e ~/.cshrc ];
then
envfile=~/.cshrc
if ! grep "# Added by FOCUS on" ${envfile} >& /dev/null ;
then
echo "Adding environment variables to ${envfile}"
echo -e "\n">> ${envfile}
echo "# Added by FOCUS on `date`:" >> ${envfile}
echo "# (makes standalone programs and Python modules available)" >> ${envfile}
echo "setenv FOCUS_ROOT ${PREFIX}" >> ${envfile}
echo "setenv PATH \${FOCUS_ROOT}/bin:\${PATH}" >> ${envfile}
echo "setenv PATH \${FOCUS_ROOT}/kernel/mrc/bin:\${PATH}" >> ${envfile}
echo "setenv PATH \${FOCUS_ROOT}/scripts/proc:\${PATH}" >> ${envfile}
echo "setenv PYTHONPATH \${FOCUS_ROOT}/scripts/proc:\${PYTHONPATH}" >> ${envfile}
fi
fi
echo "Done!"
exit 0