@@ -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
+ unamestr=` uname`
89
+ if [[ " $unamestr " == ' Darwin' ]]; then
90
+ if [ -f /usr/bin/gcc ]; then
91
+ CC=/usr/bin/gcc
92
+ else
93
+ echo " Missing /usr/bin/gcc, which must exist and be an Apple LLVM version."
94
+ exit 1
95
+ fi
96
+ if [ -f /usr/bin/g++ ]; then
97
+ CXX=/usr/bin/g++
98
+ else
99
+ echo " Missing /usr/bin/g++, which must exist and be an Apple LLVM version."
100
+ exit 1
101
+ fi
102
+ else
103
+ # If this is not OS X, default to the user-specified compiler.
104
+ # If there is no user-specified compiler, use whatever the
105
+ # GNU compilers are in the path.
106
+ if [ -z $CC ]; then
107
+ CC=gcc
108
+ fi
109
+ if [ -z $CXX ]; then
110
+ CXX=g++
111
+ fi
112
+ fi
113
+
114
+ # Verify that 'wget' is is in the path.
115
+ if ! type wget > /dev/null; then
116
+ echo
117
+ echo " $cmd requires 'wget'. Please ensure that it is installed and in your path. Aborting."
118
+ exit 1
119
+ fi
120
+ if ! type make > /dev/null; then
121
+ echo
122
+ echo " $cmd requires 'make'. Please ensure that it is installed and in your path. Aborting."
123
+ exit 1
124
+ fi
125
+ }
126
+
127
+ # Download CMake if the tar ball is not already in the present working directory
128
+ download ()
129
+ {
130
+ if [ ! -f " cmake-$version .tar.gz" ]; then
131
+ echo " Downloading cmake-$version .tar.gz"
132
+ major_minor=" ${version% .* } "
133
+ wget http://www.cmake.org/files/v$major_minor /cmake-$version .tar.gz
134
+ fi
135
+ }
136
+
137
+ # Unpack CMake if the unpacked tar ball is not in the present working directory
138
+ unpack ()
139
+ {
140
+ if [ ! -d " cmake-$version " ]; then
141
+ tar xvzf cmake-$version .tar.gz
142
+ fi
143
+ }
144
+
86
145
# Make the build directory, configure, and build
87
146
build ()
88
147
{
89
- cd cmake-$version .0 &&
90
- ./bootstrap --prefix=$install_path &&
148
+ cd cmake-$version &&
149
+ CC= $CC CXX= $CXX ./bootstrap --prefix=$install_path &&
91
150
make -j $num_threads
92
151
}
93
152
@@ -110,26 +169,17 @@ elif [[ $1 == '-v' || $1 == '-V' || $1 == '--version' ]]; then
110
169
echo " http://www.sourceryinstitute.org/license.html"
111
170
echo " "
112
171
else
113
- # Download and build CMake
172
+ # Download, unpack, and build CMake
114
173
time \
115
174
{
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
175
+ check_prerequisites &&
176
+ download &&
177
+ unpack &&
178
+ CC=$CC CXX=$CXX build $version $install_path $num_threads
129
179
} >&1 | tee build.log
130
180
echo " "
131
181
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')"
182
+ echo " 'cd cmake-$version && make install' (or 'cd cmake-$version && sudo make install')"
133
183
echo " to complete the installation."
134
184
echo " "
135
185
fi
0 commit comments