@@ -50,8 +50,8 @@ usage()
50
50
echo " Example usage:"
51
51
echo " "
52
52
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"
55
55
echo " $cmd -v"
56
56
echo " $cmd --help"
57
57
echo " "
@@ -64,7 +64,7 @@ usage()
64
64
# Default to installing CMake 3.3 if no version specified in the first
65
65
# command-line argument
66
66
if [[ $1 == ' default' ]]; then
67
- version=3.3
67
+ version=3.3.2
68
68
else
69
69
version=$1
70
70
fi
83
83
num_threads=$3
84
84
fi
85
85
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
+
86
117
# Make the build directory, configure, and build
87
118
build ()
88
119
{
89
- cd cmake-$version .0 &&
120
+ cd cmake-$version &&
90
121
./bootstrap --prefix=$install_path &&
91
122
make -j $num_threads
92
123
}
@@ -110,26 +141,17 @@ elif [[ $1 == '-v' || $1 == '-V' || $1 == '--version' ]]; then
110
141
echo " http://www.sourceryinstitute.org/license.html"
111
142
echo " "
112
143
else
113
- # Download and build CMake
144
+ # Download, unpack, and build CMake
114
145
time \
115
146
{
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
129
151
} >&1 | tee build.log
130
152
echo " "
131
153
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')"
133
155
echo " to complete the installation."
134
156
echo " "
135
157
fi
0 commit comments