Skip to content

Commit d78a4f5

Browse files
author
Damian Rouson
authored
Merge pull request #492 from sourceryinstitute/trunk-install-script
Add patched-trunk install script option: unpatched build
2 parents 7fba091 + 7f17ab2 commit d78a4f5

File tree

1 file changed

+75
-45
lines changed

1 file changed

+75
-45
lines changed

developer-scripts/patched-trunk-install.sh renamed to developer-scripts/gcc-trunk-install.sh

Lines changed: 75 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,41 @@
11
#!/usr/bin/env bash
22

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
49

510
# Print usage information and exit if this script was invoked with no arugments or with -h or --help
611
# as the first argument or in a location other than the top-level OpenCoarrays source directory
712
function usage()
813
{
914
echo "Usage:"
15+
echo ""
1016
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
1323
}
14-
[[ $# -eq 0 || "${1}" == "-h" || "${1}" == "--help" || ! -f src/libcaf.h ]] && usage
24+
[[ "${1:-}" == "-h" || "${1:-}" == "--help" || ! -f src/libcaf.h ]] && usage
1525

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}}"
1739

1840
function set_absolute_path()
1941
{
@@ -27,14 +49,9 @@ function set_absolute_path()
2749
absolute_path="${PWD%%/}/${arg}"
2850
fi
2951
}
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
3855

3956
### Define functions
4057
function choose_package_manager()
@@ -121,22 +138,30 @@ install_if_missing flex
121138

122139
# Download and build the GCC trunk:
123140
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
131150

151+
export GCC_install_prefix=${install_prefix}/gcc/trunk
132152
# Build the patched GCC trunk
133153
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}"
135161

136162
# 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}."
140165
exit 1
141166
fi
142167

@@ -155,40 +180,45 @@ function prepend_to_LD_LIBRARY_PATH() {
155180

156181
old_path="${LD_LIBRARY_PATH:-}"
157182

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/"
164185
fi
165186

166187
echo "\${LD_LIBRARY_PATH}=${LD_LIBRARY_PATH:=}"
167188

168189
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"
170191
exit 1
171192
fi
172193

173194
# Build MPICH with the patched compilers.
174195
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}"
179205

180206
# 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}."
184209
exit 1
185210
fi
186211

187212
# 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

Comments
 (0)