forked from larsimmisch/homebrew-avr
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathavr-gcc.rb
93 lines (76 loc) · 2.61 KB
/
avr-gcc.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
require 'formula'
# Atmel distributes a complete tarball of patches.
class AtmelPatches < Formula
url 'http://distribute.atmel.no/tools/opensource/Atmel-AVR-Toolchain-3.4.1.830/avr/avr-patches.tar.gz'
homepage 'http://www.atmel.com/tools/ATMELAVRTOOLCHAINFORLINUX.aspx'
sha1 '08208bdc9ddb6b4b328c1b4c94a2b81f1d750289'
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'
sha1 '691974613b1c1f15ed0182ec539fa54a12dd6f93'
depends_on 'avr-binutils'
depends_on 'gmp'
depends_on 'libmpc'
depends_on 'mpfr'
option 'disable-cxx', "Don't build the g++ compiler"
def patches
mkdir buildpath/'patches'
AtmelPatches.new.brew { cp Dir['gcc/*'], buildpath/'patches' }
{ :p0 => Dir[buildpath/'patches/*'] }
end
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'] = 'llvm-gcc'
end
args = [
"LDFLAGS=-L#{prefix}/lib",
"--target=avr",
"--with-dwarf2",
"--disable-shared",
"--disable-libada",
"--disable-libssp",
"--disable-nls",
# 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",
# Not sure if this is really needed.
"--enable-fixed-point"
]
# The C compiler is always built, C++ can be disabled
languages = %w[c]
languages << 'c++' unless build.include? 'disable-cxx'
# Pick up any autotools changes.
ENV['AUTOCONF'] = '/usr/local/bin/autoconf264'
ENV['AUTOM4TE'] = '/usr/local/bin/autom4te264'
system "autoconf264"
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