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