Skip to content
Browse files

The AVR toolchain. Initial commit.

  • Loading branch information...
0 parents commit b0d77320a3875ed177c65a6953db06647e607247 @larsimmisch committed
Showing with 191 additions and 0 deletions.
  1. +25 −0 README.md
  2. +56 −0 avr-binutils.rb
  3. +81 −0 avr-gcc.rb
  4. +29 −0 avr-libc.rb
25 README.md
@@ -0,0 +1,25 @@
+homebrew-avr
+============
+This repository contains the GNU AVR toolchain as formulae for [Homebrew](https://github.com/mxcl/homebrew).
+
+AVR is a popular family of microcontrollers, used for example in the [Arduino](http://arduino.cc) project.
+
+Installing homebrew-avr Formulae
+--------------------------------
+Just `brew tap larsimmisch/avr` and then `brew install avr-libc`.
+
+This will install avr-libc, avr-gcc and avr-binutils.
+
+You can also install via URL:
+
+```
+brew install https://raw.github.com/adamv/homebrew-avr/master/avr-libc.rb
+```
+
+Docs
+----
+`brew help`, `man brew`, or the Homebrew [wiki][].
+
+[wiki]:http://wiki.github.com/mxcl/homebrew
+[homebrew-dupes]:https://github.com/Homebrew/homebrew-dupes
+[homebrew-versions]:https://github.com/Homebrew/homebrew-versions
56 avr-binutils.rb
@@ -0,0 +1,56 @@
+require 'formula'
+
+class AvrBinutils < Formula
+ url 'http://ftp.gnu.org/gnu/binutils/binutils-2.22.tar.bz2'
+ homepage 'http://www.gnu.org/software/binutils/binutils.html'
+ md5 'ee0f10756c84979622b992a4a61ea3f5'
+
+ def install
+
+ if MacOS.lion?
+ ENV['CC'] = 'clang'
+ end
+
+ ENV['CPPFLAGS'] = "-I#{include}"
+
+ args = ["--prefix=#{prefix}",
+ "--infodir=#{info}",
+ "--mandir=#{man}",
+ "--disable-werror",
+ "--disable-nls"]
+
+ unless ARGV.include? '--without-libiberty'
+ Dir.chdir "libiberty" do
+ ohai "building libiberty"
+ system "./configure", "--enable-install-libiberty", *args
+ system "make"
+ system "make install"
+ end
+ end
+
+ unless ARGV.include? '--without-libbfd'
+ Dir.chdir "bfd" do
+ ohai "building libbfd"
+ system "./configure", "--enable-install-libbfd", *args
+ system "make"
+ system "make install"
+ end
+ end
+
+ # brew's build environment is in our way
+ ENV.delete 'CFLAGS'
+ ENV.delete 'CXXFLAGS'
+ ENV.delete 'LD'
+ ENV.delete 'CC'
+ ENV.delete 'CXX'
+
+ if MacOS.lion?
+ ENV['CC'] = 'clang'
+ end
+
+ system "./configure", "--target=avr", *args
+
+ system "make"
+ system "make install"
+ end
+end
81 avr-gcc.rb
@@ -0,0 +1,81 @@
+require 'formula'
+
+def nocxx?
+ ARGV.include? '--disable-cxx'
+end
+
+# print avr-gcc's builtin include paths
+# `avr-gcc -print-prog-name=cc1plus` -v
+
+class AvrGcc < Formula
+ homepage 'http://gcc.gnu.org'
+ url 'http://ftp.gnu.org/gnu/gcc/gcc-4.6.2/gcc-4.6.2.tar.bz2'
+ md5 '028115c4fbfb6cfd75d6369f4a90d87e'
+
+ depends_on 'larsimmisch/avr/avr-binutils'
+ depends_on 'gmp'
+ depends_on 'libmpc'
+ depends_on 'mpfr'
+
+ def options
+ [
+ ['--disable-cxx', 'Don\'t build the g++ compiler'],
+ ]
+ end
+
+ # Dont strip compilers.
+ skip_clean :all
+
+ def install
+ gmp = Formula.factory 'gmp'
+ mpfr = Formula.factory 'mpfr'
+ libmpc = Formula.factory 'libmpc'
+
+ # brew's build environment is in our way
+ ENV.delete 'CFLAGS'
+ ENV.delete 'CXXFLAGS'
+ ENV.delete 'AS'
+ ENV.delete 'LD'
+ ENV.delete 'NM'
+ ENV.delete 'RANLIB'
+
+ if MacOS.lion?
+ ENV['CC'] = 'clang'
+ end
+
+ args = [
+ "--target=avr",
+ "--disable-libssp",
+ "--disable-nls",
+ "--with-dwarf2",
+ # Sandbox everything...
+ "--prefix=#{prefix}",
+ "--with-gmp=#{gmp.prefix}",
+ "--with-mpfr=#{mpfr.prefix}",
+ "--with-mpc=#{libmpc.prefix}",
+ # ...except the stuff in share...
+ "--datarootdir=#{share}",
+ # ...and the binaries...
+ "--bindir=#{bin}",
+ # This shouldn't be necessary
+ "--with-as=/usr/local/bin/avr-as"
+ ]
+
+ # The C compiler is always built, C++ can be disabled
+ languages = %w[c]
+ languages << 'c++' unless nocxx?
+
+ Dir.mkdir 'build'
+ Dir.chdir 'build' do
+ system '../configure', "--enable-languages=#{languages.join(',')}", *args
+ system 'make'
+
+ # At this point `make check` could be invoked to run the testsuite. The
+ # deja-gnu and autogen formulae must be installed in order to do this.
+
+ system 'make install'
+ end
+ end
+end
+
+
29 avr-libc.rb
@@ -0,0 +1,29 @@
+require 'formula'
+
+class AvrLibc < Formula
+ url 'http://download.savannah.gnu.org/releases/avr-libc/avr-libc-1.8.0.tar.bz2'
+ homepage 'http://www.nongnu.org/avr-libc/'
+ md5 '54c71798f24c96bab206be098062344f'
+
+ depends_on 'larsimmisch/avr/avr-gcc'
+
+ def install
+ # brew's build environment is in our way
+ ENV.delete 'CFLAGS'
+ ENV.delete 'CXXFLAGS'
+ ENV.delete 'LD'
+ ENV.delete 'CC'
+ ENV.delete 'CXX'
+
+ avr_gcc = Formula.factory('larsimmisch/avr/avr-gcc')
+ build = `./config.guess`.chomp
+ system "./configure", "--build=#{build}", "--prefix=#{prefix}", "--host=avr"
+ system "make install"
+ avr = File.join prefix, 'avr'
+ # copy include and lib files where avr-gcc searches for them
+ # this wouldn't be necessary with a standard prefix
+ ohai "copying #{avr} -> #{avr_gcc.prefix}"
+ cp_r avr, avr_gcc.prefix
+ end
+end
+

0 comments on commit b0d7732

Please sign in to comment.
Something went wrong with that request. Please try again.