@@ -57,22 +57,52 @@ usage()
57
57
echo " "
58
58
echo " [exit 10]"
59
59
exit 10
60
+
61
+ # Private usage information
62
+ #
63
+ # The following arguments are intentionally not documented in the above public usage information because
64
+ # they are intended for use by ../install.sh only rather than for use interactively at the command line:
65
+ # Argument $2 Argument $3 Description
66
+ # --default install the default version for the corresponding package
67
+ # --default --query-path return the default installation location for the package
68
+ # --default --query-version return the default version for the package
69
+ # --default --query-url return the default download location for the package
70
+ #
71
+ # Example: ./build gcc --default --query-path
72
+ #
73
+ # With the exception of gcc, all uses of "--default" refer to the package version that would be downloaded
74
+ # if no version is specified, e.g., "./build mpich". By contrast, "./build gcc" downloads the latest
75
+ # pre-release, development branch (the "trunk"), whereas "./build gcc --default" downloads a released
76
+ # version of gcc.
77
+ #
78
+ # The following argument works only with gcc and is mutually exclusive with the above private arguments
79
+ # (it could be extended to work with any svn download):
80
+ # Argument $2 Description
81
+ # --avail list the development branches available for checkout
82
+ # -a same as --avail
83
+ #
84
+ # Example: ./build gcc --avail
60
85
}
61
86
62
87
# If the package name is recognized, then set the default version.
63
88
# Otherwise, list the allowable package names and default versions and then exit.
64
89
set_default_version ()
65
90
{
91
+ version_requested=$2
66
92
if [[ $package_to_build == " --list" || $package_to_build == " -l" ]]; then
67
93
printf " \n"
68
94
printf " The '$this_script ' script can build the following packages:\n"
95
+ elif [[ $package_to_build == " gcc" && $version_requested == " --default" ]]; then
96
+ gcc_version=" 5.3.0"
97
+ else
98
+ gcc_version=" trunk"
69
99
fi
70
100
# This is a bash 3 hack standing in for a bash 4 hash (bash 3 is the lowest common
71
101
# denominator because, for licensing reasons, OS X only has bash 3 by default.)
72
102
# See http://stackoverflow.com/questions/1494178/how-to-define-hash-tables-in-bash
73
103
package_version=(
74
104
" cmake:3.4.0"
75
- " gcc:gcc-5-branch "
105
+ " gcc:$gcc_version "
76
106
" mpich:3.1.4"
77
107
" wget:1.16.3"
78
108
" flex:2.6.0"
@@ -100,7 +130,7 @@ set_default_version()
100
130
elif [[ $package_to_build == " $KEY " ]]; then
101
131
# We recognize the package name so we set the default version:
102
132
verbosity=$1
103
- if [[ $verbosity != " quietly " ]]; then
133
+ if [[ $2 != " --default " ]]; then
104
134
printf " Using default version $VALUE \n"
105
135
fi
106
136
default_version=$VALUE
@@ -116,11 +146,16 @@ set_default_version()
116
146
117
147
check_prerequisites ()
118
148
{
149
+ if [[ $package_to_build == " gcc" && $version_requested == " --default" ]]; then
150
+ gcc_fetch=" ftp"
151
+ else
152
+ gcc_fetch=" svn"
153
+ fi
119
154
# This is a bash 3 hack standing in for a bash 4 hash (bash 3 is the lowest common
120
155
# denominator because, for licensing reasons, OS X only has bash 3 by default.)
121
156
# See http://stackoverflow.com/questions/1494178/how-to-define-hash-tables-in-bash
122
157
package_download_mechanism=(
123
- " gcc:svn "
158
+ " gcc:$gcc_fetch "
124
159
" wget:ftp"
125
160
" cmake:wget"
126
161
" mpich:wget"
@@ -166,9 +201,13 @@ set_url()
166
201
{
167
202
if [[ $package_to_build == ' cmake' ]]; then
168
203
major_minor=" ${version_to_build% .* } "
204
+ elif [[ " $package_to_build " == " gcc" && " $version_to_build " == " $default_version " ]]; then
205
+ gcc_url_head=" http://ftpmirror.gnu.org/gcc/gcc-5.3.0/"
206
+ else
207
+ gcc_url_head=" svn://gcc.gnu.org/svn/gcc/"
169
208
fi
170
209
package_url_head=(
171
- " gcc;svn://gcc.gnu.org/svn/gcc/ "
210
+ " gcc;$gcc_url_head "
172
211
" wget;ftp.gnu.org:/gnu/wget/"
173
212
" m4;ftp.gnu.org:/gnu/m4/"
174
213
" pkg-config;http://pkgconfig.freedesktop.org/releases/"
@@ -202,7 +241,7 @@ set_url()
202
241
elif [[ $version_to_build == ' --avail' || $version_to_build == ' -a' ]]; then
203
242
gcc_tail=' branches'
204
243
else
205
- gcc_tail=/branches/ $version_to_build
244
+ gcc_tail=" gcc- $version_to_build .tar.bz2 "
206
245
fi
207
246
fi
208
247
package_url_tail=(
@@ -299,6 +338,7 @@ download_if_necessary()
299
338
printf " Downloading $package_to_build $version_to_build to the following location:\n"
300
339
printf " $download_path /$package_source_directory \n"
301
340
printf " Download command: $fetch $args $url \n"
341
+ printf " Depending on the file size and network bandwidth, this could take several minutes or longer."
302
342
$fetch $args $url
303
343
if [[ $version_to_build == ' --avail' || $version_to_build == ' -a' ]]; then
304
344
# In this case, args="ls" and the list of available versions has been printed so we can move on.
@@ -390,11 +430,8 @@ package_to_build=$1
390
430
391
431
# Interpret the second command-line argument, if present, as the package version.
392
432
# Otherwise, set the default package version.
393
- if [[ -z $2 ]]; then
394
- set_default_version
395
- version_to_build=$default_version
396
- elif [[ $2 == " --default" ]]; then
397
- set_default_version " quietly"
433
+ if [[ -z $2 || $2 == " --default" ]]; then
434
+ set_default_version $*
398
435
version_to_build=$default_version
399
436
else
400
437
version_to_build=$2
@@ -446,7 +483,7 @@ elif [[ $1 == '-v' || $1 == '-V' || $1 == '--version' ]]; then
446
483
else
447
484
# Download, unpack, and build CMake
448
485
download_path=${PWD}
449
- check_prerequisites &&
486
+ check_prerequisites $* &&
450
487
download_if_necessary &&
451
488
unpack_if_necessary &&
452
489
CC=$CC CXX=$CXX build_and_install $package_to_build $version_to_build $install_path $num_threads $download_path \
0 commit comments