* config/i386/i386.md (mmx_pinsrw): Output operands in correct
[official-gcc.git] / contrib / gcc_build
blob2989628255c1c68ef9e596ff9a13c1d3c031b17f
1 #! /bin/sh
3 ########################################################################
5 # File: gcc_build
6 # Author: Mark Mitchell
7 # Date: 07/10/2000
9 # Contents:
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)
19 # any later version.
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 ########################################################################
34 # Notes
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 ########################################################################
47 # Functions
48 ########################################################################
50 # Issue the error message given by $1 and exit with a non-zero
51 # exit code.
53 error() {
54 echo "gcc_build: error: $1"
55 exit 1
58 # Issue a usage message explaining how to use this script.
60 usage() {
61 cat <<EOF
62 gcc_build [-c configure_options]
63 [-d destination_directory]
64 [-m make_boot_options]
65 [-u username]
66 [-p protocol]
67 [-t tarfile]
68 [bootstrap]
69 [build]
70 [checkout]
71 [configure]
72 [export]
73 [install]
74 [test]
75 [update]
76 EOF
77 exit 1
80 # Change to the directory given by $1.
82 changedir() {
83 cd $1 || \
84 error "Could not change directory to $1"
87 # Set up CVS environment variables
89 cvs_setup() {
90 CVSROOT=":${CVS_PROTOCOL}:${CVS_USERNAME}@"
91 CVSROOT="${CVSROOT}${CVS_SERVER}:${CVS_REPOSITORY}"
92 export CVSROOT
95 # Checkout a fresh copy of the GCC build tree.
97 checkout_gcc() {
98 # Tell CVS where to find everything.
99 cvs_setup
101 # If the destination already exists, don't risk destroying it.
102 test -e ${DESTINATION} && \
103 error "${DESTINATION} already exists"
105 # CVS doesn't allow an absolute path for the destination directory.
106 DESTINATION_PARENT=`dirname ${DESTINATION}`
107 test -d ${DESTINATION_PARENT} || \
108 error "${DESTINATION_PARENT} is not a directory"
109 changedir ${DESTINATION_PARENT}
111 # Checkout the tree
112 cvs -z 9 co -d `basename ${DESTINATION}` gcc || \
113 error "Could not check out GCC"
116 # Update GCC.
118 update_gcc() {
119 # Tell CVS where to find everything
120 cvs_setup
122 # If the destination does not already exist, complain.
123 test -d ${DESTINATION} || \
124 error "{$DESTINATION} does not exist"
125 # Enter the destination directory.
126 changedir ${DESTINATION}
128 # Update the tree
129 (./contrib/gcc_update | tee -a ${LOGFILE}) || \
130 error "Could not update GCC"
133 # Configure for a build of GCC.
135 configure_gcc() {
136 # Go to the source directory.
137 changedir ${DESTINATION}
139 # Remove the object directory.
140 rm -rf ${OBJDIR}
141 # Create it again.
142 mkdir ${OBJDIR} || \
143 error "Could not create ${OBJDIR}"
144 # Enter it.
145 changedir ${OBJDIR}
147 # Configure the tree.
148 (eval ${DESTINATION}/configure ${CONFIGURE_OPTIONS} 2>&1 |
149 tee -a ${LOGFILE}) || \
150 error "Could not configure the compiler"
153 # Bootstrap GCC. Assume configuration has already occurred.
155 bootstrap_gcc() {
156 # Go to the source directory.
157 changedir ${DESTINATION}
158 # Go to the object directory.
159 changedir ${OBJDIR}
161 # Bootstrap the compiler
162 (eval ${MAKE} ${MAKE_BOOTSTRAP_OPTIONS} bootstrap 2>&1 |
163 tee -a ${LOGFILE}) || \
164 error "Could not bootstrap the compiler"
167 # Test GCC.
169 test_gcc() {
170 # Go to the source directory.
171 changedir ${DESTINATION}
172 # Go to the object directory.
173 changedir ${OBJDIR}
175 echo "Running tests... This will take a while."
176 (${MAKE} -k check 2>&1 | tee -a ${LOGFILE})
177 (${DESTINATION}/contrib/test_summary | tee -a ${LOGFILE})
180 # Export the GCC source tree.
182 export_gcc() {
183 # Go to the source directory.
184 changedir ${DESTINATION}
185 # Go up one level.
186 changedir ..
187 # Build a tarball of the source directory.
188 tar czf ${TARFILE} \
189 --exclude=${OBJDIR} \
190 --exclude=CVS \
191 --exclude='.#*' \
192 --exclude='*~' \
193 `basename ${DESTINATION}`
196 # Install GCC.
198 install_gcc() {
199 # Go to the source directory.
200 changedir ${DESTINATION}
201 # Go to the object directory.
202 changedir ${OBJDIR}
204 (${MAKE} install 2>&1 | tee -a ${LOGFILE}) || \
205 error "Installation failed"
208 ########################################################################
209 # Initialization
210 ########################################################################
212 # The CVS server containing the GCC repository.
213 CVS_SERVER="gcc.gnu.org"
214 # The path to the repository on that server.
215 CVS_REPOSITORY="/cvs/gcc"
216 # The CVS protocol to use.
217 CVS_PROTOCOL="pserver"
218 # The username to use when connecting to the server.
219 CVS_USERNAME="anoncvs"
221 # The directory where the checked out GCC will be placed.
222 DESTINATION="${HOME}/dev/gcc"
223 # The relative path from the top of the source tree to the
224 # object directory.
225 OBJDIR="objdir"
227 # The file where information will be logged.
228 LOGFILE=${HOME}/build-gcc.$$.log
229 # The file where the tarred up sources will be placed.
230 TARFILE="${HOME}/dev/gcc.tgz"
232 # Options to pass to configure.
233 CONFIGURE_OPTIONS=
234 # The `make' program.
235 MAKE=${MAKE:-make}
236 # Options to pass to make.
237 MAKE_BOOTSTRAP_OPTIONS=
239 # Modes of operation
240 BOOTSTRAP=0
241 CHECKOUT=0
242 CONFIGURE=0
243 EXPORT=0
244 INSTALL=0
245 TEST=0
246 UPDATE=0
248 ########################################################################
249 # Main Program
250 ########################################################################
252 # Parse the options.
253 while getopts "c:d:m:p:t:u:" ARG; do
254 case $ARG in
255 c) CONFIGURE_OPTIONS="${OPTARG}";;
256 d) DESTINATION="${OPTARG}";;
257 m) MAKE_BOOTSTRAP_OPTIONS="${OPTARG}";;
258 p) CVS_PROTOCOL="${OPTARG}";;
259 t) CVS_TARGFILE="${OPTARG}";;
260 u) CVS_USERNAME="${OPTARG}";;
261 \?) usage;;
262 esac
263 done
264 shift `expr ${OPTIND} - 1`
266 # Handle the major modes.
267 while [ $# -ne 0 ]; do
268 case $1 in
269 bootstrap) BOOTSTRAP=1;;
270 build) CONFIGURE=1; BOOTSTRAP=1;;
271 checkout) CHECKOUT=1;;
272 configure) CONFIGURE=1;;
273 export) EXPORT=1;;
274 install) INSTALL=1;;
275 test) TEST=1;;
276 update) UPDATE=1;;
277 *) usage;;
278 esac
279 shift
280 done
282 # Check the arguments for sanity.
283 if [ ${CHECKOUT} -ne 0 ] && [ ${UPDATE} -ne 0 ]; then
284 error "Cannot checkout and update simultaneously"
287 # Remove any old logfiles.
288 rm -f ${LOGFILE}
289 # Tell the user where to find the logfile.
290 echo "gcc_build: The logfile for this run is ${LOGFILE}"
292 # Checkout the tree.
293 if [ ${CHECKOUT} -ne 0 ]; then
294 checkout_gcc
295 elif [ ${UPDATE} -ne 0 ]; then
296 update_gcc
299 # Configure to build the tree.
300 if [ ${CONFIGURE} -ne 0 ]; then
301 configure_gcc
304 # Bootstrap the compiler.
305 if [ ${BOOTSTRAP} -ne 0 ]; then
306 bootstrap_gcc
309 # Test the compiler
310 if [ ${TEST} -ne 0 ]; then
311 test_gcc
314 # Install the compiler.
315 if [ ${INSTALL} -ne 0 ]; then
316 install_gcc
319 # Export the sources
320 if [ ${EXPORT} -ne 0 ]; then
321 export_gcc