3 ########################################################################
6 # Author: Mark Mitchell
10 # Script to automatically download and build GCC.
12 # Copyright (c) 2000 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 # If you are using password-based CVS, you must manually log in, and
38 # not log out from, the CVS server before running this script.
40 # You can set the following variables in the environment. They
41 # have no corresponding command-line options because they should
42 # only be needed infrequently:
44 # MAKE The path to `make'.
46 ########################################################################
48 ########################################################################
50 # Issue the error message given by $1 and exit with a non-zero
54 echo "gcc_build: error: $1"
58 # Issue a usage message explaining how to use this script.
62 gcc_build [-c configure_options]
63 [-d destination_directory]
78 # Change to the directory given by $1.
82 error "Could not change directory to $1"
85 # Set up CVS environment variables
88 CVSROOT=":${CVS_PROTOCOL}:${CVS_USERNAME}@"
89 CVSROOT="${CVSROOT}${CVS_SERVER}:${CVS_REPOSITORY}"
93 # Checkout a fresh copy of the GCC build tree.
96 # Tell CVS where to find everything.
99 # If the destination already exists, don't risk destroying it.
100 test -e ${DESTINATION} && \
101 error "${DESTINATION} already exists"
103 # CVS doesn't allow an absolute path for the destination directory.
104 DESTINATION_PARENT=`dirname ${DESTINATION}`
105 test -d ${DESTINATION_PARENT} || \
106 error "${DESTINATION_PARENT} is not a directory"
107 changedir ${DESTINATION_PARENT}
110 cvs -z 9 co -d `basename ${DESTINATION}` gcc || \
111 error "Could not check out GCC"
117 # Tell CVS where to find everything
120 # If the destination does not already exist, complain.
121 test -d ${DESTINATION} || \
122 error "{$DESTINATION} does not exist"
123 # Enter the destination directory.
124 changedir ${DESTINATION}
127 (./contrib/gcc_update | tee -a ${LOGFILE}) || \
128 error "Could not update GCC"
134 # Go to the source directory.
135 changedir ${DESTINATION}
137 # Remove the object directory.
141 error "Could not create ${OBJDIR}"
145 # Configure the tree.
146 (eval ${DESTINATION}/configure ${CONFIGURE_OPTIONS} |
147 tee -a ${LOGFILE}) 2>&1 || \
148 error "Could not configure GCC"
150 # Bootstrap the compiler
151 (eval ${MAKE} ${MAKE_OPTIONS} bootstrap 2>&1 |
152 tee -a ${LOGFILE}) || \
153 error "Could not build GCC"
159 # Go to the source directory.
160 changedir ${DESTINATION}
161 # Go to the object directory.
164 echo "Running tests... This will take a while."
165 (${MAKE} -k check 2>&1 | tee -a ${LOGFILE})
166 (${DESTINATION}/contrib/test_summary | tee -a ${LOGFILE})
169 # Export the GCC source tree.
172 # Go to the source directory.
173 changedir ${DESTINATION}
176 # Build a tarball of the source directory.
178 --exclude=${OBJDIR} \
182 `basename ${DESTINATION}`
188 # Go to the source directory.
189 changedir ${DESTINATION}
190 # Go to the object directory.
193 (${MAKE} install 2>&1 | tee -a ${LOGFILE}) || \
194 error "Installation failed"
197 ########################################################################
199 ########################################################################
201 # The CVS server containing the GCC repository.
202 CVS_SERVER="gcc.gnu.org"
203 # The path to the repository on that server.
204 CVS_REPOSITORY="/cvs/gcc"
205 # The CVS protocol to use.
206 CVS_PROTOCOL="pserver"
207 # The username to use when connecting to the server.
208 CVS_USERNAME="anoncvs"
210 # The directory where the checked out GCC will be placed.
211 DESTINATION="${HOME}/dev/gcc"
212 # The relative path from the top of the source tree to the
216 # The file where information will be logged.
217 LOGFILE=${HOME}/build-gcc.$$.log
218 # The file where the tarred up sources will be placed.
219 TARFILE="${HOME}/dev/gcc.tgz"
221 # Options to pass to configure.
223 # The `make' program.
225 # Options to pass to make.
236 ########################################################################
238 ########################################################################
241 while getopts "c:d:m:p:t:u:" ARG; do
243 c) CONFIGURE_OPTIONS="${OPTARG}";;
244 d) DESTINATION="${OPTARG}";;
245 m) MAKE_OPTIONS="${OPTARG}";;
246 p) CVS_PROTOCOL="${OPTARG}";;
247 t) CVS_TARGFILE="${OPTARG}";;
248 u) CVS_USERNAME="${OPTARG}";;
252 shift `expr ${OPTIND} - 1`
254 # Handle the major modes.
255 while [ $# -ne 0 ]; do
258 checkout) CHECKOUT=1;;
268 # Check the arguments for sanity.
269 if [ ${CHECKOUT} -ne 0 ] && [ ${UPDATE} -ne 0 ]; then
270 error "Cannot checkout and update simultaneously"
273 # Remove any old logfiles.
275 # Tell the user where to find the logfile.
276 echo "gcc_build: The logfile for this run is ${LOGFILE}"
279 if [ ${CHECKOUT} -ne 0 ]; then
281 elif [ ${UPDATE} -ne 0 ]; then
285 # Build the compiler.
286 if [ ${BUILD} -ne 0 ]; then
291 if [ ${TEST} -ne 0 ]; then
295 # Install the compiler.
296 if [ ${INSTALL} -ne 0 ]; then
301 if [ ${EXPORT} -ne 0 ]; then