From bb2542f4a7727457932f573900a3316ef47a4843 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Tue, 16 May 2017 17:00:05 +0000 Subject: [PATCH] add n64-toolkit --- README.md | 8 +++ n64-toolkit/.gitignore | 6 ++ n64-toolkit/PKGBUILD.binutils | 62 +++++++++++++++++ n64-toolkit/PKGBUILD.bootstrap | 119 ++++++++++++++++++++++++++++++++ n64-toolkit/PKGBUILD.gcc | 120 +++++++++++++++++++++++++++++++++ n64-toolkit/PKGBUILD.newlib | 70 +++++++++++++++++++ n64-toolkit/build | 22 ++++++ n64-toolkit/repackage | 18 +++++ 8 files changed, 425 insertions(+) create mode 100644 n64-toolkit/.gitignore create mode 100644 n64-toolkit/PKGBUILD.binutils create mode 100644 n64-toolkit/PKGBUILD.bootstrap create mode 100644 n64-toolkit/PKGBUILD.gcc create mode 100644 n64-toolkit/PKGBUILD.newlib create mode 100644 n64-toolkit/build create mode 100644 n64-toolkit/repackage diff --git a/README.md b/README.md index 26709e0..ac624fd 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,14 @@ a few things aren't working yet, but the core functionality is there. patches tbox to compile/run with MSYS2. *a lot of stuff* isn't working yet. +### n64-toolkit + +compiles a cross-compiler for N64 homebrew. +works on both Arch and MSYS2. + +i need to rename this package at some point. +currently, it doesn't follow any guidelines. + ### xml2 modified to download from a mirror. diff --git a/n64-toolkit/.gitignore b/n64-toolkit/.gitignore new file mode 100644 index 0000000..b10f7fa --- /dev/null +++ b/n64-toolkit/.gitignore @@ -0,0 +1,6 @@ +*.bz2 +*.gz +*.xz +n64 +pkg +src diff --git a/n64-toolkit/PKGBUILD.binutils b/n64-toolkit/PKGBUILD.binutils new file mode 100644 index 0000000..40a74e4 --- /dev/null +++ b/n64-toolkit/PKGBUILD.binutils @@ -0,0 +1,62 @@ +_target=mips64 +_prefix="/opt/n64-toolchain-slim" +pkgname=n64-toolkit-binutils +pkgver=2.27 +pkgrel=1 +_binutils="binutils-$pkgver" +pkgdesc="A set of programs to assemble and manipulate binary and object files (${_target})" +arch=('any') +license=('GPL') +url="http://www.gnu.org/software/binutils/" +depends=('zlib') +source=("ftp://gcc.gnu.org/pub/binutils/releases/$_binutils.tar.bz2") +md5sums=('2869c9bf3e60ee97c74ac2a6bf4e9d68') +options=('!emptydirs' '!strip') + +prepare() { + cd "$srcdir/$_binutils" + # Hack - see native package for details + sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" libiberty/configure +} + +build() { + # the programs we're compiling are really picky about flags. + # it's best to keep it simple. + export CFLAGS="-O2" + export CXXFLAGS="-O2" + export CPPFLAGS="" + export LDFLAGS="" + + export CFLAGS_FOR_TARGET="-O2 -ffunction-sections -fdata-sections \ +-fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables" + export CXXFLAGS_FOR_TARGET="$CFLAGS_FOR_TARGET -fno-rtti" + + cd "$srcdir" + [ -d "build-binutils" ] || mkdir "build-binutils" + cd "build-binutils" + + local _build= + if [ -n "$MINGW_CHOST" ]; then + _build="--build=$MINGW_CHOST --host=$MINGW_CHOST" + fi + + "../$_binutils/configure" $_build --target=${_target} --prefix="$_prefix" \ + --enable-static \ + --disable-gold \ + --disable-multilib \ + --disable-nls \ + --disable-shared \ + --disable-werror \ + + make all +} + +package() { + local PREFIX="$pkgdir$_prefix" + + cd "$srcdir/build-binutils" + make DESTDIR="$pkgdir" install -j1 + + # strip host binaries + find "$PREFIX/bin" -type f -and \( -executable \) -exec strip '{}' \; +} diff --git a/n64-toolkit/PKGBUILD.bootstrap b/n64-toolkit/PKGBUILD.bootstrap new file mode 100644 index 0000000..99b1c6b --- /dev/null +++ b/n64-toolkit/PKGBUILD.bootstrap @@ -0,0 +1,119 @@ +_target=mips64 +_prefix="/opt/n64-toolchain-slim" +_mpfr=mpfr-3.1.4 +_gmp=gmp-6.1.0 +_mpc=mpc-1.0.3 +_isl=isl-0.16.1 +pkgname=n64-toolkit-bootstrap +pkgver=6.2.0 +pkgrel=1 +_gcc="gcc-$pkgver" +pkgdesc="The GNU Compiler Collection. Stage 1 for toolchain building (${_target})" +arch=('any') +license=('GPL' 'LGPL' 'FDL') +url='http://www.gnu.org/software/gcc/' +depends=('zlib' 'n64-toolkit-binutils') # 'libmpc' +makedepends=('gmp' 'mpfr') +provides=('n64-toolkit-gcc') +source=("ftp://gcc.gnu.org/pub/gcc/releases/$_gcc/$_gcc.tar.bz2" + "ftp://gcc.gnu.org/pub/gcc/infrastructure/$_mpfr.tar.bz2" + "ftp://gcc.gnu.org/pub/gcc/infrastructure/$_gmp.tar.bz2" + "ftp://gcc.gnu.org/pub/gcc/infrastructure/$_mpc.tar.gz" + "ftp://gcc.gnu.org/pub/gcc/infrastructure/$_isl.tar.bz2") +md5sums=('9768625159663b300ae4de2f4745fcc4' + 'b8a2f6b0e68bef46e53da2ac439e1cf4' + '86ee6e54ebfc4a90b643a65e402c4048' + 'd6a1d5f8ddea3abd2cc3e98f58352d26' + 'ac1f25a0677912952718a51f5bc20f32') +options=('!emptydirs' '!strip') + +prepare() { + cd "$srcdir/$_isl" + # Fix trailing comma which errors with -pedantic for host GCC <= 4.3 + sed -i 's/isl_stat_ok = 0,/isl_stat_ok = 0/' "include/isl/ctx.h" + + cd "$srcdir/$_gcc" + rm -rf mpfr gmp mpc isl + ln -sf "$srcdir/$_mpfr" mpfr + ln -sf "$srcdir/$_gmp" gmp + ln -sf "$srcdir/$_mpc" mpc + ln -sf "$srcdir/$_isl" isl + # Hack - see native package for details + sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {libiberty,gcc}/configure +} + +build() { + # the programs we're compiling are really picky about flags. + # it's best to keep it simple. + export CFLAGS="-O2" + export CXXFLAGS="-O2" + export CPPFLAGS="" + export LDFLAGS="" + + export CFLAGS_FOR_TARGET="-O2 -ffunction-sections -fdata-sections \ +-fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables" + export CXXFLAGS_FOR_TARGET="$CFLAGS_FOR_TARGET -fno-rtti" + + cd "$srcdir" + [ -d "build-bootstrap-gcc" ] || mkdir "build-bootstrap-gcc" + cd "build-bootstrap-gcc" + + local _build= + if [ -n "$MINGW_CHOST" ]; then + _build="--build=$MINGW_CHOST --host=$MINGW_CHOST" + fi + + "../$_gcc/configure" $_build --target=${_target} --prefix="$_prefix" \ + --disable-__cxa_atexit \ + --disable-decimal-float \ + --disable-gold \ + --disable-initfini-array \ + --disable-libada \ + --disable-libatomic \ + --disable-libgcj \ + --disable-libgomp \ + --disable-libitm \ + --disable-libquadmath \ + --disable-libquadmath-support \ + --disable-libsanitizer \ + --disable-libssp \ + --disable-libunwind-exceptions \ + --disable-libvtv \ + --disable-multiarch \ + --disable-multilib \ + --disable-nls \ + --disable-plugin \ + --disable-shared \ + --disable-threads \ + --disable-tls \ + --disable-werror \ + --enable-languages=c,c++,lto \ + --enable-static \ + --enable-target-optspace \ + --with-abi=32 \ + --with-arch=vr4300 \ + --with-newlib \ + --with-tune=vr4300 \ + --without-included-gettext \ + --without-headers \ + + make all-gcc +} + +package() { + local PREFIX="$pkgdir$_prefix" + + cd "$srcdir/build-bootstrap-gcc" + make DESTDIR="$pkgdir" install-gcc -j1 + + # strip target binaries + find "$PREFIX/lib" \( -name "*.a" -or -name "*.o" \) -exec $_target-objcopy \ + -R .comment -R .note -R .debug_info -R .debug_aranges -R .debug_pubnames -R .debug_pubtypes -R .debug_abbrev -R .debug_line -R .debug_str -R .debug_ranges -R .debug_loc \ + '{}' \; + + # strip host binaries + find "$PREFIX/bin" "$PREFIX/lib/gcc/$_target/${_gcc/gcc-/}" \ + -type f -and \( -executable \) -exec strip '{}' \; + + rm -r "$PREFIX/share/info" +} diff --git a/n64-toolkit/PKGBUILD.gcc b/n64-toolkit/PKGBUILD.gcc new file mode 100644 index 0000000..5b75764 --- /dev/null +++ b/n64-toolkit/PKGBUILD.gcc @@ -0,0 +1,120 @@ +_target=mips64 +_prefix="/opt/n64-toolchain-slim" +_mpfr=mpfr-3.1.4 +_gmp=gmp-6.1.0 +_mpc=mpc-1.0.3 +_isl=isl-0.16.1 +pkgname=n64-toolkit-gcc +pkgver=6.2.0 +pkgrel=1 +_gcc="gcc-$pkgver" +pkgdesc="The GNU Compiler Collection (${_target})" +arch=('any') +license=('GPL' 'LGPL' 'FDL') +url='http://www.gnu.org/software/gcc/' +depends=('zlib' "n64-toolkit-binutils" "n64-toolkit-newlib") # 'libmpc' +makedepends=('gmp' 'mpfr') +conflicts=('n64-toolkit-bootstrap') +provides=('n64-toolkit-bootstrap') +replaces=('n64-toolkit-bootstrap') +source=("ftp://gcc.gnu.org/pub/gcc/releases/$_gcc/$_gcc.tar.bz2" + "ftp://gcc.gnu.org/pub/gcc/infrastructure/$_mpfr.tar.bz2" + "ftp://gcc.gnu.org/pub/gcc/infrastructure/$_gmp.tar.bz2" + "ftp://gcc.gnu.org/pub/gcc/infrastructure/$_mpc.tar.gz" + "ftp://gcc.gnu.org/pub/gcc/infrastructure/$_isl.tar.bz2") +md5sums=('9768625159663b300ae4de2f4745fcc4' + 'b8a2f6b0e68bef46e53da2ac439e1cf4' + '86ee6e54ebfc4a90b643a65e402c4048' + 'd6a1d5f8ddea3abd2cc3e98f58352d26' + 'ac1f25a0677912952718a51f5bc20f32') +options=('!emptydirs' '!strip') + +prepare() { + cd "$srcdir/$_isl" + # Fix trailing comma which errors with -pedantic for host GCC <= 4.3 + sed -i 's/isl_stat_ok = 0,/isl_stat_ok = 0/' "include/isl/ctx.h" + + cd "$srcdir/$_gcc" + rm -rf mpfr gmp mpc isl + ln -sf "$srcdir/$_mpfr" mpfr + ln -sf "$srcdir/$_gmp" gmp + ln -sf "$srcdir/$_mpc" mpc + ln -sf "$srcdir/$_isl" isl + # Hack - see native package for details + sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {libiberty,gcc}/configure +} + +build() { + # the programs we're compiling are really picky about flags. + # it's best to keep it simple. + export CFLAGS="-O2" + export CXXFLAGS="-O2" + export CPPFLAGS="" + export LDFLAGS="" + + export CFLAGS_FOR_TARGET="-O2 -ffunction-sections -fdata-sections \ +-fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables" + export CXXFLAGS_FOR_TARGET="$CFLAGS_FOR_TARGET -fno-rtti" + + cd "$srcdir" + [ -d "build-gcc" ] || mkdir "build-gcc" + cd "build-gcc" + + local _build= + if [ -n "$MINGW_CHOST" ]; then + _build="--build=$MINGW_CHOST --host=$MINGW_CHOST" + fi + + "../$_gcc/configure" $_build --target=${_target} --prefix="$_prefix" \ + --disable-__cxa_atexit \ + --disable-decimal-float \ + --disable-gold \ + --disable-initfini-array \ + --disable-libada \ + --disable-libatomic \ + --disable-libgcj \ + --disable-libgomp \ + --disable-libitm \ + --disable-libquadmath \ + --disable-libquadmath-support \ + --disable-libsanitizer \ + --disable-libssp \ + --disable-libunwind-exceptions \ + --disable-libvtv \ + --disable-multiarch \ + --disable-multilib \ + --disable-nls \ + --disable-plugin \ + --disable-shared \ + --disable-threads \ + --disable-tls \ + --disable-werror \ + --enable-languages=c,c++,lto \ + --enable-static \ + --enable-target-optspace \ + --with-abi=32 \ + --with-arch=vr4300 \ + --with-newlib \ + --with-tune=vr4300 \ + --without-included-gettext \ + + make all +} + +package() { + local PREFIX="$pkgdir$_prefix" + + cd "$srcdir/build-gcc" + make DESTDIR="$pkgdir" install -j1 + + # strip target binaries + find "$PREFIX/$_target/lib" \( -name "*.a" -or -name "*.o" \) -exec $_target-objcopy \ + -R .comment -R .note -R .debug_info -R .debug_aranges -R .debug_pubnames -R .debug_pubtypes -R .debug_abbrev -R .debug_line -R .debug_str -R .debug_ranges -R .debug_loc \ + '{}' \; + + # strip host binaries + find "$PREFIX/bin" "$PREFIX/lib/gcc/$_target/${_gcc/gcc-/}" \ + -type f -and \( -executable \) -exec strip '{}' \; + + rm -r "$PREFIX/share/info" +} diff --git a/n64-toolkit/PKGBUILD.newlib b/n64-toolkit/PKGBUILD.newlib new file mode 100644 index 0000000..4d5a432 --- /dev/null +++ b/n64-toolkit/PKGBUILD.newlib @@ -0,0 +1,70 @@ +_target=mips64 +_prefix="/opt/n64-toolchain-slim" +pkgname=n64-toolkit-newlib +pkgver=2.4.0.20161025 +pkgrel=1 +_newlib="newlib-$pkgver" +pkgdesc="A C library intended for use on embedded systems (${_target})" +arch=('any') +license=('BSD') +url='http://sourceware.org/newlib/' +makedepends=('n64-toolkit-bootstrap') +source=("ftp://sourceware.org/pub/newlib/$_newlib.tar.gz") +md5sums=('6b1bf8483f71d776bbc54533054caa3e') +options=('!emptydirs' '!strip') + +build() { + export PATH="$PATH:$_prefix/bin" + + # the programs we're compiling are really picky about flags. + # it's best to keep it simple. + export CFLAGS="-O2" + export CXXFLAGS="-O2" + export CPPFLAGS="" + export LDFLAGS="" + + export CFLAGS_FOR_TARGET="-O2 -ffunction-sections -fdata-sections \ +-fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables" + export CXXFLAGS_FOR_TARGET="$CFLAGS_FOR_TARGET -fno-rtti" + + cd "$srcdir" + [ -d "build-newlib" ] || mkdir "build-newlib" + cd "build-newlib" + + local _build= + if [ -n "$MINGW_CHOST" ]; then + _build="--build=$MINGW_CHOST --host=$MINGW_CHOST" + fi + + "../$_newlib/configure" $_build --target=${_target} --prefix="$_prefix" \ + --with-newlib \ + --enable-lto \ + --enable-target-optspace \ + --enable-lite-exit \ + --enable-newlib-global-atexit \ + --enable-newlib-nano-malloc \ + --disable-shared \ + --disable-threads \ + --disable-newlib-atexit-dynamic-alloc \ + --disable-newlib-fvwrite-in-streamio \ + --disable-newlib-wide-orient \ + --disable-newlib-unbuf-stream-opt \ + --disable-newlib-supplied-syscalls \ + + #--enable-newlib-nano-formatted-io + make +} + +package() { + export PATH="$PATH:$_prefix/bin" + + local PREFIX="$pkgdir$_prefix" + + cd "$srcdir/build-newlib" + make DESTDIR="$pkgdir" install -j1 + + # strip target binaries + find "$PREFIX/$_target/lib" \( -name "*.a" -or -name "*.o" \) -exec $_target-objcopy \ + -R .comment -R .note -R .debug_info -R .debug_aranges -R .debug_pubnames -R .debug_pubtypes -R .debug_abbrev -R .debug_line -R .debug_str -R .debug_ranges -R .debug_loc \ + '{}' \; +} diff --git a/n64-toolkit/build b/n64-toolkit/build new file mode 100644 index 0000000..9df2381 --- /dev/null +++ b/n64-toolkit/build @@ -0,0 +1,22 @@ +#!/usr/bin/env zsh + +maybe_sudo() { + if which sudo >/dev/null; then + sudo "$@" + else + if [ "$1" = "-u" ]; then + shift; shift + fi + "$@" + fi +} + +set -e +maybe_sudo -u "$USER" makepkg -fp PKGBUILD.binutils +maybe_sudo pacman -U *.xz(om[1]) +maybe_sudo -u "$USER" makepkg -fp PKGBUILD.bootstrap +maybe_sudo pacman -U *.xz(om[1]) +maybe_sudo -u "$USER" makepkg -fp PKGBUILD.newlib +maybe_sudo pacman -U *.xz(om[1]) +maybe_sudo -u "$USER" makepkg -efp PKGBUILD.gcc +maybe_sudo pacman -U *.xz(om[1]) diff --git a/n64-toolkit/repackage b/n64-toolkit/repackage new file mode 100644 index 0000000..59d0778 --- /dev/null +++ b/n64-toolkit/repackage @@ -0,0 +1,18 @@ +#!/usr/bin/env zsh + +maybe_sudo() { + if which sudo >/dev/null; then + sudo "$@" + else + if [ "$1" = "-u" ]; then + shift; shift + fi + "$@" + fi +} + +set -e +maybe_sudo -u "$USER" makepkg -Rfp PKGBUILD.binutils +maybe_sudo -u "$USER" makepkg -Rfp PKGBUILD.bootstrap +maybe_sudo -u "$USER" makepkg -Rfp PKGBUILD.newlib +maybe_sudo -u "$USER" makepkg -Rfp PKGBUILD.gcc