-
Notifications
You must be signed in to change notification settings - Fork 5
/
interactive_autogen.sh
executable file
·238 lines (192 loc) · 6.82 KB
/
interactive_autogen.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
#! /bin/bash
# Crash if any sub command crashes
set -o errexit
# Crash if any unset variables are used
set -o nounset
# Get the directory that autogen.sh is in (stolen frome stackoverflow:
# http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
# ), this is the oomph-lib root directory. Doesn't follow symlinks to the
# script itself, should be robust for anything else. If you move autogen.sh
# this will need to change a little.
oomph_root="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$oomph_root"
# Load helper functions
source bin/autogen_helpers.sh
# Echo autogen's usage if requested
while getopts ":h" opt; do
case $opt in
h)
echo "This script is an interactive interface to autogen.sh."
echo "Arguments allowed for the underlying autogen.sh are:"
echo
EchoUsage
exit 0
;;
esac
done
#====================================================================
# Start Q/A session
#====================================================================
echo " "
echo "============================================================= "
echo " oomph-lib interactive installation script"
echo "============================================================= "
echo " "
# Choose build directory (for lib,include)
build_dir="$oomph_root/build"
echo " "
echo " "
echo "I'm going to install the distribution (the lib and include directories)"
echo "in:"
echo " "
echo " " $build_dir
echo " "
echo " "
if ! YesNoRead "Is this OK?" "y"; then
printf "Specify build directory [e.g. /home/joe_user/build] :"
build_dir=$(OptionRead)
fi
echo " "
echo "============================================================= "
echo " "
echo "Build directory is: "
echo " "
echo " " $build_dir
echo " "
echo "--> The include directory will be in: "
echo " "
echo " " $build_dir"/include"
echo " "
echo "--> The lib directory will be in: "
echo " "
echo " " $build_dir"/lib"
echo " "
echo "etc. "
echo " "
echo "============================================================= "
echo " "
echo "Self tests"
echo "======"
echo "Following the installation of oomph-lib you can run a comprehensive set of"
echo "self tests with 'make check -k' or with './bin/parallel_self_test.py'. The"
echo "latter version tends to be much faster because it performs multiple"
echo "self-tests at the same time."
if YesNoRead "Would you like to automatically run self tests (serially) if the build is successful?" "n"; then
run_self_tests="true"
else
run_self_tests="false"
fi
# Choose configure options file
#------------------------------
configure_options_file="config/configure_options/current"
# If the current file exists then ask if it is ok
if [[ -f $configure_options_file ]]; then
echo " "
echo "Configure options are: "
cat "$configure_options_file" | ProcessOptionsFile
echo
if YesNoRead "Is this OK?" "y"; then
accept_configure_options="true"
else
accept_configure_options="false"
fi
# Otherwise have to choose one interactively
else
accept_configure_options="false"
fi
# Continue asking if the options are OK until approved
while [[ $accept_configure_options != "true" ]]; do
# Get list of options files
configure_option_files="$(find config/configure_options -type f | sort)"
echo " "
echo "======================================================================"
echo
echo "Choose an alternative configuration file "
# Loop over files and display a menu
count=0
for file in $configure_option_files
do
#Increase the counter
count=$(expr $count + 1)
echo $count ": " $(basename $file)
done
echo
echo "Enter the Desired configuration file [1-"$count"]"
echo "Enter 0 to specify the options on the command line"
# Read in the Desired File and validate it
file_number=$(OptionRead)
if (( $file_number >= $count )) || (( $file_number < 0 )); then
# Error and go to start of loop
echo "File number out of range, trying again." 1>&2
continue
fi
# If options are to be read from the command line then store the
# options in the file config/configure_options/current
if [[ "$file_number" == "0" ]]; then
echo
echo "Enter options"
configure_options=$(OptionRead)
echo $configure_options > "config/configure_options/new_options_file"
configure_options_file="config/configure_options/new_options_file"
# Otherwise copy the desired options file to config/configure_options/current
else
# Use cut to extract the nth entry in the list
configure_options_file="$(echo $configure_option_files | cut -d \ -f $file_number)"
fi
# Check that the options are in the correct order
configure_options_are_ok="$(CheckOptions $configure_options_file)"
if test "$configure_options_are_ok" != ""; then
echo " " 1>&2
echo "===============================================================" 1>&2
echo "Error message from autogen.sh:" 1>&2
echo " " 1>&2
echo $configure_options_are_ok 1>&2
echo " " 1>&2
echo "===============================================================" 1>&2
# Fail, go back to start of while loop
continue
fi
# Ask if these options are OK
echo " "
echo "Configure options are: "
cat "$configure_options_file" | ProcessOptionsFile
echo
if YesNoRead "Is this OK?" "y"; then
accept_configure_options="true"
else
accept_configure_options="false"
fi
done
echo
echo
echo
#====================================================================
# Start actual build process
#====================================================================
# Call real autogen
build_command="./autogen.sh -b $build_dir -c ${oomph_root}/$configure_options_file $@"
echo "The interactive part of the build process is over."
echo "Running $build_command"
$build_command
# Run tests if requested
if test "$run_self_tests" == "true"; then
self_test_command="make check -k"
echo "Running self test command: $self_test_command"
$self_test_command
fi
echo " "
echo "autogen.sh has finished! If you can't spot any error messages"
echo "above this, oomph-lib should now be ready to use... "
echo " "
echo "If you encounter any problems, please study the installation"
echo "instructions and the FAQ before contacting the developers. "
echo
echo
echo "To rerun autogen.sh with the selected options use the command:"
echo "$build_command"
echo
echo "To run self tests you can use 'make check -k' or './bin/parallel_self_test.py',"
echo "to run them automatically after a succesful build use the && operator,"
echo "e.g. './autogen.sh && make check -k'."
echo
echo "To see other autogen.sh command line options run './autogen.sh -h'"