Commit | Line | Data |
---|---|---|
2536ee9d WN |
1 | #!/usr/bin/env bash |
2 | # Copyright (C) 1990-2014 Free Software Foundation | |
3 | # | |
4 | # This file is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
6 | # the Free Software Foundation; either version 3 of the License, or | |
7 | # (at your option) any later version. | |
8 | # | |
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
13 | # | |
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | # | |
17 | ||
18 | # This script creates release packages for gdb, binutils, and other | |
19 | # packages which live in src. It used to be implemented as the src-release | |
20 | # Makefile and prior to that was part of the top level Makefile, but that | |
21 | # turned out to be very messy and hard to maintain. | |
22 | ||
23 | set -e | |
24 | ||
25 | BZIPPROG=bzip2 | |
26 | GZIPPROG=gzip | |
27 | XZPROG=xz | |
28 | MD5PROG=md5sum | |
29 | MAKE=make | |
30 | CC=gcc | |
31 | CXX=g++ | |
32 | ||
33 | # Default to avoid splitting info files by setting the threshold high. | |
34 | MAKEINFOFLAGS=--split-size=5000000 | |
35 | ||
36 | # | |
37 | # Support for building net releases | |
38 | ||
39 | # Files in devo used in any net release. | |
40 | DEVO_SUPPORT="README Makefile.in configure configure.ac \ | |
41 | config.guess config.sub config move-if-change \ | |
42 | COPYING COPYING.LIB install-sh config-ml.in symlink-tree \ | |
43 | mkinstalldirs ltmain.sh missing ylwrap \ | |
44 | libtool.m4 ltsugar.m4 ltversion.m4 ltoptions.m4 \ | |
890ba06f | 45 | Makefile.def Makefile.tpl src-release.sh config.rpath \ |
2536ee9d WN |
46 | ChangeLog MAINTAINERS README-maintainer-mode \ |
47 | lt~obsolete.m4 ltgcc.m4 depcomp mkdep compile \ | |
48 | COPYING3 COPYING3.LIB" | |
49 | ||
50 | # Files in devo/etc used in any net release. | |
51 | ETC_SUPPORT="Makefile.in configure configure.in standards.texi \ | |
52 | make-stds.texi standards.info* configure.texi configure.info* \ | |
53 | ChangeLog configbuild.* configdev.* fdl.texi texi2pod.pl gnu-oids.texi" | |
54 | ||
55 | # Get the version number of a given tool | |
56 | getver() | |
57 | { | |
58 | tool=$1 | |
59 | if grep 'AC_INIT.*BFD_VERSION' $tool/configure.ac >/dev/null 2>&1; then | |
60 | bfd/configure --version | sed -n -e '1s,.* ,,p' | |
61 | elif test -f $tool/common/create-version.sh; then | |
62 | $tool/common/create-version.sh $tool 'dummy-host' 'dummy-target' VER.tmp | |
b677098d | 63 | cat VER.tmp | grep 'version\[\]' | sed 's/.*"\([^"]*\)".*/\1/' | sed 's/-git$//' |
2536ee9d WN |
64 | rm -f VER.tmp |
65 | elif test -f $tool/version.in; then | |
66 | head -1 $tool/version.in | |
67 | else | |
68 | echo VERSION | |
69 | fi | |
70 | } | |
71 | ||
72 | # Setup build directory for building release tarball | |
73 | do_proto_toplev() | |
74 | { | |
75 | package=$1 | |
76 | ver=$2 | |
77 | tool=$3 | |
78 | support_files=$4 | |
79 | echo "==> Making $package-$ver/" | |
80 | # Take out texinfo from a few places. | |
81 | sed -e '/^all\.normal: /s/\all-texinfo //' \ | |
82 | -e '/^ install-texinfo /d' \ | |
83 | <Makefile.in >tmp | |
84 | mv -f tmp Makefile.in | |
817b7711 AM |
85 | # configure. --enable-gold is needed to ensure .c/.h from .y are |
86 | # built in the gold dir. The disables speed the build a little. | |
87 | enables= | |
88 | disables= | |
89 | for dir in binutils gas gdb gold gprof ld libdecnumber readline sim; do | |
90 | case " $tool $support_files " in | |
91 | *" $dir "*) enables="$enables --enable-$dir" ;; | |
92 | *) disables="$disables --disable-$dir" ;; | |
93 | esac | |
94 | done | |
95 | echo "==> configure --target=i386-pc-linux-gnu $disables $enables" | |
96 | ./configure --target=i386-pc-linux-gnu $disables $enables | |
2536ee9d WN |
97 | $MAKE configure-host configure-target \ |
98 | ALL_GCC="" ALL_GCC_C="" ALL_GCC_CXX="" \ | |
99 | CC_FOR_TARGET="$CC" CXX_FOR_TARGET="$CXX" | |
100 | # Make links, and run "make diststuff" or "make info" when needed. | |
101 | rm -rf proto-toplev | |
102 | mkdir proto-toplev | |
103 | dirs="$DEVO_SUPPORT $support_files $tool" | |
104 | for d in $dirs ; do | |
105 | if [ -d $d ]; then | |
106 | if [ ! -f $d/Makefile ] ; then | |
107 | true | |
108 | elif grep '^diststuff:' $d/Makefile >/dev/null ; then | |
109 | (cd $d ; $MAKE MAKEINFOFLAGS="$MAKEINFOFLAGS" diststuff) \ | |
110 | || exit 1 | |
111 | elif grep '^info:' $d/Makefile >/dev/null ; then | |
112 | (cd $d ; $MAKE MAKEINFOFLAGS="$MAKEINFOFLAGS" info) \ | |
113 | || exit 1 | |
114 | fi | |
115 | if [ -d $d/proto-$d.dir ]; then | |
116 | ln -s ../$d/proto-$d.dir proto-toplev/$d | |
117 | else | |
118 | ln -s ../$d proto-toplev/$d | |
119 | fi | |
120 | else | |
121 | if (echo x$d | grep / >/dev/null); then | |
122 | mkdir -p proto-toplev/`dirname $d` | |
123 | x=`dirname $d` | |
124 | ln -s ../`echo $x/ | sed -e 's,[^/]*/,../,g'`$d proto-toplev/$d | |
125 | else | |
126 | ln -s ../$d proto-toplev/$d | |
127 | fi | |
128 | fi | |
129 | done | |
130 | (cd etc; $MAKE MAKEINFOFLAGS="$MAKEINFOFLAGS" info) | |
131 | $MAKE distclean | |
132 | mkdir proto-toplev/etc | |
133 | (cd proto-toplev/etc; | |
134 | for i in $ETC_SUPPORT; do | |
135 | ln -s ../../etc/$i . | |
136 | done) | |
137 | # | |
138 | # Take out texinfo from configurable dirs | |
139 | rm proto-toplev/configure.ac | |
140 | sed -e '/^host_tools=/s/texinfo //' \ | |
141 | <configure.ac >proto-toplev/configure.ac | |
142 | # | |
143 | mkdir proto-toplev/texinfo | |
144 | ln -s ../../texinfo/texinfo.tex proto-toplev/texinfo/ | |
145 | if test -r texinfo/util/tex3patch ; then | |
146 | mkdir proto-toplev/texinfo/util && \ | |
147 | ln -s ../../../texinfo/util/tex3patch proto-toplev/texinfo/util | |
148 | else | |
149 | true | |
150 | fi | |
151 | chmod -R og=u . || chmod og=u `find . -print` | |
152 | # | |
153 | # Create .gmo files from .po files. | |
154 | for f in `find . -name '*.po' -type f -print`; do | |
155 | msgfmt -o `echo $f | sed -e 's/\.po$/.gmo/'` $f | |
156 | done | |
157 | # | |
158 | rm -f $package-$ver | |
159 | ln -s proto-toplev $package-$ver | |
160 | } | |
161 | ||
162 | CVS_NAMES='-name CVS -o -name .cvsignore' | |
163 | ||
164 | # Add an md5sum to the built tarball | |
165 | do_md5sum() | |
166 | { | |
167 | echo "==> Adding md5 checksum to top-level directory" | |
168 | (cd proto-toplev && find * -follow \( $CVS_NAMES \) -prune \ | |
169 | -o -type f -print \ | |
170 | | xargs $MD5PROG > ../md5.new) | |
171 | rm -f proto-toplev/md5.sum | |
172 | mv md5.new proto-toplev/md5.sum | |
173 | } | |
174 | ||
175 | # Build the release tarball | |
176 | do_tar() | |
177 | { | |
178 | package=$1 | |
179 | ver=$2 | |
180 | echo "==> Making $package-$ver.tar" | |
181 | rm -f $package-$ver.tar | |
182 | find $package-$ver -follow \( $CVS_NAMES \) -prune \ | |
183 | -o -type f -print \ | |
184 | | tar cTfh - $package-$ver.tar | |
185 | } | |
186 | ||
187 | # Compress the output with bzip2 | |
188 | do_bz2() | |
189 | { | |
190 | package=$1 | |
191 | ver=$2 | |
192 | echo "==> Bzipping $package-$ver.tar.bz2" | |
193 | rm -f $package-$ver.tar.bz2 | |
194 | $BZIPPROG -k -v -9 $package-$ver.tar | |
195 | } | |
196 | ||
197 | # Compress the output with gzip | |
198 | do_gz() | |
199 | { | |
200 | package=$1 | |
201 | ver=$2 | |
202 | echo "==> Gzipping $package-$ver.tar.gz" | |
203 | rm -f $package-$ver.tar.gz | |
204 | $GZIPPROG -k -v -9 $package-$ver.tar | |
205 | } | |
206 | ||
207 | # Compress the output with xz | |
208 | do_xz() | |
209 | { | |
210 | package=$1 | |
211 | ver=$2 | |
212 | echo "==> Xzipping $package-$ver.tar.xz" | |
213 | rm -f $package-$ver.tar.xz | |
214 | $XZPROG -k -v -9 $package-$ver.tar | |
215 | } | |
216 | ||
217 | # Compress the output with all selected compresion methods | |
218 | do_compress() | |
219 | { | |
220 | package=$1 | |
221 | ver=$2 | |
222 | compressors=$3 | |
223 | for comp in $compressors; do | |
224 | case $comp in | |
225 | bz2) | |
226 | do_bz2 $package $ver;; | |
227 | gz) | |
228 | do_gz $package $ver;; | |
229 | xz) | |
230 | do_xz $package $ver;; | |
231 | *) | |
232 | echo "Unknown compression method: $comp" && exit 1;; | |
233 | esac | |
234 | done | |
235 | } | |
236 | ||
237 | # Add djunpack.bat the tarball | |
238 | do_djunpack() | |
239 | { | |
240 | package=$1 | |
241 | ver=$2 | |
242 | echo "==> Adding updated djunpack.bat to top-level directory" | |
243 | echo - 's /gdb-[0-9\.]*/$package-'"$ver"'/' | |
244 | sed < djunpack.bat > djunpack.new \ | |
245 | -e 's/gdb-[0-9][0-9\.]*/$package-'"$ver"'/' | |
246 | rm -f proto-toplev/djunpack.bat | |
247 | mv djunpack.new proto-toplev/djunpack.bat | |
248 | } | |
249 | ||
250 | # Create a release package, tar it and compress it | |
251 | tar_compress() | |
252 | { | |
253 | package=$1 | |
254 | tool=$2 | |
255 | support_files=$3 | |
256 | compressors=$4 | |
ec5b9462 HPN |
257 | verdir=${5:-$tool} |
258 | ver=$(getver $verdir) | |
2536ee9d WN |
259 | do_proto_toplev $package $ver $tool "$support_files" |
260 | do_md5sum | |
261 | do_tar $package $ver | |
262 | do_compress $package $ver "$compressors" | |
263 | } | |
264 | ||
265 | # Create a gdb release package, tar it and compress it | |
266 | gdb_tar_compress() | |
267 | { | |
268 | package=$1 | |
269 | tool=$2 | |
270 | support_files=$3 | |
271 | compressors=$4 | |
272 | ver=$(getver $tool) | |
273 | do_proto_toplev $package $ver $tool "$support_files" | |
274 | do_md5sum | |
275 | do_djunpack $package $ver | |
276 | do_tar $package $ver | |
277 | do_compress $package $ver "$compressors" | |
278 | } | |
279 | ||
280 | # The FSF "binutils" release includes gprof and ld. | |
92c695a1 | 281 | BINUTILS_SUPPORT_DIRS="bfd gas include libiberty opcodes ld elfcpp gold gprof intl setup.com makefile.vms cpu zlib" |
2536ee9d WN |
282 | binutils_release() |
283 | { | |
284 | compressors=$1 | |
285 | package=binutils | |
286 | tool=binutils | |
287 | tar_compress $package $tool "$BINUTILS_SUPPORT_DIRS" "$compressors" | |
288 | } | |
289 | ||
92c695a1 | 290 | GAS_SUPPORT_DIRS="bfd include libiberty opcodes intl setup.com makefile.vms zlib" |
2536ee9d WN |
291 | gas_release() |
292 | { | |
293 | compressors=$1 | |
294 | package=gas | |
295 | tool=gas | |
296 | tar_compress $package $tool "$GAS_SUPPORT_DIRS" "$compressors" | |
297 | } | |
298 | ||
92c695a1 | 299 | GDB_SUPPORT_DIRS="bfd include libiberty opcodes readline sim intl libdecnumber cpu zlib" |
2536ee9d WN |
300 | gdb_release() |
301 | { | |
302 | compressors=$1 | |
303 | package=gdb | |
304 | tool=gdb | |
305 | gdb_tar_compress $package $tool "$GDB_SUPPORT_DIRS" "$compressors" | |
306 | } | |
307 | ||
308 | # Corresponding to the CVS "sim" module. | |
ec5b9462 | 309 | SIM_SUPPORT_DIRS="bfd opcodes libiberty include intl gdb/version.in gdb/common/create-version.sh makefile.vms zlib" |
2536ee9d WN |
310 | sim_release() |
311 | { | |
312 | compressors=$1 | |
313 | package=sim | |
314 | tool=sim | |
ec5b9462 | 315 | tar_compress $package $tool "$SIM_SUPPORT_DIRS" "$compressors" gdb |
2536ee9d WN |
316 | } |
317 | ||
318 | usage() | |
319 | { | |
320 | echo "src-release.sh <options> <release>" | |
321 | echo "options:" | |
322 | echo " -b: Compress with bzip2" | |
323 | echo " -g: Compress with gzip" | |
324 | echo " -x: Compress with xz" | |
325 | exit 1 | |
326 | } | |
327 | ||
328 | build_release() | |
329 | { | |
330 | release=$1 | |
331 | compressors=$2 | |
332 | case $release in | |
333 | binutils) | |
334 | binutils_release "$compressors";; | |
335 | gas) | |
336 | gas_release "$compressors";; | |
337 | gdb) | |
338 | gdb_release "$compressors";; | |
339 | sim) | |
340 | sim_release "$compressors";; | |
341 | *) | |
342 | echo "Unknown release name: $release" && usage;; | |
343 | esac | |
344 | } | |
345 | ||
346 | compressors="" | |
347 | ||
348 | while getopts ":gbx" opt; do | |
349 | case $opt in | |
350 | b) | |
351 | compressors="$compressors bz2";; | |
352 | g) | |
353 | compressors="$compressors gz";; | |
354 | x) | |
355 | compressors="$compressors xz";; | |
356 | \?) | |
357 | echo "Invalid option: -$OPTARG" && usage;; | |
358 | esac | |
359 | done | |
360 | shift $((OPTIND -1)) | |
361 | release=$1 | |
362 | ||
363 | build_release $release "$compressors" |