]> git.ipfire.org Git - thirdparty/gcc.git/blame - contrib/gcc_build
* gcc_build: Remove code to put information in a log file.
[thirdparty/gcc.git] / contrib / gcc_build
CommitLineData
275d96ed 1#! /bin/sh
2
3########################################################################
4#
deeaaa98 5# File: gcc_build
275d96ed 6# Author: Mark Mitchell
7# Date: 07/10/2000
8#
9# Contents:
10# Script to automatically download and build GCC.
11#
12# Copyright (c) 2000 Free Software Foundation.
13#
14# This file is part of GNU CC.
15#
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.
20#
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.
25#
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.
30#
31########################################################################
32
33########################################################################
34# Notes
35########################################################################
36
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.
39
c0921e86 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:
43#
44# MAKE The path to `make'.
45
275d96ed 46########################################################################
47# Functions
48########################################################################
49
50# Issue the error message given by $1 and exit with a non-zero
51# exit code.
52
53error() {
931ced76 54 echo "gcc_build: error: $1"
275d96ed 55 exit 1
56}
57
58# Issue a usage message explaining how to use this script.
59
60usage() {
61cat <<EOF
931ced76 62gcc_build [-c configure_options]
275d96ed 63 [-d destination_directory]
60f107a4 64 [-m make_boot_options]
fd87d7ed 65 [-o objdir]
275d96ed 66 [-u username]
67 [-p protocol]
68 [-t tarfile]
60f107a4 69 [bootstrap]
275d96ed 70 [build]
71 [checkout]
60f107a4 72 [configure]
275d96ed 73 [export]
74 [install]
75 [test]
76 [update]
77EOF
78 exit 1
79}
80
81# Change to the directory given by $1.
82
83changedir() {
84 cd $1 || \
85 error "Could not change directory to $1"
86}
87
88# Set up CVS environment variables
89
90cvs_setup() {
91 CVSROOT=":${CVS_PROTOCOL}:${CVS_USERNAME}@"
92 CVSROOT="${CVSROOT}${CVS_SERVER}:${CVS_REPOSITORY}"
93 export CVSROOT
94}
95
96# Checkout a fresh copy of the GCC build tree.
97
98checkout_gcc() {
99 # Tell CVS where to find everything.
100 cvs_setup
101
102 # If the destination already exists, don't risk destroying it.
103 test -e ${DESTINATION} && \
104 error "${DESTINATION} already exists"
105
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}
111
112 # Checkout the tree
113 cvs -z 9 co -d `basename ${DESTINATION}` gcc || \
114 error "Could not check out GCC"
115}
116
117# Update GCC.
118
119update_gcc() {
120 # Tell CVS where to find everything
121 cvs_setup
122
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}
128
129 # Update the tree
e74f4b65 130 ./contrib/gcc_update || \
275d96ed 131 error "Could not update GCC"
132}
133
60f107a4 134# Configure for a build of GCC.
275d96ed 135
60f107a4 136configure_gcc() {
275d96ed 137 # Go to the source directory.
138 changedir ${DESTINATION}
139
140 # Remove the object directory.
141 rm -rf ${OBJDIR}
142 # Create it again.
143 mkdir ${OBJDIR} || \
144 error "Could not create ${OBJDIR}"
145 # Enter it.
146 changedir ${OBJDIR}
147
148 # Configure the tree.
e74f4b65 149 eval ${DESTINATION}/configure ${CONFIGURE_OPTIONS} || \
60f107a4 150 error "Could not configure the compiler"
151}
152
153# Bootstrap GCC. Assume configuration has already occurred.
154
155bootstrap_gcc() {
156 # Go to the source directory.
157 changedir ${DESTINATION}
158 # Go to the object directory.
159 changedir ${OBJDIR}
275d96ed 160
161 # Bootstrap the compiler
e74f4b65 162 eval ${MAKE} ${MAKE_BOOTSTRAP_OPTIONS} bootstrap || \
60f107a4 163 error "Could not bootstrap the compiler"
275d96ed 164}
165
166# Test GCC.
167
168test_gcc() {
169 # Go to the source directory.
170 changedir ${DESTINATION}
171 # Go to the object directory.
172 changedir ${OBJDIR}
173
174 echo "Running tests... This will take a while."
e74f4b65 175 ${MAKE} -k check
176 ${DESTINATION}/contrib/test_summary
275d96ed 177}
178
179# Export the GCC source tree.
180
181export_gcc() {
182 # Go to the source directory.
183 changedir ${DESTINATION}
184 # Go up one level.
185 changedir ..
1409de39 186 # Build a tarball of the source directory.
275d96ed 187 tar czf ${TARFILE} \
188 --exclude=${OBJDIR} \
189 --exclude=CVS \
190 --exclude='.#*' \
191 --exclude='*~' \
192 `basename ${DESTINATION}`
193}
194
195# Install GCC.
196
197install_gcc() {
198 # Go to the source directory.
199 changedir ${DESTINATION}
200 # Go to the object directory.
201 changedir ${OBJDIR}
202
e74f4b65 203 ${MAKE} install || error "Installation failed"
275d96ed 204}
205
206########################################################################
207# Initialization
208########################################################################
209
210# The CVS server containing the GCC repository.
211CVS_SERVER="gcc.gnu.org"
212# The path to the repository on that server.
213CVS_REPOSITORY="/cvs/gcc"
214# The CVS protocol to use.
215CVS_PROTOCOL="pserver"
216# The username to use when connecting to the server.
217CVS_USERNAME="anoncvs"
218
219# The directory where the checked out GCC will be placed.
220DESTINATION="${HOME}/dev/gcc"
221# The relative path from the top of the source tree to the
222# object directory.
223OBJDIR="objdir"
224
275d96ed 225# The file where the tarred up sources will be placed.
226TARFILE="${HOME}/dev/gcc.tgz"
227
228# Options to pass to configure.
229CONFIGURE_OPTIONS=
c0921e86 230# The `make' program.
231MAKE=${MAKE:-make}
275d96ed 232# Options to pass to make.
60f107a4 233MAKE_BOOTSTRAP_OPTIONS=
275d96ed 234
235# Modes of operation
60f107a4 236BOOTSTRAP=0
275d96ed 237CHECKOUT=0
60f107a4 238CONFIGURE=0
275d96ed 239EXPORT=0
240INSTALL=0
241TEST=0
242UPDATE=0
243
244########################################################################
245# Main Program
246########################################################################
247
248# Parse the options.
fd87d7ed 249while getopts "c:d:m:o:p:t:u:" ARG; do
275d96ed 250 case $ARG in
251 c) CONFIGURE_OPTIONS="${OPTARG}";;
252 d) DESTINATION="${OPTARG}";;
60f107a4 253 m) MAKE_BOOTSTRAP_OPTIONS="${OPTARG}";;
fd87d7ed 254 o) OBJDIR="${OPTARG}";;
275d96ed 255 p) CVS_PROTOCOL="${OPTARG}";;
256 t) CVS_TARGFILE="${OPTARG}";;
1409de39 257 u) CVS_USERNAME="${OPTARG}";;
275d96ed 258 \?) usage;;
259 esac
260done
261shift `expr ${OPTIND} - 1`
262
263# Handle the major modes.
264while [ $# -ne 0 ]; do
265 case $1 in
60f107a4 266 bootstrap) BOOTSTRAP=1;;
267 build) CONFIGURE=1; BOOTSTRAP=1;;
275d96ed 268 checkout) CHECKOUT=1;;
60f107a4 269 configure) CONFIGURE=1;;
275d96ed 270 export) EXPORT=1;;
271 install) INSTALL=1;;
272 test) TEST=1;;
273 update) UPDATE=1;;
274 *) usage;;
275 esac
276 shift
277done
278
279# Check the arguments for sanity.
280if [ ${CHECKOUT} -ne 0 ] && [ ${UPDATE} -ne 0 ]; then
281 error "Cannot checkout and update simultaneously"
282fi
283
275d96ed 284# Checkout the tree.
285if [ ${CHECKOUT} -ne 0 ]; then
286 checkout_gcc
287elif [ ${UPDATE} -ne 0 ]; then
288 update_gcc
289fi
290
60f107a4 291# Configure to build the tree.
292if [ ${CONFIGURE} -ne 0 ]; then
293 configure_gcc
294fi
295
296# Bootstrap the compiler.
297if [ ${BOOTSTRAP} -ne 0 ]; then
298 bootstrap_gcc
275d96ed 299fi
300
301# Test the compiler
302if [ ${TEST} -ne 0 ]; then
303 test_gcc
304fi
305
306# Install the compiler.
307if [ ${INSTALL} -ne 0 ]; then
308 install_gcc
309fi
310
311# Export the sources
312if [ ${EXPORT} -ne 0 ]; then
313 export_gcc
314fi