mirror of
https://git.planet-casio.com/Lephenixnoir/sh-elf-gcc.git
synced 2024-12-28 04:23:39 +01:00
6cbd8270ca
* Try to check dependencies with pacman or apt * Download and extract archives (supporting gzip and xz) * Configure and build GCC and binutils (redirecting output to file, hoping that everything goes well) * Clean up uneeded files after building * Check for conflicting builds of sh-elf-gcc in the PATH * Offer to update the profile to set the PATH at login
55 lines
1.4 KiB
Bash
Executable file
55 lines
1.4 KiB
Bash
Executable file
#! /usr/bin/env bash
|
|
|
|
path=$1/bin
|
|
tag="<sh-elf-gcc>"
|
|
|
|
# Check whether there is already such a binutils in the PATH
|
|
|
|
existing=$(which sh-elf-gcc)
|
|
rc=$?
|
|
|
|
if [[ $rc == 0 && "$existing" != "$path/sh-elf-gcc" ]]; then
|
|
echo "$tag WARNING: there seems to be another sh-elf-gcc in the PATH, be careful!" >&2
|
|
fi
|
|
|
|
if [[ $rc == 0 && "$existing" == "$path/sh-elf-gcc" ]]; then
|
|
echo "$tag This build is already in the PATH, there is nothing to do." >&2
|
|
exit 0
|
|
fi
|
|
|
|
# Try to find a suitable default
|
|
|
|
default="$HOME/.profile"
|
|
candidates="$HOME/.zprofile $HOME/.profile $HOME/.bash_profile $HOME/.zshrc $HOME/.bashrc"
|
|
|
|
for c in $candidates; do
|
|
if [[ -f $c ]]; then
|
|
default=$c
|
|
break
|
|
fi
|
|
done
|
|
|
|
# Suggest to add the path to binaries to the PATH at startup
|
|
|
|
cat <<EOF
|
|
===============================================================================
|
|
sh-elf-gcc has been compiled but is not in the PATH, so it can't be used yet.
|
|
I can add this line to your profile to update the PATH when you log in:
|
|
|
|
export PATH="\$PATH:$path"
|
|
|
|
* Press Enter to add this line to $default
|
|
* Or type "-" to skip this step
|
|
* Or type in another file name
|
|
EOF
|
|
|
|
read -p "> " startup_file
|
|
[[ -z "$startup_file" ]] && startup_file=$default
|
|
|
|
if [[ "$startup_file" == "-" ]]; then
|
|
echo "$tag Skipped setting the PATH."
|
|
else
|
|
echo "export PATH=\"\$PATH:$path\"" >> $startup_file
|
|
echo "$tag Set the PATH in $startup_file, this will take effect next login."
|
|
fi
|
|
|