2000-07-16 20:05:46 +02:00
|
|
|
#! /bin/sh
|
|
|
|
|
|
|
|
########################################################################
|
|
|
|
#
|
2000-07-16 21:25:48 +02:00
|
|
|
# File: gcc_build
|
2000-07-16 20:05:46 +02:00
|
|
|
# Author: Mark Mitchell
|
|
|
|
# Date: 07/10/2000
|
|
|
|
#
|
|
|
|
# Contents:
|
|
|
|
# Script to automatically download and build GCC.
|
|
|
|
#
|
2001-05-22 08:45:44 +02:00
|
|
|
# Copyright (c) 2000, 2001 Free Software Foundation.
|
2000-07-16 20:05:46 +02:00
|
|
|
#
|
|
|
|
# This file is part of GNU CC.
|
|
|
|
#
|
|
|
|
# GNU CC is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
# any later version.
|
|
|
|
#
|
|
|
|
# GNU CC is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with GNU CC; see the file COPYING. If not, write to
|
|
|
|
# the Free Software Foundation, 59 Temple Place - Suite 330,
|
|
|
|
# Boston, MA 02111-1307, USA.
|
|
|
|
#
|
|
|
|
########################################################################
|
|
|
|
|
|
|
|
########################################################################
|
|
|
|
# Notes
|
|
|
|
########################################################################
|
|
|
|
|
|
|
|
# If you are using password-based CVS, you must manually log in, and
|
|
|
|
# not log out from, the CVS server before running this script.
|
|
|
|
|
2000-11-01 02:58:12 +01:00
|
|
|
# You can set the following variables in the environment. They
|
|
|
|
# have no corresponding command-line options because they should
|
|
|
|
# only be needed infrequently:
|
|
|
|
#
|
|
|
|
# MAKE The path to `make'.
|
|
|
|
|
2000-07-16 20:05:46 +02:00
|
|
|
########################################################################
|
|
|
|
# Functions
|
|
|
|
########################################################################
|
|
|
|
|
|
|
|
# Issue the error message given by $1 and exit with a non-zero
|
|
|
|
# exit code.
|
|
|
|
|
|
|
|
error() {
|
2000-07-16 20:08:33 +02:00
|
|
|
echo "gcc_build: error: $1"
|
2000-07-16 20:05:46 +02:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Issue a usage message explaining how to use this script.
|
|
|
|
|
|
|
|
usage() {
|
|
|
|
cat <<EOF
|
2000-07-16 20:08:33 +02:00
|
|
|
gcc_build [-c configure_options]
|
2000-07-16 20:05:46 +02:00
|
|
|
[-d destination_directory]
|
2000-11-08 20:41:19 +01:00
|
|
|
[-m make_boot_options]
|
2000-11-12 01:29:37 +01:00
|
|
|
[-o objdir]
|
2000-07-16 20:05:46 +02:00
|
|
|
[-u username]
|
|
|
|
[-p protocol]
|
|
|
|
[-t tarfile]
|
2000-11-08 20:41:19 +01:00
|
|
|
[bootstrap]
|
2000-07-16 20:05:46 +02:00
|
|
|
[build]
|
|
|
|
[checkout]
|
2000-11-08 20:41:19 +01:00
|
|
|
[configure]
|
2000-07-16 20:05:46 +02:00
|
|
|
[export]
|
|
|
|
[install]
|
|
|
|
[test]
|
|
|
|
[update]
|
|
|
|
EOF
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Change to the directory given by $1.
|
|
|
|
|
|
|
|
changedir() {
|
|
|
|
cd $1 || \
|
|
|
|
error "Could not change directory to $1"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Set up CVS environment variables
|
|
|
|
|
|
|
|
cvs_setup() {
|
|
|
|
CVSROOT=":${CVS_PROTOCOL}:${CVS_USERNAME}@"
|
|
|
|
CVSROOT="${CVSROOT}${CVS_SERVER}:${CVS_REPOSITORY}"
|
|
|
|
export CVSROOT
|
|
|
|
}
|
|
|
|
|
|
|
|
# Checkout a fresh copy of the GCC build tree.
|
|
|
|
|
|
|
|
checkout_gcc() {
|
|
|
|
# Tell CVS where to find everything.
|
|
|
|
cvs_setup
|
|
|
|
|
|
|
|
# If the destination already exists, don't risk destroying it.
|
|
|
|
test -e ${DESTINATION} && \
|
|
|
|
error "${DESTINATION} already exists"
|
|
|
|
|
|
|
|
# CVS doesn't allow an absolute path for the destination directory.
|
|
|
|
DESTINATION_PARENT=`dirname ${DESTINATION}`
|
|
|
|
test -d ${DESTINATION_PARENT} || \
|
|
|
|
error "${DESTINATION_PARENT} is not a directory"
|
|
|
|
changedir ${DESTINATION_PARENT}
|
|
|
|
|
|
|
|
# Checkout the tree
|
|
|
|
cvs -z 9 co -d `basename ${DESTINATION}` gcc || \
|
|
|
|
error "Could not check out GCC"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Update GCC.
|
|
|
|
|
|
|
|
update_gcc() {
|
|
|
|
# Tell CVS where to find everything
|
|
|
|
cvs_setup
|
|
|
|
|
|
|
|
# If the destination does not already exist, complain.
|
|
|
|
test -d ${DESTINATION} || \
|
|
|
|
error "{$DESTINATION} does not exist"
|
|
|
|
# Enter the destination directory.
|
|
|
|
changedir ${DESTINATION}
|
|
|
|
|
|
|
|
# Update the tree
|
2001-05-22 08:45:44 +02:00
|
|
|
./contrib/gcc_update -d || \
|
2000-07-16 20:05:46 +02:00
|
|
|
error "Could not update GCC"
|
|
|
|
}
|
|
|
|
|
2000-11-08 20:41:19 +01:00
|
|
|
# Configure for a build of GCC.
|
2000-07-16 20:05:46 +02:00
|
|
|
|
2000-11-08 20:41:19 +01:00
|
|
|
configure_gcc() {
|
2000-07-16 20:05:46 +02:00
|
|
|
# Go to the source directory.
|
|
|
|
changedir ${DESTINATION}
|
|
|
|
|
|
|
|
# Remove the object directory.
|
|
|
|
rm -rf ${OBJDIR}
|
|
|
|
# Create it again.
|
|
|
|
mkdir ${OBJDIR} || \
|
|
|
|
error "Could not create ${OBJDIR}"
|
|
|
|
# Enter it.
|
|
|
|
changedir ${OBJDIR}
|
|
|
|
|
|
|
|
# Configure the tree.
|
2001-06-11 23:13:36 +02:00
|
|
|
echo "Configuring: ${DESTINATION}/configure ${CONFIGURE_OPTIONS}"
|
2000-11-21 20:16:45 +01:00
|
|
|
eval ${DESTINATION}/configure ${CONFIGURE_OPTIONS} || \
|
2000-11-08 20:41:19 +01:00
|
|
|
error "Could not configure the compiler"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Bootstrap GCC. Assume configuration has already occurred.
|
|
|
|
|
|
|
|
bootstrap_gcc() {
|
|
|
|
# Go to the source directory.
|
|
|
|
changedir ${DESTINATION}
|
|
|
|
# Go to the object directory.
|
|
|
|
changedir ${OBJDIR}
|
2000-07-16 20:05:46 +02:00
|
|
|
|
|
|
|
# Bootstrap the compiler
|
2001-06-11 23:13:36 +02:00
|
|
|
echo "Building: ${MAKE} ${MAKE_BOOTSTRAP_OPTIONS} bootstrap"
|
2000-11-21 20:16:45 +01:00
|
|
|
eval ${MAKE} ${MAKE_BOOTSTRAP_OPTIONS} bootstrap || \
|
2000-11-08 20:41:19 +01:00
|
|
|
error "Could not bootstrap the compiler"
|
2000-07-16 20:05:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Test GCC.
|
|
|
|
|
|
|
|
test_gcc() {
|
|
|
|
# Go to the source directory.
|
|
|
|
changedir ${DESTINATION}
|
|
|
|
# Go to the object directory.
|
|
|
|
changedir ${OBJDIR}
|
|
|
|
|
|
|
|
echo "Running tests... This will take a while."
|
2000-11-21 20:16:45 +01:00
|
|
|
${MAKE} -k check
|
|
|
|
${DESTINATION}/contrib/test_summary
|
2000-07-16 20:05:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Export the GCC source tree.
|
|
|
|
|
|
|
|
export_gcc() {
|
|
|
|
# Go to the source directory.
|
|
|
|
changedir ${DESTINATION}
|
|
|
|
# Go up one level.
|
|
|
|
changedir ..
|
2000-10-26 03:18:12 +02:00
|
|
|
# Build a tarball of the source directory.
|
2000-07-16 20:05:46 +02:00
|
|
|
tar czf ${TARFILE} \
|
|
|
|
--exclude=${OBJDIR} \
|
|
|
|
--exclude=CVS \
|
|
|
|
--exclude='.#*' \
|
|
|
|
--exclude='*~' \
|
|
|
|
`basename ${DESTINATION}`
|
|
|
|
}
|
|
|
|
|
|
|
|
# Install GCC.
|
|
|
|
|
|
|
|
install_gcc() {
|
|
|
|
# Go to the source directory.
|
|
|
|
changedir ${DESTINATION}
|
|
|
|
# Go to the object directory.
|
|
|
|
changedir ${OBJDIR}
|
|
|
|
|
2000-11-21 20:16:45 +01:00
|
|
|
${MAKE} install || error "Installation failed"
|
2000-07-16 20:05:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
########################################################################
|
|
|
|
# Initialization
|
|
|
|
########################################################################
|
|
|
|
|
|
|
|
# The CVS server containing the GCC repository.
|
|
|
|
CVS_SERVER="gcc.gnu.org"
|
|
|
|
# The path to the repository on that server.
|
|
|
|
CVS_REPOSITORY="/cvs/gcc"
|
|
|
|
# The CVS protocol to use.
|
|
|
|
CVS_PROTOCOL="pserver"
|
|
|
|
# The username to use when connecting to the server.
|
|
|
|
CVS_USERNAME="anoncvs"
|
|
|
|
|
|
|
|
# The directory where the checked out GCC will be placed.
|
|
|
|
DESTINATION="${HOME}/dev/gcc"
|
|
|
|
# The relative path from the top of the source tree to the
|
|
|
|
# object directory.
|
|
|
|
OBJDIR="objdir"
|
|
|
|
|
|
|
|
# The file where the tarred up sources will be placed.
|
|
|
|
TARFILE="${HOME}/dev/gcc.tgz"
|
|
|
|
|
|
|
|
# Options to pass to configure.
|
|
|
|
CONFIGURE_OPTIONS=
|
2000-11-01 02:58:12 +01:00
|
|
|
# The `make' program.
|
|
|
|
MAKE=${MAKE:-make}
|
2000-07-16 20:05:46 +02:00
|
|
|
# Options to pass to make.
|
2000-11-08 20:41:19 +01:00
|
|
|
MAKE_BOOTSTRAP_OPTIONS=
|
2000-07-16 20:05:46 +02:00
|
|
|
|
|
|
|
# Modes of operation
|
2000-11-08 20:41:19 +01:00
|
|
|
BOOTSTRAP=0
|
2000-07-16 20:05:46 +02:00
|
|
|
CHECKOUT=0
|
2000-11-08 20:41:19 +01:00
|
|
|
CONFIGURE=0
|
2000-07-16 20:05:46 +02:00
|
|
|
EXPORT=0
|
|
|
|
INSTALL=0
|
|
|
|
TEST=0
|
|
|
|
UPDATE=0
|
|
|
|
|
|
|
|
########################################################################
|
|
|
|
# Main Program
|
|
|
|
########################################################################
|
|
|
|
|
|
|
|
# Parse the options.
|
2000-11-12 01:29:37 +01:00
|
|
|
while getopts "c:d:m:o:p:t:u:" ARG; do
|
2000-07-16 20:05:46 +02:00
|
|
|
case $ARG in
|
|
|
|
c) CONFIGURE_OPTIONS="${OPTARG}";;
|
|
|
|
d) DESTINATION="${OPTARG}";;
|
2000-11-08 20:41:19 +01:00
|
|
|
m) MAKE_BOOTSTRAP_OPTIONS="${OPTARG}";;
|
2000-11-12 01:29:37 +01:00
|
|
|
o) OBJDIR="${OPTARG}";;
|
2000-07-16 20:05:46 +02:00
|
|
|
p) CVS_PROTOCOL="${OPTARG}";;
|
|
|
|
t) CVS_TARGFILE="${OPTARG}";;
|
2000-10-26 03:18:12 +02:00
|
|
|
u) CVS_USERNAME="${OPTARG}";;
|
2000-07-16 20:05:46 +02:00
|
|
|
\?) usage;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift `expr ${OPTIND} - 1`
|
|
|
|
|
|
|
|
# Handle the major modes.
|
|
|
|
while [ $# -ne 0 ]; do
|
|
|
|
case $1 in
|
2000-11-08 20:41:19 +01:00
|
|
|
bootstrap) BOOTSTRAP=1;;
|
|
|
|
build) CONFIGURE=1; BOOTSTRAP=1;;
|
2000-07-16 20:05:46 +02:00
|
|
|
checkout) CHECKOUT=1;;
|
2000-11-08 20:41:19 +01:00
|
|
|
configure) CONFIGURE=1;;
|
2000-07-16 20:05:46 +02:00
|
|
|
export) EXPORT=1;;
|
|
|
|
install) INSTALL=1;;
|
|
|
|
test) TEST=1;;
|
|
|
|
update) UPDATE=1;;
|
|
|
|
*) usage;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
# Check the arguments for sanity.
|
|
|
|
if [ ${CHECKOUT} -ne 0 ] && [ ${UPDATE} -ne 0 ]; then
|
|
|
|
error "Cannot checkout and update simultaneously"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Checkout the tree.
|
|
|
|
if [ ${CHECKOUT} -ne 0 ]; then
|
|
|
|
checkout_gcc
|
|
|
|
elif [ ${UPDATE} -ne 0 ]; then
|
|
|
|
update_gcc
|
|
|
|
fi
|
|
|
|
|
2000-11-08 20:41:19 +01:00
|
|
|
# Configure to build the tree.
|
|
|
|
if [ ${CONFIGURE} -ne 0 ]; then
|
|
|
|
configure_gcc
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Bootstrap the compiler.
|
|
|
|
if [ ${BOOTSTRAP} -ne 0 ]; then
|
|
|
|
bootstrap_gcc
|
2000-07-16 20:05:46 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Test the compiler
|
|
|
|
if [ ${TEST} -ne 0 ]; then
|
|
|
|
test_gcc
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Install the compiler.
|
|
|
|
if [ ${INSTALL} -ne 0 ]; then
|
|
|
|
install_gcc
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Export the sources
|
|
|
|
if [ ${EXPORT} -ne 0 ]; then
|
|
|
|
export_gcc
|
|
|
|
fi
|