3 ########################################################################
6 # Author: Mark Mitchell
10 # Script to automatically download and build GCC.
12 # Copyright (c) 2000, 2001, 2003 Free Software Foundation.
14 # This file is part of GCC.
16 # GCC 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 # GCC 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 GCC; 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]
64 [-m make_boot_options]
69 [-x make_check_options]
82 # Change to the directory given by $1.
86 error
"Could not change directory to $1"
89 # Set up CVS environment variables
92 CVSROOT
=":${CVS_PROTOCOL}:${CVS_USERNAME}@"
93 CVSROOT
="${CVSROOT}${CVS_SERVER}:${CVS_REPOSITORY}"
97 # Checkout a fresh copy of the GCC build tree.
100 # Tell CVS where to find everything.
103 # If the destination already exists, don't risk destroying it.
104 test -e ${DESTINATION} && \
105 error
"${DESTINATION} already exists"
107 # CVS doesn't allow an absolute path for the destination directory.
108 DESTINATION_PARENT
=`dirname ${DESTINATION}`
109 test -d ${DESTINATION_PARENT} || \
110 error
"${DESTINATION_PARENT} is not a directory"
111 changedir
${DESTINATION_PARENT}
114 $GCC_CVS -z 9 co
-d `basename ${DESTINATION}` gcc || \
115 error
"Could not check out GCC"
121 # Tell CVS where to find everything
124 # If the destination does not already exist, complain.
125 test -d ${DESTINATION} || \
126 error
"{$DESTINATION} does not exist"
127 # Enter the destination directory.
128 changedir
${DESTINATION}
131 .
/contrib
/gcc_update
-d || \
132 error
"Could not update GCC"
135 # Configure for a build of GCC.
138 # Go to the source directory.
139 changedir
${DESTINATION}
141 # Remove the object directory.
145 error
"Could not create ${OBJDIR}"
149 # Configure the tree.
150 echo "Configuring: ${DESTINATION}/configure ${CONFIGURE_OPTIONS}"
151 eval ${DESTINATION}/configure
${CONFIGURE_OPTIONS} || \
152 error
"Could not configure the compiler"
155 # Bootstrap GCC. Assume configuration has already occurred.
158 # Go to the source directory.
159 changedir
${DESTINATION}
160 # Go to the object directory.
163 # Bootstrap the compiler
164 echo "Building: ${MAKE} ${MAKE_BOOTSTRAP_OPTIONS} bootstrap"
165 eval ${MAKE} ${MAKE_BOOTSTRAP_OPTIONS} bootstrap || \
166 error
"Could not bootstrap the compiler"
172 # Go to the source directory.
173 changedir
${DESTINATION}
174 # Go to the object directory.
177 echo "Running tests... This will take a while."
178 eval \
${MAKE} -k ${MAKE_CHECK_OPTIONS} check
179 ${DESTINATION}/contrib
/test_summary
182 # Export the GCC source tree.
185 # Go to the source directory.
186 changedir
${DESTINATION}
189 # Build a tarball of the source directory.
191 --exclude=${OBJDIR} \
195 `basename ${DESTINATION}`
201 # Go to the source directory.
202 changedir
${DESTINATION}
203 # Go to the object directory.
206 ${MAKE} install || error
"Installation failed"
209 ########################################################################
211 ########################################################################
214 GCC_CVS
=${GCC_CVS-${CVS-cvs}}
215 # The CVS server containing the GCC repository.
216 CVS_SERVER
="gcc.gnu.org"
217 # The path to the repository on that server.
218 CVS_REPOSITORY
="/cvs/gcc"
219 # The CVS protocol to use.
220 CVS_PROTOCOL
="pserver"
221 # The username to use when connecting to the server.
222 CVS_USERNAME
="anoncvs"
224 # The directory where the checked out GCC will be placed.
225 DESTINATION
="${HOME}/dev/gcc"
226 # The relative path from the top of the source tree to the
230 # The file where the tarred up sources will be placed.
231 TARFILE
="${HOME}/dev/gcc.tgz"
233 # Options to pass to configure.
235 # The `make' program.
237 # Options to pass to "make bootstrap".
238 MAKE_BOOTSTRAP_OPTIONS
=
239 # Options to pass to "make check".
251 ########################################################################
253 ########################################################################
256 while getopts "c:d:m:o:p:t:u:x:" ARG
; do
258 c
) CONFIGURE_OPTIONS
="${OPTARG}";;
259 d
) DESTINATION
="${OPTARG}";;
260 m
) MAKE_BOOTSTRAP_OPTIONS
="${OPTARG}";;
261 o
) OBJDIR
="${OPTARG}";;
262 p
) CVS_PROTOCOL
="${OPTARG}";;
263 t
) TARFILE
="${OPTARG}";;
264 x
) MAKE_CHECK_OPTIONS
="${OPTARG}";;
265 u
) CVS_USERNAME
="${OPTARG}";;
269 shift `expr ${OPTIND} - 1`
271 # Handle the major modes.
272 while [ $# -ne 0 ]; do
274 bootstrap
) BOOTSTRAP
=1;;
275 build
) CONFIGURE
=1; BOOTSTRAP
=1;;
276 checkout
) CHECKOUT
=1;;
277 configure
) CONFIGURE
=1;;
287 # Check the arguments for sanity.
288 if [ ${CHECKOUT} -ne 0 ] && [ ${UPDATE} -ne 0 ]; then
289 error
"Cannot checkout and update simultaneously"
293 if [ ${CHECKOUT} -ne 0 ]; then
295 elif [ ${UPDATE} -ne 0 ]; then
299 # Configure to build the tree.
300 if [ ${CONFIGURE} -ne 0 ]; then
304 # Bootstrap the compiler.
305 if [ ${BOOTSTRAP} -ne 0 ]; then
310 if [ ${TEST} -ne 0 ]; then
314 # Install the compiler.
315 if [ ${INSTALL} -ne 0 ]; then
320 if [ ${EXPORT} -ne 0 ]; then