-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcompile.sh
executable file
·665 lines (565 loc) · 21.4 KB
/
compile.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
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
#!/bin/bash
# Define colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m'
# get current directory
current_path=$(pwd)
# set pipefail so "$?" gives 1 for piping of "false | true" for instance
# necessary because of piping to sed
set -o pipefail
# check version of cmake
# from 3.13 on, cmake can use -B and -S to specify build and source dirs
currentver="$(cmake --version | head -n 1 | awk -F "version " {'print $NF'})"
requiredver="3.13"
if [ "$(printf '%s\n' "$requiredver" "$currentver" | sort -V | head -n1)" = "$requiredver" ]; then
old_cmake=0
else
old_cmake=1
fi
# ================================================================================ #
# ================================ Default values ================================ #
# ================================================================================ #
# default compiler
CC="gcc"
CXX="g++"
# default cmake generator
CMAKE_GENERATOR="Unix Makefiles"
# default compiler flag
CO="release"
# install target
TARGET="host"
# do not install fits libraries each time
DO_FITS=false
# ================================================================================ #
# ============================ install FITS libraries ============================ #
# ================================================================================ #
function install_fits_libraries()
{
# Check if lib directory exists
echo -e "--- Install required libraries for FITS support ---"
if [ ! -d "lib" ]; then
echo -e "--- ${RED}Error:${NC} lib directory not found (incomplete polaris package?)"
exit 1
fi
cd "lib"
echo ""
# cfitsio
rm -rf "cfitsio/"
tar -xf cfitsio.tar.gz
cd "cfitsio"
mkdir -p "build"
echo -e "Configure cfitsio ..."
if [ "$old_cmake" -eq "1" ]; then
cd "build"
cmake .. \
-G "$CMAKE_GENERATOR" \
-DBUILD_SHARED_LIBS="ON" \
-DCMAKE_INSTALL_PREFIX="${current_path}/lib" \
-DCMAKE_C_COMPILER="$CC" \
-DCMAKE_C_FLAGS="-w -O3" \
-DCMAKE_CXX_COMPILER="$CXX" \
-DCMAKE_CXX_FLAGS="-w -O3" \
| sed 's/^/ /' \
&& { echo -e "Configure cfitsio [${GREEN}done${NC}]"; echo ""; } \
|| { echo -e "Configure cfitsio [${RED}Error${NC}]"; exit 1; }
else
cmake \
-S . -B build \
-G "$CMAKE_GENERATOR" \
-DBUILD_SHARED_LIBS="ON" \
-DCMAKE_INSTALL_PREFIX="${current_path}/lib" \
-DCMAKE_C_COMPILER="$CC" \
-DCMAKE_C_FLAGS="-w -O3" \
-DCMAKE_CXX_COMPILER="$CXX" \
-DCMAKE_CXX_FLAGS="-w -O3" \
| sed 's/^/ /' \
&& { echo -e "Configure cfitsio [${GREEN}done${NC}]"; echo ""; } \
|| { echo -e "Configure cfitsio [${RED}Error${NC}]"; exit 1; }
fi
echo -e "Compile cfitsio ..."
if [ "$old_cmake" -eq "1" ]; then
cmake --build . && cmake --build . --target install \
| sed 's/^/ /' \
&& { echo -e "Compile cfitsio [${GREEN}done${NC}]"; echo ""; } \
|| { echo -e "Compile cfitsio [${RED}Error${NC}]"; exit 1; }
cd ..
else
cmake --build build && cmake --build build --target install\
| sed 's/^/ /' \
&& { echo -e "Compile cfitsio [${GREEN}done${NC}]"; echo ""; } \
|| { echo -e "Compile cfitsio [${RED}Error${NC}]"; exit 1; }
fi
cd ..
echo ""
# CCfits
rm -rf "CCfits/"
tar -xf CCfits.tar.gz
cd "CCfits"
mkdir -p "build"
echo -e "Configure CCfits ..."
if [ "$old_cmake" -eq "1" ]; then
cd "build"
cmake .. \
-DCMAKE_PREFIX_PATH="../cfitsio" \
-G "$CMAKE_GENERATOR" \
-DCMAKE_PREFIX_PATH="${current_path}/lib" \
-DCMAKE_INSTALL_PREFIX="${current_path}/lib" \
-DBUILD_SHARED_LIBS="ON" \
-DCMAKE_C_COMPILER="$CC" \
-DCMAKE_C_FLAGS="-w -O3" \
-DCMAKE_CXX_COMPILER="$CXX" \
-DCMAKE_CXX_FLAGS="-w -O3" \
| sed 's/^/ /' \
&& { echo -e "Configure CCfits [${GREEN}done${NC}]"; echo ""; } \
|| { echo -e "Configure CCfits [${RED}Error${NC}]"; exit 1; }
else
cmake \
-S . -B build \
-DCMAKE_PREFIX_PATH="../cfitsio" \
-G "$CMAKE_GENERATOR" \
-DCMAKE_PREFIX_PATH="${current_path}/lib" \
-DCMAKE_INSTALL_PREFIX="${current_path}/lib" \
-DBUILD_SHARED_LIBS="ON" \
-DCMAKE_C_COMPILER="$CC" \
-DCMAKE_C_FLAGS="-w -O3" \
-DCMAKE_CXX_COMPILER="$CXX" \
-DCMAKE_CXX_FLAGS="-w -O3" \
| sed 's/^/ /' \
&& { echo -e "Configure CCfits [${GREEN}done${NC}]"; echo ""; } \
|| { echo -e "Configure CCfits [${RED}Error${NC}]"; exit 1; }
fi
echo -e "Compile CCfits ..."
if [ "$old_cmake" -eq "1" ]; then
cmake --build . && cmake --build . --target install \
| sed 's/^/ /' \
&& { echo -e "Compile CCfits [${GREEN}done${NC}]"; echo ""; } \
|| { echo -e "Compile CCfits [${RED}Error${NC}]"; exit 1; }
cd ".."
else
cmake --build build && cmake --build build --target install \
| sed 's/^/ /' \
&& { echo -e "Compile CCfits [${GREEN}done${NC}]"; echo ""; } \
|| { echo -e "Compile CCfits [${RED}Error${NC}]"; exit 1; }
fi
cd ../..
echo ""
}
# ================================================================================ #
# =============================== install POLARIS ================================ #
# ================================================================================ #
function install_polaris()
{
# remove old bins
rm -f bin/polaris
rm -f src/polaris
# remove and re-make build dir
cd src/
rm -rf build
mkdir -p build
# configure POLARIS with appropriate flags
echo -e "Configure POLARIS ..."
if [ "$old_cmake" -eq "1" ]; then
cd "build"
cmake .. \
-G "$CMAKE_GENERATOR" \
-DCMAKE_PREFIX_PATH="${current_path}/lib" \
-DCMAKE_INSTALL_PREFIX="${current_path}" \
-DBUILD_SHARED_LIBS="ON" \
-DCMAKE_C_COMPILER="$CC" \
-DCMAKE_CXX_COMPILER="$CXX" \
-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
| sed 's/^/ /' \
&& { echo -e "Configure POLARIS [${GREEN}done${NC}]"; echo ""; } \
|| { echo -e "Configure POLARIS [${RED}Error${NC}]"; exit 1; }
else
cmake \
-S . -B build \
-G "$CMAKE_GENERATOR" \
-DCMAKE_PREFIX_PATH="${current_path}/lib" \
-DCMAKE_INSTALL_PREFIX="${current_path}" \
-DBUILD_SHARED_LIBS="ON" \
-DCMAKE_C_COMPILER="$CC" \
-DCMAKE_CXX_COMPILER="$CXX" \
-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
| sed 's/^/ /' \
&& { echo -e "Configure POLARIS [${GREEN}done${NC}]"; echo ""; } \
|| { echo -e "Configure POLARIS [${RED}Error${NC}]"; exit 1; }
fi
echo ""
# compile and install POLARIS
echo -e "Compile POLARIS ..."
if [ "$old_cmake" -eq "1" ]; then
cmake --build . \
| sed 's/^/ /' \
&& { echo -e "Compile POLARIS [${GREEN}done${NC}]"; echo ""; } \
|| { echo -e "Compile POLARIS [${RED}Error${NC}]"; exit 1; }
else
cmake --build build \
| sed 's/^/ /' \
&& { echo -e "Compile POLARIS [${GREEN}done${NC}]"; echo ""; } \
|| { echo -e "Compile POLARIS [${RED}Error${NC}]"; exit 1; }
fi
echo ""
echo -e "Installing ..."
if [ "$old_cmake" -eq "1" ]; then
cmake --build . --target install \
| sed 's/^/ /' \
&& { echo -e "Installing POLARIS [${GREEN}done${NC}]"; echo ""; } \
|| { echo -e "Installing POLARIS [${RED}Error${NC}]"; exit 1; }
cd ..
else
cmake --build build --target install \
| sed 's/^/ /' \
&& { echo -e "Installing POLARIS [${GREEN}done${NC}]"; echo ""; } \
|| { echo -e "Installing POLARIS [${RED}Error${NC}]"; exit 1; }
fi
cd ..
echo ""
}
# ================================================================================ #
# ================================ Update POLARIS ================================ #
# ================================================================================ #
function update_installation()
{
cd "src"
# compile and install POLARIS
if [ "$old_cmake" -eq "1" ]; then
cd "build"
cmake --build . \
| sed 's/^/ /' \
&& { echo -e "Compile POLARIS [${GREEN}done${NC}]"; echo ""; } \
|| { echo -e "Compile POLARIS [${RED}Error${NC}]"; exit 1; }
cmake --build . --target install \
| sed 's/^/ /' \
&& { echo -e "Installing POLARIS [${GREEN}done${NC}]"; echo ""; } \
|| { echo -e "Installing POLARIS [${RED}Error${NC}]"; exit 1; }
cd ..
else
cmake --build build \
| sed 's/^/ /' \
&& { echo -e "Compile POLARIS [${GREEN}done${NC}]"; echo ""; } \
|| { echo -e "Compile POLARIS [${RED}Error${NC}]"; exit 1; }
cmake --build build --target install \
| sed 's/^/ /' \
&& { echo -e "Installing POLARIS [${GREEN}done${NC}]"; echo ""; } \
|| { echo -e "Installing POLARIS [${RED}Error${NC}]"; exit 1; }
fi
cd ".."
install_polaristools
source ${HOME}/.bashrc
exit
}
function install_polaristools()
{
# compile and install PolarisTools if available
if [[ -d "tools" ]]; then
cd "tools/"
python3 setup.py install --user &>/dev/null \
&& { echo -e "Compile and installing PolarisTools [${GREEN}done${NC}]"; echo ""; } \
|| { echo -e "Compile and installing PolarisTools [${RED}Error${NC}]"; exit 1; }
cd ".."
else
echo -e "Compile and installing PolarisTools [${RED}Error${NC}]"; exit 1;
fi
}
# ================================================================================ #
# =========================== Get user input and verify ========================== #
# ================================================================================ #
function usage() {
echo ""
echo "usage: compile.sh [-h] [-frdu] [-c CXX_COMPILER] [-g CMAKE_GENERATOR]"
echo ""
echo "Install POLARIS, PolarisTools, and optionally the cfitsio and CCfits libraries"
echo -e "${YELLOW}HINT:${NC} For first installation, use option -f"
echo ""
echo "optional arguments:"
echo "-h show this help message and exit"
echo "-f first installation (compile POLARIS, PolarisTools, and the cfitsio and CCfits libraries)"
echo "-r clear and compile POLARIS and PolarisTools (release mode) (default)"
echo "-d clear and compile POLARIS and PolarisTools (debug mode)"
echo "-u re-compile POLARIS and PolarisTools if necessary with last configuration (update)"
echo "-t (re-)compile PolarisTools only"
echo "-c CXX_compiler"
echo " choose the c++ compiler you want to use:"
echo " - gcc (default)"
echo " - icc"
echo " - clang++"
echo "-g CMAKE_GENERATOR"
echo " choose the generator for cmake:"
echo " - make (default)"
echo " - ninja"
echo ""
exit
}
release=false
debug=false
while getopts "hfrdutc:g:D" opt; do
case $opt in
h)
usage
;;
r)
# this is the default -> do nothing
# except if -d is also chosen
# release + debug -> fast debug (nice for profiling)
release=true
;;
d)
CO="debug"
# release + debug -> fast debug (nice for profiling)
debug=true
;;
u)
update_installation
;;
f)
DO_FITS=true
;;
t)
install_polaristools
source ${HOME}/.bashrc
exit
;;
c)
if [[ ${OPTARG,,} = "gcc" ]]; then
CXX="g++"
else
CXX=${OPTARG}
fi
;;
g)
if [[ ${OPTARG,,} = "ninja" ]]; then
CMAKE_GENERATOR="Ninja"
elif [[ ${OPTARG,,} = "make" || ${OPTARG,,} = "unix makefiles" ]]; then
CMAKE_GENERATOR="Unix Makefiles"
fi
;;
*)
usage
;;
esac
done
# release + debug -> fast debug (nice for profiling)
if $release && $debug; then CO="fast-debug"; fi
# Print hint for first installation
echo ""
echo -e "${YELLOW}HINT:${NC} For first installation, use option -f"
echo ""
# Search for required packages
required_packages=true
echo -e "Search for required packages ..."
if type $CXX >/dev/null 2>&1; then
echo -e " -- Required package $CXX [${GREEN}found${NC}]"
else
echo -e " -- ${RED}Error:${NC} Required package $CXX not found!"
required_packages=false
fi
if [[ $CMAKE_GENERATOR = "Ninja" ]]; then
if type "ninja" >/dev/null 2>&1; then
echo -e " -- Required package $CMAKE_GENERATOR [${GREEN}found${NC}]"
else
echo -e " -- ${RED}Error:${NC} Required package $CMAKE_GENERATOR not found!"
required_packages=false
fi
elif [[ $CMAKE_GENERATOR = "Unix Makefiles" ]]; then
if type "make" >/dev/null 2>&1; then
echo -e " -- Required package $CMAKE_GENERATOR [${GREEN}found${NC}]"
else
echo -e " -- ${RED}Error:${NC} Required package $CMAKE_GENERATOR not found!"
required_packages=false
fi
fi
if type "python3" >/dev/null 2>&1; then
echo -e " -- Required package python3 [${GREEN}found${NC}]"
for package_name in argparse io numpy os setuptools shutil struct sys; do
if python3 -c "import ${package_name}" &>/dev/null; then
echo -e " -- Required python package ${package_name} [${GREEN}found${NC}]"
else
if type "pip3" >/dev/null 2>&1; then
echo "Pip installation detected. Install ${package_name}!"
pip3 install ${package_name}
if python3 -c "import ${package_name}" &>/dev/null; then
echo -e " -- Installation succesfull. Required python package ${package_name} [${GREEN}found${NC}]"
else
echo -e " -- ${RED}Error:${NC} Installation of ${package_name} not succesfull!"
required_packages=false
fi
else
echo -e " -- ${RED}Error:${NC} Required python package ${package_name} not found!"
required_packages=false
fi
fi
done
else
echo -e " -- ${RED}Error:${NC} Required package python3 not found!"
required_packages=false
fi
if ! $required_packages; then
echo -e "${RED}Error:${NC} Installation aborted. Please contact your system admin to install the required packages."
exit 1
fi
# ================================================================================ #
# ============================= Set compiler options ============================= #
# ================================================================================ #
# intel
if [ $CXX = "icc" ]; then
if [ $TARGET = "host" ]; then
TARGET=$(hostname)
fi
case $TARGET in
prometheus)
CXXFLAGS="-march=skylake-avx512"
;;
nesh*)
CXXFLAGS="-xCORE-AVX512"
;;
fenrir)
CXXFLAGS="-I/usr/include/x86_64-linux-gnu/c++/8/ -march=skylake"
;;
oberon)
CXXFLAGS="-march=broadwell"
;;
hera|rhea|hydra)
CXXFLAGS="-march=ivybridge"
;;
atlas)
CXXFLAGS="-march=sandybridge"
;;
*)
CXXFLAGS="-xHost"
;;
esac
if [ $CO = "debug" ]; then
CXXFLAGS="-O1 -g3 -debug inline-debug-info"
elif [ $CO = "release" ]; then
CXXFLAGS="-O3 -parallel -ip -ipo -g $CXXFLAGS"
elif [ $CO = "release-multi" ]; then
CXXFLAGS="-O3 -parallel -ip -ipo -g -xAVX -axCORE-AVX512,CORE-AVX2"
elif [ $CO = "fast-debug" ]; then
CXXFLAGS="-O3 -parallel -ip -ipo -g3 -debug inline-debug-info $CXXFLAGS"
elif [ $CO = "fast-debug-multi" ]; then
CXXFLAGS="-O3 -parallel -ip -ipo -g3 -debug inline-debug-info -xAVX -axCORE-AVX512,CORE-AVX2"
else
echo "No valid option chosen"
exit 1
fi
CXXFLAGS="$CXXFLAGS -I/usr/include/x86_64-linux-gnu/c++/8/"
# gnu
elif [ $CXX = "g++" ]; then
if [ $CO = "debug" ]; then
CXXFLAGS="-O1 -g3 -Wall"
CXXFLAGS="$CXXFLAGS -Wno-unused-function -Wno-sign-compare -Wno-unused-but-set-variable -Wno-comment -Wno-unknown-pragmas -Wno-maybe-uninitialized"
elif [ $CO = "fast-debug" ]; then
CXXFLAGS="-march=native -O3 -funroll-loops -flto"
CXXFLAGS="$CXXFLAGS -g3 -Wall"
CXXFLAGS="$CXXFLAGS -Wno-unused-function -Wno-sign-compare -Wno-unused-but-set-variable -Wno-comment -Wno-unknown-pragmas"
elif [ $CO = "release" ]; then
CXXFLAGS="-march=native -O3 -funroll-loops -flto"
else
echo "No valid option chosen"
exit 1
fi
CXXFLAGS="$CXXFLAGS -fuse-linker-plugin -fuse-ld=gold"
# clang
elif [ $CXX = "clang++" ]; then
if [ $CO = "debug" ]; then
CXXFLAGS="-O1 -g3 -Wall"
CXXFLAGS="$CXXFLAGS -Wno-unused-function -Wno-sign-compare -Wno-unused-private-field -Wno-unknown-pragmas"
elif [ $CO = "fast-debug" ]; then
CXXFLAGS="-march=native -O3 -flto"
CXXFLAGS="$CXXFLAGS -g3 -Wall"
CXXFLAGS="$CXXFLAGS -Wno-unused-function -Wno-sign-compare -Wno-unused-private-field -Wno-unknown-pragmas"
elif [ $CO = "release" ]; then
CXXFLAGS="-march=native -O3 -flto"
else
echo "No valid option chosen"
exit 1
fi
CXXFLAGS="$CXXFLAGS -Wno-comment"
CC="clang"
else
echo "No valid compiler chosen"
exit 1
fi
# ================================================================================ #
# ============================= Show set-up and do it ============================ #
# ================================================================================ #
# show the chosen options
echo ""
echo "CXX: $CXX"
echo "CO: $CO"
echo "CMake Generator: $CMAKE_GENERATOR"
echo ""
echo ""
echo "Compiler flags: $CXXFLAGS"
echo ""
echo ""
if [ ! -d "projects" ]; then
mkdir "projects"
fi
# set POLARIS_PATH as environment variable
set_envvar_POLARIS_str="export POLARIS_PATH=\"${current_path}\""
# check if this variable is already in PATH to prevent multiple entries
if_POLARIS_str="if [[ \":"'$PATH'":\" != *\":"'${POLARIS_PATH}'"/bin:\"* ]]; then"
# prepend this variable to PATH
export_POLARIS_str=" export PATH=\""'${POLARIS_PATH}'"/bin:"'$PATH'"\""
# check if these lines are already in .bashrc
if ! grep -q "${set_envvar_POLARIS_str}" ${HOME}/.bashrc; then
echo -e "Add POLARIS install path to ~/.bashrc ..."
echo "${set_envvar_POLARIS_str}" >>${HOME}/.bashrc
echo "${if_POLARIS_str}" >>${HOME}/.bashrc
echo "${export_POLARIS_str}" >>${HOME}/.bashrc
echo "fi" >>${HOME}/.bashrc
echo "" >>${HOME}/.bashrc
source ${HOME}/.bashrc
echo -e "... [${GREEN}done${NC}]"
echo ""
echo ""
fi
# set POLARIS_FITS_PATH as environment variable
set_envvar_FITS_str="export POLARIS_FITS_PATH=\""'${POLARIS_PATH}'"/lib/lib\""
# check if this variable is already in LD_LIBRARY_PATH to prevent multiple entries
if_FITS_str="if [[ \":"'$LD_LIBRARY_PATH'":\" != *\":"'$POLARIS_FITS_PATH'":\"* ]]; then"
# prepend this variable to LD_LIBRARY_PATH
export_FITS_str=" export LD_LIBRARY_PATH=\""'$POLARIS_FITS_PATH'":"'$LD_LIBRARY_PATH'"\""
if ! grep -q "${set_envvar_FITS_str}" ${HOME}/.bashrc; then
echo -e "Add FITS libraries install paths to ~/.bashrc ..."
echo "${set_envvar_FITS_str}" >>${HOME}/.bashrc
echo "${if_FITS_str}" >>${HOME}/.bashrc
echo "${export_FITS_str}" >>${HOME}/.bashrc
echo "fi" >>${HOME}/.bashrc
echo "" >>${HOME}/.bashrc
source ${HOME}/.bashrc
echo -e "... [${GREEN}done${NC}]"
echo ""
echo ""
fi
if [ "$DO_FITS" = true ]; then
install_fits_libraries
fi
install_polaris
# compile and install PolarisTools if available
if [[ -d "tools" ]]; then
install_polaristools
# set POLARISTOOLS_PATH as environment variable
set_envvar_TOOLS_str="export POLARISTOOLS_PATH=\"$HOME/.local/bin\""
# check if this variable is already in PATH to prevent multiple entries
if_TOOLS_str="if [[ \":"'$PATH'":\" != *\":"'$POLARISTOOLS_PATH'":\"* ]]; then"
# prepend this variable to PATH
export_TOOLS_str=" export PATH=\""'$POLARISTOOLS_PATH'":"'$PATH'"\""
if ! grep -q "${set_envvar_TOOLS_str}" ${HOME}/.bashrc; then
echo -e "Add PolarisTools install path to ~/.bashrc ..."
echo "${set_envvar_TOOLS_str}" >>${HOME}/.bashrc
echo "${if_TOOLS_str}" >>${HOME}/.bashrc
echo "${export_TOOLS_str}" >>${HOME}/.bashrc
echo "fi" >>${HOME}/.bashrc
echo "" >>${HOME}/.bashrc
source ${HOME}/.bashrc
echo -e "... [${GREEN}done${NC}]"
echo ""
echo ""
fi
fi
source ${HOME}/.bashrc