Skip to content

Commit 7a8b2f0

Browse files
author
Damian Rouson
committed
Updating script for building CMake so that it grabs the correct tar ball.
Signed-off-by: Damian Rouson <[email protected]>
1 parent 531554d commit 7a8b2f0

File tree

1 file changed

+41
-19
lines changed

1 file changed

+41
-19
lines changed

install_prerequisites/buildcmake

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ usage()
5050
echo " Example usage:"
5151
echo ""
5252
echo " $cmd default"
53-
echo " $cmd 3.3"
54-
echo " $cmd 3.3 /opt/cmake/3.3 4"
53+
echo " $cmd 3.3.2"
54+
echo " $cmd 3.3.2 /opt/cmake/3.3.2 4"
5555
echo " $cmd -v"
5656
echo " $cmd --help"
5757
echo ""
@@ -64,7 +64,7 @@ usage()
6464
# Default to installing CMake 3.3 if no version specified in the first
6565
# command-line argument
6666
if [[ $1 == 'default' ]]; then
67-
version=3.3
67+
version=3.3.2
6868
else
6969
version=$1
7070
fi
@@ -83,10 +83,41 @@ else
8383
num_threads=$3
8484
fi
8585

86+
check_prerequisites()
87+
{
88+
if ! type wget > /dev/null; then
89+
echo
90+
echo "$cmd requires 'wget'. Please install it. Aborting."
91+
exit 1;
92+
elif ! type make > /dev/null; then
93+
echo
94+
echo "$cmd requires 'make'. Please install it. Aborting."
95+
exit 1;
96+
fi
97+
}
98+
99+
# Download CMake if the tar ball is not already in the present working directory
100+
download()
101+
{
102+
if [ ! -f "cmake-$version.tar.gz" ]; then
103+
echo "Downloading cmake-$version.tar.gz"
104+
major_minor="${version%.*}"
105+
wget http://www.cmake.org/files/v$major_minor/cmake-$version.tar.gz
106+
fi
107+
}
108+
109+
# Unpack CMake if the unpacked tar ball is not in the present working directory
110+
unpack()
111+
{
112+
if [ ! -d "cmake-$version" ]; then
113+
tar xvzf cmake-$version.tar.gz
114+
fi
115+
}
116+
86117
# Make the build directory, configure, and build
87118
build()
88119
{
89-
cd cmake-$version.0 &&
120+
cd cmake-$version &&
90121
./bootstrap --prefix=$install_path &&
91122
make -j $num_threads
92123
}
@@ -110,26 +141,17 @@ elif [[ $1 == '-v' || $1 == '-V' || $1 == '--version' ]]; then
110141
echo "http://www.sourceryinstitute.org/license.html"
111142
echo ""
112143
else
113-
# Download and build CMake
144+
# Download, unpack, and build CMake
114145
time \
115146
{
116-
if ! type wget > /dev/null; then
117-
echo
118-
echo "$cmd requires 'wget'. Please install it. Aborting."
119-
exit 1;
120-
else
121-
# Download CMake
122-
wget http://www.cmake.org/files/v$version/cmake-$version.0-1-src.tar.bz2 &&
123-
# Unpack the downloaded tape archive
124-
tar xvjf cmake-$version.0-1-src.tar.bz2 &&
125-
tar xvjf cmake-$version.0.tar.bz2 &&
126-
# Compile Cmake source
127-
build $version $install_path $num_threads
128-
fi
147+
check_prerequisites &&
148+
download &&
149+
unpack &&
150+
build $version $install_path $num_threads
129151
} >&1 | tee build.log
130152
echo ""
131153
echo "Check build.log for results. If the build was successful, type"
132-
echo "'cd cmake-$version.0 && make install' (or 'cd cmake-$version.0 && sudo make install')"
154+
echo "'cd cmake-$version && make install' (or 'cd cmake-$version && sudo make install')"
133155
echo "to complete the installation."
134156
echo ""
135157
fi

0 commit comments

Comments
 (0)