sh-elf-vhex - v1.4.0-dev1 : create bootstrap script + drop vxSDK support (WIP)
*regression* > [project] | [arch] drop vxSDK support (WIP) *add* > [scripts] | [bootstrap] create the bootstrap script *update* > [scripts] | [install] move to internal name (`install.sh` -> `_install.sh`) | [uninstall] move to internal name (`uninstall.sh` -> `_uninstall.sh`) | [utils] move to internal name (`utils.sh` -> `_utils.sh`) | [utils] review code (WIP)
This commit is contained in:
parent
404a425a7c
commit
3b071dbbdf
60
Makefile
60
Makefile
|
@ -1,60 +0,0 @@
|
|||
#---
|
||||
# This makefile is particular because it can be involved many time during the
|
||||
# building process. This is why we using many conditional rule exposition
|
||||
#
|
||||
# All possible scenarii are :
|
||||
# * sh-elf-vhex -> fxlibc -> OpenLibM -> sh-elf-vhex
|
||||
# * sh-elf-vhex -> fxlibc -> sh-elf-vhex
|
||||
# * fxlibc -> sh-elf-vhex -> fxlibc -> sh-elf-vhex
|
||||
# * OpenLibM -> sh-elf-vhex -> fxlibc -> OpenLibM -> sh-elf-vhex
|
||||
#---
|
||||
|
||||
VERSION_BINUTILS := 2.38
|
||||
VERSION_GCC := 11.3.0
|
||||
|
||||
|
||||
# check that the vxSDK is used
|
||||
|
||||
ifeq ($(VXSDK_PREFIX_INSTALL),)
|
||||
$(error you need to use the vxSDK to compile this package)
|
||||
endif
|
||||
|
||||
# default rules
|
||||
|
||||
all: build install
|
||||
|
||||
#---
|
||||
# Performs the real operations
|
||||
#---
|
||||
|
||||
ifeq ($(VXSDK_COMPILER_CIRCULAR_BUILD_WORKAROUND),)
|
||||
build:
|
||||
@ cd ./scripts/binutils && ./configure.sh --version="$(VERSION_BINUTILS)"
|
||||
@ cd ./scripts/binutils && ./build.sh
|
||||
@ cd ./scripts/gcc && ./configure.sh --version="$(VERSION_GCC)"
|
||||
@ cd ./scripts/gcc && ./build.sh
|
||||
|
||||
install:
|
||||
@ cd ./scripts && ./install.sh --prefix="$(VXSDK_PREFIX_INSTALL)"
|
||||
|
||||
uninstall:
|
||||
@ cd ./scripts && ./uninstall.sh --prefix="$(VXSDK_PREFIX_INSTALL)"
|
||||
|
||||
#---
|
||||
# If a circular build is detected, simulate that all operations have
|
||||
# successfully been executed
|
||||
#---
|
||||
|
||||
else
|
||||
build:
|
||||
@ true
|
||||
|
||||
install:
|
||||
@ true
|
||||
|
||||
uninstall:
|
||||
@ true
|
||||
|
||||
endif
|
||||
|
||||
.PHONY: all build install uninstall
|
|
@ -1,19 +0,0 @@
|
|||
# Vhex toolchain file for chadCasio graphing calculators
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
set(CMAKE_SYSTEM_VERSION 1)
|
||||
set(CMAKE_SYSTEM_PROCESSOR sh)
|
||||
|
||||
set(CMAKE_C_COMPILER sh-elf-vhex-gcc)
|
||||
set(CMAKE_CXX_COMPILER sh-elf-vhex-g++)
|
||||
|
||||
set(CMAKE_C_FLAGS_INIT "")
|
||||
set(CMAKE_CXX_FLAGS_INIT "")
|
||||
|
||||
add_compile_options(-nostdlib)
|
||||
add_link_options(-nostdlib)
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
|
@ -7,7 +7,8 @@ prefix=
|
|||
#---
|
||||
# Help screen
|
||||
#---
|
||||
help() {
|
||||
|
||||
function help() {
|
||||
cat << OEF
|
||||
Script for the installation step of binutils/GCC tools for the Vhex kernel.
|
||||
|
||||
|
@ -22,9 +23,6 @@ OEF
|
|||
exit 0
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#---
|
||||
# Parse arguments
|
||||
#---
|
||||
|
@ -41,14 +39,11 @@ for arg; do case "$arg" in
|
|||
exit 1
|
||||
esac; done
|
||||
|
||||
|
||||
|
||||
|
||||
#---
|
||||
# Installation step
|
||||
#---
|
||||
|
||||
source ../scripts/utils.sh
|
||||
source ../scripts/_utils.sh
|
||||
|
||||
TAG='<sh-elf-vhex>'
|
||||
PREFIX="$prefix"
|
||||
|
@ -71,17 +66,12 @@ if [[ "$cache" == 'false' ]]; then
|
|||
rm -rf ../../build
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
#---
|
||||
# Symbolic link executables to $PREFIX
|
||||
#---
|
||||
|
||||
echo "$TAG Symlinking binaries..."
|
||||
|
||||
cd "$SYSROOT/bin"
|
||||
|
||||
mkdir -p "$PREFIX"
|
||||
for x in *; do
|
||||
ln -sf "$SYSROOT/bin/$x" "$PREFIX/$x"
|
|
@ -0,0 +1,66 @@
|
|||
# module used to provide common variable / functions
|
||||
|
||||
## workaround to trick the linter
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
verbose=false
|
||||
fi
|
||||
|
||||
#---
|
||||
# Exposed vars
|
||||
#---
|
||||
|
||||
# select the appropriate quiet primitive
|
||||
quiet='run_normaly'
|
||||
[[ "$verbose" == "false" ]] && quiet='run_quietly vxsdk-build.log'
|
||||
export quiet
|
||||
|
||||
# Number of processor cores
|
||||
[[ $(uname) == "OpenBSD" ]] && cores=$(sysctl -n hw.ncpu) || cores=$(nproc)
|
||||
export cores
|
||||
|
||||
# Select make utility
|
||||
make_cmd='make'
|
||||
[[ $(command -v gmake >/dev/null 2>&1) ]] && make_cmd='gmake'
|
||||
export make_cmd
|
||||
|
||||
#---
|
||||
# Functions provided
|
||||
#---
|
||||
|
||||
function run_normaly() {
|
||||
echo "$@"
|
||||
if ! "$@"; then
|
||||
echo "$TAG error: command failed, abord"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function run_quietly() {
|
||||
out="$1"
|
||||
shift 1
|
||||
if ! "$@" >"$out" 2>&1; then
|
||||
>&2 echo "$TAG error: command failed, please check $(pwd)/$out o(x_x)o"
|
||||
>&2 echo "$@"
|
||||
exit 1
|
||||
fi
|
||||
rm -f "$out"
|
||||
}
|
||||
|
||||
function utils_find_last_version() {
|
||||
_version=$(find "$1/" -maxdepth 1 -type d,l)
|
||||
_version=$(echo "$_version" | sort -r )
|
||||
_version=$(echo "$_version" | head -n 1)
|
||||
_version=$(basename "$_version")
|
||||
echo "$_version"
|
||||
}
|
||||
|
||||
function get_sysroot() {
|
||||
if [ -z "${VHEX_PREFIX_SYSROOT}" ]; then
|
||||
echo 'error: are you sure to use the bootstrap script ?' >&2
|
||||
echo ' Missing sysroot information, abord' >&2
|
||||
exit 1
|
||||
fi
|
||||
SYSROOT="${VHEX_PREFIX_SYSROOT/#\~/$HOME}"
|
||||
mkdir -p "$SYSROOT"
|
||||
echo "SYSROOT"
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
#---
|
||||
# Help screen
|
||||
#---
|
||||
|
||||
function help() {
|
||||
cat << OEF
|
||||
Bootstrap script used to install or uninstall the sh-elf-vhex compiler.
|
||||
|
||||
Usage $0 [options...]
|
||||
|
||||
Options:
|
||||
-h, --help Display this help
|
||||
-v, --verbose Display extra information during operation
|
||||
--prefix-install Installation prefix
|
||||
--prefix-sysroot Sysroot prefix
|
||||
--prefix-clone Clone prefix
|
||||
--uninstall Uninstall operation
|
||||
|
||||
Notes:
|
||||
|
||||
This script will use env variables:
|
||||
VHEX_VERSION_BINUTILS - target version of BINUTILS
|
||||
VHEX_VERSION_GCC - target version of GCC
|
||||
VHEX_PREFIX_INSTALL - installation prefix
|
||||
VHEX_PREFIX_SYSROOT - sysroot prefix
|
||||
|
||||
Default value for each configuration:
|
||||
VHEX_VERSION_BINUTILS - lastest detected
|
||||
VHEX_VERSION_GCC - lastest detected
|
||||
VHEX_PREFIX_INSTALL - "~/.local/bin/"
|
||||
VHEX_PREFIX_CLONE - "~/.local/share/sh-elf-vhex"
|
||||
VHEX_PREFIX_SYSROOT - "~/.local/share/sh-elf-vhex/sysroot"
|
||||
OEF
|
||||
exit 0
|
||||
}
|
||||
|
||||
#---
|
||||
# Parse arguments
|
||||
#---
|
||||
|
||||
[[ $# -eq 0 ]] && help
|
||||
|
||||
action='install'
|
||||
VHEX_VERBOSE=false
|
||||
VHEX_PREFIX_INSTALL=~/.local/bin
|
||||
VHEX_PREFIX_SYSROOT=~/.local/share/sh-elf-vhex/sysroot
|
||||
VHEX_PREFIX_CLONE=~/.local/share/sh-elf-vhex
|
||||
|
||||
for arg; do
|
||||
case "$arg" in
|
||||
--help | -h) help;;
|
||||
--verbose | -v) VHEX_VERBOSE=true;;
|
||||
--prefix-install=*) VHEX_PREFIX_INSTALL=${arg#*=};;
|
||||
--prefix-sysroot=*) VHEX_PREFIX_SYSROOT=${arg#*=};;
|
||||
--uninstall) action='uninstall';;
|
||||
*)
|
||||
echo "error: unreconized argument '$arg', giving up." >&2
|
||||
exit 1
|
||||
esac
|
||||
done
|
||||
|
||||
#---
|
||||
# Preliminary check
|
||||
#---
|
||||
|
||||
_src=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
if [ -d "$VHEX_PREFIX_CLONE" ]; then
|
||||
echo "It seems that the project is already existing :pouce:" >&2
|
||||
echo \
|
||||
'If you realy want to install this project remove the folder' \
|
||||
"'$VHEX_PREFIX_CLONE'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source ./_utils.sh
|
||||
|
||||
VHEX_VERSION_GCC=$(utils_find_last_version "$_src/../patchs/gcc")
|
||||
VHEX_VERSION_BINUTILS=$(utils_find_last_version "$_src/../patchs/binutils")
|
||||
|
||||
if [[ "$VHEX_VERBOSE" == 'true' ]]
|
||||
then
|
||||
echo "Debug fetched information:"
|
||||
echo " - VHEX_VERSION_BINUTILS = $VHEX_VERSION_BINUTILS"
|
||||
echo " - VHEX_VERSION_GCC = $VHEX_VERSION_GCC"
|
||||
echo " - VHEX_PREFIX_INSTALL = $VHEX_PREFIX_INSTALL"
|
||||
echo " - VHEX_PREFIX_SYSROOT = $VHEX_PREFIX_SYSROOT"
|
||||
echo " - VHEX_PREFIX_CLONE = $VHEX_PREFIX_CLONE"
|
||||
fi
|
||||
|
||||
if [[ "$action" == 'install' ]]
|
||||
then
|
||||
echo 'The script will install the sh-elf-vhex compiler with:'
|
||||
echo " - GCC version: $VHEX_VERSION_GCC"
|
||||
echo " - Binutils version: $VHEX_VERSION_BINUTILS"
|
||||
echo " - Clone directory: $VHEX_PREFIX_CLONE"
|
||||
echo " - Compliler install at: $VHEX_PREFIX_INSTALL"
|
||||
read -p 'Process ? [yN]: ' -r valid
|
||||
else
|
||||
read -p 'Uninstall the sh-elf-vhex compiler ? [yN]: ' -r valid
|
||||
fi
|
||||
if [[ "$valid" != 'y' ]]; then
|
||||
echo 'Operation aborted o(x_x)o'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#---
|
||||
# Perform install operation
|
||||
#---
|
||||
|
||||
git clone \
|
||||
--depth=1 \
|
||||
https://github.com/YannMagnin/sh-elf-vhex.git \
|
||||
"$VHEX_PREFIX_CLONE"
|
||||
cd "$VHEX_PREFIX_CLONE" || exit 1
|
||||
|
||||
export VHEX_VERSION_BINUTILS
|
||||
export VHEX_VERSION_GCC
|
||||
export VHEX_VERBOSE
|
||||
export VHEX_PREFIX_INSTALL
|
||||
export VHEX_PREFIX_SYSROOT
|
||||
export VHEX_PREFIX_CLONE
|
||||
|
||||
if [[ "$action" == 'install' ]]
|
||||
then
|
||||
./scripts/binutils/configure.sh
|
||||
#./scripts/binutils/build.sh
|
||||
#./scripts/gcc/configure.sh
|
||||
#./scripts/gcc/build.sh
|
||||
#./scripts/_install.sh
|
||||
else
|
||||
./scripts/_uninstall.sh
|
||||
fi
|
||||
|
||||
echo 'Successfully installed sh-elf-vhex !'
|
||||
echo "Do not forget to export the binary path '$VHEX_PREFIX_INSTALL'"
|
||||
exit 0
|
|
@ -1,47 +0,0 @@
|
|||
# module used to provide common variable / functions
|
||||
|
||||
# select the appropriate quiet primitive
|
||||
quiet='run_normaly'
|
||||
[[ "$verbose" == "false" ]] && quiet='run_quietly vxsdk-build.log'
|
||||
|
||||
# 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
|
||||
|
||||
#
|
||||
# Functions privided
|
||||
#
|
||||
|
||||
run_normaly() {
|
||||
echo "$@"
|
||||
"$@"
|
||||
if [[ "$?" != 0 ]]; then
|
||||
echo "$TAG error: command failed, abord"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
run_quietly() {
|
||||
out="$1"
|
||||
shift 1
|
||||
"$@" >$out 2>&1
|
||||
if [[ "$?" != 0 ]]; then
|
||||
>&2 echo "$TAG error: command failed, please check $(pwd)/$out o(x_x)o"
|
||||
>&2 echo "$@"
|
||||
exit 1
|
||||
fi
|
||||
rm -f "$out"
|
||||
}
|
||||
|
||||
get_sysroot() {
|
||||
if [ -z $VXSDK_PREFIX_SYSROOT ]; then
|
||||
>2& echo "error: are you sure to use the vxSDK ?"
|
||||
>2& echo " Missing sysroot information, abord"
|
||||
exit 1
|
||||
fi
|
||||
SYSROOT="${VXSDK_PREFIX_SYSROOT/#\~/$HOME}"
|
||||
mkdir -p "$SYSROOT"
|
||||
echo "$SYSROOT"
|
||||
}
|
16
vxsdk.toml
16
vxsdk.toml
|
@ -1,16 +0,0 @@
|
|||
[project]
|
||||
name = 'sh-elf-vhex'
|
||||
type = 'app'
|
||||
target = [
|
||||
'superh'
|
||||
]
|
||||
|
||||
[superh.build]
|
||||
build = 'make build'
|
||||
install = 'make install'
|
||||
uninstall = 'make uninstall'
|
||||
|
||||
[superh.env]
|
||||
VXSDK_PUBLIC_HOOK_CMAKE_TOOLCHAIN = [
|
||||
'{VXSDK_CURRENT_SOURCE_DIR}/cmake/toolchain.cmake'
|
||||
]
|
Loading…
Reference in New Issue