@@ -57,22 +57,52 @@ usage()
5757 echo " "
5858 echo " [exit 10]"
5959 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
6085}
6186
6287# If the package name is recognized, then set the default version.
6388# Otherwise, list the allowable package names and default versions and then exit.
6489set_default_version ()
6590{
91+ version_requested=$2
6692 if [[ $package_to_build == " --list" || $package_to_build == " -l" ]]; then
6793 printf " \n"
6894 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"
6999 fi
70100 # This is a bash 3 hack standing in for a bash 4 hash (bash 3 is the lowest common
71101 # denominator because, for licensing reasons, OS X only has bash 3 by default.)
72102 # See http://stackoverflow.com/questions/1494178/how-to-define-hash-tables-in-bash
73103 package_version=(
74104 " cmake:3.4.0"
75- " gcc:gcc-5-branch "
105+ " gcc:$gcc_version "
76106 " mpich:3.1.4"
77107 " wget:1.16.3"
78108 " flex:2.6.0"
@@ -100,7 +130,7 @@ set_default_version()
100130 elif [[ $package_to_build == " $KEY " ]]; then
101131 # We recognize the package name so we set the default version:
102132 verbosity=$1
103- if [[ $verbosity != " quietly " ]]; then
133+ if [[ $2 != " --default " ]]; then
104134 printf " Using default version $VALUE \n"
105135 fi
106136 default_version=$VALUE
@@ -116,11 +146,16 @@ set_default_version()
116146
117147check_prerequisites ()
118148{
149+ if [[ $package_to_build == " gcc" && $version_requested == " --default" ]]; then
150+ gcc_fetch=" ftp"
151+ else
152+ gcc_fetch=" svn"
153+ fi
119154 # This is a bash 3 hack standing in for a bash 4 hash (bash 3 is the lowest common
120155 # denominator because, for licensing reasons, OS X only has bash 3 by default.)
121156 # See http://stackoverflow.com/questions/1494178/how-to-define-hash-tables-in-bash
122157 package_download_mechanism=(
123- " gcc:svn "
158+ " gcc:$gcc_fetch "
124159 " wget:ftp"
125160 " cmake:wget"
126161 " mpich:wget"
@@ -166,9 +201,13 @@ set_url()
166201{
167202 if [[ $package_to_build == ' cmake' ]]; then
168203 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/"
169208 fi
170209 package_url_head=(
171- " gcc;svn://gcc.gnu.org/svn/gcc/ "
210+ " gcc;$gcc_url_head "
172211 " wget;ftp.gnu.org:/gnu/wget/"
173212 " m4;ftp.gnu.org:/gnu/m4/"
174213 " pkg-config;http://pkgconfig.freedesktop.org/releases/"
@@ -202,7 +241,7 @@ set_url()
202241 elif [[ $version_to_build == ' --avail' || $version_to_build == ' -a' ]]; then
203242 gcc_tail=' branches'
204243 else
205- gcc_tail=/branches/ $version_to_build
244+ gcc_tail=" gcc- $version_to_build .tar.bz2 "
206245 fi
207246 fi
208247 package_url_tail=(
@@ -299,6 +338,7 @@ download_if_necessary()
299338 printf " Downloading $package_to_build $version_to_build to the following location:\n"
300339 printf " $download_path /$package_source_directory \n"
301340 printf " Download command: $fetch $args $url \n"
341+ printf " Depending on the file size and network bandwidth, this could take several minutes or longer."
302342 $fetch $args $url
303343 if [[ $version_to_build == ' --avail' || $version_to_build == ' -a' ]]; then
304344 # 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
390430
391431# Interpret the second command-line argument, if present, as the package version.
392432# 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 $*
398435 version_to_build=$default_version
399436else
400437 version_to_build=$2
@@ -446,7 +483,7 @@ elif [[ $1 == '-v' || $1 == '-V' || $1 == '--version' ]]; then
446483else
447484 # Download, unpack, and build CMake
448485 download_path=${PWD}
449- check_prerequisites &&
486+ check_prerequisites $* &&
450487 download_if_necessary &&
451488 unpack_if_necessary &&
452489 CC=$CC CXX=$CXX build_and_install $package_to_build $version_to_build $install_path $num_threads $download_path \
0 commit comments