2 # Copyright (C) 1990-2024 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.
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.
36 # Default to avoid splitting info files by setting the threshold high.
37 MAKEINFOFLAGS
=--split-size=5000000
40 # Support for building net releases
42 # Files in root used in any net release.
43 DEVO_SUPPORT
="ar-lib ChangeLog compile config config-ml.in config.guess \
44 config.rpath config.sub configure configure.ac COPYING COPYING.LIB \
45 COPYING3 COPYING3.LIB depcomp install-sh libtool.m4 ltgcc.m4 \
46 ltmain.sh ltoptions.m4 ltsugar.m4 ltversion.m4 lt~obsolete.m4 \
47 MAINTAINERS Makefile.def Makefile.in Makefile.tpl missing mkdep \
48 mkinstalldirs move-if-change README README-maintainer-mode \
49 SECURITY.txt src-release.sh symlink-tree test-driver ylwrap \
52 # Files in devo/etc used in any net release.
53 ETC_SUPPORT
="ChangeLog Makefile.am Makefile.in aclocal.m4 add-log.el \
54 add-log.vi configbuild.* configdev.* configure configure.ac \
55 configure.in configure.info* configure.texi fdl.texi gnu-oids.texi \
56 make-stds.texi standards.info* standards.texi texi2pod.pl \
59 # Get the version number of a given tool
63 if grep 'AC_INIT.*BFD_VERSION' $tool/configure.ac
>/dev
/null
2>&1; then
64 bfd
/configure
--version |
sed -n -e '1s,.* ,,p'
65 elif test -f $tool/common
/create-version.sh
; then
66 $tool/common
/create-version.sh
$tool 'dummy-host' 'dummy-target' VER.tmp
67 cat VER.tmp |
grep 'version\[\]' |
sed 's/.*"\([^"]*\)".*/\1/' |
sed 's/-git$//'
69 elif test $tool = "gdb"; then
70 .
/gdbsupport
/create-version.sh
$tool 'dummy-host' 'dummy-target' VER.tmp
71 cat VER.tmp |
grep 'version\[\]' |
sed 's/.*"\([^"]*\)".*/\1/' |
sed 's/-git$//'
73 elif test -f $tool/version.
in; then
74 head -n 1 $tool/version.
in
82 # Check that neither staged nor unstaged changes of any tracked file remains.
83 if [ -n "$(git status --porcelain -uno)" ]; then
84 echo "There are uncommitted changes. Please commit or stash them."
88 echo "==> Cleaning sources."
90 # Remove all untracked files.
93 # Umask for any new file created by this script.
96 # Fix permissions of all tracked files and directories according to the previously set umask.
97 echo "==> Fixing permissions."
98 permreg
=$
(printf "%o" $
((0666 & ~$
(umask))))
99 permexe
=$
(printf "%o" $
((0777 & ~$
(umask))))
100 git ls-tree
-rt --format "objectmode=%(objectmode) path=%(path)" HEAD |
while read -r objectprop
; do
108 # executable file or directory
112 # symlink, do nothing, always lrwxrwxrwx.
115 # submodule, currently do nothing
118 # unlikely, might be a future version of Git
119 echo unsupported object
at $path
126 # Setup build directory for building release tarball
136 echo "==> Making $package-$ver/"
137 # Take out texinfo from a few places.
138 sed -e '/^all\.normal: /s/\all-texinfo //' \
139 -e '/^ install-texinfo /d' \
141 mv -f tmp Makefile.
in
142 # configure. --enable-gold is needed to ensure .c/.h from .y are
143 # built in the gold dir. The disables speed the build a little.
146 for dir
in binutils gas gdb gold gprof gprofng libsframe ld libctf libdecnumber readline sim
; do
147 case " $tool $support_files " in
148 *" $dir "*) enables
="$enables --enable-$dir" ;;
149 *) disables
="$disables --disable-$dir" ;;
152 echo "==> configure --target=i386-pc-linux-gnu $disables $enables"
153 .
/configure
--target=i386-pc-linux-gnu
$disables $enables
154 $MAKE configure-host configure-target \
155 ALL_GCC
="" ALL_GCC_C
="" ALL_GCC_CXX
="" \
156 CC_FOR_TARGET
="$CC" CXX_FOR_TARGET
="$CXX"
157 # Make links, and run "make diststuff" or "make info" when needed.
160 dirs="$DEVO_SUPPORT $support_files $tool"
163 if [ ! -f $d/Makefile
] ; then
165 elif grep '^diststuff:' $d/Makefile
>/dev
/null
; then
166 (cd $d ; $MAKE MAKEINFOFLAGS
="$MAKEINFOFLAGS" diststuff
) \
168 elif grep '^info:' $d/Makefile
>/dev
/null
; then
169 (cd $d ; $MAKE MAKEINFOFLAGS
="$MAKEINFOFLAGS" info
) \
172 if [ -d $d/proto-
$d.dir
]; then
173 ln -s ..
/$d/proto-
$d.dir proto-toplev
/$d
175 ln -s ..
/$d proto-toplev
/$d
178 if (echo x
$d |
grep / >/dev
/null
); then
179 mkdir
-p proto-toplev
/`dirname $d`
181 ln -s ..
/`echo $x/ | sed -e 's,[^/]*/,../,g'`$d proto-toplev
/$d
183 ln -s ..
/$d proto-toplev
/$d
187 (cd etc
; $MAKE MAKEINFOFLAGS
="$MAKEINFOFLAGS" info
)
189 mkdir proto-toplev
/etc
190 (cd proto-toplev
/etc
;
191 for i
in $ETC_SUPPORT; do
195 # Take out texinfo from configurable dirs
196 rm proto-toplev
/configure.ac
197 sed -e '/^host_tools=/s/texinfo //' \
198 <configure.ac
>proto-toplev
/configure.ac
200 mkdir proto-toplev
/texinfo
201 ln -s ..
/..
/texinfo
/texinfo.tex proto-toplev
/texinfo
/
202 if test -r texinfo
/util
/tex3patch
; then
203 mkdir proto-toplev
/texinfo
/util
&& \
204 ln -s ..
/..
/..
/texinfo
/util
/tex3patch proto-toplev
/texinfo
/util
207 # Create .gmo files from .po files.
208 for f
in `find . -name '*.po' -type f -print`; do
209 msgfmt
-o `echo $f | sed -e 's/\.po$/.gmo/'` $f
213 ln -s proto-toplev
$package-$ver
216 CVS_NAMES
='-name CVS -o -name .cvsignore'
218 # Add a sha256sum to the built tarball
221 echo "==> Adding sha256 checksum to top-level directory"
222 (cd proto-toplev
&& find * -follow \
( $CVS_NAMES \
) -prune \
224 |
xargs $SHA256PROG > ..
/sha256.new
)
225 rm -f proto-toplev
/sha256.
sum
226 mv sha256.new proto-toplev
/sha256.
sum
229 # Build the release tarball
234 echo "==> Making $package-$ver.tar"
235 rm -f $package-$ver.
tar
236 if test x
$release_date == "x" ; then
237 find $package-$ver -follow \
( $CVS_NAMES \
) -prune -o -type f
-print \
238 |
tar cTfh
- $package-$ver.
tar
240 # Attempt to create a consistent, reproducible tarball using the
242 find $package-$ver -follow \
( $CVS_NAMES \
) -prune -o -type f
-print \
244 |
tar cTfh
- $package-$ver.
tar \
245 --mtime=$release_date --group=0 --owner=0
249 # Compress the output with bzip2
254 echo "==> Bzipping $package-$ver.tar.bz2"
255 rm -f $package-$ver.
tar.bz2
256 $BZIPPROG -k -v -9 $package-$ver.
tar
259 # Compress the output with gzip
264 echo "==> Gzipping $package-$ver.tar.gz"
265 rm -f $package-$ver.
tar.gz
266 $GZIPPROG -k -v -9 $package-$ver.
tar
269 # Compress the output with lzip
274 echo "==> Lzipping $package-$ver.tar.lz"
275 rm -f $package-$ver.
tar.lz
276 $LZIPPROG -k -v -9 $package-$ver.
tar
279 # Compress the output with xz
284 echo "==> Xzipping $package-$ver.tar.xz"
285 rm -f $package-$ver.
tar.xz
286 $XZPROG -k -v -9 -T0 $package-$ver.
tar
289 # Compress the output with zstd
294 echo "==> Zzipping $package-$ver.tar.zst"
295 rm -f $package-$ver.
tar.zst
296 $ZSTDPROG -k -v -19 -T0 $package-$ver.
tar
299 # Compress the output with all selected compresion methods
305 for comp
in $compressors; do
308 do_bz2
$package $ver;;
310 do_gz
$package $ver;;
312 do_lz
$package $ver;;
314 do_xz
$package $ver;;
316 do_zstd
$package $ver;;
318 echo "Unknown compression method: $comp" && exit 1;;
323 # Add djunpack.bat the tarball
328 echo "==> Adding updated djunpack.bat to top-level directory"
329 echo - 's /gdb-[0-9\.]*/$package-'"$ver"'/'
330 sed < djunpack.bat
> djunpack.new \
331 -e 's/gdb-[0-9][0-9\.]*/$package-'"$ver"'/'
332 rm -f proto-toplev
/djunpack.bat
333 mv djunpack.new proto-toplev
/djunpack.bat
336 # Create a release package, tar it and compress it
344 ver
=$
(getver
$verdir)
345 do_proto_toplev
$package $ver $tool "$support_files"
348 do_compress
$package $ver "$compressors"
351 # Create a gdb release package, tar it and compress it
359 do_proto_toplev
$package $ver $tool "$support_files"
361 do_djunpack
$package $ver
363 do_compress
$package $ver "$compressors"
366 # The FSF "binutils" release includes gprof and ld.
367 BINUTILS_SUPPORT_DIRS
="libsframe bfd gas include libiberty libctf opcodes ld elfcpp gold gprof gprofng setup.com makefile.vms cpu zlib"
373 tar_compress
$package $tool "$BINUTILS_SUPPORT_DIRS" "$compressors"
376 GAS_SUPPORT_DIRS
="bfd include libiberty opcodes setup.com makefile.vms zlib"
382 tar_compress
$package $tool "$GAS_SUPPORT_DIRS" "$compressors"
385 GDB_SUPPORT_DIRS
="libsframe bfd include libiberty libctf opcodes readline sim libdecnumber cpu zlib contrib gnulib gdbsupport gdbserver libbacktrace"
391 gdb_tar_compress
$package $tool "$GDB_SUPPORT_DIRS" "$compressors"
394 # Corresponding to the CVS "sim" module.
395 SIM_SUPPORT_DIRS
="libsframe bfd opcodes libiberty libctf/swap.h include gdb/version.in gdb/common/create-version.sh makefile.vms zlib gnulib"
401 tar_compress
$package $tool "$SIM_SUPPORT_DIRS" "$compressors" gdb
406 echo "src-release.sh <options> <release>"
408 echo " -b: Compress with bzip2"
409 echo " -g: Compress with gzip"
410 echo " -l: Compress with lzip"
411 echo " -x: Compress with xz"
412 echo " -z: Compress with zstd"
413 echo " -r <date>: Create a reproducible tarball using <date> as the mtime"
423 binutils_release
"$compressors";;
425 gas_release
"$compressors";;
427 gdb_release
"$compressors";;
429 sim_release
"$compressors";;
431 echo "Unknown release name: $release" && usage
;;
437 while getopts ":bglr:xz" opt
; do
440 compressors
="$compressors bz2";;
442 compressors
="$compressors gz";;
444 compressors
="$compressors lz";;
446 release_date
=$OPTARG;;
448 compressors
="$compressors xz";;
450 compressors
="$compressors zstd";;
452 echo "Invalid option: -$OPTARG" && usage
;;
458 build_release
$release "$compressors"