Initial commit
This commit is contained in:
commit
e4e9ebd5b0
4 changed files with 245 additions and 0 deletions
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
*.jpg filter=lfs diff=lfs merge=lfs -text
|
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
*~
|
||||
work/
|
||||
x-tools/
|
||||
*.xip
|
||||
*.xz
|
BIN
icon.jpg
(Stored with Git LFS)
Normal file
BIN
icon.jpg
(Stored with Git LFS)
Normal file
Binary file not shown.
236
install.sh
Executable file
236
install.sh
Executable file
|
@ -0,0 +1,236 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
|
||||
#
|
||||
# Copyright 2023 Scott Duensing <scott@kangaroopunch.com>
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the “Software”), to
|
||||
# deal in the Software without restriction, including without limitation the
|
||||
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
# sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
# IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
|
||||
PIURL=https://github.com/tttapa/docker-arm-cross-toolchain/releases/latest/download/x-tools-
|
||||
|
||||
|
||||
function buildMacOSXToolchain() {
|
||||
local SDK=$1
|
||||
local XCODE=$2
|
||||
local PLATFORM=$3
|
||||
local BASE=$(pwd)
|
||||
# This isn't great. What if there is more than one version installed?
|
||||
#local LLVM=$(ls -1 /usr/lib | grep llvm)
|
||||
#local CLANG=$(ls -1 /usr/lib/${LLVM}/lib/clang | grep -F .)
|
||||
|
||||
mkdir -p work
|
||||
|
||||
if [[ ! -d work/osxcross ]]; then
|
||||
git clone https://github.com/tpoechtrager/osxcross.git work/osxcross
|
||||
sudo work/osxcross/tools/get_dependencies.sh
|
||||
fi
|
||||
|
||||
if [[ ! -f x-tools/${PLATFORM}/toolchain.cmake ]]; then
|
||||
pushd work/osxcross
|
||||
# Have we built Apple's clang?
|
||||
#if [[ ! -d "${BASE}/clang" ]]; then
|
||||
# UNATTENDED=1 INSTALLPREFIX=${BASE}/clang ./build_apple_clang.sh
|
||||
#fi
|
||||
# Do we have an existing SDK tarball?
|
||||
if [[ ! -f "${BASE}/${SDK}" ]]; then
|
||||
# Nope. Build tarball and keep for later.
|
||||
./tools/gen_sdk_package_pbzx.sh "${BASE}/${XCODE}"
|
||||
mv -f MacOSX* "${BASE}/."
|
||||
fi
|
||||
# Put tarball in place.
|
||||
cp -f "${BASE}/${SDK}" tarballs/.
|
||||
# Build SDK.
|
||||
UNATTENDED=1 TARGET_DIR=${BASE}/x-tools/${PLATFORM} ./build.sh
|
||||
# Fix fubar in osxcross.
|
||||
[[ -d target ]] && rm -rf target
|
||||
ln -sf ${BASE}/x-tools/${PLATFORM} target
|
||||
# Build compiler runtime.
|
||||
./build_compiler_rt.sh
|
||||
# Tidy up for next build.
|
||||
./cleanup.sh
|
||||
popd
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function install_x86_64_linux() {
|
||||
# Required tools for Linux x86_64. These should always be installed.
|
||||
sudo apt-get install -y \
|
||||
binutils \
|
||||
bison \
|
||||
build-essential \
|
||||
clang \
|
||||
cmake \
|
||||
curl \
|
||||
flex \
|
||||
git \
|
||||
git-lfs \
|
||||
liblzma-dev \
|
||||
texinfo \
|
||||
unzip \
|
||||
zlib1g-dev
|
||||
}
|
||||
|
||||
|
||||
function install_x86_linux() {
|
||||
# x86 Linux support.
|
||||
sudo apt-get install -y gcc-multilib
|
||||
}
|
||||
|
||||
|
||||
function install_x86_64_windows() {
|
||||
# x86 and x86_64 Windows.
|
||||
sudo apt-get install -y mingw-w64
|
||||
}
|
||||
|
||||
|
||||
function install_aarch64_pi() {
|
||||
# Raspberry Pi, various CPUs.
|
||||
wget -O- ${PIURL}aarch64-rpi3-linux-gnu.tar.xz | tar xJ
|
||||
}
|
||||
|
||||
|
||||
function install_armv6_pi() {
|
||||
wget -O- ${PIURL}armv6-rpi-linux-gnueabihf.tar.xz | tar xJ
|
||||
}
|
||||
|
||||
|
||||
function install_armv8_pi() {
|
||||
wget -O- ${PIURL}armv8-rpi3-linux-gnueabihf.tar.xz | tar xJ
|
||||
#***TODO*** sysroots
|
||||
}
|
||||
|
||||
|
||||
|
||||
function install_x86_64_macos() {
|
||||
# MacOS x86, x86_64.
|
||||
#***TODO*** https://stackoverflow.com/questions/67712376/after-updating-gcc-clang-cant-find-libstdc-anymore
|
||||
buildMacOSXToolchain MacOSX10.13.sdk.tar.xz Xcode_9.4.1.xip x86_64-macos-apple
|
||||
}
|
||||
|
||||
|
||||
function install_aarch64_macos() {
|
||||
# MacOS aarch64.
|
||||
buildMacOSXToolchain MacOSX13.3.sdk.tar.xz Xcode_14.3.1.xip aarch64-macos-apple
|
||||
}
|
||||
|
||||
|
||||
function install_x86_dos() {
|
||||
# DJGPP for DOS.
|
||||
export DJGPP_PREFIX=$(pwd)/x-tools/djgpp
|
||||
|
||||
mkdir -p work
|
||||
|
||||
if [[ ! -d work/build-djgpp ]]; then
|
||||
git clone https://github.com/andrewwutw/build-djgpp.git work/build-djgpp
|
||||
fi
|
||||
|
||||
#if [[ ! -f x-tools/${PLATFORM}/toolchain.cmake ]]; then
|
||||
pushd work/build-djgpp
|
||||
./build-djgpp.sh 12.2.0
|
||||
popd
|
||||
#fi
|
||||
}
|
||||
|
||||
|
||||
ARCH=$1
|
||||
PLAT=$2
|
||||
|
||||
HELP=1
|
||||
|
||||
COLS=2
|
||||
ROWS=9
|
||||
row=0
|
||||
declare -A PLATFORMS=()
|
||||
PLATFORMS[0]="x86_64"; PLATFORMS[1]="linux"
|
||||
PLATFORMS[2]="x86"; PLATFORMS[3]="linux"
|
||||
PLATFORMS[4]="x86_64"; PLATFORMS[5]="windows"
|
||||
PLATFORMS[6]="aarch64"; PLATFORMS[7]="pi"
|
||||
PLATFORMS[8]="armv6"; PLATFORMS[9]="pi"
|
||||
PLATFORMS[10]="armv8"; PLATFORMS[11]="pi"
|
||||
PLATFORMS[12]="x86_64"; PLATFORMS[13]="macos"
|
||||
PLATFORMS[14]="aarch64"; PLATFORMS[15]="macos"
|
||||
PLATFORMS[16]="x86"; PLATFORMS[17]="dos"
|
||||
|
||||
# Install all toolchains.
|
||||
if [[ "${ARCH}" == "all" && "${PLAT}" == "all" ]]; then
|
||||
HELP=0
|
||||
for (( row=0; row<ROWS; row++ )); do
|
||||
set -x
|
||||
install_${ARCH}_${PLAT}
|
||||
set +x
|
||||
done
|
||||
fi
|
||||
|
||||
# Install all toolchains for a specific platform.
|
||||
if [[ "${ARCH}" == "all" && "${PLAT}" != "all" ]]; then
|
||||
HELP=0
|
||||
for (( row=0; row<ROWS; row++ )); do
|
||||
if [[ "${PLAT}" == "${PLATFORMS[$((${COLS}*${row}+1))]}" ]]; then
|
||||
set -x
|
||||
install_${ARCH}_${PLAT}
|
||||
set +x
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Install a single toolchain.
|
||||
if [[ "${ARCH}" != "all" && "${PLAT}" != "all" ]]; then
|
||||
for (( row=0; row<ROWS; row++ )); do
|
||||
if [[ "${ARCH}" == "${PLATFORMS[$((${COLS}*${row}))]}" && "${PLAT}" == "${PLATFORMS[$((${COLS}*${row}+1))]}" ]]; then
|
||||
HELP=0
|
||||
set -x
|
||||
install_${ARCH}_${PLAT}
|
||||
set +x
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Do they need help?
|
||||
if [[ ${HELP} -eq 1 ]]; then
|
||||
cat <<-HELP
|
||||
|
||||
Kangaroo Punch Toolchain Installer
|
||||
http://skunkworks.kangaroopunch.com
|
||||
|
||||
Usage: $0 [architecture] [platform]
|
||||
|
||||
Where [architecture] and [platform] are one of:
|
||||
|
||||
HELP
|
||||
for (( row=0; row<ROWS; row++ )); do
|
||||
printf ' %-10s %s\n' "${PLATFORMS[$((${COLS}*${row}))]}" "${PLATFORMS[$((${COLS}*${row}+1))]}"
|
||||
done
|
||||
cat <<-HELP
|
||||
|
||||
If [architecture] and [platform] are both "all",
|
||||
everything will be installed.
|
||||
|
||||
if [architecture] is "all", then all available
|
||||
architectures for the specified [platform] will
|
||||
be installed.
|
||||
|
||||
NOTE: You should always install x86_64 linux
|
||||
before attempting to install other
|
||||
toolchains.
|
||||
|
||||
HELP
|
||||
fi
|
Loading…
Add table
Reference in a new issue