3 ########################################################################
6 # Author: Mark Mitchell
9 # Adapted to Subversion by Ben Elliston <bje@au.ibm.com>, 2005-07-14.
12 # Script to automatically download and build GCC.
14 # Copyright (c) 2000, 2001, 2003, 2005 Free Software Foundation.
16 # This file is part of GCC.
18 # GCC is free software; you can redistribute it and/or modify
19 # it under the terms of the GNU General Public License as published by
20 # the Free Software Foundation; either version 2, or (at your option)
23 # GCC is distributed in the hope that it will be useful,
24 # but WITHOUT ANY WARRANTY; without even the implied warranty of
25 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 # GNU General Public License for more details.
28 # You should have received a copy of the GNU General Public License
29 # along with GCC; see the file COPYING. If not, write to
30 # the Free Software Foundation, 51 Franklin Street, Fifth Floor,
31 # Boston, MA 02110-1301, USA.
33 ########################################################################
35 ########################################################################
37 ########################################################################
39 # You can set the following variables in the environment. They
40 # have no corresponding command-line options because they should
41 # only be needed infrequently:
43 # MAKE The path to `make'.
45 ########################################################################
47 ########################################################################
49 # Issue the error message given by $1 and exit with a non-zero
53 echo "gcc_build: error: $1"
57 # Issue a usage message explaining how to use this script.
61 gcc_build [-c configure_options]
62 [-d destination_directory]
63 [-m make_boot_options]
68 [-x make_check_options]
81 # Change to the directory given by $1.
85 error
"Could not change directory to $1"
88 # Checkout a fresh copy of the GCC build tree.
91 # If the destination already exists, don't risk destroying it.
92 test -e ${DESTINATION} && \
93 error
"${DESTINATION} already exists"
96 test -n "${SVN_USERNAME}" && SVN_USERNAME
="${SVN_USERNAME}@"
97 SVNROOT
="${SVN_PROTOCOL}://${SVN_USERNAME}${SVN_SERVER}${SVN_REPOSITORY}"
99 $GCC_SVN co
$SVNROOT ${DESTINATION} || \
100 error
"Could not check out GCC"
106 # If the destination does not already exist, complain.
107 test -d ${DESTINATION} || \
108 error
"${DESTINATION} does not exist"
110 # Enter the destination directory.
111 changedir
${DESTINATION}
114 .
/contrib
/gcc_update || \
115 error
"Could not update GCC"
118 # Configure for a build of GCC.
121 # Go to the source directory.
122 changedir
${DESTINATION}
124 # Remove the object directory.
128 error
"Could not create ${OBJDIR}"
132 # Configure the tree.
133 echo "Configuring: ${DESTINATION}/configure ${CONFIGURE_OPTIONS}"
134 eval ${DESTINATION}/configure
${CONFIGURE_OPTIONS} || \
135 error
"Could not configure the compiler"
138 # Bootstrap GCC. Assume configuration has already occurred.
141 # Go to the source directory.
142 changedir
${DESTINATION}
143 # Go to the object directory.
146 # Bootstrap the compiler
147 echo "Building: ${MAKE} ${MAKE_BOOTSTRAP_OPTIONS} bootstrap"
148 eval ${MAKE} ${MAKE_BOOTSTRAP_OPTIONS} bootstrap || \
149 error
"Could not bootstrap the compiler"
155 # Go to the source directory.
156 changedir
${DESTINATION}
157 # Go to the object directory.
160 echo "Running tests... This will take a while."
161 eval \
${MAKE} -k ${MAKE_CHECK_OPTIONS} check
162 ${DESTINATION}/contrib
/test_summary
165 # Export the GCC source tree.
168 # Go to the source directory.
169 changedir
${DESTINATION}
172 # Build a tarball of the source directory.
174 --exclude=${OBJDIR} \
178 `basename ${DESTINATION}`
184 # Go to the source directory.
185 changedir
${DESTINATION}
186 # Go to the object directory.
189 ${MAKE} install || error
"Installation failed"
192 ########################################################################
194 ########################################################################
197 GCC_SVN
=${GCC_SVN-${SVN-svn}}
198 # The SVN server containing the GCC repository.
199 SVN_SERVER
="dberlin.org"
200 # The path to the repository on that server.
201 SVN_REPOSITORY
="/trunk"
202 # The SVN protocol to use.
204 # The username to use when connecting to the server.
205 # An empty string means anonymous.
208 # The directory where the checked out GCC will be placed.
209 DESTINATION
="${HOME}/dev/gcc"
210 # The relative path from the top of the source tree to the
214 # The file where the tarred up sources will be placed.
215 TARFILE
="${HOME}/dev/gcc.tgz"
217 # Options to pass to configure.
219 # The `make' program.
221 # Options to pass to "make bootstrap".
222 MAKE_BOOTSTRAP_OPTIONS
=
223 # Options to pass to "make check".
235 ########################################################################
237 ########################################################################
239 # Issue usage if no parameters are given.
240 test $# -eq 0 && usage
243 while getopts "c:d:m:o:p:t:u:x:" ARG
; do
245 c
) CONFIGURE_OPTIONS
="${OPTARG}";;
246 d
) DESTINATION
="${OPTARG}";;
247 m
) MAKE_BOOTSTRAP_OPTIONS
="${OPTARG}";;
248 o
) OBJDIR
="${OPTARG}";;
249 p
) SVN_PROTOCOL
="${OPTARG}";;
250 t
) TARFILE
="${OPTARG}";;
251 x
) MAKE_CHECK_OPTIONS
="${OPTARG}";;
252 u
) SVN_USERNAME
="${OPTARG}";;
256 shift `expr ${OPTIND} - 1`
258 # Handle the major modes.
259 while [ $# -ne 0 ]; do
261 bootstrap
) BOOTSTRAP
=1;;
262 build
) CONFIGURE
=1; BOOTSTRAP
=1;;
263 checkout
) CHECKOUT
=1;;
264 configure
) CONFIGURE
=1;;
274 # Check the arguments for sanity.
275 if [ ${CHECKOUT} -ne 0 ] && [ ${UPDATE} -ne 0 ]; then
276 error
"Cannot checkout and update simultaneously"
280 if [ ${CHECKOUT} -ne 0 ]; then
282 elif [ ${UPDATE} -ne 0 ]; then
286 # Configure to build the tree.
287 if [ ${CONFIGURE} -ne 0 ]; then
291 # Bootstrap the compiler.
292 if [ ${BOOTSTRAP} -ne 0 ]; then
297 if [ ${TEST} -ne 0 ]; then
301 # Install the compiler.
302 if [ ${INSTALL} -ne 0 ]; then
307 if [ ${EXPORT} -ne 0 ]; then