@@ -14,28 +14,28 @@ function usage()
14
14
echo " Usage:"
15
15
echo " "
16
16
echo " cd <opencoarrays-source-directory>"
17
- echo " ./developer_scripts/gcc-trunk-install.sh [--patch-file <patch-file-name>] [--install-prefix <installation-path>]"
17
+ echo " ./developer_scripts/gcc-trunk-install.sh [--patch-file <patch-file-name>] [--packages-root <installation-path>]"
18
18
echo " or"
19
- echo " ./developer_scripts/gcc-trunk-install.sh [-p <patch-file-name>] [-i <installation-path>]"
19
+ echo " ./developer_scripts/gcc-trunk-install.sh [-p <patch-file-name>] [-r <installation-path>]"
20
20
echo " "
21
21
echo " Square brackets surround optional arguments."
22
22
exit 0
23
23
}
24
24
[[ " ${1:- } " == " -h" || " ${1:- } " == " --help" || ! -f src/libcaf.h ]] && usage
25
25
26
- if [[ " ${1:- } " == " -i " || " ${1:- } " == " --install-prefix " ]]; then
27
- export install_prefix =" ${2} "
28
- if [[ " ${3:- } " == " -i " || " ${3:- } " == " --install-prefix " ]]; then
26
+ if [[ " ${1:- } " == " -r " || " ${1:- } " == " --packages-root " ]]; then
27
+ export packages_root =" ${2} "
28
+ if [[ " ${3:- } " == " -r " || " ${3:- } " == " --packages-root " ]]; then
29
29
export patch_file=" ${4} "
30
30
fi
31
31
elif [[ " ${1:- } " == " -p" || " ${1:- } " == " --patch-file" ]]; then
32
32
export patch_file=" ${2:- } "
33
- if [[ " ${3:- } " == " -i " || " ${3:- } " == " --install-prefix " ]]; then
34
- export install_prefix =" ${4} "
33
+ if [[ " ${3:- } " == " -r " || " ${3:- } " == " --packages-root " ]]; then
34
+ export packages_root =" ${4} "
35
35
fi
36
36
fi
37
37
export default_prefix=" ${HOME} /opt"
38
- export install_prefix =" ${install_prefix :- ${default_prefix} } "
38
+ export packages_root =" ${packages_root :- ${default_prefix} } "
39
39
40
40
function set_absolute_path()
41
41
{
@@ -146,10 +146,13 @@ if [[ ! -z "${absolute_path:-}" ]]; then
146
146
pushd prerequisites/downloads/trunk
147
147
patch -p0 < " ${absolute_path} "
148
148
popd
149
+ export patched=" patched"
149
150
fi
150
151
151
- export GCC_install_prefix=${install_prefix} /gnu/trunk
152
+
153
+ export GCC_install_prefix=${packages_root} /gnu/trunk
152
154
# Build the patched GCC trunk
155
+
153
156
echo " Rebuilding the patched GCC source."
154
157
./install.sh \
155
158
--package gcc \
@@ -166,34 +169,33 @@ if ! type "${GCC_install_prefix}"/bin/gfortran >& /dev/null; then
166
169
fi
167
170
168
171
# Ensure that the just-installed GCC libraries are used when linking
169
- echo " Setting and exporting LD_LIBRARY_PATH"
172
+ echo " Setting and exporting PATH and LD_LIBRARY_PATH"
173
+
174
+ function prepend() {
170
175
171
- function prepend_to_LD_LIBRARY_PATH() {
172
- : ${1?' set_LD_LIBRARY_PATH: missing path' }
173
- new_path=" ${1} "
174
- if [[ -z " ${LD_LIBRARY_PATH:- } " ]]; then
175
- export LD_LIBRARY_PATH=" ${new_path} "
176
+ : " ${1?' prepend(): missing prefix' } "
177
+ : " ${2?' prepend(): missing environment variable name' } "
178
+
179
+ new_prefix=" $1 "
180
+ export env_var_name=" $2 "
181
+ eval env_var_val=" \$ $2 "
182
+ if [[ -z $env_var_val ]]; then
183
+ export $env_var_name =" $new_prefix "
176
184
else
177
- export LD_LIBRARY_PATH =" ${new_path} : ${LD_LIBRARY_PATH} "
185
+ export $env_var_name =" ${new_prefix} " : $env_var_val
178
186
fi
179
187
}
180
188
181
- old_path=" ${LD_LIBRARY_PATH:- } "
182
-
183
- if [[ -d " ${GCC_install_prefix} /lib64" ]]; then
184
- prepend_to_LD_LIBRARY_PATH " ${GCC_install_prefix} /lib64/"
189
+ if type " ${GCC_install_prefix} " /bin/gfortran; then
190
+ prepend " ${GCC_install_prefix} /bin/" PATH
191
+ prepend " ${GCC_install_prefix} /lib64/" LD_LIBRARY_PATH
192
+ else
193
+ echo " GCC is not installed in the expected location ${GCC_install_prefix} "
185
194
fi
186
195
187
- echo " \$ {LD_LIBRARY_PATH}=${LD_LIBRARY_PATH:= } "
196
+ echo " Building MPICH with the ${patched:- } compilers."
197
+ export mpich_install_prefix=" ${packages_root} /mpich/3.2/gnu/trunk"
188
198
189
- if [[ " ${LD_LIBRARY_PATH} " == " ${old_path} " ]]; then
190
- echo " gfortran libraries did not install where expected: ${GCC_install_prefix} /lib64 or ${GCC_install_prefix} /lib"
191
- exit 1
192
- fi
193
-
194
- # Build MPICH with the patched compilers.
195
- echo " Building MPICH with the patched compilers."
196
- export mpich_install_prefix=" ${install_prefix} /mpich/3.2/gnu/trunk"
197
199
./install.sh \
198
200
--package mpich \
199
201
--num-threads 4 \
@@ -204,21 +206,31 @@ export mpich_install_prefix="${install_prefix}/mpich/3.2/gnu/trunk"
204
206
--install-prefix " ${mpich_install_prefix} "
205
207
206
208
# Verify that MPICH installed where expected
207
- if ! type " ${mpich_install_prefix} " /bin/mpifort; then
209
+ if type " ${mpich_install_prefix} " /bin/mpifort; then
210
+ prepend " ${mpich_install_prefix} /bin/" PATH
211
+ else
208
212
echo " MPICH is not installed in the expected location ${mpich_install_prefix} ."
209
213
exit 1
210
214
fi
211
215
212
- # Build OpenCoarrays with the patched compilers and the just-built MPICH
216
+ # Build OpenCoarrays with the just-built compilers and the just-built MPICH
213
217
echo " Building OpenCoarrays."
214
- export opencoarrays_version=$( ./install.sh --version)
218
+ export opencoarrays_version=$( ./install.sh -V opencoarrays)
219
+ export opencoarrays_install_prefix=" ${packages_root} /opencoarrays/${opencoarrays_version} /gnu/trunk"
220
+
215
221
./install.sh \
216
- --package opencoarrays \
217
- --disable-bootstrap \
218
222
--num-threads 4 \
219
223
--yes-to-all \
220
- --with-fortran " ${GCC_install_prefix} /bin/gfortran" \
221
- --with-c " ${GCC_install_prefix} /bin/gcc" \
222
- --with-cxx " ${GCC_install_prefix} /bin/g++" \
223
- --with-mpi " ${mpich_install_prefix} " \
224
- --install-prefix " ${install_prefix} /opencoarrays/${opencoarrays_version} /gnu/trunk"
224
+ --with-mpi " $mpich_install_prefix " \
225
+ --install-prefix " $opencoarrays_install_prefix "
226
+
227
+ # Verify that OpenCoarrays installed where expected
228
+ if type " ${opencoarrays_install_prefix:- } " /bin/caf >& /dev/null; then
229
+ echo " "
230
+ echo " OpenCoarrays is in $opencoarrays_install_prefix "
231
+ echo " To set up your environment for using OpenCoarrays, execute the following command:"
232
+ echo " source ${opencoarrays_install_prefix} /setup.sh"
233
+ else
234
+ echo " OpenCoarrays is not in the expected location: ${opencoarrays_install_prefix:- " (no expected location found)" } ."
235
+ exit 1
236
+ fi
0 commit comments