2 #! -*- coding:utf-8; mode:shell-script; -*-
4 # Download some prerequisites needed by GCC.
5 # Run this from the top level of the GCC source tree and the GCC build will do
6 # the right thing. Run it with the `--help` option for more information.
8 # (C) 2010-2016 Free Software Foundation
10 # This program is free software: you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation, either version 3 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 # General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program. If not, see http://www.gnu.org/licenses/.
24 program
='download_prerequisites'
25 version
='(unversioned)'
27 # MAINTAINERS: If you update the package versions below, please
28 # remember to also update the files `contrib/prerequisites.sha512` and
29 # `contrib/prerequisites.md5` with the new checksums.
31 gmp
='gmp-6.1.0.tar.bz2'
32 mpfr
='mpfr-3.1.4.tar.bz2'
33 mpc
='mpc-1.0.3.tar.gz'
34 isl
='isl-0.16.1.tar.bz2'
36 base_url
='ftp://gcc.gnu.org/pub/gcc/infrastructure/'
42 if [ ${graphite} -gt 0 ]; then echo "${isl}"; fi
51 helptext
="usage: ${program} [OPTION...]
53 Downloads some prerequisites needed by GCC. Run this from the top level of the
54 GCC source tree and the GCC build will do the right thing.
56 The following options are available:
58 --directory=DIR download and unpack packages into DIR instead of '.'
59 --force download again overwriting existing packages
60 --no-force do not download existing packages again (default)
61 --isl download ISL, needed for Graphite loop optimizations (default)
62 --graphite same as --isl
63 --no-isl don't download ISL
64 --no-graphite same as --no-isl
65 --verify verify package integrity after download (default)
66 --no-verify don't verify package integrity
67 --sha512 use SHA512 checksum to verify package integrity (default)
68 --md5 use MD5 checksum to verify package integrity
69 --help show this text and exit
70 --version show version information and exit
73 versiontext
="${program} ${version}
74 Copyright (C) 2016 Free Software Foundation, Inc.
75 This is free software; see the source for copying conditions. There is NO
76 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
101 if [ "x${argnext}" = x
]
108 directory
="${arg#--directory=}"
119 --no-isl|
--no-graphite)
137 die
"unknown option: ${arg}"
140 die
"too many arguments"
146 die
"Missing argument for option --${argnext}"
154 die
"The impossible has happened"
160 [ "x${argnext}" = x
] || die
"Missing argument for option --${argnext}"
163 [ -e .
/gcc
/BASE-VER
] \
164 || die
"You must run this script in the top-level GCC source directory"
166 [ -d "${directory}" ] \
167 || die
"No such directory: ${directory}"
169 for ar in $
(echo_archives
)
171 if [ ${force} -gt 0 ]; then rm -f "${directory}/${ar}"; fi
172 [ -e "${directory}/${ar}" ] \
173 || wget --no-verbose -O "${directory}/${ar}" "${base_url}${ar}" \
174 || die "Cannot download
${ar} from
${base_url}"
178 if [ ${verify} -gt 0 ]
180 chksumfile="contrib
/prerequisites.
${chksum}"
181 [ -r "${chksumfile}" ] || die "No checksums available
"
182 for ar in $(echo_archives)
184 grep "${ar}" "${chksumfile}" \
185 | ( cd "${directory}" && "${chksum}sum" --check ) \
186 || die "Cannot verify integrity of possibly corrupted
file ${ar}"
192 for ar in $(echo_archives)
194 package="${ar%.tar*}"
195 if [ ${force} -gt 0 ]; then rm -rf "${directory}/${package}"; fi
196 [ -e "${directory}/${package}" ] \
197 ||
( cd "${directory}" && tar -xf "${ar}" ) \
198 || die
"Cannot extract package from ${ar}"
203 for ar in $
(echo_archives
)
205 target
="${directory}/${ar%.tar*}/"
207 if [ ${force} -gt 0 ]; then rm -f "${linkname}"; fi
208 [ -e "${linkname}" ] \
209 ||
ln -s "${target}" "${linkname}" \
210 || die
"Cannot create symbolic link ${linkname} --> ${target}"
211 unset target linkname
215 echo "All prerequisites downloaded successfully."