10
10
# Copyright (c) 2015, Sourcery Institute
11
11
# All rights reserved.
12
12
#
13
- # All rights reserved.
14
13
# Redistribution and use in source and binary forms, with or without modification,
15
14
# are permitted provided that the following conditions are met:
16
15
#
@@ -41,7 +40,7 @@ usage()
41
40
echo " $cmd - Bash script for building CMake from source"
42
41
echo " "
43
42
echo " Usage (optional arguments in square brackets): "
44
- echo " $cmd <version-number>"
43
+ echo " $cmd <version-number> [<installation-path> <number-of-threads>] "
45
44
echo " or $cmd [options] "
46
45
echo " "
47
46
echo " Options:"
@@ -52,6 +51,7 @@ usage()
52
51
echo " "
53
52
echo " $cmd default"
54
53
echo " $cmd 3.3"
54
+ echo " $cmd 3.3 /opt/cmake/3.3 4"
55
55
echo " $cmd -v"
56
56
echo " $cmd --help"
57
57
echo " "
@@ -61,18 +61,6 @@ usage()
61
61
exit 1
62
62
}
63
63
64
- # Default to compiling with the GNU compilers if the environment
65
- # variables CC, FC, and CXX, are empty:
66
- if [ -z " $CC " ]; then
67
- CC=gcc
68
- fi
69
- if [ -z " $FC " ]; then
70
- FC=gfortran
71
- fi
72
- if [ -z " $CXX " ]; then
73
- CXX=g++
74
- fi
75
-
76
64
# Default to installing CMake 3.3 if no version specified in the first
77
65
# command-line argument
78
66
if [[ $1 == ' default' ]]; then
81
69
version=$1
82
70
fi
83
71
72
+ # Default to installing in the present working directory if no install path is specified:
73
+ if [ -z $2 ]; then
74
+ install_path=${PWD}
75
+ else
76
+ install_path=$2
77
+ fi
78
+
79
+ # Default to 2 threads if no specified thread count:
80
+ if [ -z $3 ]; then
81
+ num_threads=2
82
+ else
83
+ num_threads=$3
84
+ fi
85
+
84
86
# Make the build directory, configure, and build
85
87
build ()
86
88
{
87
- ./cmake-$version .0-1.sh all
89
+ cd cmake-$version .0 &&
90
+ ./bootstrap --prefix=$install_path &&
91
+ make -j $num_threads
88
92
}
89
93
90
94
if [ $# == 0 ]; then
@@ -118,11 +122,14 @@ else
118
122
wget http://www.cmake.org/files/v$version /cmake-$version .0-1-src.tar.bz2 &&
119
123
# Unpack the downloaded tape archive
120
124
tar xvjf cmake-$version .0-1-src.tar.bz2 &&
125
+ tar xvjf cmake-$version .0.tar.bz2 &&
121
126
# Compile Cmake source
122
- build $version
127
+ build $version $install_path $num_threads
123
128
fi
124
129
} >&1 | tee build.log
125
130
echo " "
126
- echo " Check build.log for results."
131
+ 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')"
133
+ echo " to complete the installation."
127
134
echo " "
128
135
fi
0 commit comments