OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [contrib/] [gcc_build] - Diff between revs 154 and 816

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 154 Rev 816
#! /bin/sh
#! /bin/sh
########################################################################
########################################################################
#
#
# File:   gcc_build
# File:   gcc_build
# Author: Mark Mitchell
# Author: Mark Mitchell
# Date:   2000-07-10
# Date:   2000-07-10
#
#
# Adapted to Subversion by Ben Elliston , 2005-07-14.
# Adapted to Subversion by Ben Elliston , 2005-07-14.
#
#
# Contents:
# Contents:
#   Script to automatically download and build GCC.
#   Script to automatically download and build GCC.
#
#
# Copyright (c) 2000, 2001, 2003, 2005 Free Software Foundation.
# Copyright (c) 2000, 2001, 2003, 2005 Free Software Foundation.
#
#
# This file is part of GCC.
# This file is part of GCC.
#
#
# GCC is free software; you can redistribute it and/or modify
# GCC is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# any later version.
#
#
# GCC is distributed in the hope that it will be useful,
# GCC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with GCC; see the file COPYING.  If not, write to
# along with GCC; see the file COPYING.  If not, write to
# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
# Boston, MA 02110-1301, USA.
#
#
########################################################################
########################################################################
########################################################################
########################################################################
# Notes
# Notes
########################################################################
########################################################################
# You can set the following variables in the environment.  They
# You can set the following variables in the environment.  They
# have no corresponding command-line options because they should
# have no corresponding command-line options because they should
# only be needed infrequently:
# only be needed infrequently:
#
#
#   MAKE                        The path to `make'.
#   MAKE                        The path to `make'.
########################################################################
########################################################################
# Functions
# Functions
########################################################################
########################################################################
# Issue the error message given by $1 and exit with a non-zero
# Issue the error message given by $1 and exit with a non-zero
# exit code.
# exit code.
error() {
error() {
    echo "gcc_build: error: $1"
    echo "gcc_build: error: $1"
    exit 1
    exit 1
}
}
# Issue a usage message explaining how to use this script.
# Issue a usage message explaining how to use this script.
usage() {
usage() {
cat <
cat <
gcc_build        [-c configure_options]
gcc_build        [-c configure_options]
                 [-d destination_directory]
                 [-d destination_directory]
                 [-m make_boot_options]
                 [-m make_boot_options]
                 [-o objdir]
                 [-o objdir]
                 [-b branch_name]
                 [-b branch_name]
                 [-u username]
                 [-u username]
                 [-p protocol]
                 [-p protocol]
                 [-t tarfile]
                 [-t tarfile]
                 [-x make_check_options]
                 [-x make_check_options]
                 [bootstrap]
                 [bootstrap]
                 [build]
                 [build]
                 [checkout]
                 [checkout]
                 [configure]
                 [configure]
                 [export]
                 [export]
                 [install]
                 [install]
                 [test]
                 [test]
                 [update]
                 [update]
EOF
EOF
    exit 1
    exit 1
}
}
# Change to the directory given by $1.
# Change to the directory given by $1.
changedir() {
changedir() {
    cd $1 || \
    cd $1 || \
        error "Could not change directory to $1"
        error "Could not change directory to $1"
}
}
# Checkout a fresh copy of the GCC build tree.
# Checkout a fresh copy of the GCC build tree.
checkout_gcc() {
checkout_gcc() {
    # If the destination already exists, don't risk destroying it.
    # If the destination already exists, don't risk destroying it.
    test -e ${DESTINATION} && \
    test -e ${DESTINATION} && \
        error "${DESTINATION} already exists"
        error "${DESTINATION} already exists"
    # Checkout the tree
    # Checkout the tree
    test -n "${SVN_USERNAME}" && SVN_USERNAME="${SVN_USERNAME}@"
    test -n "${SVN_USERNAME}" && SVN_USERNAME="${SVN_USERNAME}@"
    SVNROOT="${SVN_PROTOCOL}://${SVN_USERNAME}${SVN_SERVER}${SVN_REPOSITORY}${SVN_BRANCH}"
    SVNROOT="${SVN_PROTOCOL}://${SVN_USERNAME}${SVN_SERVER}${SVN_REPOSITORY}${SVN_BRANCH}"
    $GCC_SVN co $SVNROOT ${DESTINATION} || \
    $GCC_SVN co $SVNROOT ${DESTINATION} || \
        error "Could not check out GCC"
        error "Could not check out GCC"
}
}
# Update GCC.
# Update GCC.
update_gcc() {
update_gcc() {
    # If the destination does not already exist, complain.
    # If the destination does not already exist, complain.
    test -d ${DESTINATION} || \
    test -d ${DESTINATION} || \
        error "${DESTINATION} does not exist"
        error "${DESTINATION} does not exist"
    # Enter the destination directory.
    # Enter the destination directory.
    changedir ${DESTINATION}
    changedir ${DESTINATION}
    # Update the tree
    # Update the tree
    ./contrib/gcc_update || \
    ./contrib/gcc_update || \
        error "Could not update GCC"
        error "Could not update GCC"
}
}
# Configure for a build of GCC.
# Configure for a build of GCC.
configure_gcc() {
configure_gcc() {
    # Go to the source directory.
    # Go to the source directory.
    changedir ${DESTINATION}
    changedir ${DESTINATION}
    # Remove the object directory.
    # Remove the object directory.
    rm -rf ${OBJDIR}
    rm -rf ${OBJDIR}
    # Create it again.
    # Create it again.
    mkdir ${OBJDIR} || \
    mkdir ${OBJDIR} || \
        error "Could not create ${OBJDIR}"
        error "Could not create ${OBJDIR}"
    # Enter it.
    # Enter it.
    changedir ${OBJDIR}
    changedir ${OBJDIR}
    # Configure the tree.
    # Configure the tree.
    echo "Configuring: ${DESTINATION}/configure ${CONFIGURE_OPTIONS}"
    echo "Configuring: ${DESTINATION}/configure ${CONFIGURE_OPTIONS}"
    eval ${DESTINATION}/configure ${CONFIGURE_OPTIONS} || \
    eval ${DESTINATION}/configure ${CONFIGURE_OPTIONS} || \
        error "Could not configure the compiler"
        error "Could not configure the compiler"
}
}
# Bootstrap GCC.  Assume configuration has already occurred.
# Bootstrap GCC.  Assume configuration has already occurred.
bootstrap_gcc() {
bootstrap_gcc() {
    # Go to the source directory.
    # Go to the source directory.
    changedir ${DESTINATION}
    changedir ${DESTINATION}
    # Go to the object directory.
    # Go to the object directory.
    changedir ${OBJDIR}
    changedir ${OBJDIR}
    # Bootstrap the compiler
    # Bootstrap the compiler
    echo "Building: ${MAKE} ${MAKE_BOOTSTRAP_OPTIONS} bootstrap"
    echo "Building: ${MAKE} ${MAKE_BOOTSTRAP_OPTIONS} bootstrap"
    eval ${MAKE} ${MAKE_BOOTSTRAP_OPTIONS} bootstrap || \
    eval ${MAKE} ${MAKE_BOOTSTRAP_OPTIONS} bootstrap || \
        error "Could not bootstrap the compiler"
        error "Could not bootstrap the compiler"
}
}
# Test GCC.
# Test GCC.
test_gcc() {
test_gcc() {
    # Go to the source directory.
    # Go to the source directory.
    changedir ${DESTINATION}
    changedir ${DESTINATION}
    # Go to the object directory.
    # Go to the object directory.
    changedir ${OBJDIR}
    changedir ${OBJDIR}
    echo "Running tests...  This will take a while."
    echo "Running tests...  This will take a while."
    eval \${MAKE} -k ${MAKE_CHECK_OPTIONS} check
    eval \${MAKE} -k ${MAKE_CHECK_OPTIONS} check
    ${DESTINATION}/contrib/test_summary
    ${DESTINATION}/contrib/test_summary
}
}
# Export the GCC source tree.
# Export the GCC source tree.
export_gcc() {
export_gcc() {
    # Go to the source directory.
    # Go to the source directory.
    changedir ${DESTINATION}
    changedir ${DESTINATION}
    # Go up one level.
    # Go up one level.
    changedir ..
    changedir ..
    # Build a tarball of the source directory.
    # Build a tarball of the source directory.
    tar czf ${TARFILE} \
    tar czf ${TARFILE} \
        --exclude=${OBJDIR} \
        --exclude=${OBJDIR} \
        --exclude=.svn \
        --exclude=.svn \
        --exclude='.#*' \
        --exclude='.#*' \
        --exclude='*~' \
        --exclude='*~' \
        `basename ${DESTINATION}`
        `basename ${DESTINATION}`
}
}
# Install GCC.
# Install GCC.
install_gcc() {
install_gcc() {
    # Go to the source directory.
    # Go to the source directory.
    changedir ${DESTINATION}
    changedir ${DESTINATION}
    # Go to the object directory.
    # Go to the object directory.
    changedir ${OBJDIR}
    changedir ${OBJDIR}
    ${MAKE} install || error "Installation failed"
    ${MAKE} install || error "Installation failed"
}
}
########################################################################
########################################################################
# Initialization
# Initialization
########################################################################
########################################################################
# SVN command
# SVN command
GCC_SVN=${GCC_SVN-${SVN-svn}}
GCC_SVN=${GCC_SVN-${SVN-svn}}
# The SVN server containing the GCC repository.
# The SVN server containing the GCC repository.
SVN_SERVER="gcc.gnu.org"
SVN_SERVER="gcc.gnu.org"
# The path to the repository on that server.
# The path to the repository on that server.
SVN_REPOSITORY="/svn/gcc/"
SVN_REPOSITORY="/svn/gcc/"
# The branch to check out from that server.
# The branch to check out from that server.
# Defaults to trunk if no branch is defined with -b.
# Defaults to trunk if no branch is defined with -b.
SVN_BRANCH=""
SVN_BRANCH=""
# The SVN protocol to use.
# The SVN protocol to use.
SVN_PROTOCOL="svn"
SVN_PROTOCOL="svn"
# The username to use when connecting to the server.
# The username to use when connecting to the server.
# An empty string means anonymous.
# An empty string means anonymous.
SVN_USERNAME=""
SVN_USERNAME=""
# The directory where the checked out GCC will be placed.
# The directory where the checked out GCC will be placed.
DESTINATION="${HOME}/dev/gcc"
DESTINATION="${HOME}/dev/gcc"
# The relative path from the top of the source tree to the
# The relative path from the top of the source tree to the
# object directory.
# object directory.
OBJDIR="objdir"
OBJDIR="objdir"
# The file where the tarred up sources will be placed.
# The file where the tarred up sources will be placed.
TARFILE="${HOME}/dev/gcc.tgz"
TARFILE="${HOME}/dev/gcc.tgz"
# Options to pass to configure.
# Options to pass to configure.
CONFIGURE_OPTIONS=
CONFIGURE_OPTIONS=
# The `make' program.
# The `make' program.
MAKE=${MAKE:-make}
MAKE=${MAKE:-make}
# Options to pass to "make bootstrap".
# Options to pass to "make bootstrap".
MAKE_BOOTSTRAP_OPTIONS=
MAKE_BOOTSTRAP_OPTIONS=
# Options to pass to "make check".
# Options to pass to "make check".
MAKE_CHECK_OPTIONS=
MAKE_CHECK_OPTIONS=
# Modes of operation
# Modes of operation
BOOTSTRAP=0
BOOTSTRAP=0
CHECKOUT=0
CHECKOUT=0
CONFIGURE=0
CONFIGURE=0
EXPORT=0
EXPORT=0
INSTALL=0
INSTALL=0
TEST=0
TEST=0
UPDATE=0
UPDATE=0
########################################################################
########################################################################
# Main Program
# Main Program
########################################################################
########################################################################
# Issue usage if no parameters are given.
# Issue usage if no parameters are given.
test $# -eq 0 && usage
test $# -eq 0 && usage
# Parse the options.
# Parse the options.
while getopts "c:d:m:o:p:t:b:u:x:" ARG; do
while getopts "c:d:m:o:p:t:b:u:x:" ARG; do
    case $ARG in
    case $ARG in
    c)    CONFIGURE_OPTIONS="${OPTARG}";;
    c)    CONFIGURE_OPTIONS="${OPTARG}";;
    d)    DESTINATION="${OPTARG}";;
    d)    DESTINATION="${OPTARG}";;
    m)    MAKE_BOOTSTRAP_OPTIONS="${OPTARG}";;
    m)    MAKE_BOOTSTRAP_OPTIONS="${OPTARG}";;
    o)    OBJDIR="${OPTARG}";;
    o)    OBJDIR="${OPTARG}";;
    p)    SVN_PROTOCOL="${OPTARG}";;
    p)    SVN_PROTOCOL="${OPTARG}";;
    t)    TARFILE="${OPTARG}";;
    t)    TARFILE="${OPTARG}";;
    x)    MAKE_CHECK_OPTIONS="${OPTARG}";;
    x)    MAKE_CHECK_OPTIONS="${OPTARG}";;
    b)    SVN_BRANCH="${OPTARG}";;
    b)    SVN_BRANCH="${OPTARG}";;
    u)    SVN_USERNAME="${OPTARG}";;
    u)    SVN_USERNAME="${OPTARG}";;
    \?)   usage;;
    \?)   usage;;
    esac
    esac
done
done
shift `expr ${OPTIND} - 1`
shift `expr ${OPTIND} - 1`
# Handle the major modes.
# Handle the major modes.
while [ $# -ne 0 ]; do
while [ $# -ne 0 ]; do
    case $1 in
    case $1 in
    bootstrap) BOOTSTRAP=1;;
    bootstrap) BOOTSTRAP=1;;
    build)    CONFIGURE=1; BOOTSTRAP=1;;
    build)    CONFIGURE=1; BOOTSTRAP=1;;
    checkout) CHECKOUT=1;;
    checkout) CHECKOUT=1;;
    configure) CONFIGURE=1;;
    configure) CONFIGURE=1;;
    export)   EXPORT=1;;
    export)   EXPORT=1;;
    install)  INSTALL=1;;
    install)  INSTALL=1;;
    test)     TEST=1;;
    test)     TEST=1;;
    update)   UPDATE=1;;
    update)   UPDATE=1;;
    *)        usage;;
    *)        usage;;
    esac
    esac
    shift
    shift
done
done
# Check the arguments for sanity.
# Check the arguments for sanity.
if [ ${CHECKOUT} -ne 0 ] && [ ${UPDATE} -ne 0 ]; then
if [ ${CHECKOUT} -ne 0 ] && [ ${UPDATE} -ne 0 ]; then
    error "Cannot checkout and update simultaneously"
    error "Cannot checkout and update simultaneously"
fi
fi
if [ ${CHECKOUT} -eq 0 ] && test -n "${SVN_BRANCH}"; then
if [ ${CHECKOUT} -eq 0 ] && test -n "${SVN_BRANCH}"; then
    error "Branch argument only makes sense when doing a checkout"
    error "Branch argument only makes sense when doing a checkout"
fi
fi
# Validate the branch name.
# Validate the branch name.
if test -n "${SVN_BRANCH}"; then
if test -n "${SVN_BRANCH}"; then
    SVN_BRANCH="branches/${SVN_BRANCH}";
    SVN_BRANCH="branches/${SVN_BRANCH}";
else
else
    SVN_BRANCH="trunk";
    SVN_BRANCH="trunk";
fi
fi
# Checkout the tree.
# Checkout the tree.
if [ ${CHECKOUT} -ne 0 ]; then
if [ ${CHECKOUT} -ne 0 ]; then
    checkout_gcc
    checkout_gcc
elif [ ${UPDATE} -ne 0 ]; then
elif [ ${UPDATE} -ne 0 ]; then
    update_gcc
    update_gcc
fi
fi
# Configure to build the tree.
# Configure to build the tree.
if [ ${CONFIGURE} -ne 0 ]; then
if [ ${CONFIGURE} -ne 0 ]; then
    configure_gcc
    configure_gcc
fi
fi
# Bootstrap the compiler.
# Bootstrap the compiler.
if [ ${BOOTSTRAP} -ne 0 ]; then
if [ ${BOOTSTRAP} -ne 0 ]; then
    bootstrap_gcc
    bootstrap_gcc
fi
fi
# Test the compiler
# Test the compiler
if [ ${TEST} -ne 0 ]; then
if [ ${TEST} -ne 0 ]; then
    test_gcc
    test_gcc
fi
fi
# Install the compiler.
# Install the compiler.
if [ ${INSTALL} -ne 0 ]; then
if [ ${INSTALL} -ne 0 ]; then
    install_gcc
    install_gcc
fi
fi
# Export the sources
# Export the sources
if [ ${EXPORT} -ne 0 ]; then
if [ ${EXPORT} -ne 0 ]; then
    export_gcc
    export_gcc
fi
fi
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.