Skip to content

Commit d94ff75

Browse files
author
Damian Rouson
committed
Adding first draft of buildwget and buildflex (buildflex works on Linux but not yet on OS X). Refactored other build scripts.
1 parent c5a166e commit d94ff75

File tree

4 files changed

+414
-21
lines changed

4 files changed

+414
-21
lines changed

install_prerequisites/buildcmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ check_prerequisites()
111111
fi
112112
fi
113113

114-
# Verify that 'wget' is is in the path.
114+
# Verify that 'wget' is in the path.
115115
if ! type wget > /dev/null; then
116116
echo
117117
echo "$cmd requires 'wget'. Please ensure that it is installed and in your path. Aborting."

install_prerequisites/buildflex

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
#!/bin/bash
2+
#
3+
# buildflex
4+
#
5+
# -- This script downloads and installs the flex lexical analyzer
6+
# (http://www.flex.org).
7+
#
8+
# OpenCoarrays is distributed under the OSI-approved BSD 3-clause License:
9+
# Copyright (c) 2015, Sourcery, Inc.
10+
# Copyright (c) 2015, Sourcery Institute
11+
# All rights reserved.
12+
#
13+
# Redistribution and use in source and binary forms, with or without modification,
14+
# are permitted provided that the following conditions are met:
15+
#
16+
# 1. Redistributions of source code must retain the above copyright notice, this
17+
# list of conditions and the following disclaimer.
18+
# 2. Redistributions in binary form must reproduce the above copyright notice, this
19+
# list of conditions and the following disclaimer in the documentation and/or
20+
# other materials provided with the distribution.
21+
# 3. Neither the names of the copyright holders nor the names of their contributors
22+
# may be used to endorse or promote products derived from this software without
23+
# specific prior written permission.
24+
#
25+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
26+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
28+
# IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
29+
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30+
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
32+
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34+
# POSSIBILITY OF SUCH DAMAGE.
35+
36+
cmd=`basename $0`
37+
usage()
38+
{
39+
echo ""
40+
echo " $cmd - Bash script for building flex from source"
41+
echo ""
42+
echo " Usage (optional arguments in square brackets): "
43+
echo " $cmd <version-number> [<installation-path> <number-of-threads>]"
44+
echo " or $cmd [options] "
45+
echo ""
46+
echo " Options:"
47+
echo " --help, -h Show this help message"
48+
echo " --version, -v, -V Report version and copyright information"
49+
echo ""
50+
echo " Example usage:"
51+
echo ""
52+
echo " $cmd default"
53+
echo " $cmd 2.5.39"
54+
echo " $cmd 2.5.39 /opt/flex/2.5.39 4"
55+
echo " $cmd -v"
56+
echo " $cmd --help"
57+
echo ""
58+
echo " Note: For a list of available flex versions, visit"
59+
echo " http://www.flex.org/files/"
60+
echo ""
61+
exit 1
62+
}
63+
64+
# Default to installing flex if no version specified in the first
65+
# command-line argument
66+
if [[ $1 == 'default' ]]; then
67+
version=2.5.39
68+
else
69+
version=$1
70+
fi
71+
72+
build_path=${PWD}/flex-$version-build
73+
74+
# Default to installing in the present working directory if no install path is specified:
75+
if [ -z $2 ]; then
76+
install_path=$build_path
77+
else
78+
install_path=$2
79+
fi
80+
81+
# Default to 2 threads if no specified thread count:
82+
if [ -z $3 ]; then
83+
num_threads=1
84+
else
85+
num_threads=$3
86+
fi
87+
88+
check_prerequisites()
89+
{
90+
unamestr=`uname`
91+
if [[ "$unamestr" == 'Darwin' ]]; then
92+
if [ -f /usr/bin/gcc ]; then
93+
CC=/usr/bin/gcc
94+
else
95+
echo "Missing /usr/bin/gcc, which must exist and be an Apple LLVM version."
96+
exit 1
97+
fi
98+
if [ -f /usr/bin/g++ ]; then
99+
CXX=/usr/bin/g++
100+
else
101+
echo "Missing /usr/bin/g++, which must exist and be an Apple LLVM version."
102+
exit 1
103+
fi
104+
else
105+
# If this is not OS X, default to the user-specified compiler.
106+
# If there is no user-specified compiler, use whatever the
107+
# GNU compilers are in the path.
108+
if [ -z $CC ]; then
109+
CC=gcc
110+
fi
111+
if [ -z $CXX ]; then
112+
CXX=g++
113+
fi
114+
fi
115+
116+
# Verify that 'wget' is in the path.
117+
if ! type wget > /dev/null; then
118+
echo
119+
echo "$cmd requires 'wget'. Please ensure that it is installed and in your path. Aborting."
120+
exit 1
121+
fi
122+
if ! type make > /dev/null; then
123+
echo
124+
echo "$cmd requires 'make'. Please ensure that it is installed and in your path. Aborting."
125+
exit 1
126+
fi
127+
}
128+
129+
# Download flex if the tar ball is not already in the present working directory
130+
download()
131+
{
132+
echo "Download flex-$version (.*gz.xf ."
133+
if [ ! -f "flex-$version.tar.gz" ]; then
134+
echo "Downloading flex $version tar ball"
135+
wget http://sourceforge.net/projects/flex/files/flex-$version.tar.xz
136+
fi
137+
}
138+
139+
# Unpack flex if the unpacked tar ball is not in the present working directory
140+
unpack()
141+
{
142+
if [ ! -d "flex-$version" ]; then
143+
echo "Unpacking into flex-$version"
144+
tar xf flex-$version.tar.xz
145+
fi
146+
}
147+
148+
# Make the build directory, configure, and build
149+
build()
150+
{
151+
echo "Building flex $version"
152+
mkdir -p $build_path &&
153+
cd $build_path &&
154+
CC=$CC CXX=$CXX ../flex-$version/configure --prefix=$install_path &&
155+
make -j $num_threads
156+
}
157+
158+
if [ $# == 0 ]; then
159+
# Print usage information if script is invoked without arguments
160+
usage | less
161+
elif [[ $1 == '--help' || $1 == '-h' ]]; then
162+
# Print usage information if script is invoked with --help or -h argument
163+
usage | less
164+
elif [[ $1 == '-v' || $1 == '-V' || $1 == '--version' ]]; then
165+
# Print script copyright if invoked with -v, -V, or --version argument
166+
echo ""
167+
echo "flex Build Script"
168+
echo "Copyright (C) 2015 Sourcery, Inc."
169+
echo "Copyright (C) 2015 Sourcery Institute"
170+
echo ""
171+
echo "$cmd comes with NO WARRANTY, to the extent permitted by law."
172+
echo "You may redistribute copies of $cmd under the terms of the"
173+
echo "BSD 3-Clause License. For more information about these matters, see"
174+
echo "http://www.sourceryinstitute.org/license.html"
175+
echo ""
176+
else
177+
# Download, unpack, and build flex
178+
time \
179+
{
180+
check_prerequisites &&
181+
download &&
182+
unpack &&
183+
CC=$CC CXX=$CXX build $version $install_path $num_threads
184+
} >&1 | tee build.log
185+
echo ""
186+
echo "Check build.log for results. If the build was successful, type"
187+
echo "'cd $build_path && make install' (or 'cd $build_path && sudo make install')"
188+
echo "to complete the installation."
189+
echo ""
190+
fi

install_prerequisites/buildmpich

Lines changed: 47 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,17 @@
3232
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3333
# POSSIBILITY OF SUCH DAMAGE.
3434

35+
# Default to installing MPICH 3.1.4 if no version specified in the first
36+
# command-line argument
37+
if [[ $1 == 'default' ]]; then
38+
version=3.1.4
39+
else
40+
version=$1
41+
fi
42+
3543
cmd=`basename $0`
44+
src=mpich-$version
45+
3646
usage()
3747
{
3848
echo ""
@@ -59,6 +69,39 @@ usage()
5969
exit 1
6070
}
6171

72+
check_prerequisites()
73+
{
74+
# Verify that 'wget' is in the path.
75+
if ! type wget > /dev/null; then
76+
echo
77+
echo "$cmd requires 'wget'. Please ensure that it is installed and in your path. Aborting."
78+
exit 1
79+
fi
80+
# Verify that 'make' is in the path.
81+
if ! type make > /dev/null; then
82+
echo
83+
echo "$cmd requires 'make'. Please ensure that it is installed and in your path. Aborting."
84+
exit 1
85+
fi
86+
}
87+
88+
# Download wvet if the tar ball is not already in the present working directory
89+
download()
90+
{
91+
if [ ! -f "$src.tar.gz" ]; then
92+
echo "Downloading $src.tar.gz"
93+
wget http://www.mpich.org/static/downloads/$version/$src.tar.gz
94+
fi
95+
}
96+
97+
# Unpack CMake if the unpacked tar ball is not in the present working directory
98+
unpack()
99+
{
100+
if [ ! -d "$src" ]; then
101+
tar xvzf $src.tar.gz
102+
fi
103+
}
104+
62105
# Default to compiling with the GNU compilers if the environment
63106
# variables CC, FC, and CXX, are empty:
64107
if [ -z "$CC" ]; then
@@ -71,13 +114,6 @@ if [ -z "$CXX" ]; then
71114
CXX=g++
72115
fi
73116

74-
# Default to installing MPICH 3.1.4 if no version specified in the first
75-
# command-line argument
76-
if [[ $1 == 'default' ]]; then
77-
version=3.1.4
78-
else
79-
version=$1
80-
fi
81117
# Default to installing in the current directory if no path is provided
82118
# in the second command-line argument
83119
if [ -z $2 ]; then
@@ -94,7 +130,6 @@ else
94130
num_threads=$3
95131
fi
96132

97-
src=mpich-$version
98133

99134
# Make the build directory, configure, and build
100135
build()
@@ -124,21 +159,13 @@ elif [[ $1 == '-v' || $1 == '-V' || $1 == '--version' ]]; then
124159
echo "http://www.sourceryinstitute.org/license.html"
125160
echo ""
126161
else
127-
# Download and build mpich
162+
# Download and build MPICH
128163
time \
129164
{
130-
if ! type wget > /dev/null; then
131-
echo
132-
echo "$cmd requires 'wget'. Please install it. Aborting."
133-
exit 1;
134-
else
135-
# Download MPICH
136-
wget http://www.mpich.org/static/downloads/$version/$src.tar.gz &&
137-
# Unpack the downloaded tape archive
138-
tar xvzf $src.tar.gz &&
139-
# Compile MPICH source
165+
check_prerequisites &&
166+
download &&
167+
unpack&&
140168
build $version $install_path $num_threads
141-
fi
142169
} >&1 | tee build.log
143170
echo "Check build.log for results. If the build was successful, type"
144171
echo "'cd $src-build && make install' (or 'cd $src-build && sudo make install') "

0 commit comments

Comments
 (0)