add scripts to build sh-elf-vhex (gcc, binutils)
This commit is contained in:
parent
46eb2a9a2e
commit
1bdbc420fa
|
@ -0,0 +1,2 @@
|
|||
build
|
||||
cache
|
|
@ -0,0 +1,8 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
#
|
||||
|
||||
TARGET=$1
|
||||
PREFIX="$2"
|
||||
URL="https://ftp.gnu.org/gnu/binutils/binutils-$VERSION.tar.xz"
|
||||
ARCHIVE=$(basename "$URL")
|
|
@ -0,0 +1,25 @@
|
|||
# giteapc: version=1
|
||||
|
||||
PREFIX ?= $(GITEAPC_PREFIX)
|
||||
VERSION_BINUTILS = 2.37
|
||||
VERSION_GCC = 11.2
|
||||
|
||||
-include giteapc-config.make
|
||||
|
||||
configure:
|
||||
@ ./configure.sh --binutils $(VERSION_BINUTILS) "$(PREFIX)"
|
||||
@ ./configure.sh --gcc $(VERSION_GCC) "$(PREFIX)"
|
||||
|
||||
build:
|
||||
@ ./build.sh --binutils
|
||||
@ ./build.sh --gcc
|
||||
|
||||
install:
|
||||
@ ./install.sh --binutils "$(PREFIX)"
|
||||
@ ./install.sh --gcc "$(PREFIX)"
|
||||
|
||||
uninstall:
|
||||
@ ./uninstall.sh --binutils "$(PREFIX)"
|
||||
@ ./uninstall.sh --gcc "$(PREFIX)"
|
||||
|
||||
.PHONY: configure build install uninstall
|
|
@ -3252,7 +3252,9 @@ sh-*-elf* | sh[12346l]*-*-elf* | \
|
|||
tm_file="${tm_file} sh/embed-elf.h"
|
||||
tm_file="${tm_file} sh/superh.h"
|
||||
extra_options="${extra_options} sh/superh.opt" ;;
|
||||
sh*-*-vhex*) tm_file="${tm_file} sh/vhex.h" ;;
|
||||
sh*-*-vhex*)
|
||||
tm_file="${tm_file} newlib-stdint.h sh/vhex.h"
|
||||
use_gcc_stdint=provide ;;
|
||||
*) if test x$with_newlib = xyes \
|
||||
&& test x$with_libgloss = xyes; then
|
||||
tm_file="${tm_file} sh/newlib.h"
|
|
@ -0,0 +1,63 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
verbose=false
|
||||
|
||||
#
|
||||
# Help screen
|
||||
#
|
||||
help()
|
||||
{
|
||||
cat << OEF
|
||||
Building helper script for the configuration step of the binutils build for the
|
||||
Vhex kernel project.
|
||||
|
||||
Usage $0 [options...]
|
||||
|
||||
Configurations:
|
||||
-h, --help Display this help
|
||||
--verbose Display extra information during the building step
|
||||
OEF
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Parse argument
|
||||
#
|
||||
|
||||
for arg; do case "$arg" in
|
||||
--help | -h) help;;
|
||||
--verbose) verbose=true;;
|
||||
*)
|
||||
echo "error: unreconized argument '$arg', giving up." >&2
|
||||
exit 1
|
||||
esac; done
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Building step
|
||||
#
|
||||
|
||||
TAG='<sh-elf-vhex-binutils>'
|
||||
|
||||
|
||||
# Avoid rebuilds of the same version
|
||||
[[ ! -d ../../build/binutils/build ]] && exit 0
|
||||
cd ../../build/binutils/build
|
||||
|
||||
# Number of processor cores
|
||||
[[ $(uname) == "OpenBSD" ]] && cores=$(sysctl -n hw.ncpu) || cores=$(nproc)
|
||||
|
||||
# selecte make utility
|
||||
[[ $(command -v gmake >/dev/null 2>&1) ]] && make_cmd=gmake || make_cmd=make
|
||||
|
||||
echo "$TAG Compiling binutils (usually 5-10 minutes)..."
|
||||
|
||||
if [[ "$verbose" == 'false' ]]; then
|
||||
source ../../../scripts/util.sh
|
||||
run_quietly giteapc-build.log $make_cmd -j"$cores"
|
||||
else
|
||||
$make_cmd -j"$cores"
|
||||
fi
|
|
@ -0,0 +1,224 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
|
||||
verbose=false
|
||||
no_cache=false
|
||||
version='?'
|
||||
prefix=
|
||||
|
||||
|
||||
#
|
||||
# Help screen
|
||||
#
|
||||
help()
|
||||
{
|
||||
cat << OEF
|
||||
Configuration file for the configuration step of the binutils build for the
|
||||
Vhex kernel project.
|
||||
|
||||
Usage $0 [options...]
|
||||
|
||||
Configurations:
|
||||
-h, --help Display this help
|
||||
--no-cache Do not keep the archive of binutils
|
||||
--verbose Display extra information during the configuration step
|
||||
--prefix=<PREFIX> Installation prefix
|
||||
--version=<VERSION> Select the binutils version. If the '?' argument is
|
||||
passed then all binutils version with Vhex patch
|
||||
availables will be printed
|
||||
OEF
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Parse argument
|
||||
#
|
||||
|
||||
[[ $# -eq 0 ]] && help
|
||||
|
||||
for arg; do case "$arg" in
|
||||
--help | -h) help;;
|
||||
--verbose) verbose=true;;
|
||||
--no-cache) no_cache=true;;
|
||||
--prefix=*) prefix=${arg#*=};;
|
||||
--version=*) version=${arg#*=};;
|
||||
*)
|
||||
echo "error: unreconized argument '$arg', giving up." >&2
|
||||
exit 1
|
||||
esac; done
|
||||
|
||||
|
||||
#
|
||||
# Check parsing validity
|
||||
#
|
||||
|
||||
# check version
|
||||
list_version=$(basename $(ls -d ../../patchs/binutils/*))
|
||||
if [[ "$version" == '?' ]]; then
|
||||
echo "$list_version"
|
||||
exit 0
|
||||
fi
|
||||
if [[ ! $list_version =~ (^|[[:space:]])$version($|[[:space:]]) ]]; then
|
||||
echo "binutils version '$version' is not supported by Vhex"
|
||||
echo 'abording...'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Configuration part
|
||||
# @note
|
||||
# This part is forked from the sh-elf-binutils repository created by
|
||||
# Lephenixnoir.
|
||||
#
|
||||
|
||||
TAG='<sh-elf-vhex-binutils>'
|
||||
VERSION=$version
|
||||
PREFIX="$prefix"
|
||||
URL="https://ftp.gnu.org/gnu/binutils/binutils-$VERSION.tar.xz"
|
||||
ARCHIVE="../../cache/$(basename $URL)"
|
||||
|
||||
# Avoid rebuilds of the same version
|
||||
|
||||
existing_as="$PREFIX/bin/sh-elf-vhex-as"
|
||||
|
||||
if [[ -f "$existing_as" ]]; then
|
||||
existing_version=$($existing_as --version | head -n 1 | grep -Eo '[0-9.]+$')
|
||||
if [[ $existing_version == $VERSION ]]; then
|
||||
echo "$TAG Version $VERSION already installed, skipping rebuild"
|
||||
if [[ -e build ]]; then
|
||||
rm -rf build
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check dependencies for binutils and GCC
|
||||
if command -v pkg >/dev/null 2>&1; then
|
||||
deps="libmpfr libmpc libgmp libpng flex clang git texinfo libisl bison xz-utils"
|
||||
pm=pkg
|
||||
pm_has="dpkg -s"
|
||||
pm_install="pkg install"
|
||||
elif command -v apt >/dev/null 2>&1; then
|
||||
deps="libmpfr-dev libmpc-dev libgmp-dev libpng-dev libppl-dev flex g++ git texinfo xz-utils"
|
||||
pm=apt
|
||||
pm_has="dpkg -s"
|
||||
pm_install="sudo apt install"
|
||||
elif command -v pacman >/dev/null 2>&1; then
|
||||
deps="mpfr libmpc gmp libpng ppl flex gcc git texinfo xz"
|
||||
pm=pacman
|
||||
pm_has="pacman -Qi"
|
||||
pm_install="sudo pacman -S"
|
||||
else
|
||||
trust_deps=1
|
||||
fi
|
||||
|
||||
missing=""
|
||||
if [[ -z "$trust_deps" ]]; then
|
||||
for d in $deps; do
|
||||
if ! $pm_has $d >/dev/null 2>&1; then
|
||||
missing="$missing $d"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Offer to install dependencies
|
||||
|
||||
if [[ ! -z "$missing" ]]; then
|
||||
echo "$TAG Based on $pm, some dependencies are missing: $missing"
|
||||
echo -n "$TAG Do you want to run '$pm_install $missing' to install them (Y/n)? "
|
||||
|
||||
read do_install
|
||||
if [[ "$do_install" == "y" || "$do_install" == "Y" || "$do_install" == "" ]]; then
|
||||
$pm_install $missing
|
||||
else
|
||||
echo "$TAG Skipping dependencies, hoping it will build anyway."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Download archive
|
||||
|
||||
if [[ -f "$ARCHIVE" ]]; then
|
||||
echo "$TAG Found $ARCHIVE, skipping download"
|
||||
else
|
||||
mkdir -p $(dirname "$ARCHIVE")
|
||||
echo "$TAG Downloading $URL..."
|
||||
if command -v curl >/dev/null 2>&1; then
|
||||
curl $URL -o $ARCHIVE
|
||||
elif command -v wget >/dev/null 2>&1; then
|
||||
wget -q --show-progress $URL -O $ARCHIVE
|
||||
else
|
||||
echo "$TAG error: no curl or wget; install one or download archive yourself" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Extract archive (OpenBDS-compliant version)
|
||||
|
||||
echo "$TAG Extracting $ARCHIVE..."
|
||||
|
||||
mkdir -p ../../build/binutils/
|
||||
cd ../../build/binutils
|
||||
|
||||
unxz -c < $ARCHIVE | tar -xf -
|
||||
|
||||
|
||||
# Touch intl/plural.c to avoid regenerating it from intl/plural.y with recent
|
||||
# versions of bison, which is subject to the following known bug.
|
||||
# * https://sourceware.org/bugzilla/show_bug.cgi?id=22941
|
||||
# * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92008
|
||||
touch binutils-$VERSION/intl/plural.c
|
||||
|
||||
# Apply binutils patchs for Vhex
|
||||
|
||||
echo "$TAG Apply Vhex patchs..."
|
||||
cp -r ../../patchs/binutils/$VERSION/* ./binutils-$VERSION/
|
||||
|
||||
# Create build folder
|
||||
|
||||
[[ -d "build" ]] && rm -rf build
|
||||
mkdir build
|
||||
|
||||
# Configure. binutils does not support the uninstall target (wow) so we just
|
||||
# install in this directory and later symlink executables to $PREFIX/bin.
|
||||
|
||||
PREFIX="$(pwd)"
|
||||
cd build
|
||||
|
||||
echo "$TAG Configuring binutils..."
|
||||
|
||||
if command -v termux-setup-storage >/dev/null 2>&1; then
|
||||
# Since the __ANDROID_API__ flag is hardcoded as 24 in clang, and <stdio.h>
|
||||
# doesn't prototype some functions when this flag is too low, fixes it's
|
||||
# version by checking system's properties so as to prevent from missing prototypes
|
||||
# of existing functions such as fgets_unlocked (only if API >= 28)
|
||||
# See the following issues :
|
||||
# * https://github.com/termux/termux-packages/issues/6176
|
||||
# * https://github.com/termux/termux-packages/issues/2469
|
||||
|
||||
export CFLAGS="-D__ANDROID_API__=$(getprop ro.build.version.sdk) -g -O2" \
|
||||
CXXFLAGS="-D__ANDROID_API__=$(getprop ro.build.version.sdk) -g -O2"
|
||||
fi
|
||||
|
||||
# Real configuration step
|
||||
if [[ "$verbose" == "true" ]]; then
|
||||
../binutils-$VERSION/configure --prefix="$PREFIX" --target=sh-elf-vhex \
|
||||
--with-multilib-list=m3,m4-nofpu --disable-nls --enable-lto
|
||||
else
|
||||
source ../../../scripts/util.sh
|
||||
|
||||
run_quietly giteapc-configure.log \
|
||||
../binutils-$VERSION/configure --prefix="$PREFIX" --target=sh-elf-vhex \
|
||||
--with-multilib-list=m3,m4-nofpu --disable-nls --enable-lto
|
||||
fi
|
||||
cd ..
|
||||
|
||||
# cache management
|
||||
if [[ "$no_cache" == 'true' ]]; then
|
||||
echo "$TAG Removing $ARCHIVE..."
|
||||
rm -f $ARCHIVE
|
||||
fi
|
||||
exit 0
|
|
@ -0,0 +1,99 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
verbose=false
|
||||
cache=false
|
||||
prefix=
|
||||
|
||||
|
||||
#
|
||||
# Help screen
|
||||
#
|
||||
help()
|
||||
{
|
||||
cat << OEF
|
||||
Installation helper script for the configuration step of the binutils build for
|
||||
the Vhex kernel project.
|
||||
|
||||
Usage $0 [options...]
|
||||
|
||||
Configurations:
|
||||
-h, --help Display this help
|
||||
--cache Keep the build and sources directory
|
||||
--verbose Display extra information during the installation step
|
||||
--prefix=<PREFIX> Installation prefix
|
||||
OEF
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Parse argument
|
||||
#
|
||||
|
||||
[[ $# -eq 0 ]] && help
|
||||
|
||||
for arg; do case "$arg" in
|
||||
--help | -h) help;;
|
||||
--verbose) verbose=true;;
|
||||
--cache) cache=true;;
|
||||
--prefix=*) prefix=${arg#*=};;
|
||||
*)
|
||||
echo "error: unreconized argument '$arg', giving up." >&2
|
||||
exit 1
|
||||
esac; done
|
||||
|
||||
|
||||
#
|
||||
# Installation step
|
||||
# @note
|
||||
# This part is forked from the sh-elf-binutils repository created by
|
||||
# Lephenixnoir.
|
||||
#
|
||||
|
||||
TAG='<sh-elf-vhex-binutils>'
|
||||
PREFIX="$prefix"
|
||||
|
||||
# Avoid rebuilds of the same version
|
||||
|
||||
[[ ! -d ../../build/binutils/build ]] && exit 0
|
||||
cd ../../build/binutils/build
|
||||
|
||||
# add utilities
|
||||
|
||||
source ../../../scripts/util.sh
|
||||
|
||||
|
||||
# check gmake or make (macos support)
|
||||
|
||||
if command -v gmake >/dev/null 2>&1; then
|
||||
make_command=gmake
|
||||
else
|
||||
make_command=make
|
||||
fi
|
||||
|
||||
# build part
|
||||
|
||||
echo "$TAG Installing to local folder..."
|
||||
if [[ "$verbose" == 'true' ]]; then
|
||||
$make_command install-strip
|
||||
else
|
||||
run_quietly giteapc-install.log $make_command install-strip
|
||||
fi
|
||||
cd ..
|
||||
|
||||
# Symbolic link executables to $PREFIX/bin
|
||||
|
||||
echo "$TAG Symlinking binaries..."
|
||||
mkdir -p $PREFIX/bin
|
||||
for x in bin/*; do
|
||||
ln -sf "$(pwd)/$x" "$PREFIX/$x"
|
||||
done
|
||||
|
||||
# Cleanup build files
|
||||
|
||||
if [[ "$cache" == 'false' ]]; then
|
||||
echo "$TAG Cleaning up build files..."
|
||||
rm -rf binutils-*/
|
||||
rm -rf build/
|
||||
fi
|
|
@ -0,0 +1,57 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
verbose=false
|
||||
prefix=
|
||||
|
||||
|
||||
#
|
||||
# Help screen
|
||||
#
|
||||
help()
|
||||
{
|
||||
cat << OEF
|
||||
Installation helper script for the configuration step of the binutils build for
|
||||
the Vhex kernel project.
|
||||
|
||||
Usage $0 [options...]
|
||||
|
||||
Configurations:
|
||||
-h, --help Display this help
|
||||
--verbose Display extra information during the installation step
|
||||
--prefix=<PREFIX> Installation prefix
|
||||
OEF
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Parse argument
|
||||
#
|
||||
|
||||
for arg; do case "$arg" in
|
||||
--help | -h) help;;
|
||||
--verbose) verbose=true;;
|
||||
--prefix=*) prefix=${arg#*=};;
|
||||
*)
|
||||
echo "error: unreconized argument '$arg', giving up." >&2
|
||||
exit 1
|
||||
esac; done
|
||||
|
||||
|
||||
#
|
||||
# Unistall step
|
||||
#
|
||||
|
||||
TAG='<sh-elf-vhex-binutils>'
|
||||
PREFIX="$prefix"
|
||||
|
||||
# Remove symlinks
|
||||
echo "$TAG Removing symlinks to binaries..."
|
||||
for x in bin/*; do
|
||||
rm "$PREFIX/$x"
|
||||
done
|
||||
|
||||
# Remove local files
|
||||
echo "$TAG Removing installed files..."
|
||||
rm -rf bin/ sh-elf-vhex/ share/ lib/
|
|
@ -0,0 +1,13 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
echo "Compil and install binutils"
|
||||
cd binutils
|
||||
./configure.sh --version=2.37 --prefix=/tmp \
|
||||
&& ./build.sh \
|
||||
&& ./install.sh --prefix=/tmp
|
||||
|
||||
echo "Compil and install GCC"
|
||||
cd ../gcc
|
||||
./configure.sh --version=11.2.0 --prefix=/tmp \
|
||||
&& ./build.sh
|
||||
#&& ./install.sh --prefix=/home/yann/CASIO/vhex-compiler/sh-elf-vhex/scripts
|
|
@ -0,0 +1,241 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
verbose=false
|
||||
|
||||
read -n 1 -p 'wait user key....' _test
|
||||
|
||||
#
|
||||
# Help screen
|
||||
#
|
||||
help()
|
||||
{
|
||||
cat << OEF
|
||||
Building helper script for the configuration step of the binutils build for the
|
||||
Vhex kernel project.
|
||||
|
||||
Usage $0 [options...]
|
||||
|
||||
Configurations:
|
||||
-h, --help Display this help
|
||||
--verbose Display extra information during the building step
|
||||
OEF
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Parse argument
|
||||
#
|
||||
|
||||
for arg; do case "$arg" in
|
||||
--help | -h) help;;
|
||||
--verbose) verbose=true;;
|
||||
*)
|
||||
echo "error: unreconized argument '$arg', giving up." >&2
|
||||
exit 1
|
||||
esac; done
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Building step
|
||||
# @note:
|
||||
# We need to build GCC a least two time. This because we whant to enable
|
||||
# shared version of the libgcc. But, to compile the librarie, we need to build
|
||||
# our own standard C librarie, which required openlibm and the libgcc.
|
||||
#
|
||||
# To avoid this, we will configure and build the GCC tools and the static
|
||||
# libgcc. This will enable us to compile the openlibm, then our libc. After
|
||||
# that we will anable to build the shared version of the libgcc.
|
||||
#
|
||||
|
||||
|
||||
|
||||
## Get external information before starting the building step
|
||||
|
||||
# verbose tag
|
||||
TAG='<sh-elf-vhex-gcc>'
|
||||
|
||||
# import utility
|
||||
source ../util.sh
|
||||
|
||||
# Number of processor cores
|
||||
[[ $(uname) == "OpenBSD" ]] && cores=$(sysctl -n hw.ncpu) || cores=$(nproc)
|
||||
|
||||
# check macos make utility
|
||||
[[ $(command -v gmake >/dev/null 2>&1) ]] && make_cmd=gmake || make_cmd=make
|
||||
|
||||
# check quiet build
|
||||
[[ "$verbose" == "true" ]] && quiet='' || quiet='run_quietly giteapc-build.log'
|
||||
|
||||
# OpenBSD apparently installs these in /usr/local
|
||||
extra_args=
|
||||
if [[ $(uname) == "OpenBSD" ]]; then
|
||||
extra_args="--with-gmp=/usr/local --with-mpfr=/usr/local --with-mpc=/usr/local"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
## create the building directory
|
||||
|
||||
mkdir -p ../../build/gcc/build
|
||||
cd ../../build/gcc/build
|
||||
|
||||
|
||||
## first configuration
|
||||
|
||||
echo "$TAG Configuring GCC (stage 1)..."
|
||||
|
||||
# Configure. GCC does not support make uninstall so we install in this
|
||||
# directory and later symlink executables to $PREFIX/bin.
|
||||
|
||||
PREFIX="$(pwd)/.."
|
||||
|
||||
$quiet ../gcc/configure --prefix=$PREFIX --target=sh-elf-vhex \
|
||||
--with-multilib-list=m3,m4-nofpu --enable-languages=c --without-headers \
|
||||
--disable-nls --enable-lto --disable-shared $extra_args
|
||||
|
||||
|
||||
|
||||
## first build
|
||||
|
||||
echo "$TAG Compiling GCC (stage 1) (usually 10-20 minutes)..."
|
||||
|
||||
$quiet $make_cmd -j"$cores" all-gcc
|
||||
|
||||
echo "$TAG Install GCC (stage 1)..."
|
||||
|
||||
$quiet $make_cmd -j"$cores" install-strip-gcc
|
||||
|
||||
echo "$TAG Compiling libgcc (stage 1)..."
|
||||
|
||||
$quiet $make_cmd -j"$cores" all-target-libgcc
|
||||
|
||||
echo "$TAG Install libgcc (stage 1)..."
|
||||
|
||||
$quiet $make_cmd -j"$cores" install-strip-target-libgcc
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Patch the C standar library
|
||||
#
|
||||
|
||||
# export binary
|
||||
|
||||
cd ..
|
||||
|
||||
export PATH="$PATH:$(pwd)/bin"
|
||||
export PATH="$PATH:$(pwd)/sh-elf-vhex/bin"
|
||||
|
||||
cd ..
|
||||
|
||||
## Install OpenLibM
|
||||
|
||||
echo "$TAG Install OpenLibM..."
|
||||
|
||||
rm -rf OpenLibm
|
||||
$quiet git clone https://gitea.planet-casio.com/Lephenixnoir/OpenLibm.git --depth=1
|
||||
cd OpenLibm
|
||||
|
||||
# get installation path
|
||||
LIP=$(sh-elf-vhex-gcc --print-search-dirs | grep install | sed 's/install: //')
|
||||
|
||||
# build
|
||||
$quiet $make_cmd USEGCC=1 ARCH=sh3eb TOOLPREFIX=sh-elf-vhex- \
|
||||
CC=sh-elf-vhex-gcc AR=sh-elf-vhex-ar \
|
||||
libdir="$LIP" includedir="$LIP/include"
|
||||
|
||||
# install
|
||||
$quiet $make_cmd USEGCC=1 ARCH=sh3eb TOOLPREFIX=sh-elf-vhex- \
|
||||
CC=sh-elf-vhex-gcc AR=sh-elf-vhex-ar \
|
||||
libdir="$LIP" includedir="$LIP/include" \
|
||||
install-static install-headers
|
||||
|
||||
cd ..
|
||||
|
||||
|
||||
echo "$TAG Patch the standard library..."
|
||||
|
||||
rm -rf fxlibc
|
||||
git clone https://gitea.planet-casio.com/Vhex-Kernel-Core/fxlibc.git
|
||||
cd fxlibc
|
||||
git checkout dev
|
||||
|
||||
$quiet cmake -DFXLIBC_TARGET=vhex-sh -B build-vhex \
|
||||
-DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-vhex.cmake \
|
||||
-DCMAKE_C_COMPILER_WORKS=1 -DCMAKE_INSTALL_PREFIX="$LIP"
|
||||
|
||||
cd build-vhex
|
||||
|
||||
$quiet $make_cmd
|
||||
|
||||
cd ../..
|
||||
|
||||
|
||||
#
|
||||
# Build the GCC state-2
|
||||
#
|
||||
|
||||
echo "$TAG Configuring GCC (stage 2)..."
|
||||
|
||||
cd gcc
|
||||
|
||||
## remove stage 1 compilation part
|
||||
|
||||
rm -rf $(ls | grep -v gcc | grep -v sh-elf-vhex)
|
||||
|
||||
## build
|
||||
|
||||
mkdir -p build
|
||||
cd build
|
||||
|
||||
$quiet ../gcc/configure --prefix=$PREFIX --target=sh-elf-vhex \
|
||||
--with-multilib-list=m3,m4-nofpu --enable-languages=c --without-headers \
|
||||
--disable-nls --enable-lto $extra_args
|
||||
|
||||
echo "$TAG Compiling GCC (stage 2) (usually 10-20 minutes)..."
|
||||
|
||||
$quiet $make_cmd -j"$cores" all-gcc
|
||||
|
||||
echo "$TAG Install GCC (stage 2)..."
|
||||
|
||||
$quiet $make_cmd -j"$cores" install-strip-gcc
|
||||
|
||||
## libc patch
|
||||
|
||||
echo "$TAG Install C standar library..."
|
||||
|
||||
cd ../../OpenLibm
|
||||
echo " - OpenLibm"
|
||||
$quiet $make_cmd USEGCC=1 ARCH=sh3eb TOOLPREFIX=sh-elf-vhex- \
|
||||
CC=sh-elf-vhex-gcc AR=sh-elf-vhex-ar \
|
||||
libdir="$LIP" includedir="$LIP/include" \
|
||||
install-static install-headers
|
||||
|
||||
cd ../fxlibc/build-vhex
|
||||
echo " - FxLibC"
|
||||
$quiet $make_cmd install
|
||||
|
||||
|
||||
|
||||
cd ../../gcc/build
|
||||
|
||||
# it seems that the generation of the shared libgcc search the
|
||||
# libc in a non-conventional path
|
||||
|
||||
rm -rf $(pwd)/../sh-elf-vhex/lib
|
||||
ln -sf $LIP/lib $(pwd)/../sh-elf-vhex/lib
|
||||
|
||||
echo "$TAG Compiling libgcc (stage 2)..."
|
||||
|
||||
$quiet $make_cmd -j"$cores" all-target-libgcc
|
||||
|
||||
echo "$TAG Install libgcc (stage 2)..."
|
||||
|
||||
$quiet $make_cmd -j"$cores" install-strip-target-libgcc
|
||||
|
||||
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,147 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
verbose=false
|
||||
no_cache=false
|
||||
version='?'
|
||||
prefix=
|
||||
|
||||
|
||||
#
|
||||
# Help screen
|
||||
#
|
||||
help()
|
||||
{
|
||||
cat << OEF
|
||||
Configuration file for the configuration step of the GCC build for the Vhex
|
||||
kernel project.
|
||||
|
||||
Usage $0 [options...]
|
||||
|
||||
Configurations:
|
||||
-h, --help Display this help
|
||||
--no-cache Do not keep the archive of binutils
|
||||
--verbose Display extra information during the configuration step
|
||||
--prefix=<PREFIX> Installation prefix
|
||||
--version=<VERSION> Select the GCC version. If the '?' argument is
|
||||
passed then all binutils version with Vhex patch
|
||||
availables will be printed
|
||||
OEF
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Parse argument
|
||||
#
|
||||
|
||||
[[ $# -eq 0 ]] && help
|
||||
|
||||
for arg; do case "$arg" in
|
||||
--help | -h) help;;
|
||||
--verbose) verbose=true;;
|
||||
--no-cache) no_cache=true;;
|
||||
--prefix=*) prefix=${arg#*=};;
|
||||
--version=*) version=${arg#*=};;
|
||||
*)
|
||||
echo "error: unreconized argument '$arg', giving up." >&2
|
||||
exit 1
|
||||
esac; done
|
||||
|
||||
|
||||
#
|
||||
# Check parsing validity
|
||||
#
|
||||
|
||||
# check version
|
||||
list_version=$(basename $(ls -d ../../patchs/gcc/*))
|
||||
if [[ "$version" == '?' ]]; then
|
||||
echo "$list_version"
|
||||
exit 0
|
||||
fi
|
||||
if [[ ! $list_version =~ (^|[[:space:]])$version($|[[:space:]]) ]]; then
|
||||
echo "GCC version '$version' is not supported by Vhex"
|
||||
echo 'abording...'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#
|
||||
# Configuration part
|
||||
# @note
|
||||
# This part is forked from the sh-elf-binutils repository created by
|
||||
# Lephenixnoir.
|
||||
#
|
||||
|
||||
TAG='<sh-elf-vhex-gcc>'
|
||||
VERSION="$version"
|
||||
PREFIX="$prefix"
|
||||
URL="https://ftp.gnu.org/gnu/gcc/gcc-$VERSION/gcc-$VERSION.tar.xz"
|
||||
ARCHIVE="../../cache/$(basename $URL)"
|
||||
|
||||
# Avoid rebuilds of the same version
|
||||
|
||||
existing_gcc="$PREFIX/bin/sh-elf-vhex-gcc"
|
||||
|
||||
if [[ -f "$existing_gcc" ]]; then
|
||||
existing_version=$($existing_gcc --version | head -n 1 | grep -Eo '[0-9.]+$')
|
||||
if [[ $existing_version == $VERSION ]]; then
|
||||
echo "$TAG Version $VERSION already installed, skipping rebuild"
|
||||
if [[ -e build ]]; then
|
||||
rm -rf build
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Download archive
|
||||
|
||||
if [[ -f "$ARCHIVE" ]]; then
|
||||
echo "$TAG Found $ARCHIVE, skipping download"
|
||||
else
|
||||
echo "$TAG Downloading $URL..."
|
||||
if command -v curl >/dev/null 2>&1; then
|
||||
curl $URL -o $ARCHIVE
|
||||
elif command -v wget >/dev/null 2>&1; then
|
||||
wget -q --show-progress $URL -O $ARCHIVE
|
||||
else
|
||||
echo "$TAG error: no curl or wget; install one or download archive yourself" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Extract archive (openBSD-compliant version)
|
||||
|
||||
echo "$TAG Extracting $ARCHIVE..."
|
||||
|
||||
mkdir -p ../../build/gcc/
|
||||
cd ../../build/gcc
|
||||
|
||||
unxz -c < $ARCHIVE | tar -xf -
|
||||
|
||||
# Apply GCC patchs for Vhex
|
||||
|
||||
echo "$TAG Apply Vhex patchs..."
|
||||
cp -r ../../patchs/gcc/$VERSION/* ./gcc-$VERSION/
|
||||
|
||||
# Rename the directory to avoid path deduction during configuration part in
|
||||
# build.sh
|
||||
|
||||
[[ -d ./gcc ]] && rm -rf ./gcc
|
||||
mv ./gcc-$VERSION/ ./gcc
|
||||
|
||||
# Symlink as, ld, ar and ranlib, which gcc will not find by itself (we renamed
|
||||
# them from sh3eb-elf-* to sh-elf-* with --program-prefix).
|
||||
mkdir -p sh-elf-vhex/bin
|
||||
ln -sf $PREFIX/bin/sh-elf-vhex-as sh-elf-vhex/bin/as
|
||||
ln -sf $PREFIX/bin/sh-elf-vhex-ld sh-elf-vhex/bin/ld
|
||||
ln -sf $PREFIX/bin/sh-elf-vhex-ar sh-elf-vhex/bin/ar
|
||||
ln -sf $PREFIX/bin/sh-elf-vhex-ranlib sh-elf-vhex/bin/ranlib
|
||||
|
||||
# patch OpenLibM building error (find for sh-elf-vhex-ar)
|
||||
ln -sf $PREFIX/bin/sh-elf-vhex-ar sh-elf-vhex/bin/sh-elf-vhex-ar
|
||||
|
||||
if [[ "$no_cache" == 'true' ]]; then
|
||||
echo "$TAG Removing $ARCHIVE..."
|
||||
rm -f $ARCHIVE
|
||||
fi
|
||||
exit 0
|
|
@ -0,0 +1,9 @@
|
|||
run_quietly() {
|
||||
out="$1"
|
||||
shift 1
|
||||
"$@" >$out 2>&1
|
||||
if [[ "$?" != 0 ]]; then
|
||||
echo "$TAG error: build failed, please check $(pwd)/$out o(x_x)o"
|
||||
exit 1
|
||||
fi
|
||||
}
|
Loading…
Reference in New Issue