forked from plietar/homebrew-stm32
-
Notifications
You must be signed in to change notification settings - Fork 0
/
arm-none-eabi-gcc.rb
108 lines (89 loc) · 3.41 KB
/
arm-none-eabi-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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
require 'formula'
class ArmNoneEabiGcc < Formula
homepage 'http://www.gnu.org/software/gcc/gcc.html'
url 'https://ftpmirror.gnu.org/gcc/gcc-9.2.0/gcc-9.2.0.tar.xz'
mirror 'https://gcc.gnu.org/pub/gcc/releases/gcc-9.2.0/gcc-9.2.0.tar.xz'
sha256 'ea6ef08f121239da5695f76c9b33637a118dcf63e24164422231917fa61fb206'
# http://sourceware.org/newlib/
resource 'newlib' do
url 'ftp://sourceware.org/pub/newlib/newlib-3.1.0.tar.gz'
sha256 'fb4fa1cc21e9060719208300a61420e4089d6de6ef59cf533b57fe74801d102a'
end
depends_on 'gmp'
depends_on 'libmpc'
depends_on 'mpfr'
depends_on 'isl'
depends_on 'arm-none-eabi-binutils'
option 'disable-cxx', 'Don\'t build the g++ compiler'
def install
resource('newlib').stage do
(buildpath).install Dir['newlib', 'libgloss']
end
# See https://gcc.gnu.org/ml/gcc/2014-05/msg00014.html
ENV["CC"] += " -fbracket-depth=1024"
ENV["CXX"] += " -fbracket-depth=1024"
# The C compiler is always built, C++ can be disabled
languages = %w[c]
languages << 'c++' unless build.include? 'disable-cxx'
args = [
"--target=arm-none-eabi",
"--prefix=#{prefix}",
"--enable-multilib",
"--enable-interwork",
"--with-multilib-list=aprofile,rmprofile",
"--enable-languages=#{languages.join(',')}",
"--with-gnu-as",
"--with-gnu-ld",
"--with-ld=#{Formula["arm-none-eabi-binutils"].opt_bin/'arm-none-eabi-ld'}",
"--with-as=#{Formula["arm-none-eabi-binutils"].opt_bin/'arm-none-eabi-as'}",
"--with-newlib",
"--with-headers=newlib/libc/include",
"--disable-shared",
"--disable-threads",
"--disable-libssp",
"--disable-libstdcxx-pch",
"--disable-libgomp",
"--disable-tls",
"--disable-nls",
"--disable-newlib-supplied-syscalls",
"--enable-newlib-global-atexit",
"--enable-newlib-nano-formatted-io",
"--enable-newlib-reent-small",
"--disable-newlib-fvwrite-in-streamio",
"--disable-newlib-fseek-optimization",
"--disable-newlib-wide-orient",
"--enable-newlib-nano-malloc",
"--disable-newlib-unbuf-stream-opt",
"--enable-lite-exit",
"--enable-target-optspace",
"--with-gmp=#{Formula["gmp"].opt_prefix}",
"--with-mpfr=#{Formula["mpfr"].opt_prefix}",
"--with-mpc=#{Formula["libmpc"].opt_prefix}",
"--with-isl=#{Formula["isl"].opt_prefix}",
"--with-system-zlib"
]
mkdir 'build' do
system "../configure", *args
system "make"
ENV.deparallelize
system "make install"
end
# info and man7 files conflict with native gcc
info.rmtree
man7.rmtree
# stdcxx's python helpers may conflict with native gcc
(share + "gcc-#{version}/python").rmtree
lib_paths = `#{prefix}/bin/arm-none-eabi-gcc -print-multi-lib`
lib_paths.each_line.map { |line| line.split(";").first }.each do |lib_path|
cd prefix/"arm-none-eabi/lib/#{lib_path}" do
["libc", "libg", "librdimon"].each do |lib_name|
ln_s "#{lib_name}.a", "#{lib_name}_nano.a"
end
end
end
end
test do
(testpath/"noop.c").write "void _start() {}"
system "#{bin}/arm-none-eabi-gcc", "-o", "noop", "-nostartfiles", "noop.c"
end
end