forked from hyrise/bencho
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.sh
executable file
·69 lines (60 loc) · 1.35 KB
/
configure.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
#!/bin/bash
file="settings.conf"
declare -a flags=('PROD' 'PAPI' 'VERBOSE_BUILD' 'GNUPLOT' 'PYPLOT' 'RPLOT')
# create default settings if none exists
if [ ! -f $file ]; then
echo "PROD=0" > $file
echo "PAPI=0" >> $file
echo "VERBOSE_BUILD=0" >> $file
echo "GNUPLOT=0" >> $file
echo "PYPLOT=0" >> $file
echo "RPLOT=0" >> $file
#echo "PREFETCH=0" >> $file
#echo "THREAD_AFFINITY=0" >> $file
#echo "TREX_SSE=0" >> $file
fi
# check if new flags came with a new version, adds them if nessecary
for flag in "${flags[@]}"
do
found=0
while read myline
do
if [[ ${myline%%=*} == ${flag} ]]; then
found=1
fi
done < $file
if [[ $found -eq 0 ]]; then
echo "${flag}=0" >> $file
fi
done
# read in settings file
i=0
while read myline
do
(( i++ ))
# split line
var[i]=${myline%%=*}
val[i]=${myline##*=}
# echo ?
if [ $1 ]; then
printf ${var[$i]}"="${val[$i]}", "
fi
done < $file
# set new values
if [ $1 ]; then
echo
else
rm $file
c=1
while [[ $c -le $i ]]; do
printf ${var[$c]}"="${val[$c]}"? : "
read -n 1 answer
if [ $answer ]; then
echo ${var[$c]}"="$answer >> $file
echo
else
echo ${var[$c]}"="${val[$c]} >> $file
fi
(( c++ ))
done
fi