3 ########################################################################
6 # Author: Jeffrey Law, Bernd Schmidt, Mark Mitchell
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)
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 ########################################################################
35 ########################################################################
37 # Here is an example usage of this script, to create a GCC 3.0.2
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 ########################################################################
47 ########################################################################
49 # Issue the error message given by $1 and exit with a non-zero
53 echo "gcc_release: error: $1"
57 # Issue the informational message given by $1.
60 echo "gcc_release: $1"
63 # Issue a usage message explaining how to use this script.
67 gcc_release [-d destination]
77 # Change to the directory given by $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.
90 echo `basename ${SOURCE_DIRECTORY}`/$x
94 # Build the source tree that will be the basis for the release
95 # in ${WORKING_DIRECTORY}/gcc-${RELEASE}.
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"
114 # Export the current sources.
115 inform
"Retrieving release sources"
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 # For a prerelease or real release, we need to generate additional
126 # files not present in CVS.
127 if [ $SNAPSHOT -ne 1 ]; then
128 # Generate the documentation.
129 inform
"Building install docs"
130 SOURCEDIR
=${SOURCE_DIRECTORY}/gcc
/doc
131 DESTDIR
=${SOURCE_DIRECTORY}/INSTALL
134 ${SOURCE_DIRECTORY}/gcc
/doc
/install.texi2html
136 # Regenerate the NEWS file.
137 contrib
/gennews
> gcc
/NEWS || \
138 error
"Could not regenerate NEWS files"
140 # Now, we must build the compiler in order to create any generated
141 # files that are supposed to go in the source directory. This is
142 # also a good sanity check to make sure that the release builds
143 # on at least one platform.
144 inform
"Building compiler"
145 OBJECT_DIRECTORY
=..
/objdir
146 contrib
/gcc_build
-d ${SOURCE_DIRECTORY} -o ${OBJECT_DIRECTORY} build || \
147 error
"Could not rebuild GCC"
149 # Regenerate the Fotran NEWS and BUGS files.
150 (cd ${OBJECT_DIRECTORY}/gcc
/f
&& make f77.rebuilt
) || \
151 error
"Could not regenerate Fortran NEWS and BUGS files"
154 # Move message catalogs to source directory.
155 mv ..
/objdir
/gcc
/po
/*.gmo gcc
/po
/
157 # Create a `.brik' file to use for checking the validity of the
159 changedir
"${SOURCE_DIRECTORY}"
160 BRIK_FILE
=`mktemp /tmp/gcc_release.XXXXXXX`
161 ((find .
-type f |
sort > $BRIK_FILE) && \
162 brik
-Gb -f ${BRIK_FILE} > .brik
&& \
163 rm ${BRIK_FILE}) || \
164 error
"Could not compute brik checksum"
167 # Buid a single tarfile. The first argument is the name of the name
168 # of the tarfile to build, without any suffixes. They will be added
169 # automatically. The rest of the arguments are the files or
170 # directories to include.
173 # Get the name of the destination tar file.
177 # Build the tar file itself.
178 (${TAR} cf - "$@" | ${GZIP} > ${TARFILE}) || \
179 error
"Could not build tarfile"
180 FILE_LIST
="${FILE_LIST} ${TARFILE}"
183 # Build the various tar files for the release.
186 inform
"Building tarfiles"
188 changedir
"${WORKING_DIRECTORY}"
190 # The GNU Coding Standards specify that all files should
192 chmod -R a
+r
${SOURCE_DIRECTORY}
193 # And that all directories have mode 777.
194 find ${SOURCE_DIRECTORY} -type d
-exec chmod 777 {} \
;
196 # Build one huge tarfile for the entire distribution.
197 build_tarfile gcc-
${RELEASE} `basename ${SOURCE_DIRECTORY}`
199 # Now, build one for each of the languages.
200 build_tarfile gcc-g
++-${RELEASE} ${CPLUSPLUS_DIRS}
201 build_tarfile gcc-g77-
${RELEASE} ${FORTRAN_DIRS}
202 build_tarfile gcc-java-
${RELEASE} ${JAVA_DIRS}
203 build_tarfile gcc-objc-
${RELEASE} ${OBJECTIVEC_DIRS}
204 build_tarfile gcc-testsuite-
${RELEASE} ${TESTSUITE_DIRS}
206 # The core is everything else.
208 for x
in ${CPLUSPLUS_DIRS} ${FORTRAN_DIRS} ${JAVA_DIRS} \
209 ${OBJECTIVEC_DIRS} ${TESTSUITE_DIRS}; do
210 EXCLUDES
="${EXCLUDES} --exclude $x"
212 build_tarfile gcc-core-
${RELEASE} ${EXCLUDES} \
213 `basename ${SOURCE_DIRECTORY}`
215 # Possibly build diffs.
216 if [ -n "$OLD_TARS" ]; then
217 for old_tar
in $OLD_TARS; do
223 for f
in ${FILE_LIST}; do
225 zcat
$f |
${BZIP2} > ${bzfile}
226 FILE_LIST
="${FILE_LIST} ${bzfile}"
230 # Build diffs against an old release.
234 old_vers
=${old_file%.tar.gz}
235 old_vers
=${old_vers#gcc-}
236 inform
"Building diffs against version $old_vers"
237 for f
in gcc gcc-g
++ gcc-g77 gcc-java gcc-objc gcc-testsuite gcc-core
; do
238 old_tar
=${old_dir}/${f}-${old_vers}.
tar.gz
239 new_tar
=${WORKING_DIRECTORY}/${f}-${RELEASE}.
tar.gz
240 if [ -e $old_tar ] && [ -e $new_tar ]; then
241 build_diff
$old_tar gcc-
${old_vers} $new_tar gcc-
${RELEASE} \
242 ${f}-${old_vers}-${RELEASE}.
diff.gz
247 # Build an individual diff.
249 changedir
"${WORKING_DIRECTORY}"
251 mkdir
$tmpdir || error
"Could not create directory $tmpdir"
253 tar xfz
$1 || error
"Could not unpack $1 for diffs"
254 tar xfz
$3 || error
"Could not unpack $3 for diffs"
255 ${DIFF} $2 $4 |
${GZIP} > ..
/$5
256 if [ $?
-eq 2 ]; then
257 error
"Trouble making diffs from $1 to $3"
261 FILE_LIST
="${FILE_LIST} $5"
264 # Upload the files to the FTP server.
267 inform
"Uploading files"
269 changedir
"${WORKING_DIRECTORY}"
271 # Copy the tar files to the FTP server.
272 for x
in gcc
*.gz gcc
*.bz2
; do
274 ${SCP} ${x} ${FTP_PATH} || \
275 error
"Could not upload ${x}"
280 ########################################################################
282 ########################################################################
285 DATE
=`date "+%Y%m%d"`
287 # The CVS server containing the GCC repository.
288 CVS_SERVER
="gcc.gnu.org"
289 # The path to the repository on that server.
290 CVS_REPOSITORY
="/cvs/gcc"
291 # The CVS protocol to use.
293 # The username to use when connecting to the server.
294 CVS_USERNAME
="${USER}"
296 # The path to the directory where the files are uploaded for FTP.
297 FTP_PATH
="gccadmin@gcc.gnu.org:~ftp/pub/gcc"
299 # The major number for the release. For release `3.0.2' this would be
302 # The minor number for the release. For release `3.0.2' this would be
305 # The revision number for the release. For release `3.0.2' this would
308 # The complete name of the release.
311 # The name of the branch from which the release should be made.
314 # The tag to apply to the sources used for the release.
317 # The old tarballs from which to generate diffs.
320 # The directory that will be used to construct the release. The
321 # release itself will be placed in a subdirectory of this diretory.
325 # The directory that will contain the GCC sources.
328 # The directories that should be part of the various language-specific
329 # tar files. These are all relative to the top of the source tree.
330 CPLUSPLUS_DIRS
="gcc/cp libstdc++-v3"
331 FORTRAN_DIRS
="gcc/f libf2c"
332 JAVA_DIRS
="gcc/java libjava libffi fastjar zlib boehm-gc"
333 OBJECTIVEC_DIRS
="gcc/objc libobjc"
334 TESTSUITE_DIRS
="gcc/testsuite"
336 # Non-zero if this is the final release, rather than a prerelease.
339 # Non-zero if we are building a snapshot, and don't build gcc or
340 # include generated files.
343 # Major operation modes.
348 # Files generated to upload.
353 BZIP2
="${BZIP2:-bzip2}"
354 CVS
="${CVS:-cvs -f -Q}"
355 DIFF
="${DIFF:-diff -Nrc3pad}"
356 GZIP
="${GZIP:-gzip --best}"
360 ########################################################################
361 # Command Line Processing
362 ########################################################################
365 while getopts "d:fr:u:t:p:s" ARG
; do
367 d
) DESTINATION
="${OPTARG}";;
368 r
) RELEASE
="${OPTARG}";;
370 u
) CVS_USERNAME
="${OPTARG}";;
373 p
) OLD_TARS
="${OLD_TARS} ${OPTARG}";;
377 shift `expr ${OPTIND} - 1`
379 # Perform consistency checking.
380 if [ -z ${CVS_USERNAME} ]; then
381 error
"No username specified"
384 if [ -z ${RELEASE} ]; then
385 error
"No release number specified"
388 if [ ! -d ${DESTINATION} ]; then
389 error
"\`${DESTINATION}' is not a directory"
392 # Compute the major and minor release numbers.
393 RELEASE_MAJOR
=`echo $RELEASE | awk --assign FS=. '{ print $1; }'`
394 RELEASE_MINOR
=`echo $RELEASE | awk --assign FS=. '{ print $2; }'`
395 RELEASE_REVISION
=`echo $RELEASE | awk --assign FS=. '{ print $3; }'`
397 if [ -z "${RELEASE_MAJOR}" ] ||
[ -z "${RELEASE_MINOR}" ]; then
398 error
"Release number \`${RELEASE}' is invalid"
401 if [ -n "${RELEASE_REVISION}" ]; then
402 error
"Revision releases are unsupported"
405 # Compute the full name of the release.
406 if [ -z "${RELEASE_REVISION}" ]; then
407 RELEASE
="${RELEASE_MAJOR}.${RELEASE_MINOR}"
409 RELEASE
="${RELEASE_MAJOR}.${RELEASE_MINOR}.${RELEASE_REVISION}"
412 # Compute the name of the branch, which is based solely on the major
414 BRANCH
="gcc-${RELEASE_MAJOR}_${RELEASE_MINOR}-branch"
416 # If this is not a final release, set various parameters acordingly.
417 if [ ${FINAL} -ne 1 ]; then
418 RELEASE
="${RELEASE}-${DATE}"
419 FTP_PATH
="${FTP_PATH}/snapshots"
421 FTP_PATH
="${FTP_PATH}/releases"
424 # Compute the name of the WORKING_DIRECTORY and the SOURCE_DIRECTORY.
425 WORKING_DIRECTORY
="${DESTINATION}/gcc-${RELEASE}"
426 SOURCE_DIRECTORY
="${WORKING_DIRECTORY}/gcc-${RELEASE}"
428 # Recompute the names of all the language-specific directories,
429 # relative to the WORKING_DIRECTORY.
430 CPLUSPLUS_DIRS
=`adjust_dirs ${CPLUSPLUS_DIRS}`
431 FORTRAN_DIRS
=`adjust_dirs ${FORTRAN_DIRS}`
432 JAVA_DIRS
=`adjust_dirs ${JAVA_DIRS}`
433 OBJECTIVEC_DIRS
=`adjust_dirs ${OBJECTIVEC_DIRS}`
434 TESTSUITE_DIRS
=`adjust_dirs ${TESTSUITE_DIRS}`
437 CVSROOT
=":${CVS_PROTOCOL}:${CVS_USERNAME}@"
438 CVSROOT
="${CVSROOT}${CVS_SERVER}:${CVS_REPOSITORY}"
441 ########################################################################
443 ########################################################################
445 # Handle the major modes.
446 while [ $# -ne 0 ]; do
448 sources
) MODE_SOURCES
=1;;
449 tarfiles
) MODE_TARFILES
=1;;
450 upload
) MODE_UPLOAD
=1;;
451 all
) MODE_SOURCES
=1; MODE_TARFILES
=1; MODE_UPLOAD
=1;;
452 *) error
"Unknown mode $1";;
457 # Build the source directory.
459 if [ $MODE_SOURCES -ne 0 ]; then
463 # Build the tar files.
465 if [ $MODE_TARFILES -ne 0 ]; then
469 # Upload them to the FTP server.
471 if [ $MODE_UPLOAD -ne 0 ]; then