Last active
November 20, 2023 08:37
-
-
Save asdfugil/8d629aa1d9f5080a4c6c868b47600879 to your computer and use it in GitHub Desktop.
procursus-toolchain-fbsd.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
export PREFIX="${HOME}"/.local | |
export GNUBINDIR="${PREFIX}"/libexec/gnubin | |
mkdir -p "${GNUBINDIR}" | |
COREUTILS='basename cat chgrp chmod chown chroot cksum comm cp csplit cut date dd df dir dircolors dirname du echo env expand expr factor false fmt fold groups head hostid hostname id install join kill link ln logname ls md5sum mkdir mkfifo mknod mv nice nl nohup od paste pathchk pinky pr printenv printf ptx pwd readlink rm rmdir seq sha1sum shred sleep sort split stat stty su sum sync tac tail tee test touch tr true tsort tty uname unexpand uniq unlink uptime users vdir wc who whoami yes' | |
OTHER_GNU_BINS='make tar sed patch find' | |
if [ ! -f "${GNUBINDIR}/.link_complete" ]; then | |
for util in $COREUTILS $OTHER_GNU_BINS; do | |
ln -sfn /usr/local/bin/g$util "${GNUBINDIR}/${util}" | |
done | |
ln -sfn /usr/local/bin/grep "${GNUBINDIR}/grep" | |
touch "${GNUBINDIR}/.link_complete" | |
fi | |
export PATH="${GNUBINDIR}":"${PATH}" | |
export TAPI_VERSION=1100.0.11 | |
wget -O /tmp/libtapi.tar.gz https://github.com/tpoechtrager/apple-libtapi/archive/refs/heads/${TAPI_VERSION}.tar.gz | |
gtar -xf /tmp/libtapi.tar.gz | |
rm /tmp/libtapi.tar.gz | |
mkdir -p apple-libtapi-${TAPI_VERSION}/build | |
pushd apple-libtapi-${TAPI_VERSION}/build | |
TAPI_INCLUDE_FIX="-I $PWD/../src/llvm/projects/clang/include " | |
TAPI_INCLUDE_FIX+="-I $PWD/projects/clang/include " | |
cmake ../src/llvm \ | |
-DCMAKE_CXX_FLAGS="${TAPI_INCLUDE_FIX}" \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DCMAKE_INSTALL_PREFIX=${PREFIX} \ | |
-DTAPI_FULL_VERSION="${TAPI_VERSION}" \ | |
-DLLVM_ENABLE_PROJECTS="libtapi" \ | |
-DTAPI_INCLUDE_TESTS=OFF \ | |
-DLLVM_INCLUDE_TESTS=OFF | |
gmake -j$(sysctl -n hw.ncpu) clangBasic libtapi | |
gmake -j$(sysctl -n hw.ncpu) install-libtapi install-tapi-headers | |
popd | |
git clone https://github.com/tpoechtrager/cctools-port.git | |
cd cctools-port/cctools | |
./configure \ | |
--prefix=${PREFIX} \ | |
--with-libtapi=${PREFIX} \ | |
--target=aarch64-apple-darwin | |
gmake -j$(sysctl -n hw.ncpu) | |
gmake install | |
gmake clean | |
./configure \ | |
--prefix=${PREFIX} \ | |
--with-libtapi=${PREFIX} \ | |
--target=x86_64-apple-darwin | |
gmake -j$(sysctl -n hw.ncpu) | |
gmake install | |
gmake clean | |
cd ../.. | |
git clone git://git.saurik.com/ldid.git | |
cd ldid | |
git submodule update --init | |
c++ -O3 -g0 -c -std=c++11 -I/usr/local/include -o ldid.o ldid.cpp | |
c++ -O3 -g0 -L/usr/local/lib -o ldid ldid.o -x c lookup2.c -lcrypto -lplist-2.0 | |
install -m755 ./ldid ${PREFIX}/bin/ldid | |
cd .. | |
mkdir -p ~/cctools/{SDK,MacOSX-SDKs,iOS-SDKs} | |
git clone --depth=1 https://github.com/xybp888/iOS-SDKs ~/cctools/iOS-SDKs | |
ln -s ~/cctools/iOS-SDKs/iPhoneOS14.5.sdk ~/cctools/SDK/iPhoneOS.sdk | |
git clone --depth=1 https://github.com/phracker/MacOSX-SDKs ~/cctools/MacOSX-SDKs | |
ln -s ~/cctools/MacOSX-SDKs/MacOSX11.3.sdk ~/cctools/SDK/MacOSX.sdk | |
cd ~/cctools/SDK | |
wget -P /tmp https://cdn.discordapp.com/attachments/672628720497852459/871756626066018354/AppleTVOS.sdk.zst https://cdn.discordapp.com/attachments/672628720497852459/871756640754470933/WatchOS.sdk.zst | |
zstd -d /tmp/{AppleTVOS,WatchOS}.sdk.zst | |
rm /tmp/{AppleTVOS,WatchOS}.sdk.zst | |
cd ../.. | |
echo 'Done.' | |
echo 'Don't forget to add ${PREFIX}/bin to your PATH, as well as setting the GNUBINDIR environmental veriable in your shell's .profile or .profile equivlant.' | |
echo '' | |
echo 'export PATH='"${PREFIX}"'/bin:${PATH}' | |
echo 'export GNUBINDIR='"${GNUBINDIR}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment