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