Fix: Segmentation fault caused by npd in objdump
[binutils-gdb.git] / src-release.sh
blob465aee4ed2be6150008f70193363386580d82ede
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"
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"
55 # Get the version number of a given tool
56 getver()
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
63 cat VER.tmp | grep 'version\[\]' | sed 's/.*"\([^"]*\)".*/\1/' | sed 's/-git$//'
64 rm -f VER.tmp
65 elif test $tool = "gdb"; then
66 ./gdbsupport/create-version.sh $tool 'dummy-host' 'dummy-target' VER.tmp
67 cat VER.tmp | grep 'version\[\]' | sed 's/.*"\([^"]*\)".*/\1/' | sed 's/-git$//'
68 rm -f VER.tmp
69 elif test -f $tool/version.in; then
70 head -n 1 $tool/version.in
71 else
72 echo VERSION
76 # Setup build directory for building release tarball
77 do_proto_toplev()
79 package=$1
80 ver=$2
81 tool=$3
82 support_files=$4
84 echo "==> Cleaning sources."
85 find \( -name "*.orig" -o -name "*.rej" -o -name "*~" -o -name ".#*" -o -name "*~$bkpat" \) -exec rm {} \;
87 echo "==> Making $package-$ver/"
88 # Take out texinfo from a few places.
89 sed -e '/^all\.normal: /s/\all-texinfo //' \
90 -e '/^ install-texinfo /d' \
91 <Makefile.in >tmp
92 mv -f tmp Makefile.in
93 # configure. --enable-gold is needed to ensure .c/.h from .y are
94 # built in the gold dir. The disables speed the build a little.
95 enables=
96 disables=
97 for dir in binutils gas gdb gold gprof gprofng libsframe ld libctf libdecnumber readline sim; do
98 case " $tool $support_files " in
99 *" $dir "*) enables="$enables --enable-$dir" ;;
100 *) disables="$disables --disable-$dir" ;;
101 esac
102 done
103 echo "==> configure --target=i386-pc-linux-gnu $disables $enables"
104 ./configure --target=i386-pc-linux-gnu $disables $enables
105 $MAKE configure-host configure-target \
106 ALL_GCC="" ALL_GCC_C="" ALL_GCC_CXX="" \
107 CC_FOR_TARGET="$CC" CXX_FOR_TARGET="$CXX"
108 # Make links, and run "make diststuff" or "make info" when needed.
109 rm -rf proto-toplev
110 mkdir proto-toplev
111 dirs="$DEVO_SUPPORT $support_files $tool"
112 for d in $dirs ; do
113 if [ -d $d ]; then
114 if [ ! -f $d/Makefile ] ; then
115 true
116 elif grep '^diststuff:' $d/Makefile >/dev/null ; then
117 (cd $d ; $MAKE MAKEINFOFLAGS="$MAKEINFOFLAGS" diststuff) \
118 || exit 1
119 elif grep '^info:' $d/Makefile >/dev/null ; then
120 (cd $d ; $MAKE MAKEINFOFLAGS="$MAKEINFOFLAGS" info) \
121 || exit 1
123 if [ -d $d/proto-$d.dir ]; then
124 ln -s ../$d/proto-$d.dir proto-toplev/$d
125 else
126 ln -s ../$d proto-toplev/$d
128 else
129 if (echo x$d | grep / >/dev/null); then
130 mkdir -p proto-toplev/`dirname $d`
131 x=`dirname $d`
132 ln -s ../`echo $x/ | sed -e 's,[^/]*/,../,g'`$d proto-toplev/$d
133 else
134 ln -s ../$d proto-toplev/$d
137 done
138 (cd etc; $MAKE MAKEINFOFLAGS="$MAKEINFOFLAGS" info)
139 $MAKE distclean
140 mkdir proto-toplev/etc
141 (cd proto-toplev/etc;
142 for i in $ETC_SUPPORT; do
143 ln -s ../../etc/$i .
144 done)
146 # Take out texinfo from configurable dirs
147 rm proto-toplev/configure.ac
148 sed -e '/^host_tools=/s/texinfo //' \
149 <configure.ac >proto-toplev/configure.ac
151 mkdir proto-toplev/texinfo
152 ln -s ../../texinfo/texinfo.tex proto-toplev/texinfo/
153 if test -r texinfo/util/tex3patch ; then
154 mkdir proto-toplev/texinfo/util && \
155 ln -s ../../../texinfo/util/tex3patch proto-toplev/texinfo/util
157 chmod -R og=u . || chmod og=u `find . -print`
159 # Create .gmo files from .po files.
160 for f in `find . -name '*.po' -type f -print`; do
161 msgfmt -o `echo $f | sed -e 's/\.po$/.gmo/'` $f
162 done
164 rm -f $package-$ver
165 ln -s proto-toplev $package-$ver
168 CVS_NAMES='-name CVS -o -name .cvsignore'
170 # Add a sha256sum to the built tarball
171 do_sha256sum()
173 echo "==> Adding sha256 checksum to top-level directory"
174 (cd proto-toplev && find * -follow \( $CVS_NAMES \) -prune \
175 -o -type f -print \
176 | xargs $SHA256PROG > ../sha256.new)
177 rm -f proto-toplev/sha256.sum
178 mv sha256.new proto-toplev/sha256.sum
181 # Build the release tarball
182 do_tar()
184 package=$1
185 ver=$2
186 echo "==> Making $package-$ver.tar"
187 rm -f $package-$ver.tar
188 if test x$release_date == "x" ; then
189 find $package-$ver -follow \( $CVS_NAMES \) -prune -o -type f -print \
190 | tar cTfh - $package-$ver.tar
191 else
192 # Attempt to create a consistent, reproducible tarball using the
193 # specified date.
194 find $package-$ver -follow \( $CVS_NAMES \) -prune -o -type f -print \
195 | LC_ALL=C sort \
196 | tar cTfh - $package-$ver.tar \
197 --mtime=$release_date --group=0 --owner=0
201 # Compress the output with bzip2
202 do_bz2()
204 package=$1
205 ver=$2
206 echo "==> Bzipping $package-$ver.tar.bz2"
207 rm -f $package-$ver.tar.bz2
208 $BZIPPROG -k -v -9 $package-$ver.tar
211 # Compress the output with gzip
212 do_gz()
214 package=$1
215 ver=$2
216 echo "==> Gzipping $package-$ver.tar.gz"
217 rm -f $package-$ver.tar.gz
218 $GZIPPROG -k -v -9 $package-$ver.tar
221 # Compress the output with lzip
222 do_lz()
224 package=$1
225 ver=$2
226 echo "==> Lzipping $package-$ver.tar.lz"
227 rm -f $package-$ver.tar.lz
228 $LZIPPROG -k -v -9 $package-$ver.tar
231 # Compress the output with xz
232 do_xz()
234 package=$1
235 ver=$2
236 echo "==> Xzipping $package-$ver.tar.xz"
237 rm -f $package-$ver.tar.xz
238 $XZPROG -k -v -9 $package-$ver.tar
241 # Compress the output with all selected compresion methods
242 do_compress()
244 package=$1
245 ver=$2
246 compressors=$3
247 for comp in $compressors; do
248 case $comp in
249 bz2)
250 do_bz2 $package $ver;;
252 do_gz $package $ver;;
254 do_lz $package $ver;;
256 do_xz $package $ver;;
258 echo "Unknown compression method: $comp" && exit 1;;
259 esac
260 done
263 # Add djunpack.bat the tarball
264 do_djunpack()
266 package=$1
267 ver=$2
268 echo "==> Adding updated djunpack.bat to top-level directory"
269 echo - 's /gdb-[0-9\.]*/$package-'"$ver"'/'
270 sed < djunpack.bat > djunpack.new \
271 -e 's/gdb-[0-9][0-9\.]*/$package-'"$ver"'/'
272 rm -f proto-toplev/djunpack.bat
273 mv djunpack.new proto-toplev/djunpack.bat
276 # Create a release package, tar it and compress it
277 tar_compress()
279 package=$1
280 tool=$2
281 support_files=$3
282 compressors=$4
283 verdir=${5:-$tool}
284 ver=$(getver $verdir)
285 do_proto_toplev $package $ver $tool "$support_files"
286 do_sha256sum
287 do_tar $package $ver
288 do_compress $package $ver "$compressors"
291 # Create a gdb release package, tar it and compress it
292 gdb_tar_compress()
294 package=$1
295 tool=$2
296 support_files=$3
297 compressors=$4
298 ver=$(getver $tool)
299 do_proto_toplev $package $ver $tool "$support_files"
300 do_sha256sum
301 do_djunpack $package $ver
302 do_tar $package $ver
303 do_compress $package $ver "$compressors"
306 # The FSF "binutils" release includes gprof and ld.
307 BINUTILS_SUPPORT_DIRS="libsframe bfd gas include libiberty libctf opcodes ld elfcpp gold gprof gprofng intl setup.com makefile.vms cpu zlib"
308 binutils_release()
310 compressors=$1
311 package=binutils
312 tool=binutils
313 tar_compress $package $tool "$BINUTILS_SUPPORT_DIRS" "$compressors"
316 GAS_SUPPORT_DIRS="bfd include libiberty opcodes intl setup.com makefile.vms zlib"
317 gas_release()
319 compressors=$1
320 package=gas
321 tool=gas
322 tar_compress $package $tool "$GAS_SUPPORT_DIRS" "$compressors"
325 GDB_SUPPORT_DIRS="libsframe bfd include libiberty libctf opcodes readline sim intl libdecnumber cpu zlib contrib gnulib gdbsupport gdbserver libbacktrace"
326 gdb_release()
328 compressors=$1
329 package=gdb
330 tool=gdb
331 gdb_tar_compress $package $tool "$GDB_SUPPORT_DIRS" "$compressors"
334 # Corresponding to the CVS "sim" module.
335 SIM_SUPPORT_DIRS="libsframe bfd opcodes libiberty libctf/swap.h include intl gdb/version.in gdb/common/create-version.sh makefile.vms zlib gnulib"
336 sim_release()
338 compressors=$1
339 package=sim
340 tool=sim
341 tar_compress $package $tool "$SIM_SUPPORT_DIRS" "$compressors" gdb
344 usage()
346 echo "src-release.sh <options> <release>"
347 echo "options:"
348 echo " -b: Compress with bzip2"
349 echo " -g: Compress with gzip"
350 echo " -l: Compress with lzip"
351 echo " -x: Compress with xz"
352 echo " -r <date>: Create a reproducible tarball using <date> as the mtime"
353 exit 1
356 build_release()
358 release=$1
359 compressors=$2
360 case $release in
361 binutils)
362 binutils_release "$compressors";;
363 gas)
364 gas_release "$compressors";;
365 gdb)
366 gdb_release "$compressors";;
367 sim)
368 sim_release "$compressors";;
370 echo "Unknown release name: $release" && usage;;
371 esac
374 compressors=""
376 while getopts ":bglr:x" opt; do
377 case $opt in
379 compressors="$compressors bz2";;
381 compressors="$compressors gz";;
383 compressors="$compressors lz";;
385 release_date=$OPTARG;;
387 compressors="$compressors xz";;
389 echo "Invalid option: -$OPTARG" && usage;;
390 esac
391 done
392 shift $((OPTIND -1))
393 release=$1
395 build_release $release "$compressors"