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]
69 [-x make_check_options]
82 # Change to the directory given by $1.
86 error "Could not change directory to $1"
89 # Checkout a fresh copy of the GCC build tree.
92 # If the destination already exists, don't risk destroying it.
93 test -e ${DESTINATION} && \
94 error "${DESTINATION} already exists"
97 test -n "${SVN_USERNAME}" && SVN_USERNAME="${SVN_USERNAME}@"
98 SVNROOT="${SVN_PROTOCOL}://${SVN_USERNAME}${SVN_SERVER}${SVN_REPOSITORY}${SVN_BRANCH}"
100 $GCC_SVN co $SVNROOT ${DESTINATION} || \
101 error "Could not check out GCC"
107 # If the destination does not already exist, complain.
108 test -d ${DESTINATION} || \
109 error "${DESTINATION} does not exist"
111 # Enter the destination directory.
112 changedir ${DESTINATION}
115 ./contrib/gcc_update || \
116 error "Could not update GCC"
119 # Configure for a build of GCC.
122 # Go to the source directory.
123 changedir ${DESTINATION}
125 # Remove the object directory.
129 error "Could not create ${OBJDIR}"
133 # Configure the tree.
134 echo "Configuring: ${DESTINATION}/configure ${CONFIGURE_OPTIONS}"
135 eval ${DESTINATION}/configure ${CONFIGURE_OPTIONS} || \
136 error "Could not configure the compiler"
139 # Bootstrap GCC. Assume configuration has already occurred.
142 # Go to the source directory.
143 changedir ${DESTINATION}
144 # Go to the object directory.
147 # Bootstrap the compiler
148 echo "Building: ${MAKE} ${MAKE_BOOTSTRAP_OPTIONS} bootstrap"
149 eval ${MAKE} ${MAKE_BOOTSTRAP_OPTIONS} bootstrap || \
150 error "Could not bootstrap the compiler"
156 # Go to the source directory.
157 changedir ${DESTINATION}
158 # Go to the object directory.
161 echo "Running tests... This will take a while."
162 eval \${MAKE} -k ${MAKE_CHECK_OPTIONS} check
163 ${DESTINATION}/contrib/test_summary
166 # Export the GCC source tree.
169 # Go to the source directory.
170 changedir ${DESTINATION}
173 # Build a tarball of the source directory.
175 --exclude=${OBJDIR} \
179 `basename ${DESTINATION}`
185 # Go to the source directory.
186 changedir ${DESTINATION}
187 # Go to the object directory.
190 ${MAKE} install || error "Installation failed"
193 ########################################################################
195 ########################################################################
198 GCC_SVN=${GCC_SVN-${SVN-svn}}
199 # The SVN server containing the GCC repository.
200 SVN_SERVER="gcc.gnu.org"
201 # The path to the repository on that server.
202 SVN_REPOSITORY="/svn/gcc/"
203 # The branch to check out from that server.
205 # The SVN protocol to use.
207 # The username to use when connecting to the server.
208 # An empty string means anonymous.
211 # The directory where the checked out GCC will be placed.
212 DESTINATION="${HOME}/dev/gcc"
213 # The relative path from the top of the source tree to the
217 # The file where the tarred up sources will be placed.
218 TARFILE="${HOME}/dev/gcc.tgz"
220 # Options to pass to configure.
222 # The `make' program.
224 # Options to pass to "make bootstrap".
225 MAKE_BOOTSTRAP_OPTIONS=
226 # Options to pass to "make check".
238 ########################################################################
240 ########################################################################
242 # Issue usage if no parameters are given.
243 test $# -eq 0 && usage
246 while getopts "c:d:m:o:p:t:b:u:x:" ARG; do
248 c) CONFIGURE_OPTIONS="${OPTARG}";;
249 d) DESTINATION="${OPTARG}";;
250 m) MAKE_BOOTSTRAP_OPTIONS="${OPTARG}";;
251 o) OBJDIR="${OPTARG}";;
252 p) SVN_PROTOCOL="${OPTARG}";;
253 t) TARFILE="${OPTARG}";;
254 x) MAKE_CHECK_OPTIONS="${OPTARG}";;
255 b) SVN_BRANCH="${OPTARG}";;
256 u) SVN_USERNAME="${OPTARG}";;
260 shift `expr ${OPTIND} - 1`
262 # Handle the major modes.
263 while [ $# -ne 0 ]; do
265 bootstrap) BOOTSTRAP=1;;
266 build) CONFIGURE=1; BOOTSTRAP=1;;
267 checkout) CHECKOUT=1;;
268 configure) CONFIGURE=1;;
278 # Check the arguments for sanity.
279 if [ ${CHECKOUT} -ne 0 ] && [ ${UPDATE} -ne 0 ]; then
280 error "Cannot checkout and update simultaneously"
283 if [ ${CHECKOUT} -eq 0 ] && test -n "${SVN_BRANCH}"; then
284 error "Branch argument only makes sense when doing a checkout"
287 # Validate the branch name.
288 if test "${SVN_BRANCH}" != "trunk"; then
289 SVN_BRANCH="branches/${SVN_BRANCH}";
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