Set GDB version number to 15.2.
[binutils-gdb.git] / src-release.sh
blob0e95dde18bc3e567eebf14b7005b93bc94ecdc59
1 #!/usr/bin/env bash
2 # Copyright (C) 1990-2020 Free Software Foundation
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.
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/>.
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.
23 set -e
25 BZIPPROG=bzip2
26 GZIPPROG=gzip
27 LZIPPROG=lzip
28 XZPROG=xz
29 SHA256PROG=sha256sum
30 MAKE=make
31 CC=gcc
32 CXX=g++
33 release_date=
35 # Default to avoid splitting info files by setting the threshold high.
36 MAKEINFOFLAGS=--split-size=5000000
39 # Support for building net releases
41 # Files in root used in any net release.
42 DEVO_SUPPORT="ar-lib ChangeLog compile config config-ml.in config.guess \
43 config.rpath config.sub configure configure.ac COPYING COPYING.LIB \
44 COPYING3 COPYING3.LIB depcomp install-sh libtool.m4 ltgcc.m4 \
45 ltmain.sh ltoptions.m4 ltsugar.m4 ltversion.m4 lt~obsolete.m4 \
46 MAINTAINERS Makefile.def Makefile.in Makefile.tpl missing mkdep \
47 mkinstalldirs move-if-change README README-maintainer-mode \
48 SECURITY.txt src-release.sh symlink-tree test-driver ylwrap \
49 multilib.am"
51 # Files in devo/etc used in any net release.
52 ETC_SUPPORT="ChangeLog Makefile.am Makefile.in aclocal.m4 add-log.el \
53 add-log.vi configbuild.* configdev.* configure configure.ac \
54 configure.in configure.info* configure.texi fdl.texi gnu-oids.texi \
55 make-stds.texi standards.info* standards.texi texi2pod.pl \
56 update-copyright.py"
58 # Get the version number of a given tool
59 getver()
61 tool=$1
62 if grep 'AC_INIT.*BFD_VERSION' $tool/configure.ac >/dev/null 2>&1; then
63 bfd/configure --version | sed -n -e '1s,.* ,,p'
64 elif test -f $tool/common/create-version.sh; then
65 $tool/common/create-version.sh $tool 'dummy-host' 'dummy-target' VER.tmp
66 cat VER.tmp | grep 'version\[\]' | sed 's/.*"\([^"]*\)".*/\1/' | sed 's/-git$//'
67 rm -f VER.tmp
68 elif test $tool = "gdb"; then
69 ./gdbsupport/create-version.sh $tool 'dummy-host' 'dummy-target' VER.tmp
70 cat VER.tmp | grep 'version\[\]' | sed 's/.*"\([^"]*\)".*/\1/' | sed 's/-git$//'
71 rm -f VER.tmp
72 elif test -f $tool/version.in; then
73 head -n 1 $tool/version.in
74 else
75 echo VERSION
79 # Setup build directory for building release tarball
80 do_proto_toplev()
82 package=$1
83 ver=$2
84 tool=$3
85 support_files=$4
87 echo "==> Cleaning sources."
88 find \( -name "*.orig" -o -name "*.rej" -o -name "*~" -o -name ".#*" -o -name "*~$bkpat" \) -exec rm {} \;
90 echo "==> Making $package-$ver/"
91 # Take out texinfo from a few places.
92 sed -e '/^all\.normal: /s/\all-texinfo //' \
93 -e '/^ install-texinfo /d' \
94 <Makefile.in >tmp
95 mv -f tmp Makefile.in
96 # configure. --enable-gold is needed to ensure .c/.h from .y are
97 # built in the gold dir. The disables speed the build a little.
98 enables=
99 disables=
100 for dir in binutils gas gdb gold gprof gprofng libsframe ld libctf libdecnumber readline sim; do
101 case " $tool $support_files " in
102 *" $dir "*) enables="$enables --enable-$dir" ;;
103 *) disables="$disables --disable-$dir" ;;
104 esac
105 done
106 echo "==> configure --target=i386-pc-linux-gnu $disables $enables"
107 ./configure --target=i386-pc-linux-gnu $disables $enables
108 $MAKE configure-host configure-target \
109 ALL_GCC="" ALL_GCC_C="" ALL_GCC_CXX="" \
110 CC_FOR_TARGET="$CC" CXX_FOR_TARGET="$CXX"
111 # Make links, and run "make diststuff" or "make info" when needed.
112 rm -rf proto-toplev
113 mkdir proto-toplev
114 dirs="$DEVO_SUPPORT $support_files $tool"
115 for d in $dirs ; do
116 if [ -d $d ]; then
117 if [ ! -f $d/Makefile ] ; then
118 true
119 elif grep '^diststuff:' $d/Makefile >/dev/null ; then
120 (cd $d ; $MAKE MAKEINFOFLAGS="$MAKEINFOFLAGS" diststuff) \
121 || exit 1
122 elif grep '^info:' $d/Makefile >/dev/null ; then
123 (cd $d ; $MAKE MAKEINFOFLAGS="$MAKEINFOFLAGS" info) \
124 || exit 1
126 if [ -d $d/proto-$d.dir ]; then
127 ln -s ../$d/proto-$d.dir proto-toplev/$d
128 else
129 ln -s ../$d proto-toplev/$d
131 else
132 if (echo x$d | grep / >/dev/null); then
133 mkdir -p proto-toplev/`dirname $d`
134 x=`dirname $d`
135 ln -s ../`echo $x/ | sed -e 's,[^/]*/,../,g'`$d proto-toplev/$d
136 else
137 ln -s ../$d proto-toplev/$d
140 done
141 (cd etc; $MAKE MAKEINFOFLAGS="$MAKEINFOFLAGS" info)
142 $MAKE distclean
143 mkdir proto-toplev/etc
144 (cd proto-toplev/etc;
145 for i in $ETC_SUPPORT; do
146 ln -s ../../etc/$i .
147 done)
149 # Take out texinfo from configurable dirs
150 rm proto-toplev/configure.ac
151 sed -e '/^host_tools=/s/texinfo //' \
152 <configure.ac >proto-toplev/configure.ac
154 mkdir proto-toplev/texinfo
155 ln -s ../../texinfo/texinfo.tex proto-toplev/texinfo/
156 if test -r texinfo/util/tex3patch ; then
157 mkdir proto-toplev/texinfo/util && \
158 ln -s ../../../texinfo/util/tex3patch proto-toplev/texinfo/util
160 chmod -R og=u . || chmod og=u `find . -print`
162 # Create .gmo files from .po files.
163 for f in `find . -name '*.po' -type f -print`; do
164 msgfmt -o `echo $f | sed -e 's/\.po$/.gmo/'` $f
165 done
167 rm -f $package-$ver
168 ln -s proto-toplev $package-$ver
171 CVS_NAMES='-name CVS -o -name .cvsignore'
173 # Add a sha256sum to the built tarball
174 do_sha256sum()
176 echo "==> Adding sha256 checksum to top-level directory"
177 (cd proto-toplev && find * -follow \( $CVS_NAMES \) -prune \
178 -o -type f -print \
179 | xargs $SHA256PROG > ../sha256.new)
180 rm -f proto-toplev/sha256.sum
181 mv sha256.new proto-toplev/sha256.sum
184 # Build the release tarball
185 do_tar()
187 package=$1
188 ver=$2
189 echo "==> Making $package-$ver.tar"
190 rm -f $package-$ver.tar
191 if test x$release_date == "x" ; then
192 find $package-$ver -follow \( $CVS_NAMES \) -prune -o -type f -print \
193 | tar cTfh - $package-$ver.tar
194 else
195 # Attempt to create a consistent, reproducible tarball using the
196 # specified date.
197 find $package-$ver -follow \( $CVS_NAMES \) -prune -o -type f -print \
198 | LC_ALL=C sort \
199 | tar cTfh - $package-$ver.tar \
200 --mtime=$release_date --group=0 --owner=0
204 # Compress the output with bzip2
205 do_bz2()
207 package=$1
208 ver=$2
209 echo "==> Bzipping $package-$ver.tar.bz2"
210 rm -f $package-$ver.tar.bz2
211 $BZIPPROG -k -v -9 $package-$ver.tar
214 # Compress the output with gzip
215 do_gz()
217 package=$1
218 ver=$2
219 echo "==> Gzipping $package-$ver.tar.gz"
220 rm -f $package-$ver.tar.gz
221 $GZIPPROG -k -v -9 $package-$ver.tar
224 # Compress the output with lzip
225 do_lz()
227 package=$1
228 ver=$2
229 echo "==> Lzipping $package-$ver.tar.lz"
230 rm -f $package-$ver.tar.lz
231 $LZIPPROG -k -v -9 $package-$ver.tar
234 # Compress the output with xz
235 do_xz()
237 package=$1
238 ver=$2
239 echo "==> Xzipping $package-$ver.tar.xz"
240 rm -f $package-$ver.tar.xz
241 $XZPROG -k -v -9 $package-$ver.tar
244 # Compress the output with all selected compresion methods
245 do_compress()
247 package=$1
248 ver=$2
249 compressors=$3
250 for comp in $compressors; do
251 case $comp in
252 bz2)
253 do_bz2 $package $ver;;
255 do_gz $package $ver;;
257 do_lz $package $ver;;
259 do_xz $package $ver;;
261 echo "Unknown compression method: $comp" && exit 1;;
262 esac
263 done
266 # Add djunpack.bat the tarball
267 do_djunpack()
269 package=$1
270 ver=$2
271 echo "==> Adding updated djunpack.bat to top-level directory"
272 echo - 's /gdb-[0-9\.]*/$package-'"$ver"'/'
273 sed < djunpack.bat > djunpack.new \
274 -e 's/gdb-[0-9][0-9\.]*/$package-'"$ver"'/'
275 rm -f proto-toplev/djunpack.bat
276 mv djunpack.new proto-toplev/djunpack.bat
279 # Create a release package, tar it and compress it
280 tar_compress()
282 package=$1
283 tool=$2
284 support_files=$3
285 compressors=$4
286 verdir=${5:-$tool}
287 ver=$(getver $verdir)
288 do_proto_toplev $package $ver $tool "$support_files"
289 do_sha256sum
290 do_tar $package $ver
291 do_compress $package $ver "$compressors"
294 # Create a gdb release package, tar it and compress it
295 gdb_tar_compress()
297 package=$1
298 tool=$2
299 support_files=$3
300 compressors=$4
301 ver=$(getver $tool)
302 do_proto_toplev $package $ver $tool "$support_files"
303 do_sha256sum
304 do_djunpack $package $ver
305 do_tar $package $ver
306 do_compress $package $ver "$compressors"
309 # The FSF "binutils" release includes gprof and ld.
310 BINUTILS_SUPPORT_DIRS="libsframe bfd gas include libiberty libctf opcodes ld elfcpp gold gprof gprofng setup.com makefile.vms cpu zlib"
311 binutils_release()
313 compressors=$1
314 package=binutils
315 tool=binutils
316 tar_compress $package $tool "$BINUTILS_SUPPORT_DIRS" "$compressors"
319 GAS_SUPPORT_DIRS="bfd include libiberty opcodes setup.com makefile.vms zlib"
320 gas_release()
322 compressors=$1
323 package=gas
324 tool=gas
325 tar_compress $package $tool "$GAS_SUPPORT_DIRS" "$compressors"
328 GDB_SUPPORT_DIRS="libsframe bfd include libiberty libctf opcodes readline sim libdecnumber cpu zlib contrib gnulib gdbsupport gdbserver libbacktrace"
329 gdb_release()
331 compressors=$1
332 package=gdb
333 tool=gdb
334 gdb_tar_compress $package $tool "$GDB_SUPPORT_DIRS" "$compressors"
337 # Corresponding to the CVS "sim" module.
338 SIM_SUPPORT_DIRS="libsframe bfd opcodes libiberty libctf/swap.h include gdb/version.in gdb/common/create-version.sh makefile.vms zlib gnulib"
339 sim_release()
341 compressors=$1
342 package=sim
343 tool=sim
344 tar_compress $package $tool "$SIM_SUPPORT_DIRS" "$compressors" gdb
347 usage()
349 echo "src-release.sh <options> <release>"
350 echo "options:"
351 echo " -b: Compress with bzip2"
352 echo " -g: Compress with gzip"
353 echo " -l: Compress with lzip"
354 echo " -x: Compress with xz"
355 echo " -r <date>: Create a reproducible tarball using <date> as the mtime"
356 exit 1
359 build_release()
361 release=$1
362 compressors=$2
363 case $release in
364 binutils)
365 binutils_release "$compressors";;
366 gas)
367 gas_release "$compressors";;
368 gdb)
369 gdb_release "$compressors";;
370 sim)
371 sim_release "$compressors";;
373 echo "Unknown release name: $release" && usage;;
374 esac
377 compressors=""
379 while getopts ":bglr:x" opt; do
380 case $opt in
382 compressors="$compressors bz2";;
384 compressors="$compressors gz";;
386 compressors="$compressors lz";;
388 release_date=$OPTARG;;
390 compressors="$compressors xz";;
392 echo "Invalid option: -$OPTARG" && usage;;
393 esac
394 done
395 shift $((OPTIND -1))
396 release=$1
398 build_release $release "$compressors"