]>
git.ipfire.org Git - thirdparty/gcc.git/blob - contrib/gcc_build
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]
64 [-m make_boot_options]
81 # Change to the directory given by $1.
85 error
"Could not change directory to $1"
88 # Set up CVS environment variables
91 CVSROOT
=":${CVS_PROTOCOL}:${CVS_USERNAME}@"
92 CVSROOT
="${CVSROOT}${CVS_SERVER}:${CVS_REPOSITORY}"
96 # Checkout a fresh copy of the GCC build tree.
99 # Tell CVS where to find everything.
102 # If the destination already exists, don't risk destroying it.
103 test -e ${DESTINATION} && \
104 error
"${DESTINATION} already exists"
106 # CVS doesn't allow an absolute path for the destination directory.
107 DESTINATION_PARENT
=`dirname ${DESTINATION}`
108 test -d ${DESTINATION_PARENT} || \
109 error
"${DESTINATION_PARENT} is not a directory"
110 changedir
${DESTINATION_PARENT}
113 cvs
-z 9 co
-d `basename ${DESTINATION}` gcc || \
114 error
"Could not check out GCC"
120 # Tell CVS where to find everything
123 # If the destination does not already exist, complain.
124 test -d ${DESTINATION} || \
125 error
"{$DESTINATION} does not exist"
126 # Enter the destination directory.
127 changedir
${DESTINATION}
130 (.
/contrib
/gcc_update |
tee -a ${LOGFILE}) || \
131 error
"Could not update GCC"
134 # Configure for a build of GCC.
137 # Go to the source directory.
138 changedir
${DESTINATION}
140 # Remove the object directory.
144 error
"Could not create ${OBJDIR}"
148 # Configure the tree.
149 (eval ${DESTINATION}/configure
${CONFIGURE_OPTIONS} 2>&1 |
150 tee -a ${LOGFILE}) || \
151 error
"Could not configure the compiler"
154 # Bootstrap GCC. Assume configuration has already occurred.
157 # Go to the source directory.
158 changedir
${DESTINATION}
159 # Go to the object directory.
162 # Bootstrap the compiler
163 (eval ${MAKE} ${MAKE_BOOTSTRAP_OPTIONS} bootstrap
2>&1 |
164 tee -a ${LOGFILE}) || \
165 error
"Could not bootstrap the compiler"
171 # Go to the source directory.
172 changedir
${DESTINATION}
173 # Go to the object directory.
176 echo "Running tests... This will take a while."
177 (${MAKE} -k check
2>&1 |
tee -a ${LOGFILE})
178 (${DESTINATION}/contrib
/test_summary |
tee -a ${LOGFILE})
181 # Export the GCC source tree.
184 # Go to the source directory.
185 changedir
${DESTINATION}
188 # Build a tarball of the source directory.
190 --exclude=${OBJDIR} \
194 `basename ${DESTINATION}`
200 # Go to the source directory.
201 changedir
${DESTINATION}
202 # Go to the object directory.
205 (${MAKE} install 2>&1 |
tee -a ${LOGFILE}) || \
206 error
"Installation failed"
209 ########################################################################
211 ########################################################################
213 # The CVS server containing the GCC repository.
214 CVS_SERVER
="gcc.gnu.org"
215 # The path to the repository on that server.
216 CVS_REPOSITORY
="/cvs/gcc"
217 # The CVS protocol to use.
218 CVS_PROTOCOL
="pserver"
219 # The username to use when connecting to the server.
220 CVS_USERNAME
="anoncvs"
222 # The directory where the checked out GCC will be placed.
223 DESTINATION
="${HOME}/dev/gcc"
224 # The relative path from the top of the source tree to the
228 # The file where information will be logged.
229 LOGFILE
=${HOME}/build-gcc.$$.log
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.
238 MAKE_BOOTSTRAP_OPTIONS
=
249 ########################################################################
251 ########################################################################
254 while getopts "c:d:m:o:p:t:u:" ARG
; do
256 c
) CONFIGURE_OPTIONS
="${OPTARG}";;
257 d
) DESTINATION
="${OPTARG}";;
258 m
) MAKE_BOOTSTRAP_OPTIONS
="${OPTARG}";;
259 o
) OBJDIR
="${OPTARG}";;
260 p
) CVS_PROTOCOL
="${OPTARG}";;
261 t
) CVS_TARGFILE
="${OPTARG}";;
262 u
) CVS_USERNAME
="${OPTARG}";;
266 shift `expr ${OPTIND} - 1`
268 # Handle the major modes.
269 while [ $# -ne 0 ]; do
271 bootstrap
) BOOTSTRAP
=1;;
272 build
) CONFIGURE
=1; BOOTSTRAP
=1;;
273 checkout
) CHECKOUT
=1;;
274 configure
) CONFIGURE
=1;;
284 # Check the arguments for sanity.
285 if [ ${CHECKOUT} -ne 0 ] && [ ${UPDATE} -ne 0 ]; then
286 error
"Cannot checkout and update simultaneously"
289 # Remove any old logfiles.
291 # Tell the user where to find the logfile.
292 echo "gcc_build: The logfile for this run is ${LOGFILE}"
295 if [ ${CHECKOUT} -ne 0 ]; then
297 elif [ ${UPDATE} -ne 0 ]; then
301 # Configure to build the tree.
302 if [ ${CONFIGURE} -ne 0 ]; then
306 # Bootstrap the compiler.
307 if [ ${BOOTSTRAP} -ne 0 ]; then
312 if [ ${TEST} -ne 0 ]; then
316 # Install the compiler.
317 if [ ${INSTALL} -ne 0 ]; then
322 if [ ${EXPORT} -ne 0 ]; then