11#! /bin/bash
2+ #
3+ # buildmpich
4+ #
5+ # -- This script ownloads and installs the MPICH library (http://www.mpich.org).
6+ #
27# OpenCoarrays is distributed under the OSI-approved BSD 3-clause License:
38# Copyright (c) 2015, Sourcery, Inc.
49# Copyright (c) 2015, Sourcery Institute
510# All rights reserved.
611#
7- # This script downloads and installs the MPICH library (http://www.mpich.org).
8- #
912# All rights reserved.
1013# Redistribution and use in source and binary forms, with or without modification,
1114# are permitted provided that the following conditions are met:
@@ -34,9 +37,11 @@ cmd=`basename $0`
3437usage ()
3538{
3639 echo " "
37- echo " $cmd - Bash script for building GCC from source"
40+ echo " $cmd - Bash script for building MPICH from source"
3841 echo " "
39- echo " Usage: $cmd <branch-name> <install-path> <number-of-threads> [options] ..."
42+ echo " Usage (optional arguments in square brackets): "
43+ echo " $cmd <version-number> <install-path> <number-of-threads>"
44+ echo " or $cmd [options] "
4045 echo " "
4146 echo " Options:"
4247 echo " --help, -h Show this help message"
@@ -49,13 +54,14 @@ usage()
4954 echo " $cmd -v"
5055 echo " $cmd --help"
5156 echo " "
52- echo " Note: use svn ls svn://gcc.gnu.org/svn/gcc/branches "
53- echo " to list all available branches. "
57+ echo " Note: For a list of available MPICH versions, visit "
58+ echo " http://www.mpich.org/static/downloads/ "
5459 echo " "
5560 exit 1
5661}
5762
58- # Default to compiling with the GNU compilers
63+ # Default to compiling with the GNU compilers if the environment
64+ # variables CC, FC, and CXX, are empty:
5965if [ -z " $CC " ]; then
6066 CC=gcc
6167fi
@@ -66,21 +72,40 @@ if [ -z "$CXX" ]; then
6672 CXX=g++
6773fi
6874
69- build ()
70- {
71- mkdir -p $src \- build &&
72- cd $src \- build &&
73- CC=$CC FC=$FC CXX=$CXX ../$src /configure --prefix=$2 &&
74- make -j $num_threads
75- }
75+ # Default to installing MPICH 3.1.4 if no version specified in the first
76+ # command-line argument
77+ if [[ $1 == ' default' ]]; then
78+ version=3.1.4
79+ else
80+ version=$1
81+ fi
82+ # Default to installing in the current directory if no path is provided
83+ # in the second command-line argument
84+ if [ -z $2 ]; then
85+ install_path=${PWD}
86+ else
87+ install_path=$2
88+ fi
7689
77- # Default to 2 threads if no specified thread count:
90+ # Default to building with 2 threads if no thread count is specified
91+ # in the third command-line argument
7892if [ -z $3 ]; then
7993 num_threads=2
8094else
8195 num_threads=$3
8296fi
8397
98+ src=mpich-$version
99+
100+ # Make the build directory, configure, and build
101+ build ()
102+ {
103+ mkdir -p $src \- build &&
104+ cd $src \- build &&
105+ CC=$CC FC=$FC CXX=$CXX ../$src /configure --prefix=$install_path &&
106+ make -j $num_threads
107+ }
108+
84109if [ $# == 0 ]; then
85110 # Print usage information if script is invoked without arguments
86111 usage | less
@@ -90,7 +115,7 @@ elif [[ $1 == '--help' || $1 == '-h' ]]; then
90115elif [[ $1 == ' -v' || $1 == ' -V' || $1 == ' --version' ]]; then
91116 # Print script copyright if invoked with -v, -V, or --version argument
92117 echo " "
93- echo " GCC Build Script"
118+ echo " MPICH Build Script"
94119 echo " Copyright (C) 2015 Sourcery, Inc."
95120 echo " Copyright (C) 2015 Sourcery Institute"
96121 echo " "
@@ -100,23 +125,20 @@ elif [[ $1 == '-v' || $1 == '-V' || $1 == '--version' ]]; then
100125 echo " http://www.sourceryinstitute.org/license.html"
101126 echo " "
102127else
103- if [[ $1 == ' default' ]]; then
104- version=3.1.4
105- else
106- version=$1
107- fi
108- src=mpich-$version
109- # Build mpich
128+ # Download and build mpich
110129 time \
111130 {
112131 if ! type wget > /dev/null; then
113132 echo
114133 echo " $cmd requires 'wget'. Please install it. Aborting."
115134 exit 1;
116135 else
136+ # Download MPICH
117137 wget http://www.mpich.org/static/downloads/$version /$src .tar.gz &&
138+ # Unpack the downloaded tape archive
118139 tar xvzf $src .tar.gz &&
119- build $version $2 $num_threads
140+ # Compile MPICH source
141+ build $version $install_path $num_threads
120142 fi
121143 } >&1 | tee build.log
122144 echo " Check build.log for results. If the build was successful,"
0 commit comments