]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame_incremental - src-release.sh
Re-run make-target-delegates.py
[thirdparty/binutils-gdb.git] / src-release.sh
... / ...
CommitLineData
1#!/usr/bin/env bash
2# Copyright (C) 1990-2020 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
23set -e
24
25BZIPPROG=bzip2
26GZIPPROG=gzip
27LZIPPROG=lzip
28XZPROG=xz
29SHA256PROG=sha256sum
30MAKE=make
31CC=gcc
32CXX=g++
33release_date=
34
35# Default to avoid splitting info files by setting the threshold high.
36MAKEINFOFLAGS=--split-size=5000000
37
38#
39# Support for building net releases
40
41# Files in root used in any net release.
42DEVO_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"
50
51# Files in devo/etc used in any net release.
52ETC_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"
57
58# Get the version number of a given tool
59getver()
60{
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
76 fi
77}
78
79# Setup build directory for building release tarball
80do_proto_toplev()
81{
82 package=$1
83 ver=$2
84 tool=$3
85 support_files=$4
86
87 echo "==> Cleaning sources."
88 find \( -name "*.orig" -o -name "*.rej" -o -name "*~" -o -name ".#*" -o -name "*~$bkpat" \) -exec rm {} \;
89
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
125 fi
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
130 fi
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
138 fi
139 fi
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)
148 #
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
153 #
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
159 fi
160 chmod -R og=u . || chmod og=u `find . -print`
161 #
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
166 #
167 rm -f $package-$ver
168 ln -s proto-toplev $package-$ver
169}
170
171CVS_NAMES='-name CVS -o -name .cvsignore'
172
173# Add a sha256sum to the built tarball
174do_sha256sum()
175{
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
182}
183
184# Build the release tarball
185do_tar()
186{
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
201 fi
202}
203
204# Compress the output with bzip2
205do_bz2()
206{
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
212}
213
214# Compress the output with gzip
215do_gz()
216{
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
222}
223
224# Compress the output with lzip
225do_lz()
226{
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
232}
233
234# Compress the output with xz
235do_xz()
236{
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
242}
243
244# Compress the output with all selected compresion methods
245do_compress()
246{
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;;
254 gz)
255 do_gz $package $ver;;
256 lz)
257 do_lz $package $ver;;
258 xz)
259 do_xz $package $ver;;
260 *)
261 echo "Unknown compression method: $comp" && exit 1;;
262 esac
263 done
264}
265
266# Add djunpack.bat the tarball
267do_djunpack()
268{
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
277}
278
279# Create a release package, tar it and compress it
280tar_compress()
281{
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"
292}
293
294# Create a gdb release package, tar it and compress it
295gdb_tar_compress()
296{
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"
307}
308
309# The FSF "binutils" release includes gprof and ld.
310BINUTILS_SUPPORT_DIRS="libsframe bfd gas include libiberty libctf opcodes ld elfcpp gold gprof gprofng setup.com makefile.vms cpu zlib"
311binutils_release()
312{
313 compressors=$1
314 package=binutils
315 tool=binutils
316 tar_compress $package $tool "$BINUTILS_SUPPORT_DIRS" "$compressors"
317}
318
319GAS_SUPPORT_DIRS="bfd include libiberty opcodes setup.com makefile.vms zlib"
320gas_release()
321{
322 compressors=$1
323 package=gas
324 tool=gas
325 tar_compress $package $tool "$GAS_SUPPORT_DIRS" "$compressors"
326}
327
328GDB_SUPPORT_DIRS="libsframe bfd include libiberty libctf opcodes readline sim libdecnumber cpu zlib contrib gnulib gdbsupport gdbserver libbacktrace"
329gdb_release()
330{
331 compressors=$1
332 package=gdb
333 tool=gdb
334 gdb_tar_compress $package $tool "$GDB_SUPPORT_DIRS" "$compressors"
335}
336
337# Corresponding to the CVS "sim" module.
338SIM_SUPPORT_DIRS="libsframe bfd opcodes libiberty libctf/swap.h include gdb/version.in gdb/common/create-version.sh makefile.vms zlib gnulib"
339sim_release()
340{
341 compressors=$1
342 package=sim
343 tool=sim
344 tar_compress $package $tool "$SIM_SUPPORT_DIRS" "$compressors" gdb
345}
346
347usage()
348{
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
357}
358
359build_release()
360{
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";;
372 *)
373 echo "Unknown release name: $release" && usage;;
374 esac
375}
376
377compressors=""
378
379while getopts ":bglr:x" opt; do
380 case $opt in
381 b)
382 compressors="$compressors bz2";;
383 g)
384 compressors="$compressors gz";;
385 l)
386 compressors="$compressors lz";;
387 r)
388 release_date=$OPTARG;;
389 x)
390 compressors="$compressors xz";;
391 \?)
392 echo "Invalid option: -$OPTARG" && usage;;
393 esac
394done
395shift $((OPTIND -1))
396release=$1
397
398build_release $release "$compressors"