#!/bin/bash
|
#!/bin/bash
|
|
|
# Copyright (C) 2009, 2010 Embecosm Limited
|
# Copyright (C) 2009, 2010 Embecosm Limited
|
# Copyright (C) 2010 ORSoC AB
|
# Copyright (C) 2010 ORSoC AB
|
|
|
# Contributor Joern Rennecke <joern.rennecke@embecosm.com>
|
# Contributor Joern Rennecke <joern.rennecke@embecosm.com>
|
# Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
|
# Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
|
# Contributor Julius Baxter <julius.baxter@orsoc.se>
|
# Contributor Julius Baxter <julius.baxter@orsoc.se>
|
|
|
# This file is a script to build key elements of the OpenRISC tool chain
|
# This file is a script to build key elements of the OpenRISC tool chain
|
|
|
# This program is free software; you can redistribute it and/or modify it
|
# This program 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
|
# under the terms of the GNU General Public License as published by the Free
|
# Software Foundation; either version 3 of the License, or (at your option)
|
# Software Foundation; either version 3 of the License, or (at your option)
|
# any later version.
|
# any later version.
|
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
# more details.
|
# more details.
|
|
|
# You should have received a copy of the GNU General Public License along
|
# You should have received a copy of the GNU General Public License along
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
# This script builds two GNU C/C++ tool chains:
|
# This script builds two GNU C/C++ tool chains:
|
|
|
# 1. With target or32-elf (fully or32-unknown-elf-newlib) for use on bare
|
# 1. With target or32-elf (fully or32-unknown-elf-newlib) for use on bare
|
# metal targets
|
# metal targets
|
|
|
# 2. With target or32-linux (fully or32-unknown-linux-uclibc) for use with
|
# 2. With target or32-linux (fully or32-unknown-linux-uclibc) for use with
|
# OpenRISC linux.
|
# OpenRISC linux.
|
|
|
# In both cases the binutils, gcc and C/C++ libraries are built using a
|
# In both cases the binutils, gcc and C/C++ libraries are built using a
|
# unified source directory created by linking the top level directories from
|
# unified source directory created by linking the top level directories from
|
# binutils and gcc. For the first tool chain, newlib and libgloss are also
|
# binutils and gcc. For the first tool chain, newlib and libgloss are also
|
# linked into the unified source directory.
|
# linked into the unified source directory.
|
|
|
# GDB 7.2 does not have fully compatible binutils directories, so is built
|
# GDB 7.2 does not have fully compatible binutils directories, so is built
|
# separately.
|
# separately.
|
|
|
# For the or32-linux tool chain, the system headers are needed to bootstrap
|
# For the or32-linux tool chain, the system headers are needed to bootstrap
|
# the building of libgcc. This is achieved by a 2 stage process
|
# the building of libgcc. This is achieved by a 2 stage process
|
|
|
# 1. Configure, build and install gcc for C only for or32-linux using the host
|
# 1. Configure, build and install gcc for C only for or32-linux using the host
|
# system's headers, installing into a temporary prefix.
|
# system's headers, installing into a temporary prefix.
|
|
|
# 2. Clean the gcc build directory and reconfigure, build and install gcc for
|
# 2. Clean the gcc build directory and reconfigure, build and install gcc for
|
# C and C++ using the headers from the temporary prefix.
|
# C and C++ using the headers from the temporary prefix.
|
|
|
# Once this is complete, the Linux headers are installed and uClibc can be
|
# Once this is complete, the Linux headers are installed and uClibc can be
|
# built.
|
# built.
|
|
|
# The following arguments control how the script runs:
|
# The following arguments control how the script runs:
|
|
|
# --force
|
# --force
|
# Ensure the unified source directory and build directories are recreated.
|
# Ensure the unified source directory and build directories are recreated.
|
|
|
# --prefix <dir>
|
# --prefix <dir>
|
# Specify the install directory (default /opt/or32-new)
|
# Specify the install directory (default /opt/or32-new)
|
|
|
# --prefix-tmp <dir>
|
# --prefix-tmp <dir>
|
# Specify the temporary install directory (default /tmp/or32-tmp-${USER}).
|
# Specify the temporary install directory (default /tmp/or32-tmp-${USER}).
|
# Incorporating the user name avoid name clashes with other users
|
# Incorporating the user name avoid name clashes with other users
|
|
|
# --unisrc-dir <dir>
|
# --unisrc-dir <dir>
|
# Specify the unified source directory (default unisrc)
|
# Specify the unified source directory (default unisrc)
|
|
|
# --build-dir-elf <dir>
|
# --build-dir-elf <dir>
|
# Specify the build directory for the newlib (or32-elf) tool chain
|
# Specify the build directory for the newlib (or32-elf) tool chain
|
# (default bd-elf).
|
# (default bd-elf).
|
|
|
# --build-dir-elf-gdb <dir>
|
# --build-dir-elf-gdb <dir>
|
# Specify the build directory for the newlib (or32-elf) GDB (default
|
# Specify the build directory for the newlib (or32-elf) GDB (default
|
# bd-elf-gdb).
|
# bd-elf-gdb).
|
|
|
# --build-dir-linux <dir>
|
# --build-dir-linux <dir>
|
# Specify the build directory for the uClibc (or32-linux) tool chain
|
# Specify the build directory for the uClibc (or32-linux) tool chain
|
# (default bd-linux)
|
# (default bd-linux)
|
|
|
# --build-dir-linux-gdb <dir>
|
# --build-dir-linux-gdb <dir>
|
# Specify the build directory for the uClibc (or32-linux) GDB (default
|
# Specify the build directory for the uClibc (or32-linux) GDB (default
|
# bd-linux-gdb)
|
# bd-linux-gdb)
|
|
|
# --or1ksim-dir <dir>
|
# --or1ksim-dir <dir>
|
# Specify the Or1ksim installation directory. Used by GDB, which links in
|
# Specify the Or1ksim installation directory. Used by GDB, which links in
|
# the Or1ksim simulator (default /opt/or1ksim-new)
|
# the Or1ksim simulator (default /opt/or1ksim-new)
|
|
|
# --binutils-dir
|
# --binutils-dir
|
# Source directory for binutils (default binutils-2.20.1)
|
# Source directory for binutils (default binutils-2.20.1)
|
|
|
# --gcc-dir
|
# --gcc-dir
|
# Source directory for gcc (default gcc-4.5.1')
|
# Source directory for gcc (default gcc-4.5.1')
|
|
|
# --newlib-dir
|
# --newlib-dir
|
# Source directory for newlib (default newlib-1.18.0)
|
# Source directory for newlib (default newlib-1.18.0)
|
|
|
# --uclibc_dir
|
# --uclibc-dir
|
# Source directory for uClibc (default uclibc-0.9.31)
|
# Source directory for uClibc (default uclibc-0.9.31)
|
|
|
# --gdb_dir
|
# --gdb-dir
|
# Source directory for gdb (default gdb-7.2)
|
# Source directory for gdb (default gdb-7.2)
|
|
|
# --linux_dir
|
# --linux-dir
|
# Source directory for Linux (default linux-2.6.35)
|
# Source directory for Linux (default linux-2.6.35)
|
|
|
# --no-or32-elf
|
# --no-or32-elf
|
# Don't configure, build and install the newlib (or32-elf) tool chain.
|
# Don't configure, build and install the newlib (or32-elf) tool chain.
|
|
|
# --no-or32-linux
|
# --no-or32-linux
|
# Don't configure, build and install the uClibc (or32-linux) tool chain.
|
# Don't configure, build and install the uClibc (or32-linux) tool chain.
|
|
|
# --nolink
|
# --nolink
|
# Don't build the unified source directory (default is to build it)
|
# Don't build the unified source directory (default is to build it)
|
|
|
# --noconfig
|
# --noconfig
|
# Don't run configure. Note that this will break the two stage build of
|
# Don't run configure. Note that this will break the two stage build of
|
# gcc for Linux, so it should only be used if at least one of the uClibc
|
# gcc for Linux, so it should only be used if at least one of the uClibc
|
# stages is being omitted (default is to configure)
|
# stages is being omitted (default is to configure)
|
|
|
# --nobuild
|
# --nobuild
|
# Don't build any tools. Useful just to reinstall stuff (default is to
|
# Don't build any tools. Useful just to reinstall stuff (default is to
|
# build).
|
# build).
|
|
|
# --check
|
# --check
|
# Run DejaGnu tests using the or32-elf tool chain (default do not run).
|
# Run DejaGnu tests using the or32-elf tool chain (default do not run).
|
|
|
# --noinstall
|
# --noinstall
|
# Don't run install. Beware that this will omit the installation of Linux
|
# Don't run install. Beware that this will omit the installation of Linux
|
# headers, required for uClibc building and the installation of headers
|
# headers, required for uClibc building and the installation of headers
|
# from stage1 of gcc for Linux, required for stage2 of gcc for Linux. So
|
# from stage1 of gcc for Linux, required for stage2 of gcc for Linux. So
|
# only use if at least one of the uClibc stages is being omitted (default
|
# only use if at least one of the uClibc stages is being omitted (default
|
# is to install).
|
# is to install).
|
|
|
# --no-newlib
|
# --no-newlib
|
# Don't build newlib (default is to build newlib)
|
# Don't build newlib (default is to build newlib)
|
|
|
# --no-uclibc
|
# --no-uclibc
|
# Don't build uClibc (default is to build uClibc)
|
# Don't build uClibc (default is to build uClibc)
|
|
|
# --no-uclibc-stage1
|
# --no-uclibc-stage1
|
# Don't do the stage1 build of gcc for Linux (default is to build stage1).
|
# Don't do the stage1 build of gcc for Linux (default is to build stage1).
|
|
|
# --no-uclibc-stage2
|
# --no-uclibc-stage2
|
# Don't do the stage2 build of gcc for Linux (default is to build stage2).
|
# Don't do the stage2 build of gcc for Linux (default is to build stage2).
|
|
|
# --help
|
# --help
|
# List these options and exit
|
# List these options and exit
|
|
|
# In general global variables track each of these options. In addition the
|
# In general global variables track each of these options. In addition the
|
# following global variables are used:
|
# following global variables are used:
|
|
|
# target - the current target (or32-elf or or32-linux).
|
# target - the current target (or32-elf or or32-linux).
|
|
|
|
|
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
# Set the default values of all parameters
|
# Set the default values of all parameters
|
function set_defaults {
|
function set_defaults {
|
# Public params
|
# Public params
|
force_flag="false"
|
force_flag="false"
|
prefix="/opt/or32-new"
|
prefix="/opt/or32-new"
|
prefix_tmp="/tmp/or32-tmp-${USER}"
|
prefix_tmp="/tmp/or32-tmp-${USER}"
|
unisrc_dir="unisrc"
|
unisrc_dir="unisrc"
|
bd_elf="bd-elf"
|
bd_elf="bd-elf"
|
bd_elf_gdb="bd-elf-gdb"
|
bd_elf_gdb="bd-elf-gdb"
|
bd_linux="bd-linux"
|
bd_linux="bd-linux"
|
bd_linux_gdb="bd-linux-gdb"
|
bd_linux_gdb="bd-linux-gdb"
|
or1ksim_dir="/opt/or1ksim-new"
|
or1ksim_dir="/opt/or1ksim-new"
|
binutils_dir="binutils-2.20.1"
|
binutils_dir="binutils-2.20.1"
|
gcc_dir="gcc-4.5.1"
|
gcc_dir="gcc-4.5.1"
|
newlib_dir="newlib-1.18.0"
|
newlib_dir="newlib-1.18.0"
|
uclibc_dir="uclibc-0.9.31"
|
uclibc_dir="uclibc-0.9.31"
|
gdb_dir="gdb-7.2"
|
gdb_dir="gdb-7.2"
|
linux_dir="linux-2.6.35"
|
linux_dir="linux-2.6.35"
|
or32_elf_flag="true"
|
or32_elf_flag="true"
|
or32_linux_flag="true"
|
or32_linux_flag="true"
|
link_flag="true"
|
link_flag="true"
|
config_flag="true"
|
config_flag="true"
|
build_flag="true"
|
build_flag="true"
|
check_flag="false"
|
check_flag="false"
|
install_flag="true"
|
install_flag="true"
|
newlib_flag="true"
|
newlib_flag="true"
|
uclibc_flag="true"
|
uclibc_flag="true"
|
uclibc_stage1_flag="true"
|
uclibc_stage1_flag="true"
|
uclibc_stage2_flag="true"
|
uclibc_stage2_flag="true"
|
|
|
# Consequential params
|
# Consequential params
|
newlib_config="--with-newlib"
|
newlib_config="--with-newlib"
|
newlib_build="all-target-newlib all-target-libgloss"
|
newlib_build="all-target-newlib all-target-libgloss"
|
newlib_check="check-target-newlib check-target-libgloss"
|
newlib_check="check-target-newlib check-target-libgloss"
|
newlib_install="install-target-newlib install-target-libgloss"
|
newlib_install="install-target-newlib install-target-libgloss"
|
|
|
# Determine how many processes to use in parallel building. If
|
# Determine how many processes to use in parallel building. If
|
# /proc/cpuinfo is avaliable, limit load to launch extra jobs to number of
|
# /proc/cpuinfo is avaliable, limit load to launch extra jobs to number of
|
# processors + 1. If /proc/cpuinfo is not available, we use a constant of
|
# processors + 1. If /proc/cpuinfo is not available, we use a constant of
|
# 2.
|
# 2.
|
make_n_jobs=`(echo processor;cat /proc/cpuinfo 2>/dev/null || \
|
make_n_jobs=`(echo processor;cat /proc/cpuinfo 2>/dev/null || \
|
echo processor) | grep -c processor`
|
echo processor) | grep -c processor`
|
make_load="-j $make_n_jobs -l $make_n_jobs"
|
make_load="-j $make_n_jobs -l $make_n_jobs"
|
unset make_n_jobs
|
unset make_n_jobs
|
|
|
} # set_defaults ()
|
} # set_defaults ()
|
|
|
|
|
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
# Parse the arguments
|
# Parse the arguments
|
function parse_args {
|
function parse_args {
|
until
|
until
|
opt=$1
|
opt=$1
|
case ${opt}
|
case ${opt}
|
in
|
in
|
--force)
|
--force)
|
force_flag="true";
|
force_flag="true";
|
;;
|
;;
|
|
|
--prefix)
|
--prefix)
|
prefix=$2;
|
prefix=$2;
|
shift;
|
shift;
|
;;
|
;;
|
|
|
--prefix-tmp)
|
--prefix-tmp)
|
prefix_tmp=$2;
|
prefix_tmp=$2;
|
shift;
|
shift;
|
;;
|
;;
|
|
|
--unisrc_dir)
|
--unisrc_dir)
|
unisrc_dir=$2;
|
unisrc_dir=$2;
|
shift;
|
shift;
|
;;
|
;;
|
|
|
--bd-elf)
|
--bd-elf)
|
bd_elf=$2;
|
bd_elf=$2;
|
shift;
|
shift;
|
;;
|
;;
|
|
|
--bd-elf-gdb)
|
--bd-elf-gdb)
|
bd_elf_gdb=$2;
|
bd_elf_gdb=$2;
|
shift;
|
shift;
|
;;
|
;;
|
|
|
--bd-linux)
|
--bd-linux)
|
bd_linux=$2;
|
bd_linux=$2;
|
shift;
|
shift;
|
;;
|
;;
|
|
|
--bd-linux-gdb)
|
--bd-linux-gdb)
|
bd_linux_gdb=$2;
|
bd_linux_gdb=$2;
|
shift;
|
shift;
|
;;
|
;;
|
|
|
--or1ksim-dir)
|
--or1ksim-dir)
|
or1ksim_dir=$2;
|
or1ksim_dir=$2;
|
shift;
|
shift;
|
;;
|
;;
|
|
|
--binutils-dir)
|
--binutils-dir)
|
binutils_dir=$2;
|
binutils_dir=$2;
|
shift;
|
shift;
|
;;
|
;;
|
|
|
--gcc-dir)
|
--gcc-dir)
|
gcc_dir=$2;
|
gcc_dir=$2;
|
shift;
|
shift;
|
;;
|
;;
|
|
|
--newlib-dir)
|
--newlib-dir)
|
newlib_dir=$2;
|
newlib_dir=$2;
|
shift;
|
shift;
|
;;
|
;;
|
|
|
--uclibc-dir)
|
--uclibc-dir)
|
uclibc_dir=$2;
|
uclibc_dir=$2;
|
shift;
|
shift;
|
;;
|
;;
|
|
|
--gdb-dir)
|
--gdb-dir)
|
gdb_dir=$2;
|
gdb_dir=$2;
|
shift;
|
shift;
|
;;
|
;;
|
|
|
--linux-dir)
|
--linux-dir)
|
linux_dir=$2;
|
linux_dir=$2;
|
shift;
|
shift;
|
;;
|
;;
|
|
|
--no-or32-elf)
|
--no-or32-elf)
|
or32_elf_flag="false"
|
or32_elf_flag="false"
|
;;
|
;;
|
|
|
--no-or32-linux)
|
--no-or32-linux)
|
or32_linux_flag="false"
|
or32_linux_flag="false"
|
;;
|
;;
|
|
|
--nolink)
|
--nolink)
|
link_flag="false";
|
link_flag="false";
|
;;
|
;;
|
|
|
--noconfig)
|
--noconfig)
|
config_flag="false";
|
config_flag="false";
|
;;
|
;;
|
|
|
--nobuild)
|
--nobuild)
|
build_flag="false";
|
build_flag="false";
|
;;
|
;;
|
|
|
--check)
|
--check)
|
check_flag="true";
|
check_flag="true";
|
;;
|
;;
|
|
|
--noinstall)
|
--noinstall)
|
install_flag="false";
|
install_flag="false";
|
;;
|
;;
|
|
|
--no-newlib)
|
--no-newlib)
|
newlib_flag="false";
|
newlib_flag="false";
|
|
|
newlib_config="";
|
newlib_config="";
|
newlib_build="";
|
newlib_build="";
|
newlib_check="";
|
newlib_check="";
|
newlib_install="";
|
newlib_install="";
|
;;
|
;;
|
|
|
--no-uclibc)
|
--no-uclibc)
|
uclibc_flag="false";
|
uclibc_flag="false";
|
;;
|
;;
|
|
|
--no-uclibc-stage1)
|
--no-uclibc-stage1)
|
uclibc_stage1_flag="false";
|
uclibc_stage1_flag="false";
|
;;
|
;;
|
|
|
--no-uclibc-stage2)
|
--no-uclibc-stage2)
|
uclibc_stage2_flag="false";
|
uclibc_stage2_flag="false";
|
;;
|
;;
|
|
|
--help)
|
--help)
|
cat <<EOF;
|
cat <<EOF;
|
--force
|
--force
|
Ensure the unified source directory and build directories are recreated.
|
Ensure the unified source directory and build directories are recreated.
|
|
|
--prefix <dir>
|
--prefix <dir>
|
Specify the install directory (default /opt/or32-new)
|
Specify the install directory (default /opt/or32-new)
|
|
|
--prefix-tmp <dir>
|
--prefix-tmp <dir>
|
Specify the temporary install directory (default /tmp/or32-tmp-${USER}).
|
Specify the temporary install directory (default /tmp/or32-tmp-${USER}).
|
Incorporating the user name avoid name clashes with other users
|
Incorporating the user name avoid name clashes with other users
|
|
|
--unisrc-dir <dir>
|
--unisrc-dir <dir>
|
Specify the unified source directory (default unisrc)
|
Specify the unified source directory (default unisrc)
|
|
|
--build-dir-elf <dir>
|
--build-dir-elf <dir>
|
Specify the build directory for the newlib (or32-elf) tool chain
|
Specify the build directory for the newlib (or32-elf) tool chain
|
(default bd-elf).
|
(default bd-elf).
|
|
|
--build-dir-elf-gdb <dir>
|
--build-dir-elf-gdb <dir>
|
Specify the build directory for the newlib (or32-elf) GDB (default
|
Specify the build directory for the newlib (or32-elf) GDB (default
|
bd-elf-gdb).
|
bd-elf-gdb).
|
|
|
--build-dir-linux <dir>
|
--build-dir-linux <dir>
|
Specify the build directory for the uClibc (or32-linux) tool chain
|
Specify the build directory for the uClibc (or32-linux) tool chain
|
(default bd-linux)
|
(default bd-linux)
|
|
|
--build-dir-linux-gdb <dir>
|
--build-dir-linux-gdb <dir>
|
Specify the build directory for the uClibc (or32-linux) GDB (default
|
Specify the build directory for the uClibc (or32-linux) GDB (default
|
bd-linux-gdb)
|
bd-linux-gdb)
|
|
|
--or1ksim-dir <dir>
|
--or1ksim-dir <dir>
|
Specify the Or1ksim installation directory. Used by GDB, which links in
|
Specify the Or1ksim installation directory. Used by GDB, which links in
|
the Or1ksim simulator (default /opt/or1ksim-new)
|
the Or1ksim simulator (default /opt/or1ksim-new)
|
|
|
--binutils-dir
|
--binutils-dir
|
Source directory for binutils (default binutils-2.20.1)
|
Source directory for binutils (default binutils-2.20.1)
|
|
|
--gcc-dir
|
--gcc-dir
|
Source directory for gcc (default gcc-4.5.1')
|
Source directory for gcc (default gcc-4.5.1')
|
|
|
--newlib-dir
|
--newlib-dir
|
Source directory for newlib (default newlib-1.18.0)
|
Source directory for newlib (default newlib-1.18.0)
|
|
|
--uclibc_dir
|
--uclibc_dir
|
Source directory for uClibc (default uclibc-0.9.31)
|
Source directory for uClibc (default uclibc-0.9.31)
|
|
|
--gdb_dir
|
--gdb_dir
|
Source directory for gdb (default gdb-7.2)
|
Source directory for gdb (default gdb-7.2)
|
|
|
--linux_dir
|
--linux_dir
|
Source directory for Linux (default linux-2.6.35)
|
Source directory for Linux (default linux-2.6.35)
|
|
|
--no-or32-elf
|
--no-or32-elf
|
Don't configure, build and install the newlib (or32-elf) tool chain.
|
Don't configure, build and install the newlib (or32-elf) tool chain.
|
|
|
--no-or32-linux
|
--no-or32-linux
|
Don't configure, build and install the uClibc (or32-linux) tool chain.
|
Don't configure, build and install the uClibc (or32-linux) tool chain.
|
|
|
--nolink
|
--nolink
|
Don't build the unified source directory (default is to build it)
|
Don't build the unified source directory (default is to build it)
|
|
|
--noconfig
|
--noconfig
|
Don't run configure. Note that this will break the two stage build of
|
Don't run configure. Note that this will break the two stage build of
|
gcc for Linux, so it should only be used if at least one of the uClibc
|
gcc for Linux, so it should only be used if at least one of the uClibc
|
stages is being omitted (default is to configure)
|
stages is being omitted (default is to configure)
|
|
|
--nobuild
|
--nobuild
|
Don't build any tools. Useful just to reinstall stuff (default is to
|
Don't build any tools. Useful just to reinstall stuff (default is to
|
build).
|
build).
|
|
|
--check
|
--check
|
Run DejaGnu tests using the or32-elf tool chain (default do not run).
|
Run DejaGnu tests using the or32-elf tool chain (default do not run).
|
|
|
--noinstall
|
--noinstall
|
Don't run install. Beware that this will omit the installation of Linux
|
Don't run install. Beware that this will omit the installation of Linux
|
headers, required for uClibc building and the installation of headers
|
headers, required for uClibc building and the installation of headers
|
from stage1 of gcc for Linux, required for stage2 of gcc for Linux. So
|
from stage1 of gcc for Linux, required for stage2 of gcc for Linux. So
|
only use if at least one of the uClibc stages is being omitted (default
|
only use if at least one of the uClibc stages is being omitted (default
|
is to install).
|
is to install).
|
|
|
--no-newlib
|
--no-newlib
|
Don't build newlib (default is to build newlib)
|
Don't build newlib (default is to build newlib)
|
|
|
--no-uclibc
|
--no-uclibc
|
Don't build uClibc (default is to build uClibc)
|
Don't build uClibc (default is to build uClibc)
|
|
|
--no-uclibc-stage1
|
--no-uclibc-stage1
|
Don't do the stage1 build of gcc for Linux (default is to build stage1).
|
Don't do the stage1 build of gcc for Linux (default is to build stage1).
|
|
|
--no-uclibc-stage2
|
--no-uclibc-stage2
|
Don't do the stage2 build of gcc for Linux (default is to build stage2).
|
Don't do the stage2 build of gcc for Linux (default is to build stage2).
|
|
|
--help
|
--help
|
List these options and exit
|
List these options and exit
|
EOF
|
EOF
|
exit 0
|
exit 0
|
;;
|
;;
|
|
|
--*)
|
--*)
|
echo "unrecognized option \"$1\""
|
echo "unrecognized option \"$1\""
|
exit 1
|
exit 1
|
;;
|
;;
|
|
|
*)
|
*)
|
opt=""
|
opt=""
|
;;
|
;;
|
esac;
|
esac;
|
[ -z "${opt}" ]
|
[ -z "${opt}" ]
|
do
|
do
|
shift
|
shift
|
done
|
done
|
|
|
} # parse_args
|
} # parse_args
|
|
|
|
|
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
# Sanity check argument values
|
# Sanity check argument values
|
function sanity_check {
|
function sanity_check {
|
# Check unified source directory is meaningful if we are linking and that
|
# Check unified source directory is meaningful if we are linking and that
|
# we can create it.
|
# we can create it.
|
if [ "true" == "${link_flag}" ]
|
if [ "true" == "${link_flag}" ]
|
then
|
then
|
# Is it meaninful
|
# Is it meaninful
|
case ${unisrc_dir}
|
case ${unisrc_dir}
|
in
|
in
|
"")
|
"")
|
unisrc_prefix='.'
|
unisrc_prefix='.'
|
;;
|
;;
|
|
|
*/*)
|
*/*)
|
echo "/ in unified source directory not implemented"
|
echo "/ in unified source directory not implemented"
|
exit 1
|
exit 1
|
;;
|
;;
|
|
|
*..*)
|
*..*)
|
echo ".. in unified source directory not implemented"
|
echo ".. in unified source directory not implemented"
|
exit 1
|
exit 1
|
;;
|
;;
|
*)
|
*)
|
unisrc_prefix='..'
|
unisrc_prefix='..'
|
;;
|
;;
|
esac
|
esac
|
|
|
# Check it's a directory, and if it doesn't exist that we can create
|
# Check it's a directory, and if it doesn't exist that we can create
|
# it.
|
# it.
|
if [ -n "${unisrc_dir}" ]
|
if [ -n "${unisrc_dir}" ]
|
then
|
then
|
if [ ! -d ${unisrc_dir} ]
|
if [ ! -d ${unisrc_dir} ]
|
then
|
then
|
if [ -e ${unisrc_dir} ]
|
if [ -e ${unisrc_dir} ]
|
then
|
then
|
echo "${unisrc_dir} is not a directory";
|
echo "${unisrc_dir} is not a directory";
|
exit 1
|
exit 1
|
fi
|
fi
|
|
|
mkdir ${unisrc_dir}
|
mkdir ${unisrc_dir}
|
fi
|
fi
|
fi
|
fi
|
fi
|
fi
|
} # sanity_check
|
} # sanity_check
|
|
|
|
|
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
# Conditionally build the unified source directory. We know by now it's a
|
# Conditionally build the unified source directory. We know by now it's a
|
# viable and extant directory.
|
# viable and extant directory.
|
function link_unified {
|
function link_unified {
|
if [ "true" == "${link_flag}" ]
|
if [ "true" == "${link_flag}" ]
|
then
|
then
|
mkdir -p ${unisrc_dir}
|
mkdir -p ${unisrc_dir}
|
cd ${unisrc_dir}
|
cd ${unisrc_dir}
|
ignore_list=". .. CVS .svn"
|
ignore_list=". .. CVS .svn"
|
component_dirs="${binutils_dir} ${gcc_dir} ${newlib_dir}"
|
component_dirs="${binutils_dir} ${gcc_dir} ${newlib_dir}"
|
|
|
for srcdir in ${component_dirs}
|
for srcdir in ${component_dirs}
|
do
|
do
|
echo "Component: $srcdir"
|
echo "Component: $srcdir"
|
case srcdir
|
case srcdir
|
in
|
in
|
/* | [A-Za-z]:[\\/]*)
|
/* | [A-Za-z]:[\\/]*)
|
;;
|
;;
|
|
|
*)
|
*)
|
srcdir="${unisrc_prefix}/${srcdir}"
|
srcdir="${unisrc_prefix}/${srcdir}"
|
;;
|
;;
|
esac
|
esac
|
|
|
files=`ls -a ${srcdir}`
|
files=`ls -a ${srcdir}`
|
|
|
for f in ${files}
|
for f in ${files}
|
do
|
do
|
found=
|
found=
|
|
|
for i in ${ignore_list}
|
for i in ${ignore_list}
|
do
|
do
|
if [ "$f" = "$i" ]
|
if [ "$f" = "$i" ]
|
then
|
then
|
found=yes
|
found=yes
|
fi
|
fi
|
done
|
done
|
|
|
if [ -z "${found}" ]
|
if [ -z "${found}" ]
|
then
|
then
|
echo "$f ..linked"
|
echo "$f ..linked"
|
ln -s ${srcdir}/$f .
|
ln -s ${srcdir}/$f .
|
fi
|
fi
|
done
|
done
|
|
|
ignore_list="${ignore_list} ${files}"
|
ignore_list="${ignore_list} ${files}"
|
done
|
done
|
|
|
if [ $? != 0 ]
|
if [ $? != 0 ]
|
then
|
then
|
echo "failed to create ${unisrc_dir}"
|
echo "failed to create ${unisrc_dir}"
|
exit 1
|
exit 1
|
fi
|
fi
|
|
|
unset component_dirs
|
unset component_dirs
|
unset ignore_list
|
unset ignore_list
|
cd ..
|
cd -
|
fi
|
fi
|
} # link_unified
|
} # link_unified
|
|
|
|
|
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
# Conditionally configure a GNU source directory (could be the unified
|
# Conditionally configure a GNU source directory (could be the unified
|
# directory, or GDB)
|
# directory, or GDB)
|
|
|
# @param[in] $1 "true" if we should execute this function
|
# @param[in] $1 "true" if we should execute this function
|
# @param[in] $2 The prefix to use for installation.
|
# @param[in] $2 The prefix to use for installation.
|
# @param[in] $3 The build directory to configure in.
|
# @param[in] $3 The build directory to configure in.
|
# @param[in] $4 The source directory containing configure (relative to $1)
|
# @param[in] $4 The source directory containing configure (relative to $1)
|
# @param[in] $5 The languages to configure for.
|
# @param[in] $5 The languages to configure for.
|
# @param[in] $6, ... Additional configure args.
|
# @param[in] $6, ... Additional configure args.
|
function gnu_config {
|
function gnu_config {
|
cond=$1
|
cond=$1
|
shift
|
shift
|
|
|
if [ "true" == ${cond} ]
|
if [ "true" == ${cond} ]
|
then
|
then
|
this_prefix=$1
|
this_prefix=$1
|
shift
|
shift
|
top_builddir=$1
|
top_builddir=$1
|
shift
|
shift
|
top_srcdir=$1
|
top_srcdir=$1
|
shift
|
shift
|
langs=$1
|
langs=$1
|
shift
|
shift
|
|
|
echo "bld-all.sh: gnu_config ${top_builddir} ${top_srcdir} ${langs} $*"
|
echo "bld-all.sh: gnu_config ${top_builddir} ${top_srcdir} ${langs} $*"
|
|
|
verstr="OpenRISC 32-bit toolchain for ${target} (built `date +%Y%m%d`)"
|
verstr="OpenRISC 32-bit toolchain for ${target} (built `date +%Y%m%d`)"
|
|
|
mkdir -p ${top_builddir} && \
|
mkdir -p ${top_builddir} && \
|
cd ${top_builddir} && \
|
cd ${top_builddir} && \
|
${top_srcdir}/configure --target=${target} \
|
${top_srcdir}/configure --target=${target} \
|
--with-pkgversion="${verstr}" \
|
--with-pkgversion="${verstr}" \
|
--with-bugurl=http://www.opencores.org/ \
|
--with-bugurl=http://www.opencores.org/ \
|
--with-or1ksim=${or1ksim_dir} \
|
--with-or1ksim=${or1ksim_dir} \
|
--enable-fast-install=N/A --disable-libssp \
|
--enable-fast-install=N/A --disable-libssp \
|
--enable-languages=${langs} --prefix=${this_prefix} $*
|
--enable-languages=${langs} --prefix=${this_prefix} $*
|
|
|
if [ $? != 0 ]
|
if [ $? != 0 ]
|
then
|
then
|
echo "configure failed."
|
echo "configure failed."
|
exit 1
|
exit 1
|
fi
|
fi
|
|
|
cd ..
|
cd -
|
|
|
unset verstr
|
unset verstr
|
unset langs
|
unset langs
|
unset top_srcdir
|
unset top_srcdir
|
unset top_builddir
|
unset top_builddir
|
unset this_prefix
|
unset this_prefix
|
fi
|
fi
|
|
|
unset cond
|
unset cond
|
|
|
} # gnu_config
|
} # gnu_config
|
|
|
|
|
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
# Conditionally run make and check the result.
|
# Conditionally run make and check the result.
|
|
|
# @param[in] $1 "true" if we should execute this function
|
# @param[in] $1 "true" if we should execute this function
|
# @param[in] $2 The build directory to make in
|
# @param[in] $2 The build directory to make in
|
# @param[in] $3, ... The targets to make
|
# @param[in] $3, ... The targets to make
|
function gnu_make {
|
function gnu_make {
|
cond=$1
|
cond=$1
|
shift
|
shift
|
|
|
if [ "true" == ${cond} ]
|
if [ "true" == ${cond} ]
|
then
|
then
|
echo "bld-all.sh: gnu_make $*"
|
echo "bld-all.sh: gnu_make $*"
|
|
|
cd $1
|
cd $1
|
shift
|
shift
|
|
|
make $make_load $*
|
make $make_load $*
|
|
|
if [ $? != 0 ]
|
if [ $? != 0 ]
|
then
|
then
|
echo "make ($*) failed."
|
echo "make ($*) failed."
|
exit 1
|
exit 1
|
fi
|
fi
|
|
|
cd ..
|
cd -
|
fi
|
fi
|
|
|
unset cond
|
unset cond
|
|
|
} # gnu_make
|
} # gnu_make
|
|
|
|
|
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
# Conditionally relocate the newlib headers and libraries.
|
# Conditionally relocate the newlib headers and libraries.
|
function relocate_newlib {
|
function relocate_newlib {
|
if [ "true" == "${newlib_flag}" ]
|
if [ "true" == "${newlib_flag}" ]
|
then
|
then
|
echo "bld-all.sh: Relocating newlib"
|
echo "bld-all.sh: Relocating newlib"
|
|
|
mkdir -p ${prefix}/or32-elf/newlib
|
mkdir -p ${prefix}/or32-elf/newlib
|
rm -rf ${prefix}/or32-elf/newlib-include
|
rm -rf ${prefix}/or32-elf/newlib-include
|
|
|
if [ -d ${prefix}/or32-elf/include ]
|
if [ -d ${prefix}/or32-elf/include ]
|
then
|
then
|
mv ${prefix}/or32-elf/include \
|
mv ${prefix}/or32-elf/include \
|
${prefix}/or32-elf/newlib-include
|
${prefix}/or32-elf/newlib-include
|
fi
|
fi
|
|
|
if [ -d ${prefix}/or32-elf/lib ]
|
if [ -d ${prefix}/or32-elf/lib ]
|
then
|
then
|
afiles=`ls -1 ${prefix}/or32-elf/lib | grep '\.a' | head -1`
|
afiles=`ls -1 ${prefix}/or32-elf/lib | grep '\.a' | head -1`
|
|
|
if [ "x$afiles" != "x" ]
|
if [ "x$afiles" != "x" ]
|
then
|
then
|
mv ${prefix}/or32-elf/lib/*.a ${prefix}/or32-elf/newlib
|
mv ${prefix}/or32-elf/lib/*.a ${prefix}/or32-elf/newlib
|
fi
|
fi
|
fi
|
fi
|
|
|
if [ -f ${prefix}/or32-elf/lib/crt0.o ]
|
if [ -f ${prefix}/or32-elf/lib/crt0.o ]
|
then
|
then
|
mv ${prefix}/or32-elf/lib/crt0.o ${prefix}/or32-elf/newlib
|
mv ${prefix}/or32-elf/lib/crt0.o ${prefix}/or32-elf/newlib
|
fi
|
fi
|
fi
|
fi
|
} # relocate_newlib
|
} # relocate_newlib
|
|
|
|
|
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
# Conditionally configure and install the Linux headers
|
# Conditionally configure and install the Linux headers
|
|
|
# @param[in] $1 The prefix to use for installation.
|
# @param[in] $1 The prefix to use for installation.
|
function install_linux_headers {
|
function install_linux_headers {
|
this_prefix=$1
|
this_prefix=$1
|
|
|
cd $linux_dir
|
cd $linux_dir
|
|
|
if [ "true" == "${config_flag}" ]
|
if [ "true" == "${config_flag}" ]
|
then
|
then
|
echo "bld-all.sh: Configuring Linux headers"
|
echo "bld-all.sh: Configuring Linux headers"
|
|
|
make ARCH=or32 defconfig
|
make ARCH=or32 defconfig
|
|
|
if [ $? != 0 ];
|
if [ $? != 0 ];
|
then
|
then
|
echo "Linux configure failed"
|
echo "Linux configure failed"
|
exit 1
|
exit 1
|
fi
|
fi
|
fi
|
fi
|
|
|
# This is a bit iffy. We do rely on the headers being installed for uClibc
|
# This is a bit iffy. We do rely on the headers being installed for uClibc
|
# to build, so not installing the first time would be a bit dodgy.
|
# to build, so not installing the first time would be a bit dodgy.
|
if [ "true" == "${install_flag}" ]
|
if [ "true" == "${install_flag}" ]
|
then
|
then
|
echo "bld-all.sh: Installing Linux headers"
|
echo "bld-all.sh: Installing Linux headers"
|
|
|
make INSTALL_HDR_PATH=${this_prefix}/or32-linux headers_install
|
make INSTALL_HDR_PATH=${this_prefix}/or32-linux headers_install
|
|
|
if [ $? != 0 ];
|
if [ $? != 0 ];
|
then
|
then
|
echo "Linux header installation failed"
|
echo "Linux header installation failed"
|
exit 1
|
exit 1
|
fi
|
fi
|
|
|
unset this_prefix
|
unset this_prefix
|
fi
|
fi
|
|
|
cd ..
|
cd -
|
|
|
} # install_linux_headers
|
} # install_linux_headers
|
|
|
|
|
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
# Conditionally configure uClibc
|
# Conditionally configure uClibc
|
|
|
# @param[in] $1 The prefix to use for installation.
|
# @param[in] $1 The prefix to use for installation.
|
function uclibc_config {
|
function uclibc_config {
|
|
|
if [ "true" == "${config_flag}" ]
|
if [ "true" == "${config_flag}" ]
|
then
|
then
|
this_prefix=$1
|
this_prefix=$1
|
echo "bld-all.sh: Configuring uClibc"
|
echo "bld-all.sh: Configuring uClibc"
|
|
|
cd ${uclibc_dir}
|
cd ${uclibc_dir}
|
|
|
kheaders="KERNEL_HEADERS=\\\"${this_prefix}\\/or32-linux\\/include\\\""
|
kheaders="KERNEL_HEADERS=\\\"${this_prefix}\\/or32-linux\\/include\\\""
|
devprefix="DEVEL_PREFIX=\\\"${this_prefix}\\/or32-linux\\\""
|
devprefix="DEVEL_PREFIX=\\\"${this_prefix}\\/or32-linux\\\""
|
ccprefix="CROSS_COMPILER_PREFIX=\\\"or32-linux-\\\""
|
ccprefix="CROSS_COMPILER_PREFIX=\\\"or32-linux-\\\""
|
|
|
sed -i extra/Configs/defconfigs/or32 \
|
sed -i extra/Configs/defconfigs/or32 \
|
-e "s|KERNEL_HEADERS.*|${kheaders}|g" \
|
-e "s|KERNEL_HEADERS.*|${kheaders}|g" \
|
-e "s|DEVEL_PREFIX.*|${devprefix}|g" \
|
-e "s|DEVEL_PREFIX.*|${devprefix}|g" \
|
-e "s|CROSS_COMPILER_PREFIX.*|${ccprefix}|g"
|
-e "s|CROSS_COMPILER_PREFIX.*|${ccprefix}|g"
|
|
|
if [ $? != 0 ];
|
if [ $? != 0 ];
|
then
|
then
|
echo "uClibc sed failed"
|
echo "uClibc sed failed"
|
exit 1
|
exit 1
|
fi
|
fi
|
|
|
make ARCH=or32 defconfig
|
make ARCH=or32 defconfig
|
|
|
if [ $? != 0 ];
|
if [ $? != 0 ];
|
then
|
then
|
echo "uClibc configure failed"
|
echo "uClibc configure failed"
|
exit 1
|
exit 1
|
fi
|
fi
|
|
|
unset this_prefix
|
unset this_prefix
|
unset ccprefix
|
unset ccprefix
|
unset devprefix
|
unset devprefix
|
unset kheaders
|
unset kheaders
|
|
|
cd ..
|
cd -
|
fi
|
fi
|
} # uclibc_config
|
} # uclibc_config
|
|
|
|
|
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
# Conditionally build and install uClibc
|
# Conditionally build and install uClibc
|
function uclibc_build_install {
|
function uclibc_build_install {
|
cd ${uclibc_dir}
|
cd ${uclibc_dir}
|
|
|
if [ "true" == "${build_flag}" ]
|
if [ "true" == "${build_flag}" ]
|
then
|
then
|
echo "bld-all.sh: Building uClibc"
|
echo "bld-all.sh: Building uClibc"
|
|
|
make ARCH=or32 all
|
make ARCH=or32 all
|
|
|
if [ $? != 0 ];
|
if [ $? != 0 ];
|
then
|
then
|
echo "uClibc build failed"
|
echo "uClibc build failed"
|
exit 1
|
exit 1
|
fi
|
fi
|
fi
|
fi
|
|
|
if [ "true" == "${install_flag}" ]
|
if [ "true" == "${install_flag}" ]
|
then
|
then
|
echo "bld-all.sh: Installing uClibc"
|
echo "bld-all.sh: Installing uClibc"
|
|
|
make ARCH=or32 install
|
make ARCH=or32 install
|
|
|
if [ $? != 0 ];
|
if [ $? != 0 ];
|
then
|
then
|
echo "uClibc install failed"
|
echo "uClibc install failed"
|
exit 1
|
exit 1
|
fi
|
fi
|
fi
|
fi
|
|
|
cd ..
|
cd -
|
|
|
} # uclibc_build_install
|
} # uclibc_build_install
|
|
|
|
|
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
# Main program
|
# Main program
|
set_defaults
|
set_defaults
|
parse_args $*
|
parse_args $*
|
sanity_check
|
sanity_check
|
|
|
if [ "true" == "${force_flag}" ]
|
if [ "true" == "${force_flag}" ]
|
then
|
then
|
echo -n "bld-all.sh: removing ${unisrc_dir} ${bd_elf} ${bd_elf_gdb} "
|
echo -n "bld-all.sh: removing ${unisrc_dir} ${bd_elf} ${bd_elf_gdb} "
|
echo "${bd_linux} ${bd_linux_gdb}"
|
echo "${bd_linux} ${bd_linux_gdb}"
|
rm -rf ${unisrc_dir} ${bd_elf} ${bd_elf_gdb} ${bd_linux} ${bd_linux_gdb}
|
rm -rf ${unisrc_dir} ${bd_elf} ${bd_elf_gdb} ${bd_linux} ${bd_linux_gdb}
|
fi
|
fi
|
|
|
link_unified
|
link_unified
|
|
|
# Build the newlib (or32-elf) tool chain.
|
# Build the newlib (or32-elf) tool chain.
|
if [ "true" == "${or32_elf_flag}" ]
|
if [ "true" == "${or32_elf_flag}" ]
|
then
|
then
|
target="or32-elf"
|
target="or32-elf"
|
|
|
echo "bld-all.sh: or32-elf toolchain"
|
echo "bld-all.sh: or32-elf toolchain"
|
|
|
# Configure all
|
# Configure all
|
gnu_config ${config_flag} ${prefix} ${bd_elf} ../${unisrc_dir} "c,c++" \
|
gnu_config ${config_flag} ${prefix} ${bd_elf} ../${unisrc_dir} "c,c++" \
|
"${newlib_config}"
|
"${newlib_config}"
|
gnu_config ${config_flag} ${prefix} ${bd_elf_gdb} ../${gdb_dir} "c,c++"
|
gnu_config ${config_flag} ${prefix} ${bd_elf_gdb} ../${gdb_dir} "c,c++"
|
|
|
# Build all
|
# Build all
|
gnu_make ${build_flag} ${bd_elf} all-build all-binutils all-gas all-ld
|
gnu_make ${build_flag} ${bd_elf} all-build all-binutils all-gas all-ld
|
gnu_make ${build_flag} ${bd_elf} all-gcc
|
gnu_make ${build_flag} ${bd_elf} all-gcc
|
gnu_make ${build_flag} ${bd_elf} all-target-libgcc all-target-libstdc++-v3 \
|
gnu_make ${build_flag} ${bd_elf} all-target-libgcc all-target-libstdc++-v3 \
|
${newlib_build}
|
${newlib_build}
|
gnu_make ${build_flag} ${bd_elf_gdb} all-build all-sim all-gdb
|
gnu_make ${build_flag} ${bd_elf_gdb} all-build all-sim all-gdb
|
|
|
# Check all
|
# Check all
|
gnu_make ${check_flag} ${bd_elf} check-binutils check-gas check-ld \
|
gnu_make ${check_flag} ${bd_elf} check-binutils check-gas check-ld \
|
check-gcc check-target-libgcc check-target-libstdc++-v3 ${newlib_check}
|
check-gcc check-target-libgcc check-target-libstdc++-v3 ${newlib_check}
|
gnu_make ${check_flag} ${bd_elf_gdb} check-sim check-gdb
|
gnu_make ${check_flag} ${bd_elf_gdb} check-sim check-gdb
|
|
|
# Install all
|
# Install all
|
gnu_make ${install_flag} ${bd_elf} install-binutils install-gas install-ld \
|
gnu_make ${install_flag} ${bd_elf} install-binutils install-gas install-ld \
|
install-gcc install-target-libgcc install-target-libstdc++-v3 \
|
install-gcc install-target-libgcc install-target-libstdc++-v3 \
|
${newlib_install}
|
${newlib_install}
|
gnu_make ${install_flag} ${bd_elf_gdb} install-sim install-gdb
|
gnu_make ${install_flag} ${bd_elf_gdb} install-sim install-gdb
|
relocate_newlib
|
relocate_newlib
|
fi
|
fi
|
|
|
# Build the uClibc (or32-linux) tool chain
|
# Build the uClibc (or32-linux) tool chain
|
if [ "true" == "${or32_linux_flag}" ]
|
if [ "true" == "${or32_linux_flag}" ]
|
then
|
then
|
target="or32-linux"
|
target="or32-linux"
|
|
|
echo "bld-all.sh: or32-linux toolchain"
|
echo "bld-all.sh: or32-linux toolchain"
|
|
|
# Stage 1 binutils/GCC build uses no headers and only C
|
# Stage 1 binutils/GCC build uses no headers and only C
|
# language. This is just to create the libc headers, which we put in the
|
# language. This is just to create the libc headers, which we put in the
|
# temporary prefix directory.
|
# temporary prefix directory.
|
if [ "true" == "${uclibc_stage1_flag}" ]
|
if [ "true" == "${uclibc_stage1_flag}" ]
|
then
|
then
|
echo "bld-all.sh: uClibc GCC stage 1"
|
echo "bld-all.sh: uClibc GCC stage 1"
|
|
|
# Make a clean temporary install directory.
|
# Make a clean temporary install directory.
|
rm -rf ${prefix_tmp}
|
rm -rf ${prefix_tmp}
|
mkdir ${prefix_tmp}
|
mkdir ${prefix_tmp}
|
|
|
gnu_config ${config_flag} ${prefix_tmp} ${bd_linux} ../${unisrc_dir} \
|
gnu_config ${config_flag} ${prefix_tmp} ${bd_linux} ../${unisrc_dir} \
|
"c" "--without-headers --enable-threads=single"
|
"c" "--without-headers --enable-threads=single"
|
gnu_make ${build_flag} ${bd_linux} all-build all-binutils all-gas all-ld
|
gnu_make ${build_flag} ${bd_linux} all-build all-binutils all-gas all-ld
|
gnu_make ${build_flag} ${bd_linux} all-gcc
|
gnu_make ${build_flag} ${bd_linux} all-gcc
|
gnu_make ${build_flag} ${bd_linux} all-target-libgcc
|
gnu_make ${build_flag} ${bd_linux} all-target-libgcc
|
gnu_make ${install_flag} ${bd_linux} install-binutils install-gas \
|
gnu_make ${install_flag} ${bd_linux} install-binutils install-gas \
|
install-ld
|
install-ld
|
gnu_make ${install_flag} ${bd_linux} install-gcc install-target-libgcc
|
gnu_make ${install_flag} ${bd_linux} install-gcc install-target-libgcc
|
|
|
# Create the headers using our temporary tool chain
|
# Create the headers using our temporary tool chain
|
save_path="${PATH}"
|
save_path="${PATH}"
|
export PATH="${prefix_tmp}/bin:${PATH}"
|
export PATH="${prefix_tmp}/bin:${PATH}"
|
install_linux_headers ${prefix_tmp}
|
install_linux_headers ${prefix_tmp}
|
uclibc_config ${prefix_tmp}
|
uclibc_config ${prefix_tmp}
|
uclibc_build_install
|
uclibc_build_install
|
PATH="${save_path}"
|
PATH="${save_path}"
|
unset save_path
|
unset save_path
|
fi
|
fi
|
|
|
# If we are doing both stage 1 and stage 2, then we need to completely
|
# If we are doing both stage 1 and stage 2, then we need to completely
|
# clean gcc and target libraries. Just blow the entire directory away.
|
# clean gcc and target libraries. Just blow the entire directory away.
|
if [ "truetrue" == "${uclibc_stage1_flag}${uclibc_stage2_flag}" ]
|
if [ "truetrue" == "${uclibc_stage1_flag}${uclibc_stage2_flag}" ]
|
then
|
then
|
echo "bld-all.sh: uClibc GCC inter-stage cleaning"
|
echo "bld-all.sh: uClibc GCC inter-stage cleaning"
|
rm -rf ${bd_linux}/gcc ${bd_linux}/or32-linux
|
rm -rf ${bd_linux}/gcc ${bd_linux}/or32-linux
|
fi
|
fi
|
|
|
# Stage 2 GCC uses the headers installed from stage 1.
|
# Stage 2 GCC uses the headers installed from stage 1.
|
if [ "true" == "${uclibc_stage2_flag}" ]
|
if [ "true" == "${uclibc_stage2_flag}" ]
|
then
|
then
|
echo "bld-all.sh: uClibc GCC stage 2"
|
echo "bld-all.sh: uClibc GCC stage 2"
|
|
|
# FIXME: uclibc is supposed to provide thread support, but doesn't.
|
# FIXME: uclibc is supposed to provide thread support, but doesn't.
|
thread_hack="--disable-threads --disable-libgomp"
|
thread_hack="--disable-threads --disable-libgomp"
|
|
|
gnu_config ${config_flag} ${prefix} ${bd_linux} ../${unisrc_dir} \
|
gnu_config ${config_flag} ${prefix} ${bd_linux} ../${unisrc_dir} \
|
"c,c++" \
|
"c,c++" \
|
"--with-headers=${prefix_tmp}/or32-linux/include $thread_hack"
|
"--with-headers=${prefix_tmp}/or32-linux/include $thread_hack"
|
gnu_make ${build_flag} ${bd_linux} all-build all-binutils all-gas all-ld
|
gnu_make ${build_flag} ${bd_linux} all-build all-binutils all-gas all-ld
|
gnu_make ${build_flag} ${bd_linux} all-gcc
|
gnu_make ${build_flag} ${bd_linux} all-gcc
|
gnu_make ${build_flag} ${bd_linux} all-target-libgcc
|
gnu_make ${build_flag} ${bd_linux} all-target-libgcc
|
gnu_make ${install_flag} ${bd_linux} install-binutils install-gas \
|
gnu_make ${install_flag} ${bd_linux} install-binutils install-gas \
|
install-ld
|
install-ld
|
gnu_make ${install_flag} ${bd_linux} install-gcc install-target-libgcc
|
gnu_make ${install_flag} ${bd_linux} install-gcc install-target-libgcc
|
|
|
unset thread_hack
|
unset thread_hack
|
|
|
# We need to build uClibc before building the C++ libraries, which in
|
# We need to build uClibc before building the C++ libraries, which in
|
# turn needs the Linux headers
|
# turn needs the Linux headers
|
export PATH=${prefix}/bin:${PATH}
|
export PATH=${prefix}/bin:${PATH}
|
install_linux_headers ${prefix}
|
install_linux_headers ${prefix}
|
uclibc_config ${prefix}
|
uclibc_config ${prefix}
|
uclibc_build_install
|
uclibc_build_install
|
|
|
# Finish building the C++ library
|
# Finish building the C++ library
|
gnu_make ${build_flag} ${bd_linux} all-target-libstdc++-v3
|
gnu_make ${build_flag} ${bd_linux} all-target-libstdc++-v3
|
gnu_make ${install_flag} ${bd_linux} install-target-libstdc++-v3
|
gnu_make ${install_flag} ${bd_linux} install-target-libstdc++-v3
|
fi
|
fi
|
|
|
# Configure, build and install GDB (note we need to reconfigure in case
|
# Configure, build and install GDB (note we need to reconfigure in case
|
# only stage1 has been run previously).
|
# only stage1 has been run previously).
|
gnu_config ${config_flag} ${prefix} ${bd_linux_gdb} ../${gdb_dir} "c,c++"
|
gnu_config ${config_flag} ${prefix} ${bd_linux_gdb} ../${gdb_dir} "c,c++"
|
gnu_make ${build_flag} ${bd_linux_gdb} all-build all-sim all-gdb
|
gnu_make ${build_flag} ${bd_linux_gdb} all-build all-sim all-gdb
|
gnu_make ${install_flag} ${bd_linux_gdb} install-sim install-gdb
|
gnu_make ${install_flag} ${bd_linux_gdb} install-sim install-gdb
|
fi
|
fi
|
|
|