* toplev.c (lang_independent_f_options): Remove
[official-gcc.git] / contrib / gcc_release
blobee74591e064d5c6aaf9c3203435d3a8587be0e4b
1 #! /bin/sh
3 ########################################################################
5 # File: gcc_release
6 # Author: Jeffrey Law, Bernd Schmidt, Mark Mitchell
7 # Date: 2001-05-25
9 # Contents:
10 # Script to create a GCC release.
12 # Copyright (c) 2001 Free Software Foundation.
14 # This file is part of GNU CC.
16 # GNU CC is free software; you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation; either version 2, or (at your option)
19 # any later version.
21 # GNU CC is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
26 # You should have received a copy of the GNU General Public License
27 # along with GNU CC; see the file COPYING. If not, write to
28 # the Free Software Foundation, 59 Temple Place - Suite 330,
29 # Boston, MA 02111-1307, USA.
31 ########################################################################
33 ########################################################################
34 # Notes
35 ########################################################################
37 # Here is an example usage of this script, to create the GCC 3.0.2
38 # release:
40 # gcc_release -r 3.0.2
42 # This script will automatically use the head of the release branch
43 # to generate the release.
45 ########################################################################
46 # Functions
47 ########################################################################
49 # Issue the error message given by $1 and exit with a non-zero
50 # exit code.
52 error() {
53 echo "gcc_release: error: $1"
54 exit 1
57 # Issue the informational message given by $1.
59 inform() {
60 echo "gcc_release: $1"
63 # Issue a usage message explaining how to use this script.
65 usage() {
66 cat <<EOF
67 gcc_release [-d destination]
68 [-u username]
69 [-r release]
70 [-t tag]
71 [-p previous-tarball]
72 [-b] [-s] [-f]
73 EOF
74 exit 1
77 # Change to the directory given by $1.
79 changedir() {
80 cd $1 || \
81 error "Could not change directory to $1"
84 # Each of the arguments is a directory name, relative to the top
85 # of the source tree. Return another name for that directory, relative
86 # to the working directory.
88 adjust_dirs() {
89 for x in $@; do
90 echo `basename ${SOURCE_DIRECTORY}`/$x
91 done
94 # Build the source tree that will be the basis for the release
95 # in ${WORKING_DIRECTORY}/gcc-${RELEASE}.
97 build_sources() {
98 # If the WORKING_DIRECTORY already exists, do not risk destroying it.
99 if [ -r ${WORKING_DIRECTORY} ]; then
100 error "\`${WORKING_DIRECTORY}' already exists"
102 # Create the WORKING_DIRECTORY.
103 mkdir "${WORKING_DIRECTORY}" \
104 || error "Could not create \`${WORKING_DIRECTORY}'"
105 changedir "${WORKING_DIRECTORY}"
107 if [ -n "${TAG}" ]; then
108 inform "Tagging release sources"
109 ${CVS} -z 9 rtag -r ${BRANCH} ${TAG} gcc || \
110 error "Could not tag release sources"
111 BRANCH=$TAG
114 # Export the current sources.
115 inform "Retrieving release sources"
116 ${CVS} \
117 -z 9 export -d "`basename ${SOURCE_DIRECTORY}`" \
118 -r ${BRANCH} gcc || \
119 error "Could not retrieve release sources"
121 # Run gcc_update on them to set up the timestamps nicely.
122 changedir "gcc-${RELEASE}"
123 contrib/gcc_update --touch
125 # Now, we must build the compiler in order to create any generated
126 # files that are supposed to go in the source directory. This is
127 # also a good sanity check to make sure that the release builds
128 # on at least one platform.
129 if [ $SNAPSHOT -ne 1 ]; then
130 inform "Building compiler"
131 contrib/gcc_build -d ${SOURCE_DIRECTORY} -o ../objdir build || \
132 error "Could not rebuild GCC"
135 # Move message catalogs to source directory.
136 mv ../objdir/gcc/po/*.gmo gcc/po/
138 # Create a `.brik' file to use for checking the validity of the
139 # release.
140 changedir "${SOURCE_DIRECTORY}"
141 BRIK_FILE=`mktemp /tmp/gcc_release.XXXXXXX`
142 ((find . -type f | sort > $BRIK_FILE) && \
143 brik -Gb -f ${BRIK_FILE} > .brik && \
144 rm ${BRIK_FILE}) || \
145 error "Could not compute brik checksum"
148 # Buid a single tarfile. The first argument is the name of the name
149 # of the tarfile to build, without any suffixes. They will be added
150 # automatically. The rest of the arguments are the files or
151 # directories to include.
153 build_tarfile() {
154 # Get the name of the destination tar file.
155 TARFILE="$1.tar.gz"
156 shift
158 # Build the tar file itself.
159 (${TAR} cf - "$@" | ${GZIP} > ${TARFILE}) || \
160 error "Could not build tarfile"
161 FILE_LIST="${FILE_LIST} ${TARFILE}"
164 # Build the various tar files for the release.
166 build_tarfiles() {
167 inform "Building tarfiles"
169 changedir "${WORKING_DIRECTORY}"
171 # Build one huge tarfile for the entire distribution.
172 build_tarfile gcc-${RELEASE} `basename ${SOURCE_DIRECTORY}`
174 # Now, build one for each of the languages.
175 build_tarfile gcc-g++-${RELEASE} ${CPLUSPLUS_DIRS}
176 build_tarfile gcc-g77-${RELEASE} ${FORTRAN_DIRS}
177 build_tarfile gcc-java-${RELEASE} ${JAVA_DIRS}
178 build_tarfile gcc-objc-${RELEASE} ${OBJECTIVEC_DIRS}
179 build_tarfile gcc-testsuite-${RELEASE} ${TESTSUITE_DIRS}
181 # The core is everything else.
182 EXCLUDES=""
183 for x in ${CPLUSPLUS_DIRS} ${FORTRAN_DIRS} ${JAVA_DIRS} \
184 ${OBJECTIVEC_DIRS} ${TESTSUITE_DIRS}; do
185 EXCLUDES="${EXCLUDES} --exclude $x"
186 done
187 build_tarfile gcc-core-${RELEASE} ${EXCLUDES} \
188 `basename ${SOURCE_DIRECTORY}`
190 # Possibly build diffs.
191 if [ -n "$OLD_TARS" ]; then
192 for old_tar in $OLD_TARS; do
193 build_diffs $old_tar
194 done
197 # Possibly build .bz2 files.
198 if [ $CREATE_BZIP2 -ne 0 ]; then
199 for f in ${FILE_LIST}; do
200 bzfile=${f%.gz}.bz2
201 zcat $f | ${BZIP2} > ${bzfile}
202 FILE_LIST="${FILE_LIST} ${bzfile}"
203 done
207 # Build diffs against an old release.
208 build_diffs() {
209 old_dir=${1%/*}
210 old_file=${1##*/}
211 old_vers=${old_file%.tar.gz}
212 old_vers=${old_vers#gcc-}
213 inform "Building diffs against version $old_vers"
214 for f in gcc gcc-g++ gcc-g77 gcc-java gcc-objc gcc-testsuite gcc-core; do
215 old_tar=${old_dir}/${f}-${old_vers}.tar.gz
216 new_tar=${WORKING_DIRECTORY}/${f}-${RELEASE}.tar.gz
217 if [ -e $old_tar ] && [ -e $new_tar ]; then
218 build_diff $old_tar gcc-${old_vers} $new_tar gcc-${RELEASE} \
219 ${f}-${old_vers}-${RELEASE}.diff.gz
221 done
224 # Build an individual diff.
225 build_diff() {
226 changedir "${WORKING_DIRECTORY}"
227 tmpdir=gccdiff.$$
228 mkdir $tmpdir || error "Could not create directory $tmpdir"
229 changedir $tmpdir
230 tar xfz $1 || error "Could not unpack $1 for diffs"
231 tar xfz $3 || error "Could not unpack $3 for diffs"
232 ${DIFF} $2 $4 | ${GZIP} > ../$5
233 if [ $? -eq 2 ]; then
234 error "Trouble making diffs from $1 to $3"
236 changedir ..
237 rm -rf $tmpdir
238 FILE_LIST="${FILE_LIST} $5"
241 # Upload the files to the FTP server.
243 upload_files() {
244 inform "Uploading files"
246 changedir "${WORKING_DIRECTORY}"
248 # Copy the tar files to the FTP server.
249 for x in gcc*.gz gcc*.bz2; do
250 if [ -e ${x} ]; then
251 ${SCP} ${x} ${FTP_PATH} || \
252 error "Could not upload ${x}"
254 done
257 ########################################################################
258 # Initialization
259 ########################################################################
261 # Today's date.
262 DATE=`date "+%Y%m%d"`
264 # The CVS server containing the GCC repository.
265 CVS_SERVER="gcc.gnu.org"
266 # The path to the repository on that server.
267 CVS_REPOSITORY="/cvs/gcc"
268 # The CVS protocol to use.
269 CVS_PROTOCOL="ext"
270 # The username to use when connecting to the server.
271 CVS_USERNAME="${USER}"
273 # The path to the directory where the files are uploaded for FTP.
274 FTP_PATH="gccadmin@gcc.gnu.org:~ftp/pub/gcc"
276 # The major number for the release. For release `3.0.2' this would be
277 # `3'
278 RELEASE_MAJOR=""
279 # The minor number for the release. For release `3.0.2' this would be
280 # `0'.
281 RELEASE_MINOR=""
282 # The revision number for the release. For release `3.0.2' this would
283 # be `2'.
284 RELEASE_REVISION=""
285 # The complete name of the release.
286 RELEASE=""
288 # The name of the branch from which the release should be made.
289 BRANCH=""
291 # The tag to apply to the sources used for the release.
292 TAG=""
294 # The old tarballs from which to generate diffs.
295 OLD_TARS=""
297 # The directory that will be used to construct the release. The
298 # release itself will be placed in a subdirectory of this diretory.
299 DESTINATION=${HOME}
300 # The subdirectory.
301 WORKING_DIRECTORY=""
302 # The directory that will contain the GCC sources.
303 SOURCE_DIRECTORY=""
305 # The directories that should be part of the various language-specific
306 # tar files. These are all relative to the top of the source tree.
307 CPLUSPLUS_DIRS="gcc/cp libstdc++-v3"
308 FORTRAN_DIRS="gcc/f libf2c"
309 JAVA_DIRS="gcc/java libjava libffi fastjar zlib boehm-gc"
310 OBJECTIVEC_DIRS="gcc/objc libobjc"
311 TESTSUITE_DIRS="gcc/testsuite"
313 # Non-zero if this is the final release, rather than a prerelease.
314 FINAL=0
316 # Non-zero if we create .bz2 files.
317 CREATE_BZIP2=0
319 # Non-zero if we are building a snapshot, and don't build gcc or
320 # include generated files.
321 SNAPSHOT=0
323 # Major operation modes.
324 MODE_SOURCES=0
325 MODE_TARFILES=0
326 MODE_UPLOAD=0
328 # Files generated to upload.
329 FILE_LIST=""
331 # Programs we use.
333 BZIP2="${BZIP2:-bzip2}"
334 CVS="${CVS:-cvs -f -Q}"
335 DIFF="${DIFF:-diff -Nrc3pad}"
336 GZIP="${GZIP:-gzip --best}"
337 SCP="${SCP:-scp}"
338 TAR="${TAR:-tar}"
340 ########################################################################
341 # Command Line Processing
342 ########################################################################
344 # Parse the options.
345 while getopts "d:fr:u:t:p:bs" ARG; do
346 case $ARG in
347 d) DESTINATION="${OPTARG}";;
348 r) RELEASE="${OPTARG}";;
349 t) TAG="${OPTARG}";;
350 u) CVS_USERNAME="${OPTARG}";;
351 f) FINAL=1;;
352 b) CREATE_BZIP2=1;;
353 s) SNAPSHOT=1;;
354 p) OLD_TARS="${OLD_TARS} ${OPTARG}";;
355 \?) usage;;
356 esac
357 done
358 shift `expr ${OPTIND} - 1`
360 # Perform consistency checking.
361 if [ -z ${CVS_USERNAME} ]; then
362 error "No username specified"
365 if [ -z ${RELEASE} ]; then
366 error "No release number specified"
369 if [ ! -d ${DESTINATION} ]; then
370 error "\`${DESTINATION}' is not a directory"
373 # Compute the major and minor release numbers.
374 RELEASE_MAJOR=`echo $RELEASE | awk --assign FS=. '{ print $1; }'`
375 RELEASE_MINOR=`echo $RELEASE | awk --assign FS=. '{ print $2; }'`
376 RELEASE_REVISION=`echo $RELEASE | awk --assign FS=. '{ print $3; }'`
378 if [ -z "${RELEASE_MAJOR}" ] || [ -z "${RELEASE_MINOR}" ]; then
379 error "Release number \`${RELEASE}' is invalid"
382 if [ -n "${RELEASE_REVISION}" ]; then
383 error "Revision releases are unsupported"
386 # Compute the full name of the release.
387 if [ -z "${RELEASE_REVISION}" ]; then
388 RELEASE="${RELEASE_MAJOR}.${RELEASE_MINOR}"
389 else
390 RELEASE="${RELEASE_MAJOR}.${RELEASE_MINOR}.${RELEASE_REVISION}"
393 # Compute the name of the branch, which is based solely on the major
394 # release number.
395 BRANCH="gcc-${RELEASE_MAJOR}_${RELEASE_MINOR}-branch"
397 # If this is not a final release, set various parameters acordingly.
398 if [ ${FINAL} -ne 1 ]; then
399 RELEASE="${RELEASE}-${DATE}"
400 FTP_PATH="${FTP_PATH}/snapshots"
401 else
402 FTP_PATH="${FTP_PATH}/releases"
405 # Compute the name of the WORKING_DIRECTORY and the SOURCE_DIRECTORY.
406 WORKING_DIRECTORY="${DESTINATION}/gcc-${RELEASE}"
407 SOURCE_DIRECTORY="${WORKING_DIRECTORY}/gcc-${RELEASE}"
409 # Recompute the names of all the language-specific directories,
410 # relative to the WORKING_DIRECTORY.
411 CPLUSPLUS_DIRS=`adjust_dirs ${CPLUSPLUS_DIRS}`
412 FORTRAN_DIRS=`adjust_dirs ${FORTRAN_DIRS}`
413 JAVA_DIRS=`adjust_dirs ${JAVA_DIRS}`
414 OBJECTIVEC_DIRS=`adjust_dirs ${OBJECTIVEC_DIRS}`
415 TESTSUITE_DIRS=`adjust_dirs ${TESTSUITE_DIRS}`
417 # Set up CVSROOT.
418 CVSROOT=":${CVS_PROTOCOL}:${CVS_USERNAME}@"
419 CVSROOT="${CVSROOT}${CVS_SERVER}:${CVS_REPOSITORY}"
420 export CVSROOT
422 ########################################################################
423 # Main Program
424 ########################################################################
426 # Handle the major modes.
427 while [ $# -ne 0 ]; do
428 case $1 in
429 sources) MODE_SOURCES=1;;
430 tarfiles) MODE_TARFILES=1;;
431 upload) MODE_UPLOAD=1;;
432 all) MODE_SOURCES=1; MODE_TARFILES=1; MODE_UPLOAD=1;;
433 *) error "Unknown mode $1";;
434 esac
435 shift
436 done
438 # Build the source directory.
440 if [ $MODE_SOURCES -ne 0 ]; then
441 build_sources
444 # Build the tar files.
446 if [ $MODE_TARFILES -ne 0 ]; then
447 build_tarfiles
450 # Upload them to the FTP server.
452 if [ $MODE_UPLOAD -ne 0 ]; then
453 upload_files