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