1
1
#! /usr/bin/env bash
2
2
3
- # ## Diagnostics ###
3
+ # Exit on error or use of an unset variable:
4
+ set -o errexit
5
+ set -o nounset
6
+
7
+ # Return the highest exit code in a chain of pipes:
8
+ set -o pipefail
4
9
5
10
# Print usage information and exit if this script was invoked with no arugments or with -h or --help
6
11
# as the first argument or in a location other than the top-level OpenCoarrays source directory
7
12
function usage()
8
13
{
9
14
echo " Usage:"
15
+ echo " "
10
16
echo " cd <opencoarrays-source-directory>"
11
- echo " ./developer_scripts/patched-trunk-install.sh <patch-file>"
12
- exit 1
17
+ echo " ./developer_scripts/gcc-trunk-install.sh [--patch-file <patch-file-name>] [--install-prefix <installation-path>]"
18
+ echo " or"
19
+ echo " ./developer_scripts/gcc-trunk-install.sh [-p <patch-file-name>] [-i <installation-path>]"
20
+ echo " "
21
+ echo " Square brackets surround optional arguments."
22
+ exit 0
13
23
}
14
- [[ $# -eq 0 || " ${1} " == " -h" || " ${1} " == " --help" || ! -f src/libcaf.h ]] && usage
24
+ [[ " ${1:- } " == " -h" || " ${1:- } " == " --help" || ! -f src/libcaf.h ]] && usage
15
25
16
- patch_file=" ${1} "
26
+ if [[ " ${1:- } " == " -i" || " ${1:- } " == " --install-prefix" ]]; then
27
+ export install_prefix=" ${2} "
28
+ if [[ " ${3:- } " == " -i" || " ${3:- } " == " --install-prefix" ]]; then
29
+ export patch_file=" ${4} "
30
+ fi
31
+ elif [[ " ${1:- } " == " -p" || " ${1:- } " == " --patch-file" ]]; then
32
+ export patch_file=" ${2:- } "
33
+ if [[ " ${3:- } " == " -i" || " ${3:- } " == " --install-prefix" ]]; then
34
+ export install_prefix=" ${4} "
35
+ fi
36
+ fi
37
+ export default_prefix=" ${HOME} /opt"
38
+ export install_prefix=" ${install_prefix:- ${default_prefix} } "
17
39
18
40
function set_absolute_path()
19
41
{
@@ -27,14 +49,9 @@ function set_absolute_path()
27
49
absolute_path=" ${PWD%%/ } /${arg} "
28
50
fi
29
51
}
30
- set_absolute_path " ${patch_file} "
31
-
32
- # Exit on error or use of an unset variable:
33
- set -o errexit
34
- set -o nounset
35
-
36
- # Return the highest exit code in a chain of pipes:
37
- set -o pipefail
52
+ if [[ ! -z " ${patch_file:- } " ]]; then
53
+ set_absolute_path " ${patch_file} "
54
+ fi
38
55
39
56
# ## Define functions
40
57
function choose_package_manager()
@@ -121,22 +138,30 @@ install_if_missing flex
121
138
122
139
# Download and build the GCC trunk:
123
140
echo " Downloading the GCC trunk."
124
- ./install.sh --only-download --package gcc --install-branch trunk
125
-
126
- # Patch the GCC trunk and rebuild
127
- echo " Patching the GCC source using ${absolute_path} ."
128
- pushd prerequisites/downloads/trunk
129
- patch -p0 < " ${absolute_path} "
130
- popd
141
+ ./install.sh --only-download --package gcc --install-branch trunk --yes-to-all
142
+
143
+ if [[ ! -z " ${absolute_path:- } " ]]; then
144
+ # Patch the GCC trunk and rebuild
145
+ echo " Patching the GCC source using ${absolute_path} ."
146
+ pushd prerequisites/downloads/trunk
147
+ patch -p0 < " ${absolute_path} "
148
+ popd
149
+ fi
131
150
151
+ export GCC_install_prefix=${install_prefix} /gcc/trunk
132
152
# Build the patched GCC trunk
133
153
echo " Rebuilding the patched GCC source."
134
- ./install.sh --package gcc --install-branch trunk --yes-to-all
154
+ ./install.sh \
155
+ --package gcc \
156
+ --install-branch trunk \
157
+ --yes-to-all \
158
+ --num-threads 4 \
159
+ --disable-bootstrap \
160
+ --install-prefix " ${GCC_install_prefix} "
135
161
136
162
# Verify that GCC installed in the expected path
137
- patched_GCC_install_path=${PWD} /prerequisites/installations/gcc/trunk
138
- if ! type " ${patched_GCC_install_path} " /bin/gfortran >& /dev/null; then
139
- echo " gfortran is not installed in the expected location ${patched_GCC_install_path} ."
163
+ if ! type " ${GCC_install_prefix} " /bin/gfortran >& /dev/null; then
164
+ echo " gfortran is not installed in the expected location ${GCC_install_prefix} ."
140
165
exit 1
141
166
fi
142
167
@@ -155,40 +180,45 @@ function prepend_to_LD_LIBRARY_PATH() {
155
180
156
181
old_path=" ${LD_LIBRARY_PATH:- } "
157
182
158
- if [[ -d " ${PWD} /prerequisites/installations/gcc/trunk/lib" ]]; then
159
- prepend_to_LD_LIBRARY_PATH " ${patched_GCC_install_path} /lib/"
160
- fi
161
-
162
- if [[ -d " ${PWD} /prerequisites/installations/gcc/trunk/lib64" ]]; then
163
- prepend_to_LD_LIBRARY_PATH " ${patched_GCC_install_path} /lib64/"
183
+ if [[ -d " ${GCC_install_prefix} /lib64" ]]; then
184
+ prepend_to_LD_LIBRARY_PATH " ${GCC_install_prefix} /lib64/"
164
185
fi
165
186
166
187
echo " \$ {LD_LIBRARY_PATH}=${LD_LIBRARY_PATH:= } "
167
188
168
189
if [[ " ${LD_LIBRARY_PATH} " == " ${old_path} " ]]; then
169
- echo " gfortran libraries did not install where expected: ${patched_GCC_install_path } /lib64 or ${patched_GCC_install_path } /lib"
190
+ echo " gfortran libraries did not install where expected: ${GCC_install_prefix } /lib64 or ${GCC_install_prefix } /lib"
170
191
exit 1
171
192
fi
172
193
173
194
# Build MPICH with the patched compilers.
174
195
echo " Building MPICH with the patched compilers."
175
- ./install.sh --package mpich --yes-to-all \
176
- --with-fortran " ${patched_GCC_install_path} /bin/gfortran" \
177
- --with-c " ${patched_GCC_install_path} /bin/gcc" \
178
- --with-cxx " ${patched_GCC_install_path} /bin/g++"
196
+ export mpich_install_prefix=" ${install_prefix} /mpich/3.2/gnu/trunk"
197
+ ./install.sh \
198
+ --package mpich \
199
+ --num-threads 4 \
200
+ --yes-to-all \
201
+ --with-fortran " ${GCC_install_prefix} /bin/gfortran" \
202
+ --with-c " ${GCC_install_prefix} /bin/gcc" \
203
+ --with-cxx " ${GCC_install_prefix} /bin/g++" \
204
+ --install-prefix " ${mpich_install_prefix} "
179
205
180
206
# Verify that MPICH installed where expected
181
- mpich_install_path=$( ./install.sh -P mpich)
182
- if ! type " ${mpich_install_path} " /bin/mpifort; then
183
- echo " MPICH is not installed in the expected location ${mpich_install_path} ."
207
+ if ! type " ${mpich_install_prefix} " /bin/mpifort; then
208
+ echo " MPICH is not installed in the expected location ${mpich_install_prefix} ."
184
209
exit 1
185
210
fi
186
211
187
212
# Build OpenCoarrays with the patched compilers and the just-built MPICH
188
- echo " Building OpenCoarrays with the patched compilers"
189
- # Build OpenCoarrays with the patched compiler:
190
- ./install.sh --yes-to-all \
191
- --with-fortran " ${patched_GCC_install_path} /bin/gfortran" \
192
- --with-c " ${patched_GCC_install_path} /bin/gcc" \
193
- --with-cxx " ${patched_GCC_install_path} /bin/g++" \
194
- --with-mpi " ${mpich_install_path} "
213
+ echo " Building OpenCoarrays."
214
+ export opencoarrays_version=$( ./install.sh --version)
215
+ ./install.sh \
216
+ --package opencoarrays \
217
+ --disable-bootstrap \
218
+ --num-threads 4 \
219
+ --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"
0 commit comments