forked from FairRootGroup/FairSoft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_clean.sh
executable file
·516 lines (443 loc) · 13.2 KB
/
make_clean.sh
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
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
#!/bin/bash
####
# Script to remove all temporary and installed files for the different packages.
# The script also removes all temporary and installed file for dependent packages.
# If you choose to remove e.g. the root package the script will run "make clean"
# in the base directory of root. It will also remove all innstalled files in
# SIMPATH_INSTALL and the calls the function for all packges which depends on
# the root package, e.g. pluto.
####
main() {
if [ $# -eq 0 -o $# -gt 2 ];
then
print_help
exit 1
fi
package=$1
if [ $# -eq 2 ];
then
rm_installed_files=true
else
rm_installed_files=false
fi
# Extract the directory where the script is loacted
SIMPATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
if [ -e $SIMPATH/config.cache ]; then
source $SIMPATH/config.cache
else
echo "Could not find the config.cache file."
exit 1
fi
source $SIMPATH/scripts/package_versions.sh
source $SIMPATH/scripts/functions.sh
echo "Check if all variables are properly defined in config.cache."
check_variables
echo "All variables are properly defined in config.cache."
check_package_exist $package
clean_$package
cd $SIMPATH_INSTALL
if [ -e bin/fairsoft-config ]; then
rm bin/fairsoft-config
rm include/FairSoftVersion.h
fi
find $SIMPATH -type d -empty -delete
exit 0
}
print_help() {
echo ""
echo ""
echo "This shell script will remove temporary files for the package"
echo "specified by the first parameter. If the second parameter is"
echo "present the script will also remove the installed files."
echo "To remove the temporary files of all packages the command is"
echo " ./make_clean_install.sh all"
echo "If the installed and temporary files of all packages should"
echo "be rmoved the command is"
echo " ./make_clean_install.sh all true"
echo ""
echo ""
}
clean_cmake() {
echo "Remove temporary files from package CMake"
if [ -e $SIMPATH/basics/cmake ]; then
cd $SIMPATH/basics/cmake
make clean
fi
if [ "$rm_installed_files" = "true" ]; then
echo "Remove installed files from package CMake"
if [ -e $SIMPATH_INSTALL/bin/cmake ]; then
cd $SIMPATH/basics/cmake
make uninstall
cd $SIMPATH_INSTALL
rm -rf share/cmake-2.8 share/doc/CMake
fi
fi
}
clean_gtest() {
echo "Remove temporary files from package gtest"
if [ -e $SIMPATH/basics/gtest/build ]; then
rm -rf $SIMPATH/basics/gtest/build
fi
if [ "$rm_installed_files" = "true" ]; then
echo "Remove installed files from package gtest"
cd $SIMPATH_INSTALL
rm -rf include/gtest
rm -f lib/libgtest*.a
fi
}
clean_gsl() {
echo "Remove temporary files from package gsl"
if [ -e $SIMPATH/basics/gsl ]; then
cd $SIMPATH/basics/gsl
make clean
fi
if [ "$rm_installed_files" = "true" ]; then
echo "Remove installed files from package gsl"
if [ -e $SIMPATH_INSTALL/bin/gsl-config ]; then
cd $SIMPATH/basics/gsl
make uninstall
cd $SIMPATH_INSTALL/lib
rm -f libgsl*.so
fi
fi
clean_root
}
clean_icu() {
if [ "$compiler" = "Clang" -a "$platform" = "linux" ]; then
echo "Remove temporary files from package icu"
echo "Remove installed files from package icu"
echo "Not implemented yet"
# Boost depends on some systems on icu
# Needed only for linux + clang
clean_boost
else
echo "ICU was not build for this compiler and platform"
fi
}
clean_boost() {
echo "Remove temporary files from package boost"
if [ -e $SIMPATH/basics/boost ]; then
cd $SIMPATH/basics
#./b2 --clean install
rm -rf boost $BOOSTVERSION
fi
if [ "$rm_installed_files" = "true" ]; then
echo "Remove installed files from package boost"
if [ -e $SIMPATH_INSTALL/include/boost ]; then
cd $SIMPATH_INSTALL
rm -rf include/boost
rm -f lib/libboost*
fi
fi
}
clean_pythia6() {
echo "Remove temporary files from package pythia6"
if [ -e $SIMPATH/generators/pythia6/build ]; then
rm -rf $SIMPATH/generators/pythia6/build
fi
if [ "$rm_installed_files" = "true" ]; then
echo "Remove installed files from package pythia6"
if [ -e $SIMPATH_INSTALL/lib/libPythia6.so ]; then
rm -f $SIMPATH_INSTALL/lib/libPythia6*
fi
fi
clean_root
}
clean_hepmc() {
echo "Remove temporary files from package hepmc"
if [ -e $SIMPATH/generators/build_HepMC ]; then
rm -rf $SIMPATH/generators/build_HepMC
fi
if [ "$rm_installed_files" = "true" ]; then
echo "Remove installed files from package hepmc"
if [ -e $SIMPATH_INSTALL/lib/libHepMC.a ]; then
rm -rf $SIMPATH_INSTALL/include/HepMC
rm -rf $SIMPATH_INSTALL/share/HepMC
rm -f $SIMPATH_INSTALL/lib/libHepMC*
fi
fi
clean_pythia8
}
clean_pythia8() {
if [ ! $pythia8_cleaned ]; then
echo "Remove temporary files from package pythia8"
if [ -e $SIMPATH/generators/pythia8/lib ]; then
cd $SIMPATH/generators/pythia8
make distclean
fi
if [ "$rm_installed_files" = "true" ]; then
echo "Remove installed files from package pythia8"
if [ -e $SIMPATH_INSTALL/lib/libpythia8.so ]; then
rm -rf $SIMPATH_INSTALL/include/Pythia8
rm -rf $SIMPATH_INSTALL/share/pythia8
rm -f $SIMPATH_INSTALL/lib/libpythia8*
rm -f $SIMPATH_INSTALL/lib/liblhapdfdummy*
fi
fi
clean_root
pythia8_cleaned=true
fi
}
clean_xercesc() {
if [ "$build_python" = "yes" ]; then
if [ "$rm_installed_files" = "true" ]; then
echo "Remove installed files from package xercesc"
cd $SIMPATH/basics/xercesc
make uninstall
cd $SIMPATH_INSTALL/lib
rm -f libxerces*
fi
echo "Remove temporary files from package xercesc"
if [ -e $SIMPATH/basics/xercesc ]; then
cd $SIMPATH/basics/xercesc
make clean
fi
clean_geant4
else
echo "XercesC was not build for the current settings"
fi
}
clean_mesa() {
if [ "$compiler" = "Clang" -a "$platform" = "linux" ]; then
echo "Remove temporary files from package mesa"
echo "Remove installed files from package mesa"
echo "Not implemented yet"
# Geant4 and Root depend on Mesa/OpenGl
# needed only for linux + clang
clean_geant4
clean_root
else
echo "Mesa was not build for this compiler and platform"
fi
}
clean_geant4() {
if [ ! $geant4_cleaned ]; then
echo "Remove temporary files from package geant4"
if [ -e $SIMPATH/transport/geant4/build ]; then
rm -rf $SIMPATH/transport/geant4/build
fi
if [ "$rm_installed_files" = "true" ]; then
echo "Remove installed files from package geant4"
if [ -e $SIMPATH_INSTALL/lib/libG3toG4.so ]; then
rm -rf $SIMPATH_INSTALL/include/Geant4
rm -r $SIMPATH_INSTALL/share/Geant4
rm -rf $SIMPATH_INSTALL/share/$GEANT4VERSIONp
rm -f $SIMPATH_INSTALL/bin/geant4*
rm -f $SIMPATH_INSTALL/lib/libG4*
rm -f $SIMPATH_INSTALL/lib/libG3toG4*
rm -rf $SIMPATH_INSTALL/lib/$GEANT4VERSIONp
fi
fi
# Root, vgm and geant4_vmc depend on geant4
clean_root
clean_g4py
clean_geant4_vmc
clean_vgm
geant4_cleaned=true
fi
}
clean_root() {
if [ ! $root_cleaned ]; then
if [ "$rm_installed_files" = "true" ]; then
echo "Remove installed files from package root"
cd $SIMPATH/tools/root
make uninstall
cd $SIMPATH_INSTALL
rm -rf lib/root
rm -rf include/root
fi
echo "Remove temporary files from package root"
if [ -e $SIMPATH/tools/root ]; then
cd $SIMPATH/tools/root
make clean
fi
clean_pluto
clean_vgm
clean_geant4_vmc
clean_geant3
root_cleaned=true
fi
}
clean_g4py() {
if [ ! $g4py_cleaned ]; then
if [ "$build_python" = "yes" ]; then
echo "Remove temporary files from package g4py"
if [ -e $SIMPATH/transport/geant4/build_g4py ]; then
rm -rf $SIMPATH/transport/geant4/build_g4py
fi
echo "Remove installed files from package g4py"
if [ -e $SIMPATH_INSTALL/lib/g4py ]; then
rm -rf $SIMPATH_INSTALL/lib/g4py
rm -rf $SIMPATH_INSTALL/lib/Geant4
fi
else
echo "g4py was not build for the current settings"
fi
g4py_cleaned=true
fi
}
clean_pluto() {
if [ ! $pluto_cleaned ]; then
echo "Remove temporary files from package pluto"
if [ -e $SIMPATH/generators/pluto/Makefile ]; then
cd $SIMPATH/generators/pluto
make clean
make pluginclean
fi
if [ "$rm_installed_files" = "true" ]; then
echo "Remove installed files from package pluto"
if [ -e $SIMPATH_INSTALL/lib/libPluto.a ]; then
rm -f $SIMPATH_INSTALL/lib/libPluto*
rm -rf $SIMPATH_INSTALL/include/pluto
fi
fi
pluto_cleaned=true
fi
}
clean_geant3() {
if [ ! $geant3_cleaned ]; then
echo "Remove temporary files from package geant3"
if [ -e $SIMPATH/transport/geant3/lib ]; then
rm -rf $SIMPATH/transport/geant3/lib
rm -rf $SIMPATH/transport/geant3/tgt_*
fi
if [ "$rm_installed_files" = "true" ]; then
echo "Remove installed files from package geant3"
if [ -e $SIMPATH_INSTALL/lib/libgeant321.so ]; then
rm -f $SIMPATH_INSTALL/lib/libgeant321.so
rm -rf $SIMPATH_INSTALL/include/TGeant3
rm -rf $SIMPATH_INSTALL/share/geant3
fi
fi
geant3_cleaned=true
fi
}
clean_vgm() {
if [ ! $vgm_cleaned ]; then
echo "Remove temporary files from package vgm"
if [ -e $SIMPATH/transport/vgm/build_cmake ]; then
rm -rf $SIMPATH/transport/vgm/build_cmake
fi
if [ "$rm_installed_files" = "true" ]; then
echo "Remove installed files from package vgm"
if [ -e $SIMPATH_INSTALL/lib/libBaseVGM.so ]; then
rm -f $SIMPATH_INSTALL/lib/lib*GM.*
rm -rf $SIMPATH_INSTALL/include/*GM
fi
fi
clean_geant4_vmc
vgm_cleaned=true
fi
}
clean_geant4_vmc() {
if [ ! $geant4_vmc_cleaned ]; then
echo "Remove temporary files from package geant4_vmc"
if [ -e $SIMPATH/transport/geant4_vmc/tmp ]; then
rm -rf $SIMPATH/transport/geant4_vmc/tmp
rm -rf $SIMPATH/transport/geant4_vmc/lib
rm -rf $SIMPATH/transport/geant4_vmc/include
fi
if [ "$rm_installed_files" = "true" ]; then
echo "Remove installed files from package geant4_vmc"
if [ -e $SIMPATH_INSTALL/lib/libg4root.so ]; then
rm -f $SIMPATH_INSTALL/lib/libg4root.*
rm -f $SIMPATH_INSTALL/lib/libgeant4vmc.*
rm -rf $SIMPATH_INSTALL/include/geant4vmc
rm -rf $SIMPATH_INSTALL/share/geant4_vmc
fi
fi
geant4_vmc_cleaned=true
fi
}
clean_millipede() {
echo "Remove temporary files from package millipede"
if [ -e $SIMPATH/basics/MillepedeII/build ]; then
rm -rf $SIMPATH/basics/MillepedeII/build
cd $SIMPATH/basics/MillepedeII
make clean
rm -f $SIMPATH/basics/MillepedeII/pede
fi
if [ "$rm_installed_files" = "true" ]; then
echo "Remove installed files from package millipede"
if [ -e $SIMPATH_INSTALL/lib/libMille.so ]; then
rm -f $SIMPATH_INSTALL/lib/libMille.*
rm -f $SIMPATH_INSTALL/include/Mille.h
rm -f $SIMPATH_INSTALL/bin/pede
fi
fi
}
clean_zeromq() {
echo "Remove temporary files from package zeromq"
if [ -e $SIMPATH/basics/zeromq ]; then
cd $SIMPATH/basics/zeromq
make clean
fi
if [ "$rm_installed_files" = "true" ]; then
echo "Remove installed files from package zeromq"
if [ -e $SIMPATH_INSTALL/lib/libzmq.a ]; then
cd $SIMPATH/basics/zeromq
make uninstall
cd $SIMPATH_INSTALL
rm -f lib/libzmq.*
rm -f include/zmq.hpp
fi
fi
}
clean_protobuf() {
echo "Remove temporary files from package protobuf"
if [ -e $SIMPATH/basics/protobuf ]; then
cd $SIMPATH/basics/protobuf
make clean
fi
if [ "$rm_installed_files" = "true" ]; then
echo "Remove installed files from package protobuf"
if [ -e $SIMPATH_INSTALL/bin/protoc ]; then
cd $SIMPATH/basics/protobuf
make uninstall
fi
fi
}
clean_nanomsg() {
echo "Remove temporary files from package nanomsg"
if [ -e $SIMPATH/basics/nanomsg ]; then
cd $SIMPATH/basics/nanomsg
make clean
fi
if [ "$rm_installed_files" = "true" ]; then
echo "Remove installed files from package nanomsg"
if [ -e $SIMPATH_INSTALL/bin/nanocat ]; then
cd $SIMPATH/basics/nanomsg
make uninstall
rm -f $SIMPATH_INSTALL/bin/nn_*
fi
fi
}
clean_all() {
valid_packages="cmake gtest gsl icu boost pythia6 hepmc pythia8 xercesc mesa geant4 root g4py pluto geant3 vgm geant4_vmc millipede zeromq protobuf nanomsg"
for pack in $valid_packages
do
clean_$pack
done
}
check_package_exist() {
valid_packages="cmake gtest gsl icu boost pythia6 hepmc pythia8 xercesc mesa geant4 root g4py pluto geant3 vgm geant4_vmc millipede zeromq protobuf nanomsg"
if [ "$1" = "all" ]; then
return
fi
for pack in $valid_packages
do
if [ "$1" = "$pack" ]; then
return
fi
done
echo "The package \"$1\" is not a valid package name."
echo "Valid package names are: "
for pack in $valid_packages
do
echo " $pack"
done
exit 1
}
# call the main function after all other functions are already defined
main "$@"
exit