annotate contrib/download_prerequisites @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #! /bin/sh
111
kono
parents: 68
diff changeset
2 #! -*- coding:utf-8; mode:shell-script; -*-
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3
111
kono
parents: 68
diff changeset
4 # Download some prerequisites needed by GCC.
kono
parents: 68
diff changeset
5 # Run this from the top level of the GCC source tree and the GCC build will do
kono
parents: 68
diff changeset
6 # the right thing. Run it with the `--help` option for more information.
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 #
111
kono
parents: 68
diff changeset
8 # (C) 2010-2016 Free Software Foundation
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 #
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 # This program is free software: you can redistribute it and/or modify
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 # it under the terms of the GNU General Public License as published by
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 # the Free Software Foundation, either version 3 of the License, or
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 # (at your option) any later version.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 #
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 # This program is distributed in the hope that it will be useful, but
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 # General Public License for more details.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 #
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 # You should have received a copy of the GNU General Public License
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 # along with this program. If not, see http://www.gnu.org/licenses/.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22
111
kono
parents: 68
diff changeset
23 program='download_prerequisites'
kono
parents: 68
diff changeset
24 version='(unversioned)'
kono
parents: 68
diff changeset
25
kono
parents: 68
diff changeset
26 # MAINTAINERS: If you update the package versions below, please
kono
parents: 68
diff changeset
27 # remember to also update the files `contrib/prerequisites.sha512` and
kono
parents: 68
diff changeset
28 # `contrib/prerequisites.md5` with the new checksums.
kono
parents: 68
diff changeset
29
kono
parents: 68
diff changeset
30 gmp='gmp-6.1.0.tar.bz2'
kono
parents: 68
diff changeset
31 mpfr='mpfr-3.1.4.tar.bz2'
kono
parents: 68
diff changeset
32 mpc='mpc-1.0.3.tar.gz'
kono
parents: 68
diff changeset
33 isl='isl-0.18.tar.bz2'
kono
parents: 68
diff changeset
34
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
35 base_url='http://gcc.gnu.org/pub/gcc/infrastructure/'
111
kono
parents: 68
diff changeset
36
kono
parents: 68
diff changeset
37 echo_archives() {
kono
parents: 68
diff changeset
38 echo "${gmp}"
kono
parents: 68
diff changeset
39 echo "${mpfr}"
kono
parents: 68
diff changeset
40 echo "${mpc}"
kono
parents: 68
diff changeset
41 if [ ${graphite} -gt 0 ]; then echo "${isl}"; fi
kono
parents: 68
diff changeset
42 }
kono
parents: 68
diff changeset
43
kono
parents: 68
diff changeset
44 graphite=1
kono
parents: 68
diff changeset
45 verify=1
kono
parents: 68
diff changeset
46 force=0
kono
parents: 68
diff changeset
47 OS=$(uname)
kono
parents: 68
diff changeset
48
kono
parents: 68
diff changeset
49 case $OS in
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
50 "Darwin"|"FreeBSD"|"DragonFly")
111
kono
parents: 68
diff changeset
51 chksum='shasum -a 512 --check'
kono
parents: 68
diff changeset
52 ;;
kono
parents: 68
diff changeset
53 *)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
54 chksum='sha512sum -c'
111
kono
parents: 68
diff changeset
55 ;;
kono
parents: 68
diff changeset
56 esac
kono
parents: 68
diff changeset
57
kono
parents: 68
diff changeset
58 if type wget > /dev/null ; then
kono
parents: 68
diff changeset
59 fetch='wget'
kono
parents: 68
diff changeset
60 else
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
61 fetch='curl -LO'
111
kono
parents: 68
diff changeset
62 fi
kono
parents: 68
diff changeset
63 chksum_extension='sha512'
kono
parents: 68
diff changeset
64 directory='.'
kono
parents: 68
diff changeset
65
kono
parents: 68
diff changeset
66 helptext="usage: ${program} [OPTION...]
kono
parents: 68
diff changeset
67
kono
parents: 68
diff changeset
68 Downloads some prerequisites needed by GCC. Run this from the top level of the
kono
parents: 68
diff changeset
69 GCC source tree and the GCC build will do the right thing.
kono
parents: 68
diff changeset
70
kono
parents: 68
diff changeset
71 The following options are available:
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72
111
kono
parents: 68
diff changeset
73 --directory=DIR download and unpack packages into DIR instead of '.'
kono
parents: 68
diff changeset
74 --force download again overwriting existing packages
kono
parents: 68
diff changeset
75 --no-force do not download existing packages again (default)
kono
parents: 68
diff changeset
76 --isl download ISL, needed for Graphite loop optimizations (default)
kono
parents: 68
diff changeset
77 --graphite same as --isl
kono
parents: 68
diff changeset
78 --no-isl don't download ISL
kono
parents: 68
diff changeset
79 --no-graphite same as --no-isl
kono
parents: 68
diff changeset
80 --verify verify package integrity after download (default)
kono
parents: 68
diff changeset
81 --no-verify don't verify package integrity
kono
parents: 68
diff changeset
82 --sha512 use SHA512 checksum to verify package integrity (default)
kono
parents: 68
diff changeset
83 --md5 use MD5 checksum to verify package integrity
kono
parents: 68
diff changeset
84 --help show this text and exit
kono
parents: 68
diff changeset
85 --version show version information and exit
kono
parents: 68
diff changeset
86 "
kono
parents: 68
diff changeset
87
kono
parents: 68
diff changeset
88 versiontext="${program} ${version}
kono
parents: 68
diff changeset
89 Copyright (C) 2016 Free Software Foundation, Inc.
kono
parents: 68
diff changeset
90 This is free software; see the source for copying conditions. There is NO
kono
parents: 68
diff changeset
91 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
kono
parents: 68
diff changeset
92
kono
parents: 68
diff changeset
93 die() {
kono
parents: 68
diff changeset
94 echo "error: $@" >&2
kono
parents: 68
diff changeset
95 exit 1
kono
parents: 68
diff changeset
96 }
kono
parents: 68
diff changeset
97
kono
parents: 68
diff changeset
98 for arg in "$@"
kono
parents: 68
diff changeset
99 do
kono
parents: 68
diff changeset
100 case "${arg}" in
kono
parents: 68
diff changeset
101 --help)
kono
parents: 68
diff changeset
102 echo "${helptext}"
kono
parents: 68
diff changeset
103 exit
kono
parents: 68
diff changeset
104 ;;
kono
parents: 68
diff changeset
105 --version)
kono
parents: 68
diff changeset
106 echo "${versiontext}"
kono
parents: 68
diff changeset
107 exit
kono
parents: 68
diff changeset
108 ;;
kono
parents: 68
diff changeset
109 esac
kono
parents: 68
diff changeset
110 done
kono
parents: 68
diff changeset
111 unset arg
kono
parents: 68
diff changeset
112
kono
parents: 68
diff changeset
113 # Emulate Linux's 'md5 --check' on macOS
kono
parents: 68
diff changeset
114 md5_check() {
kono
parents: 68
diff changeset
115 # Store the standard input: a line from contrib/prerequisites.md5:
kono
parents: 68
diff changeset
116 md5_checksum_line=$(cat -)
kono
parents: 68
diff changeset
117 # Grab the text before the first space
kono
parents: 68
diff changeset
118 md5_checksum_expected="${md5_checksum_line%% *}"
kono
parents: 68
diff changeset
119 # Grab the text after the first space
kono
parents: 68
diff changeset
120 file_to_check="${md5_checksum_line##* }"
kono
parents: 68
diff changeset
121 # Calculate the md5 checksum for the downloaded file
kono
parents: 68
diff changeset
122 md5_checksum_output=$(md5 -r "${file_to_check}")
kono
parents: 68
diff changeset
123 # Grab the text before the first space
kono
parents: 68
diff changeset
124 md5_checksum_detected="${md5_checksum_output%% *}"
kono
parents: 68
diff changeset
125 [ "${md5_checksum_expected}" == "${md5_checksum_detected}" ] \
kono
parents: 68
diff changeset
126 || die "Cannot verify integrity of possibly corrupted file ${file_to_check}"
kono
parents: 68
diff changeset
127 echo "${file_to_check}: OK"
kono
parents: 68
diff changeset
128 }
kono
parents: 68
diff changeset
129
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
130
111
kono
parents: 68
diff changeset
131 argnext=
kono
parents: 68
diff changeset
132 for arg in "$@"
kono
parents: 68
diff changeset
133 do
kono
parents: 68
diff changeset
134 if [ "x${argnext}" = x ]
kono
parents: 68
diff changeset
135 then
kono
parents: 68
diff changeset
136 case "${arg}" in
kono
parents: 68
diff changeset
137 --directory)
kono
parents: 68
diff changeset
138 argnext='directory'
kono
parents: 68
diff changeset
139 ;;
kono
parents: 68
diff changeset
140 --directory=*)
kono
parents: 68
diff changeset
141 directory="${arg#--directory=}"
kono
parents: 68
diff changeset
142 ;;
kono
parents: 68
diff changeset
143 --force)
kono
parents: 68
diff changeset
144 force=1
kono
parents: 68
diff changeset
145 ;;
kono
parents: 68
diff changeset
146 --no-force)
kono
parents: 68
diff changeset
147 force=0
kono
parents: 68
diff changeset
148 ;;
kono
parents: 68
diff changeset
149 --isl|--graphite)
kono
parents: 68
diff changeset
150 graphite=1
kono
parents: 68
diff changeset
151 ;;
kono
parents: 68
diff changeset
152 --no-isl|--no-graphite)
kono
parents: 68
diff changeset
153 graphite=0
kono
parents: 68
diff changeset
154 ;;
kono
parents: 68
diff changeset
155 --verify)
kono
parents: 68
diff changeset
156 verify=1
kono
parents: 68
diff changeset
157 ;;
kono
parents: 68
diff changeset
158 --no-verify)
kono
parents: 68
diff changeset
159 verify=0
kono
parents: 68
diff changeset
160 ;;
kono
parents: 68
diff changeset
161 --sha512)
kono
parents: 68
diff changeset
162 case $OS in
kono
parents: 68
diff changeset
163 "Darwin")
kono
parents: 68
diff changeset
164 chksum='shasum -a 512 --check'
kono
parents: 68
diff changeset
165 ;;
kono
parents: 68
diff changeset
166 *)
kono
parents: 68
diff changeset
167 chksum='sha512sum --check'
kono
parents: 68
diff changeset
168 ;;
kono
parents: 68
diff changeset
169 esac
kono
parents: 68
diff changeset
170 chksum_extension='sha512'
kono
parents: 68
diff changeset
171 verify=1
kono
parents: 68
diff changeset
172 ;;
kono
parents: 68
diff changeset
173 --md5)
kono
parents: 68
diff changeset
174 case $OS in
kono
parents: 68
diff changeset
175 "Darwin")
kono
parents: 68
diff changeset
176 chksum='md5_check'
kono
parents: 68
diff changeset
177 ;;
kono
parents: 68
diff changeset
178 *)
kono
parents: 68
diff changeset
179 chksum='md5 --check'
kono
parents: 68
diff changeset
180 ;;
kono
parents: 68
diff changeset
181 esac
kono
parents: 68
diff changeset
182 chksum_extension='md5'
kono
parents: 68
diff changeset
183 verify=1
kono
parents: 68
diff changeset
184 ;;
kono
parents: 68
diff changeset
185 -*)
kono
parents: 68
diff changeset
186 die "unknown option: ${arg}"
kono
parents: 68
diff changeset
187 ;;
kono
parents: 68
diff changeset
188 *)
kono
parents: 68
diff changeset
189 die "too many arguments"
kono
parents: 68
diff changeset
190 ;;
kono
parents: 68
diff changeset
191 esac
kono
parents: 68
diff changeset
192 else
kono
parents: 68
diff changeset
193 case "${arg}" in
kono
parents: 68
diff changeset
194 -*)
kono
parents: 68
diff changeset
195 die "Missing argument for option --${argnext}"
kono
parents: 68
diff changeset
196 ;;
kono
parents: 68
diff changeset
197 esac
kono
parents: 68
diff changeset
198 case "${argnext}" in
kono
parents: 68
diff changeset
199 directory)
kono
parents: 68
diff changeset
200 directory="${arg}"
kono
parents: 68
diff changeset
201 ;;
kono
parents: 68
diff changeset
202 *)
kono
parents: 68
diff changeset
203 die "The impossible has happened"
kono
parents: 68
diff changeset
204 ;;
kono
parents: 68
diff changeset
205 esac
kono
parents: 68
diff changeset
206 argnext=
kono
parents: 68
diff changeset
207 fi
kono
parents: 68
diff changeset
208 done
kono
parents: 68
diff changeset
209 [ "x${argnext}" = x ] || die "Missing argument for option --${argnext}"
kono
parents: 68
diff changeset
210 unset arg argnext
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
211
111
kono
parents: 68
diff changeset
212 [ -e ./gcc/BASE-VER ] \
kono
parents: 68
diff changeset
213 || die "You must run this script in the top-level GCC source directory"
kono
parents: 68
diff changeset
214
kono
parents: 68
diff changeset
215 [ -d "${directory}" ] \
kono
parents: 68
diff changeset
216 || die "No such directory: ${directory}"
kono
parents: 68
diff changeset
217
kono
parents: 68
diff changeset
218 for ar in $(echo_archives)
kono
parents: 68
diff changeset
219 do
kono
parents: 68
diff changeset
220 if [ ${force} -gt 0 ]; then rm -f "${directory}/${ar}"; fi
kono
parents: 68
diff changeset
221 [ -e "${directory}/${ar}" ] \
kono
parents: 68
diff changeset
222 || ${fetch} --no-verbose -O "${directory}/${ar}" "${base_url}${ar}" \
kono
parents: 68
diff changeset
223 || die "Cannot download ${ar} from ${base_url}"
kono
parents: 68
diff changeset
224 done
kono
parents: 68
diff changeset
225 unset ar
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
226
111
kono
parents: 68
diff changeset
227 if [ ${verify} -gt 0 ]
kono
parents: 68
diff changeset
228 then
kono
parents: 68
diff changeset
229 chksumfile="contrib/prerequisites.${chksum_extension}"
kono
parents: 68
diff changeset
230 [ -r "${chksumfile}" ] || die "No checksums available"
kono
parents: 68
diff changeset
231 for ar in $(echo_archives)
kono
parents: 68
diff changeset
232 do
kono
parents: 68
diff changeset
233 grep "${ar}" "${chksumfile}" \
kono
parents: 68
diff changeset
234 | ( cd "${directory}" && ${chksum} ) \
kono
parents: 68
diff changeset
235 || die "Cannot verify integrity of possibly corrupted file ${ar}"
kono
parents: 68
diff changeset
236 done
kono
parents: 68
diff changeset
237 unset chksumfile
kono
parents: 68
diff changeset
238 fi
kono
parents: 68
diff changeset
239 unset ar
kono
parents: 68
diff changeset
240
kono
parents: 68
diff changeset
241 for ar in $(echo_archives)
kono
parents: 68
diff changeset
242 do
kono
parents: 68
diff changeset
243 package="${ar%.tar*}"
kono
parents: 68
diff changeset
244 if [ ${force} -gt 0 ]; then rm -rf "${directory}/${package}"; fi
kono
parents: 68
diff changeset
245 [ -e "${directory}/${package}" ] \
kono
parents: 68
diff changeset
246 || ( cd "${directory}" && tar -xf "${ar}" ) \
kono
parents: 68
diff changeset
247 || die "Cannot extract package from ${ar}"
kono
parents: 68
diff changeset
248 unset package
kono
parents: 68
diff changeset
249 done
kono
parents: 68
diff changeset
250 unset ar
kono
parents: 68
diff changeset
251
kono
parents: 68
diff changeset
252 for ar in $(echo_archives)
kono
parents: 68
diff changeset
253 do
kono
parents: 68
diff changeset
254 target="${directory}/${ar%.tar*}/"
kono
parents: 68
diff changeset
255 linkname="${ar%-*}"
kono
parents: 68
diff changeset
256 if [ ${force} -gt 0 ]; then rm -f "${linkname}"; fi
kono
parents: 68
diff changeset
257 [ -e "${linkname}" ] \
kono
parents: 68
diff changeset
258 || ln -s "${target}" "${linkname}" \
kono
parents: 68
diff changeset
259 || die "Cannot create symbolic link ${linkname} --> ${target}"
kono
parents: 68
diff changeset
260 unset target linkname
kono
parents: 68
diff changeset
261 done
kono
parents: 68
diff changeset
262 unset ar
kono
parents: 68
diff changeset
263
kono
parents: 68
diff changeset
264 echo "All prerequisites downloaded successfully."