[binutils, ARM, 5/16] BF insns infrastructure with new global reloc R_ARM_THM_BF16
[binutils-gdb.git] / src-release.sh
blob8a50d97603b37b605e6333a23645f47c042ce3b1
1 #!/usr/bin/env bash
2 # Copyright (C) 1990-2018 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 MD5PROG=md5sum
30 MAKE=make
31 CC=gcc
32 CXX=g++
34 # Default to avoid splitting info files by setting the threshold high.
35 MAKEINFOFLAGS=--split-size=5000000
38 # Support for building net releases
40 # Files in root used in any net release.
41 DEVO_SUPPORT="ar-lib ChangeLog compile config config-ml.in config.guess \
42 config.rpath config.sub configure configure.ac COPYING COPYING.LIB \
43 COPYING3 COPYING3.LIB depcomp install-sh libtool.m4 ltgcc.m4 \
44 ltmain.sh ltoptions.m4 ltsugar.m4 ltversion.m4 lt~obsolete.m4 \
45 MAINTAINERS Makefile.def Makefile.in Makefile.tpl missing mkdep \
46 mkinstalldirs move-if-change README README-maintainer-mode \
47 src-release.sh symlink-tree test-driver ylwrap"
49 # Files in devo/etc used in any net release.
50 ETC_SUPPORT="Makefile.in configure configure.in standards.texi \
51 make-stds.texi standards.info* configure.texi configure.info* \
52 ChangeLog configbuild.* configdev.* fdl.texi texi2pod.pl gnu-oids.texi"
54 # Get the version number of a given tool
55 getver()
57 tool=$1
58 if grep 'AC_INIT.*BFD_VERSION' $tool/configure.ac >/dev/null 2>&1; then
59 bfd/configure --version | sed -n -e '1s,.* ,,p'
60 elif test -f $tool/common/create-version.sh; then
61 $tool/common/create-version.sh $tool 'dummy-host' 'dummy-target' VER.tmp
62 cat VER.tmp | grep 'version\[\]' | sed 's/.*"\([^"]*\)".*/\1/' | sed 's/-git$//'
63 rm -f VER.tmp
64 elif test -f $tool/version.in; then
65 head -1 $tool/version.in
66 else
67 echo VERSION
71 # Setup build directory for building release tarball
72 do_proto_toplev()
74 package=$1
75 ver=$2
76 tool=$3
77 support_files=$4
79 echo "==> Cleaning sources."
80 find \( -name "*.orig" -o -name "*.rej" -o -name "*~" -o -name ".#*" -o -name "*~$bkpat" \) -exec rm {} \;
82 echo "==> Making $package-$ver/"
83 # Take out texinfo from a few places.
84 sed -e '/^all\.normal: /s/\all-texinfo //' \
85 -e '/^ install-texinfo /d' \
86 <Makefile.in >tmp
87 mv -f tmp Makefile.in
88 # configure. --enable-gold is needed to ensure .c/.h from .y are
89 # built in the gold dir. The disables speed the build a little.
90 enables=
91 disables=
92 for dir in binutils gas gdb gold gprof ld libdecnumber readline sim; do
93 case " $tool $support_files " in
94 *" $dir "*) enables="$enables --enable-$dir" ;;
95 *) disables="$disables --disable-$dir" ;;
96 esac
97 done
98 echo "==> configure --target=i386-pc-linux-gnu $disables $enables"
99 ./configure --target=i386-pc-linux-gnu $disables $enables
100 $MAKE configure-host configure-target \
101 ALL_GCC="" ALL_GCC_C="" ALL_GCC_CXX="" \
102 CC_FOR_TARGET="$CC" CXX_FOR_TARGET="$CXX"
103 # Make links, and run "make diststuff" or "make info" when needed.
104 rm -rf proto-toplev
105 mkdir proto-toplev
106 dirs="$DEVO_SUPPORT $support_files $tool"
107 for d in $dirs ; do
108 if [ -d $d ]; then
109 if [ ! -f $d/Makefile ] ; then
110 true
111 elif grep '^diststuff:' $d/Makefile >/dev/null ; then
112 (cd $d ; $MAKE MAKEINFOFLAGS="$MAKEINFOFLAGS" diststuff) \
113 || exit 1
114 elif grep '^info:' $d/Makefile >/dev/null ; then
115 (cd $d ; $MAKE MAKEINFOFLAGS="$MAKEINFOFLAGS" info) \
116 || exit 1
118 if [ -d $d/proto-$d.dir ]; then
119 ln -s ../$d/proto-$d.dir proto-toplev/$d
120 else
121 ln -s ../$d proto-toplev/$d
123 else
124 if (echo x$d | grep / >/dev/null); then
125 mkdir -p proto-toplev/`dirname $d`
126 x=`dirname $d`
127 ln -s ../`echo $x/ | sed -e 's,[^/]*/,../,g'`$d proto-toplev/$d
128 else
129 ln -s ../$d proto-toplev/$d
132 done
133 (cd etc; $MAKE MAKEINFOFLAGS="$MAKEINFOFLAGS" info)
134 $MAKE distclean
135 mkdir proto-toplev/etc
136 (cd proto-toplev/etc;
137 for i in $ETC_SUPPORT; do
138 ln -s ../../etc/$i .
139 done)
141 # Take out texinfo from configurable dirs
142 rm proto-toplev/configure.ac
143 sed -e '/^host_tools=/s/texinfo //' \
144 <configure.ac >proto-toplev/configure.ac
146 mkdir proto-toplev/texinfo
147 ln -s ../../texinfo/texinfo.tex proto-toplev/texinfo/
148 if test -r texinfo/util/tex3patch ; then
149 mkdir proto-toplev/texinfo/util && \
150 ln -s ../../../texinfo/util/tex3patch proto-toplev/texinfo/util
151 else
152 true
154 chmod -R og=u . || chmod og=u `find . -print`
156 # Create .gmo files from .po files.
157 for f in `find . -name '*.po' -type f -print`; do
158 msgfmt -o `echo $f | sed -e 's/\.po$/.gmo/'` $f
159 done
161 rm -f $package-$ver
162 ln -s proto-toplev $package-$ver
165 CVS_NAMES='-name CVS -o -name .cvsignore'
167 # Add an md5sum to the built tarball
168 do_md5sum()
170 echo "==> Adding md5 checksum to top-level directory"
171 (cd proto-toplev && find * -follow \( $CVS_NAMES \) -prune \
172 -o -type f -print \
173 | xargs $MD5PROG > ../md5.new)
174 rm -f proto-toplev/md5.sum
175 mv md5.new proto-toplev/md5.sum
178 # Build the release tarball
179 do_tar()
181 package=$1
182 ver=$2
183 echo "==> Making $package-$ver.tar"
184 rm -f $package-$ver.tar
185 find $package-$ver -follow \( $CVS_NAMES \) -prune \
186 -o -type f -print \
187 | tar cTfh - $package-$ver.tar
190 # Compress the output with bzip2
191 do_bz2()
193 package=$1
194 ver=$2
195 echo "==> Bzipping $package-$ver.tar.bz2"
196 rm -f $package-$ver.tar.bz2
197 $BZIPPROG -k -v -9 $package-$ver.tar
200 # Compress the output with gzip
201 do_gz()
203 package=$1
204 ver=$2
205 echo "==> Gzipping $package-$ver.tar.gz"
206 rm -f $package-$ver.tar.gz
207 $GZIPPROG -k -v -9 $package-$ver.tar
210 # Compress the output with lzip
211 do_lz()
213 package=$1
214 ver=$2
215 echo "==> Lzipping $package-$ver.tar.lz"
216 rm -f $package-$ver.tar.lz
217 $LZIPPROG -k -v -9 $package-$ver.tar
220 # Compress the output with xz
221 do_xz()
223 package=$1
224 ver=$2
225 echo "==> Xzipping $package-$ver.tar.xz"
226 rm -f $package-$ver.tar.xz
227 $XZPROG -k -v -9 $package-$ver.tar
230 # Compress the output with all selected compresion methods
231 do_compress()
233 package=$1
234 ver=$2
235 compressors=$3
236 for comp in $compressors; do
237 case $comp in
238 bz2)
239 do_bz2 $package $ver;;
241 do_gz $package $ver;;
243 do_lz $package $ver;;
245 do_xz $package $ver;;
247 echo "Unknown compression method: $comp" && exit 1;;
248 esac
249 done
252 # Add djunpack.bat the tarball
253 do_djunpack()
255 package=$1
256 ver=$2
257 echo "==> Adding updated djunpack.bat to top-level directory"
258 echo - 's /gdb-[0-9\.]*/$package-'"$ver"'/'
259 sed < djunpack.bat > djunpack.new \
260 -e 's/gdb-[0-9][0-9\.]*/$package-'"$ver"'/'
261 rm -f proto-toplev/djunpack.bat
262 mv djunpack.new proto-toplev/djunpack.bat
265 # Create a release package, tar it and compress it
266 tar_compress()
268 package=$1
269 tool=$2
270 support_files=$3
271 compressors=$4
272 verdir=${5:-$tool}
273 ver=$(getver $verdir)
274 do_proto_toplev $package $ver $tool "$support_files"
275 do_md5sum
276 do_tar $package $ver
277 do_compress $package $ver "$compressors"
280 # Create a gdb release package, tar it and compress it
281 gdb_tar_compress()
283 package=$1
284 tool=$2
285 support_files=$3
286 compressors=$4
287 ver=$(getver $tool)
288 do_proto_toplev $package $ver $tool "$support_files"
289 do_md5sum
290 do_djunpack $package $ver
291 do_tar $package $ver
292 do_compress $package $ver "$compressors"
295 # The FSF "binutils" release includes gprof and ld.
296 BINUTILS_SUPPORT_DIRS="bfd gas include libiberty opcodes ld elfcpp gold gprof intl setup.com makefile.vms cpu zlib"
297 binutils_release()
299 compressors=$1
300 package=binutils
301 tool=binutils
302 tar_compress $package $tool "$BINUTILS_SUPPORT_DIRS" "$compressors"
305 GAS_SUPPORT_DIRS="bfd include libiberty opcodes intl setup.com makefile.vms zlib"
306 gas_release()
308 compressors=$1
309 package=gas
310 tool=gas
311 tar_compress $package $tool "$GAS_SUPPORT_DIRS" "$compressors"
314 GDB_SUPPORT_DIRS="bfd include libiberty opcodes readline sim intl libdecnumber cpu zlib contrib"
315 gdb_release()
317 compressors=$1
318 package=gdb
319 tool=gdb
320 gdb_tar_compress $package $tool "$GDB_SUPPORT_DIRS" "$compressors"
323 # Corresponding to the CVS "sim" module.
324 SIM_SUPPORT_DIRS="bfd opcodes libiberty include intl gdb/version.in gdb/common/create-version.sh makefile.vms zlib"
325 sim_release()
327 compressors=$1
328 package=sim
329 tool=sim
330 tar_compress $package $tool "$SIM_SUPPORT_DIRS" "$compressors" gdb
333 usage()
335 echo "src-release.sh <options> <release>"
336 echo "options:"
337 echo " -b: Compress with bzip2"
338 echo " -g: Compress with gzip"
339 echo " -l: Compress with lzip"
340 echo " -x: Compress with xz"
341 exit 1
344 build_release()
346 release=$1
347 compressors=$2
348 case $release in
349 binutils)
350 binutils_release "$compressors";;
351 gas)
352 gas_release "$compressors";;
353 gdb)
354 gdb_release "$compressors";;
355 sim)
356 sim_release "$compressors";;
358 echo "Unknown release name: $release" && usage;;
359 esac
362 compressors=""
364 while getopts ":bglx" opt; do
365 case $opt in
367 compressors="$compressors bz2";;
369 compressors="$compressors gz";;
371 compressors="$compressors lz";;
373 compressors="$compressors xz";;
375 echo "Invalid option: -$OPTARG" && usage;;
376 esac
377 done
378 shift $((OPTIND -1))
379 release=$1
381 build_release $release "$compressors"