-
Notifications
You must be signed in to change notification settings - Fork 15
/
Portfile
275 lines (238 loc) · 12.1 KB
/
Portfile
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
# $Id$
# Maybe we should copy a lot of what the arm-elf-gcc Portfile does into this.
# like including newlib, and a lot of the build options
PortSystem 1.0
set targetarch arm-none-eabi
name ${targetarch}-gcc-linaro
version 4.5-2011.01-1
set branch [join [lrange [split ${version} .] 0 1] .]
set newlibversion 1.19.0
categories cross devel
platforms darwin
maintainers nomaintainer
description gcc cross-compilers for ${targetarch}, with newlib runtime library.
long_description gnu compilers collection (including c and c++) for ${targetarch}, with newlib runtime library.
homepage http://gcc.gnu.org/
master_sites http://launchpad.net/gcc-linaro/4.5/${version}/+download/:gcc \
http://download.paparazziuav.org/linux/source/newlib/ \
ftp://sources.redhat.com/pub/newlib/:newlib
distfiles gcc-linaro-${version}.tar.bz2:gcc \
newlib-${newlibversion}.tar.gz:newlib
use_bzip2 yes
checksums gcc-linaro-4.5-2011.01-1.tar.bz2 \
md5 82d9719082edbbfa1baaae590add19a1 \
sha1 8112f919c324324b62510af92c40511694bfe626 \
rmd160 a35f1f0e93f65c2f807326b07fa24a098fe12ef9 \
newlib-1.19.0.tar.gz \
md5 0966e19f03217db9e9076894b47e6601 \
sha1 b2269d30ce7b93b7c714b90ef2f40221c2df0fcd \
rmd160 a28bd656ec895da0738dac3fb367851a2992d724
# All cross ports violate the mtree layout.
destroot.violate_mtree yes
depends_lib-append port:gmp \
port:mpfr \
port:mpc \
port:libmpc\
port:gettext \
port:libiconv \
port:${targetarch}-binutils
# gmp and mpfr are not universal
universal_variant no
worksrcdir build
extract.only gcc-linaro-${version}.tar.bz2
# Extract newlib and create a symlink of newlib/newlib in gcc directory.
post-extract {
system "cd ${workpath} && gzip -dc ${distpath}/newlib-${newlibversion}.tar.gz | tar -xf -"
system "ln -s ${workpath}/newlib-${newlibversion}/newlib ${workpath}/gcc-linaro-${version}/"
}
patch.dir ${workpath}/gcc-linaro-${version}
patchfiles \
patch-gcc-config-arm-t-arm-elf.diff
# Since we don't build gcc and binutils at the same time, gcc's Makefile will try to transform
# program names as gcc's name (add -${version} with ${version} being the version of gcc).
# But it won't work because binutils binaries don't have the ${version} suffix, and even if they
# had, they would actually have the binutils' version suffix (and not gcc's version).
# So let's tell gcc's Makefile not to do that mistake.
set environment [list AR_FOR_TARGET=${targetarch}-ar \
AS_FOR_TARGET=${targetarch}-as \
LD_FOR_TARGET=${targetarch}-ld \
NM_FOR_TARGET=${targetarch}-nm \
RANLIB_FOR_TARGET=${targetarch}-ranlib ]
pre-configure {
file mkdir ${worksrcpath}
}
configure.env ${environment}
configure.cmd ../gcc-linaro-${version}/configure
configure.optflags-delete -O2
configure.pipe
configure.cc gcc
configure.cxx g++
configure.cppflags
configure.ldflags
configure.cc-append -I${prefix}/include
configure.args --target=${targetarch} \
--program-prefix=${targetarch}- \
--enable-interwork \
--enable-multilib \
--enable-languages="c" \
--with-newlib \
--with-gnu-as \
--with-gnu-ld \
--disable-nls \
--disable-shared \
--disable-threads \
--with-headers=${workpath}/newlib-${newlibversion}/newlib/libc/include \
--disable-libssp \
--disable-libstdcxx-pch \
--disable-libmudflap \
--disable-libgomp \
--disable-werror \
--with-system-zlib \
--with-gmp=${prefix} \
--with-mpfr=${prefix} \
--with-mpc=${prefix} \
--with-libiconv-prefix=${prefix} \
--disable-newlib-supplied-syscalls
if {${os.platform} == "darwin" && ($build_arch == "x86_64" || $build_arch == "ppc64")} {
configure.args-append --build=${build_arch}-apple-darwin${os.version} \
--host=${build_arch}-apple-darwin${os.version}
}
configure.cc_archflags
configure.cxx_archflags
configure.objc_archflags
if {[info exists configure.ld_archflags]} {
configure.ld_archflags
}
build.args ${environment}
destroot.args ${environment}
post-patch {
namespace eval crossgcc {}
# Fix the info pages and related stuff.
#
# path: path to the doc directory (e.g. gas/doc/)
# makefile: path to Makefile.in (e.g. gas/doc/Makefile.in)
# name: name of the info page (e.g. as)
# suffix: suffix of the souce page (texinfo or texi)
proc crossgcc::fixinfo { path makefile name suffix } {
global targetarch worksrcpath
# Fix the source
reinplace "s|setfilename ${name}.info|setfilename ${targetarch}-${name}.info|g" \
${worksrcpath}/${path}/${name}.${suffix}
reinplace "s|(${name})|(${targetarch}-${name})|g" \
${worksrcpath}/${path}/${name}.${suffix}
reinplace "s|@file{${name}}|@file{${targetarch}-${name}}|g" \
${worksrcpath}/${path}/${name}.${suffix}
# Fix the Makefile
reinplace "s| ${name}.info| ${targetarch}-${name}.info|g" \
${worksrcpath}/${makefile}
reinplace "s|/${name}.info|/${targetarch}-${name}.info|g" \
${worksrcpath}/${makefile}
reinplace "s|^${name}.info|${targetarch}-${name}.info|g" \
${worksrcpath}/${makefile}
reinplace "s| ${name}.pod| ${targetarch}-${name}.pod|g" \
${worksrcpath}/${makefile}
reinplace "s|/${name}.pod|/${targetarch}-${name}.pod|g" \
${worksrcpath}/${makefile}
reinplace "s|^${name}.pod|${targetarch}-${name}.pod|g" \
${worksrcpath}/${makefile}
reinplace "s| ${name}.${suffix}| ${targetarch}-${name}.${suffix}|g" \
${worksrcpath}/${makefile}
reinplace "s|/${name}.${suffix}|/${targetarch}-${name}.${suffix}|g" \
${worksrcpath}/${makefile}
reinplace "s|^${name}.${suffix}|${targetarch}-${name}.${suffix}|g" \
${worksrcpath}/${makefile}
# Rename the source
file rename ${worksrcpath}/${path}/${name}.${suffix} \
${worksrcpath}/${path}/${targetarch}-${name}.${suffix}
# Fix install-info's dir.
# (note: this may be effectless if there was no info dir to be fixed)
reinplace "s|--info-dir=\$(DESTDIR)\$(infodir)|--dir-file=\$(DESTDIR)\$(infodir)/${targetarch}-gcc-dir|g" \
"${worksrcpath}/${makefile}"
}
# Fix the gettext files and related stuff.
#
# module: name of the module (e.g. gas)
proc crossgcc::fixgettext { module } {
global targetarch worksrcpath
if { [ file exists "${worksrcpath}/${module}/Makefile.in" ] } {
reinplace "s|@PACKAGE@|${targetarch}-@PACKAGE@|g" \
"${worksrcpath}/${module}/Makefile.in"
reinplace "s|${module}\.mo|${targetarch}-${module}.mo|g" \
"${worksrcpath}/${module}/Makefile.in"
}
if { [ file exists "${worksrcpath}/${module}/doc/Makefile.in" ] } {
reinplace "s|@PACKAGE@|${targetarch}-@PACKAGE@|g" \
"${worksrcpath}/${module}/doc/Makefile.in"
}
}
# # gcc/doc/cpp.texi
# crossgcc::fixinfo gcc/doc/ gcc/Makefile.in cpp texi
# # gcc/doc/cppinternals.texi
# crossgcc::fixinfo gcc/doc/ gcc/Makefile.in cppinternals texi
# # gcc/doc/gcc.texi
# crossgcc::fixinfo gcc/doc/ gcc/Makefile.in gcc texi
# # gcc/doc/gccint.texi
# crossgcc::fixinfo gcc/doc/ gcc/Makefile.in gccint texi
# # gcc/fortran/gfortran.texi
# crossgcc::fixinfo gcc/fortran/ gcc/fortran/Make-lang.in gfortran texi
# # gcc/java/gcj.texi
# crossgcc::fixinfo gcc/java/ gcc/java/Make-lang.in gcj texi
# # gcc/doc/gccinstall.info
# crossgcc::fixinfo gcc/doc/ gcc/Makefile.in gccinstall info
# # gettext stuff.
# crossgcc::fixgettext gcc
# crossgcc::fixgettext libcpp
}
pre-destroot {
# gcc needs the cross directory structure to be present
# in order to fill it during installation.
file mkdir "${destroot}${prefix}/${targetarch}/bin"
file mkdir "${destroot}${prefix}/${targetarch}/lib"
}
post-destroot {
namespace eval crossgcc {}
# Rename a man page if it exists.
#
# section: section of the man page (e.g. 1)
# manpage: name of the man page (e.g. cpp)
proc crossgcc::rename_man_page { section manpage } {
global targetarch destroot prefix
set manpage_path "${destroot}${prefix}/share/man/man${section}/${manpage}.${section}"
if { [ file exists ${manpage_path} ] } {
file rename ${manpage_path} \
"${destroot}${prefix}/share/man/man${section}/${targetarch}-${manpage}.${section}"
}
}
# Stuff I don't want (either because they're in the system
# or because they would conflict with other FSF ports)
# (it's easier for maintainability purposes to fix things here)
# aliases for locales (should be on the system)
file delete "${destroot}${prefix}/share/locale/locale.alias"
# FSF propaganda (should already be there or would conflict)
file delete -force "${destroot}${prefix}/share/man/man7"
# (host) libiberty
foreach f [glob -directory "${destroot}${prefix}/lib" libiberty.a */libiberty.a] {
file delete $f
}
# aliases for charsets (should already be there)
file delete "${destroot}${prefix}/lib/charset.alias"
# Remove man pages for tools that are not built as part of cross-gcc
file delete "${destroot}${prefix}/share/man/man1/rmic.1"
file delete "${destroot}${prefix}/share/man/man1/rmiregistry.1"
file delete "${destroot}${prefix}/share/man/man1/jv-convert.1"
file delete "${destroot}${prefix}/share/man/man1/gij.1"
# For some reason, some man pages are not prefixed while they should have been
# (to avoid conflicting).
crossgcc::rename_man_page 1 cpp
crossgcc::rename_man_page 1 gcjh
crossgcc::rename_man_page 1 gcov
crossgcc::rename_man_page 1 jcf-dump
crossgcc::rename_man_page 1 jv-scan
# There is a bug in gcc/Makefile::install-driver
# For cross compilers, $(GCC_INSTALL_NAME) is equal to
# $(target_noncanonical)-gcc-$(version)
# and hence the driver isn't installed.
xinstall -c "${workpath}/build/gcc/xgcc" \
"${destroot}${prefix}/bin/${targetarch}-gcc-${version}"
}