Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@z4yx
Created January 18, 2020 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save z4yx/dbae4821547625f272de0f9b50abd8ed to your computer and use it in GitHub Desktop.
Save z4yx/dbae4821547625f272de0f9b50abd8ed to your computer and use it in GitHub Desktop.
MIPS GCC for Homebrew
class MipselNoneElfBinutils < Formula
desc "FSF Binutils for mipsel cross development"
homepage "https://www.gnu.org/software/binutils/"
url "https://ftp.gnu.org/gnu/binutils/binutils-2.32.tar.gz"
sha256 "9b0d97b3d30df184d302bced12f976aa1e5fbf4b0be696cdebc6cca30411a46e"
def install
system "./configure", "--target=mipsel-none-elf",
"--disable-multilib",
"--disable-nls",
"--disable-werror",
"--prefix=#{prefix}"
system "make"
system "make", "install"
end
test do
assert_match "f()", shell_output("#{bin}/mipsel-none-elf-c++filt _Z1fv")
end
end
class MipselNoneElfBinutils < Formula
desc "FSF Binutils for mipsel cross development"
homepage "https://www.gnu.org/software/binutils/"
url "https://ftp.gnu.org/gnu/binutils/binutils-2.32.tar.gz"
sha256 "9b0d97b3d30df184d302bced12f976aa1e5fbf4b0be696cdebc6cca30411a46e"
def install
system "./configure", "--target=mipsel-none-elf",
"--disable-multilib",
"--disable-nls",
"--disable-werror",
"--prefix=#{prefix}"
system "make"
system "make", "install"
end
test do
assert_match "f()", shell_output("#{bin}/mipsel-none-elf-c++filt _Z1fv")
end
end
class MipselNoneElfGcc < Formula
desc "The GNU compiler collection for mipsel"
homepage "https://gcc.gnu.org"
url "https://ftp.gnu.org/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.xz"
sha256 "ea6ef08f121239da5695f76c9b33637a118dcf63e24164422231917fa61fb206"
depends_on "gmp"
depends_on "mipsel-none-elf-binutils"
depends_on "libmpc"
depends_on "mpfr"
def install
mkdir "mipsel-none-elf-gcc-build" do
system "../configure", "--target=mipsel-none-elf",
"--prefix=#{prefix}",
"--without-isl",
"--disable-nls",
"--disable-threads",
"--disable-shared",
"--disable-libssp",
"--disable-libstdcxx-pch",
"--disable-libgomp",
"--disable-werror",
"--without-headers",
"--with-as=#{Formula["mipsel-none-elf-binutils"].bin}/mipsel-none-elf-as",
"--with-ld=#{Formula["mipsel-none-elf-binutils"].bin}/mipsel-none-elf-ld",
"--enable-languages=c,c++"
system "make", "all-gcc"
system "make", "install-gcc"
system "make", "all-target-libgcc"
system "make", "install-target-libgcc"
end
end
test do
(testpath/"test-c.c").write <<~EOS
int main(void)
{
int i=0;
while(i<10) i++;
return i;
}
EOS
system "#{bin}/mipsel-none-elf-gcc", "-c", "-o", "test-c.o", "test-c.c"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment