forked from larsimmisch/homebrew-avr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathavr-gcc.rb
90 lines (72 loc) · 2.26 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
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.9.1/gcc-4.9.1.tar.bz2'
sha256 'd334781a124ada6f38e63b545e2a3b8c2183049515a1abab6d513f109f1d717e'
depends_on '0xPIT/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'] = 'llvm-gcc'
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",
"--disable-install-libiberty",
"--enable-fixed-point"
]
# 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'
#multios = '.'
# multios = `gcc --print-multi-os-dir`.chomp
# binutils already has a libiberty.a. We remove ours, because
# otherwise, the symlinking of the keg fails
# File.unlink "#{prefix}/lib/#{multios}/libiberty.a"
end
end
end