* stmt.c (decl_conflicts_with_clobbers_p): Add REG_P check.
[official-gcc.git] / maintainer-scripts / gcc_release
blob45169e78f764bf62848021ce7e4d93506cd17783
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, 2002 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 a GCC 3.0.2
38 # prerelease:
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 [-s] [-f] [-l]
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 this is a final release, make sure that the ChangeLogs
108 # and version strings are updated.
109 if [ ${FINAL} -ne 0 ]; then
110 inform "Updating ChangeLogs and version files"
112 ${CVS} co -d "`basename ${SOURCE_DIRECTORY}`" \
113 -r ${BRANCH} gcc || \
114 error "Could not check out release sources"
115 for x in `find ${SOURCE_DIRECTORY} -name ChangeLog`; do
116 cat - ${x} > ${x}.new <<EOF
117 ${LONG_DATE} Release Manager
119 * GCC ${RELEASE} Released.
122 mv ${x}.new ${x} || \
123 error "Could not update ${x}"
124 (changedir `dirname ${x}` && \
125 ${CVS} ci -m 'Mark ChangeLog' `basename ${x}`) || \
126 error "Could not commit ${x}"
127 done
129 # Update `gcc/version.c'.
130 for x in gcc/version.c; do
131 y=`basename ${x}`
132 (changedir `dirname ${SOURCE_DIRECTORY}/${x}` && \
133 sed -e 's|= \".*\"|= \"'${RELEASE}'\"|g' < ${y} > ${y}.new && \
134 mv ${y}.new ${y} && \
135 ${CVS} ci -m 'Update version' ${y}) || \
136 error "Could not update ${x}"
137 done
139 # Make sure we tag the sources for a final release.
140 TAG="gcc_`echo ${RELEASE} | tr . _`_release"
142 rm -rf ${SOURCE_DIRECTORY}
145 # Tag the sources.
146 if [ -n "${TAG}" ]; then
147 inform "Tagging release sources"
148 ${CVS} rtag -r ${BRANCH} -F ${TAG} gcc || \
149 error "Could not tag release sources"
150 BRANCH=$TAG
153 # Export the current sources.
154 inform "Retrieving release sources"
155 ${CVS} \
156 export -d "`basename ${SOURCE_DIRECTORY}`" \
157 -r ${BRANCH} gcc || \
158 error "Could not retrieve release sources"
160 # Run gcc_update on them to set up the timestamps nicely.
161 changedir "gcc-${RELEASE}"
162 contrib/gcc_update --touch
164 # Obtain some documentation files from the wwwdocs module.
165 inform "Retrieving HTML documentation"
166 changedir "${WORKING_DIRECTORY}"
167 for x in bugs gnats faq; do
168 (${CVS} export -r HEAD wwwdocs/htdocs/${x}.html && \
169 cp ${WORKING_DIRECTORY}/wwwdocs/htdocs/${x}.html \
170 ${SOURCE_DIRECTORY}) || \
171 error "Could not retrieve ${x}.html"
172 done
174 inform "Generating plain-text documentation from HTML"
175 changedir "${SOURCE_DIRECTORY}"
176 for file in *.html; do
177 newfile=`echo $file | sed -e 's/.html//' | tr "[:lower:]" "[:upper:]"`
178 (${ENV} TERM=vt100 lynx -dump $file \
179 | sed -e "s#file://localhost`/bin/pwd`\(.*\)#http://gcc.gnu.org\1#g" \
180 > $newfile) || \
181 error "Could not regenerate documentation"
182 done
184 # For a prerelease or real release, we need to generate additional
185 # files not present in CVS.
186 changedir "${SOURCE_DIRECTORY}"
187 if [ $SNAPSHOT -ne 1 ]; then
188 # Generate the documentation.
189 inform "Building install docs"
190 SOURCEDIR=${SOURCE_DIRECTORY}/gcc/doc
191 DESTDIR=${SOURCE_DIRECTORY}/INSTALL
192 export SOURCEDIR
193 export DESTDIR
194 ${SOURCE_DIRECTORY}/gcc/doc/install.texi2html
196 # Regenerate the NEWS file.
197 contrib/gennews > gcc/NEWS || \
198 error "Could not regenerate NEWS files"
200 # Now, we must build the compiler in order to create any generated
201 # files that are supposed to go in the source directory. This is
202 # also a good sanity check to make sure that the release builds
203 # on at least one platform.
204 inform "Building compiler"
205 OBJECT_DIRECTORY=../objdir
206 contrib/gcc_build -d ${SOURCE_DIRECTORY} -o ${OBJECT_DIRECTORY} build || \
207 error "Could not rebuild GCC"
209 # Regenerate the Fotran NEWS and BUGS files.
210 (cd ${OBJECT_DIRECTORY}/gcc && make f77.rebuilt) || \
211 error "Could not regenerate Fortran NEWS and BUGS files"
214 # Move message catalogs to source directory.
215 mv ../objdir/gcc/po/*.gmo gcc/po/
217 # Create a `.brik' file to use for checking the validity of the
218 # release.
219 changedir "${SOURCE_DIRECTORY}"
220 BRIK_FILE=`mktemp /tmp/gcc_release.XXXXXXX`
221 ((find . -type f | sort > $BRIK_FILE) && \
222 brik -Gb -f ${BRIK_FILE} > .brik && \
223 rm ${BRIK_FILE}) || \
224 error "Could not compute brik checksum"
227 # Buid a single tarfile. The first argument is the name of the name
228 # of the tarfile to build, without any suffixes. They will be added
229 # automatically. The rest of the arguments are the files or
230 # directories to include.
232 build_tarfile() {
233 # Get the name of the destination tar file.
234 TARFILE="$1.tar.gz"
235 shift
237 # Build the tar file itself.
238 (${TAR} cf - "$@" | ${GZIP} > ${TARFILE}) || \
239 error "Could not build tarfile"
240 FILE_LIST="${FILE_LIST} ${TARFILE}"
243 # Build the various tar files for the release.
245 build_tarfiles() {
246 inform "Building tarfiles"
248 changedir "${WORKING_DIRECTORY}"
250 # The GNU Coding Standards specify that all files should
251 # world readable.
252 chmod -R a+r ${SOURCE_DIRECTORY}
253 # And that all directories have mode 777.
254 find ${SOURCE_DIRECTORY} -type d -exec chmod 777 {} \;
256 # Build one huge tarfile for the entire distribution.
257 build_tarfile gcc-${RELEASE} `basename ${SOURCE_DIRECTORY}`
259 # Now, build one for each of the languages.
260 build_tarfile gcc-ada-${RELEASE} ${ADA_DIRS}
261 build_tarfile gcc-g++-${RELEASE} ${CPLUSPLUS_DIRS}
262 build_tarfile gcc-g77-${RELEASE} ${FORTRAN_DIRS}
263 build_tarfile gcc-java-${RELEASE} ${JAVA_DIRS}
264 build_tarfile gcc-objc-${RELEASE} ${OBJECTIVEC_DIRS}
265 build_tarfile gcc-testsuite-${RELEASE} ${TESTSUITE_DIRS}
267 # The core is everything else.
268 EXCLUDES=""
269 for x in ${ADA_DIRS} ${CPLUSPLUS_DIRS} ${FORTRAN_DIRS} \
270 ${JAVA_DIRS} ${OBJECTIVEC_DIRS} ${TESTSUITE_DIRS}; do
271 EXCLUDES="${EXCLUDES} --exclude $x"
272 done
273 build_tarfile gcc-core-${RELEASE} ${EXCLUDES} \
274 `basename ${SOURCE_DIRECTORY}`
277 # Build .bz2 files.
278 build_bzip2() {
279 for f in ${FILE_LIST}; do
280 bzfile=${f%.gz}.bz2
281 (zcat $f | ${BZIP2} > ${bzfile}) || error "Could not create ${bzfile}"
282 done
285 # Build diffs against an old release.
286 build_diffs() {
287 old_dir=${1%/*}
288 old_file=${1##*/}
289 old_vers=${old_file%.tar.gz}
290 old_vers=${old_vers#gcc-}
291 inform "Building diffs against version $old_vers"
292 for f in gcc gcc-ada gcc-g++ gcc-g77 gcc-java gcc-objc gcc-testsuite gcc-core; do
293 old_tar=${old_dir}/${f}-${old_vers}.tar.gz
294 new_tar=${WORKING_DIRECTORY}/${f}-${RELEASE}.tar.gz
295 if [ -e $old_tar ] && [ -e $new_tar ]; then
296 build_diff $old_tar gcc-${old_vers} $new_tar gcc-${RELEASE} \
297 ${f}-${old_vers}-${RELEASE}.diff.gz
299 done
302 # Build an individual diff.
303 build_diff() {
304 changedir "${WORKING_DIRECTORY}"
305 tmpdir=gccdiff.$$
306 mkdir $tmpdir || error "Could not create directory $tmpdir"
307 changedir $tmpdir
308 tar xfz $1 || error "Could not unpack $1 for diffs"
309 tar xfz $3 || error "Could not unpack $3 for diffs"
310 ${DIFF} $2 $4 > ../${5%.gz}
311 if [ $? -eq 2 ]; then
312 error "Trouble making diffs from $1 to $3"
314 ${GZIP} ../${5%.gz} || error "Could not gzip ../${5%.gz}"
315 changedir ..
316 rm -rf $tmpdir
317 FILE_LIST="${FILE_LIST} $5"
320 # Upload the files to the FTP server.
322 upload_files() {
323 inform "Uploading files"
325 changedir "${WORKING_DIRECTORY}"
327 # Make sure the directory exists on the server.
328 if [ $LOCAL -eq 0 ]; then
329 ${SSH} -l ${GCC_USERNAME} ${GCC_HOSTNAME} mkdir ${FTP_PATH}
330 UPLOAD_PATH="${GCC_USERNAME}@${GCC_HOSTNAME}:${FTP_PATH}"
331 else
332 mkdir -p "${FTP_PATH}" \
333 || error "Could not create \`${FTP_PATH}'"
334 UPLOAD_PATH=${FTP_PATH}
337 for x in gcc*.gz gcc*.bz2; do
338 if [ -e ${x} ]; then
339 # Make sure the file will be readable on the server.
340 chmod a+r ${x}
341 # Copy it.
342 ${SCP} ${x} ${UPLOAD_PATH} || error "Could not upload ${x}"
344 done
347 ########################################################################
348 # Initialization
349 ########################################################################
351 # Today's date.
352 DATE=`date "+%Y%m%d"`
353 LONG_DATE=`date "+%Y-%m-%d"`
355 # The CVS server containing the GCC repository.
356 CVS_SERVER="gcc.gnu.org"
357 # The path to the repository on that server.
358 CVS_REPOSITORY="/cvs/gcc"
359 # The CVS protocol to use.
360 CVS_PROTOCOL="ext"
361 # The username to use when connecting to the server.
362 CVS_USERNAME="${USER}"
364 # The machine to which files will be uploaded.
365 GCC_HOSTNAME="gcc.gnu.org"
366 # The name of the account on the machine to which files are uploaded.
367 GCC_USERNAME="gccadmin"
368 # The directory in which the files will be placed.
369 FTP_PATH="~ftp/pub/gcc"
371 # The major number for the release. For release `3.0.2' this would be
372 # `3'
373 RELEASE_MAJOR=""
374 # The minor number for the release. For release `3.0.2' this would be
375 # `0'.
376 RELEASE_MINOR=""
377 # The revision number for the release. For release `3.0.2' this would
378 # be `2'.
379 RELEASE_REVISION=""
380 # The complete name of the release.
381 RELEASE=""
383 # The name of the branch from which the release should be made.
384 BRANCH=""
386 # The tag to apply to the sources used for the release.
387 TAG=""
389 # The old tarballs from which to generate diffs.
390 OLD_TARS=""
392 # The directory that will be used to construct the release. The
393 # release itself will be placed in a subdirectory of this diretory.
394 DESTINATION=${HOME}
395 # The subdirectory.
396 WORKING_DIRECTORY=""
397 # The directory that will contain the GCC sources.
398 SOURCE_DIRECTORY=""
400 # The directories that should be part of the various language-specific
401 # tar files. These are all relative to the top of the source tree.
402 ADA_DIRS="gcc/ada"
403 CPLUSPLUS_DIRS="gcc/cp libstdc++-v3"
404 FORTRAN_DIRS="gcc/f libf2c"
405 JAVA_DIRS="gcc/java libjava libffi fastjar zlib boehm-gc"
406 OBJECTIVEC_DIRS="gcc/objc libobjc"
407 TESTSUITE_DIRS="gcc/testsuite"
409 # Non-zero if this is the final release, rather than a prerelease.
410 FINAL=0
412 # Non-zero if we are building a snapshot, and don't build gcc or
413 # include generated files.
414 SNAPSHOT=0
416 # Non-zero if we are running locally on gcc.gnu.org, and use local CVS
417 # and copy directly to the FTP directory.
418 LOCAL=0
420 # Major operation modes.
421 MODE_BZIP2=0
422 MODE_DIFFS=0
423 MODE_SOURCES=0
424 MODE_TARFILES=0
425 MODE_UPLOAD=0
427 # .gz files generated to create .bz2 files from.
428 FILE_LIST=""
430 # Programs we use.
432 BZIP2="${BZIP2:-bzip2}"
433 CVS="${CVS:-cvs -f -Q -z9}"
434 DIFF="${DIFF:-diff -Nrc3pad}"
435 ENV="${ENV:-env}"
436 GZIP="${GZIP:-gzip --best}"
437 SCP="${SCP:-scp -p}"
438 SSH="${SSH:-ssh}"
439 TAR="${TAR:-tar}"
441 ########################################################################
442 # Command Line Processing
443 ########################################################################
445 # Parse the options.
446 while getopts "d:fr:u:t:p:sl" ARG; do
447 case $ARG in
448 d) DESTINATION="${OPTARG}";;
449 r) RELEASE="${OPTARG}";;
450 t) TAG="${OPTARG}";;
451 u) CVS_USERNAME="${OPTARG}";;
452 f) FINAL=1;;
453 s) SNAPSHOT=1;;
454 l) LOCAL=1
455 SCP=cp
456 FTP_PATH=~ftp/pub/gcc
457 PATH=~:/usr/local/bin:$PATH;;
458 p) OLD_TARS="${OLD_TARS} ${OPTARG}"
459 if [ -d ${OPTARG} ]; then
460 error "-p argument must name a tarball"
461 fi;;
462 \?) usage;;
463 esac
464 done
465 shift `expr ${OPTIND} - 1`
467 # Perform consistency checking.
468 if [ ${LOCAL} -eq 0 ] && [ -z ${CVS_USERNAME} ]; then
469 error "No username specified"
472 if [ ! -d ${DESTINATION} ]; then
473 error "\`${DESTINATION}' is not a directory"
476 if [ $SNAPSHOT -eq 0 ]; then
477 if [ -z ${RELEASE} ]; then
478 error "No release number specified"
481 # Compute the major and minor release numbers.
482 RELEASE_MAJOR=`echo $RELEASE | awk --assign FS=. '{ print $1; }'`
483 RELEASE_MINOR=`echo $RELEASE | awk --assign FS=. '{ print $2; }'`
484 RELEASE_REVISION=`echo $RELEASE | awk --assign FS=. '{ print $3; }'`
486 if [ -z "${RELEASE_MAJOR}" ] || [ -z "${RELEASE_MINOR}" ]; then
487 error "Release number \`${RELEASE}' is invalid"
490 # Compute the full name of the release.
491 if [ -z "${RELEASE_REVISION}" ]; then
492 RELEASE="${RELEASE_MAJOR}.${RELEASE_MINOR}"
493 else
494 RELEASE="${RELEASE_MAJOR}.${RELEASE_MINOR}.${RELEASE_REVISION}"
497 # Compute the name of the branch, which is based solely on the major
498 # and minor release numbers.
499 BRANCH="gcc-${RELEASE_MAJOR}_${RELEASE_MINOR}-branch"
501 # If this is not a final release, set various parameters acordingly.
502 if [ ${FINAL} -ne 1 ]; then
503 RELEASE="${RELEASE}-${DATE}"
504 FTP_PATH="${FTP_PATH}/snapshots/"
505 else
506 FTP_PATH="${FTP_PATH}/releases/gcc-${RELEASE}/"
508 else
509 RELEASE=$DATE
510 # For now snapshots come from the mainline.
511 BRANCH=HEAD
512 FTP_PATH="${FTP_PATH}/snapshots/${LONG_DATE}"
513 TAG=gcc_ss_${DATE}
515 # Building locally on gcc.gnu.org, we know what the last snapshot date
516 # was.
517 if [ $LOCAL -ne 0 ]; then
518 LAST_DATE=`cat ~/.snapshot_date`
519 LAST_LONG_DATE=`date --date=$LAST_DATE +%Y-%m-%d`
520 LAST_DIR=~ftp/pub/gcc/snapshots/${LAST_LONG_DATE}
521 OLD_TARS=${LAST_DIR}/gcc-${LAST_DATE}.tar.gz
525 # Compute the name of the WORKING_DIRECTORY and the SOURCE_DIRECTORY.
526 WORKING_DIRECTORY="${DESTINATION}/gcc-${RELEASE}"
527 SOURCE_DIRECTORY="${WORKING_DIRECTORY}/gcc-${RELEASE}"
529 # Recompute the names of all the language-specific directories,
530 # relative to the WORKING_DIRECTORY.
531 ADA_DIRS=`adjust_dirs ${ADA_DIRS}`
532 CPLUSPLUS_DIRS=`adjust_dirs ${CPLUSPLUS_DIRS}`
533 FORTRAN_DIRS=`adjust_dirs ${FORTRAN_DIRS}`
534 JAVA_DIRS=`adjust_dirs ${JAVA_DIRS}`
535 OBJECTIVEC_DIRS=`adjust_dirs ${OBJECTIVEC_DIRS}`
536 TESTSUITE_DIRS=`adjust_dirs ${TESTSUITE_DIRS}`
538 # Set up CVSROOT.
539 if [ $LOCAL -eq 0 ]; then
540 CVSROOT=":${CVS_PROTOCOL}:${CVS_USERNAME}@"
541 CVSROOT="${CVSROOT}${CVS_SERVER}:${CVS_REPOSITORY}"
542 else
543 CVSROOT="${CVS_REPOSITORY}"
545 export CVSROOT
547 ########################################################################
548 # Main Program
549 ########################################################################
551 # Set the timezone to UTC
552 TZ="UTC0"
553 export TZ
555 # Handle the major modes.
556 while [ $# -ne 0 ]; do
557 case $1 in
558 bzip2) MODE_BZIP2=1;;
559 diffs) MODE_DIFFS=1;;
560 sources) MODE_SOURCES=1;;
561 tarfiles) MODE_TARFILES=1;;
562 upload) MODE_UPLOAD=1;;
563 all) MODE_SOURCES=1; MODE_TARFILES=1; MODE_DIFFS=1; MODE_BZIP2=1; MODE_UPLOAD=1;;
564 *) error "Unknown mode $1";;
565 esac
566 shift
567 done
569 # Build the source directory.
571 if [ $MODE_SOURCES -ne 0 ]; then
572 build_sources
575 # Build the tar files.
577 if [ $MODE_TARFILES -ne 0 ]; then
578 build_tarfiles
581 # Build diffs
583 if [ $MODE_DIFFS -ne 0 ]; then
584 # Possibly build diffs.
585 if [ -n "$OLD_TARS" ]; then
586 for old_tar in $OLD_TARS; do
587 build_diffs $old_tar
588 done
592 # Build bzip2 files
593 if [ $MODE_BZIP2 -ne 0 ]; then
594 build_bzip2
597 # Upload them to the FTP server.
599 if [ $MODE_UPLOAD -ne 0 ]; then
600 upload_files
602 # For snapshots, make some further updates.
603 if [ $SNAPSHOT -ne 0 ] && [ $LOCAL -ne 0 ]; then
604 # Update links on the FTP server.
605 TEXT_DATE=`date --date=$DATE +%B\ %d,\ %Y`
606 cd ~ftp/pub/gcc/snapshots
607 sed -e "s%@DATE@%$DATE%g" -e "s%@LAST_DATE@%$LAST_DATE%g" \
608 -e "s%@LONG_DATE@%$LONG_DATE%g" \
609 -e "s%@TEXT_DATE@%$TEXT_DATE%g" < ~/scripts/snapshot-README > $$
610 mv $$ README
611 sed -e "s%@DATE@%$DATE%g" -e "s%@LAST_DATE@%$LAST_DATE%g" \
612 -e "s%@LONG_DATE@%$LONG_DATE%g" \
613 -e "s%@TEXT_DATE@%$TEXT_DATE%g" < ~/scripts/snapshot-index.html > $$
614 mv $$ index.html
616 touch LATEST-IS-$LONG_DATE
617 rm -f LATEST-IS-$LAST_LONG_DATE
619 # Update snapshot date file.
620 changedir ~
621 echo $DATE >.snapshot_date
623 # Update gcc_latest_snapshot tag.
624 ${CVS} rtag -d gcc_latest_snapshot gcc
625 ${CVS} rtag -rgcc_ss_${DATE} gcc_latest_snapshot gcc
627 # Announce the snapshot.
628 export QMAILHOST=gcc.gnu.org
629 mail -s "gcc-ss-$DATE is now available" gcc@gcc.gnu.org < ~ftp/pub/gcc/snapshots/README
631 # Remove working directory
632 rm -rf ${WORKING_DIRECTORY}