1 | # $Id: $ |
---|
2 | |
---|
3 | PortSystem 1.0 |
---|
4 | |
---|
5 | name arm-eabi-gcc |
---|
6 | version 4.3.2 |
---|
7 | set branch [join [lrange [split ${version} .] 0 1] .] |
---|
8 | |
---|
9 | # Parameters for this port. |
---|
10 | set newlibversion 1.16.0 |
---|
11 | set crossgcc-target arm-eabi |
---|
12 | set default-languages --enable-languages="c,c++,objc" |
---|
13 | |
---|
14 | description gcc cross-compilers for arm-eabi, with newlib runtime library. |
---|
15 | long_description gnu compilers collection (including c++, fortran and objc) for \ |
---|
16 | arm-eabi, with newlib runtime library. |
---|
17 | homepage http://gcc.gnu.org/ |
---|
18 | platforms darwin |
---|
19 | categories cross devel |
---|
20 | maintainers nomaintainer |
---|
21 | # an exception in the license allows dependents to not be GPL |
---|
22 | license {GPL-3+ Permissive} |
---|
23 | master_sites gnu:gcc/gcc-${version}/:gcc \ |
---|
24 | ftp://sources.redhat.com/pub/newlib/:newlib \ |
---|
25 | http://www.mirrorservice.org/sites/sourceware.org/pub/newlib/:newlib |
---|
26 | distfiles gcc-${version}.tar.bz2:gcc newlib-${newlibversion}.tar.gz:newlib |
---|
27 | worksrcdir gcc-${version} |
---|
28 | checksums gcc-${version}.tar.bz2 \ |
---|
29 | md5 5dfac5da961ecd5f227c3175859a486d \ |
---|
30 | sha1 787b566ad4f386a9896e2d5703e6ff5e7ccaca58 \ |
---|
31 | rmd160 0ced28bd2e0d89f081cf88273b5f1530599b52fb \ |
---|
32 | newlib-${newlibversion}.tar.gz \ |
---|
33 | md5 bf8f1f9e3ca83d732c00a79a6ef29bc4 \ |
---|
34 | sha1 841edec33d19a9e549984982fb92445ee967e265 \ |
---|
35 | rmd160 fa40ff43e858da3093c9f3b5b203724b9b327696 |
---|
36 | patchfiles patch-gcc-config-arm-t-arm-elf.diff \ |
---|
37 | patch-newlib-libc-configure.diff \ |
---|
38 | Make-lang.in.diff |
---|
39 | |
---|
40 | # All cross ports violate the mtree layout. |
---|
41 | destroot.violate_mtree yes |
---|
42 | |
---|
43 | # Download everything to gcc/ |
---|
44 | dist_subdir gcc |
---|
45 | |
---|
46 | depends_lib port:${crossgcc-target}-binutils \ |
---|
47 | port:gmp \ |
---|
48 | port:mpfr \ |
---|
49 | port:gettext \ |
---|
50 | port:libmpc |
---|
51 | |
---|
52 | # arm-eabi-binutils is not universal |
---|
53 | universal_variant no |
---|
54 | |
---|
55 | # gcc is .bz2, newlib is .gz. |
---|
56 | # let's extract only gcc with MacPorts infrastructure, we'll do newlib manually. |
---|
57 | use_bzip2 yes |
---|
58 | extract.only gcc-${version}.tar.bz2 |
---|
59 | |
---|
60 | # Extract newlib and create a symlink of newlib/newlib in gcc directory. |
---|
61 | post-extract { |
---|
62 | system "cd ${workpath} && gzip -dc ${distpath}/newlib-${newlibversion}.tar.gz | tar -xf -" |
---|
63 | system "ln -s ${workpath}/newlib-${newlibversion}/newlib ${workpath}/gcc-${version}/" |
---|
64 | } |
---|
65 | |
---|
66 | # Since we don't build gcc and binutils at the same time, gcc's Makefile will try to transform |
---|
67 | # program names as gcc's name (add -${version} with ${version} being the version of gcc). |
---|
68 | # But it won't work because binutils binaries don't have the ${version} suffix, and even if they |
---|
69 | # had, they would actually have the binutils' version suffix (and not gcc's version). |
---|
70 | # So let's tell gcc's Makefile not to do that mistake. |
---|
71 | |
---|
72 | set environment [list AR_FOR_TARGET=${crossgcc-target}-ar \ |
---|
73 | AS_FOR_TARGET=${crossgcc-target}-as \ |
---|
74 | LD_FOR_TARGET=${crossgcc-target}-ld \ |
---|
75 | NM_FOR_TARGET=${crossgcc-target}-nm \ |
---|
76 | RANLIB_FOR_TARGET=${crossgcc-target}-ranlib] |
---|
77 | |
---|
78 | proc multilibpatch_enable { options dirnames exceptions matches } { |
---|
79 | global worksrcpath |
---|
80 | system "echo 'MULTILIB_OPTIONS += ${options}' >> ${worksrcpath}/gcc/config/arm/t-arm-elf" |
---|
81 | system "echo 'MULTILIB_DIRNAMES += ${dirnames}' >> ${worksrcpath}/gcc/config/arm/t-arm-elf" |
---|
82 | system "echo 'MULTILIB_EXCEPTIONS += ${exceptions}' >> ${worksrcpath}/gcc/config/arm/t-arm-elf" |
---|
83 | system "echo 'MULTILIB_MATCHES += ${matches}' >> ${worksrcpath}/gcc/config/arm/t-arm-elf" |
---|
84 | } |
---|
85 | |
---|
86 | variant be description {big endian multilib support} { |
---|
87 | post-patch { |
---|
88 | multilibpatch_enable \ |
---|
89 | "mlittle-endian/mbig-endian" \ |
---|
90 | "le be" \ |
---|
91 | "" \ |
---|
92 | "mbig-endian=mbe mlittle-endian=mle" |
---|
93 | } |
---|
94 | } |
---|
95 | |
---|
96 | variant ep9312 description {ep9312 multilib support} { |
---|
97 | post-patch { |
---|
98 | multilibpatch_enable \ |
---|
99 | "mcpu=ep9312" \ |
---|
100 | "ep9312" \ |
---|
101 | "*mthumb/*mcpu=ep9312* *mcpu=ep9312*/*mhard-float*" \ |
---|
102 | "" |
---|
103 | } |
---|
104 | } |
---|
105 | |
---|
106 | variant fpu description {fpu multilib support} { |
---|
107 | post-patch { |
---|
108 | multilibpatch_enable \ |
---|
109 | "mhard-float/msoft-float" \ |
---|
110 | "fpu soft" \ |
---|
111 | "*mthumb/*mhard-float*" \ |
---|
112 | "" |
---|
113 | } |
---|
114 | configure.args-append --enable-fpu |
---|
115 | } |
---|
116 | |
---|
117 | variant interwork description {thumb interwork multilib support} { |
---|
118 | post-patch { |
---|
119 | multilibpatch_enable \ |
---|
120 | "mno-thumb-interwork/mthumb-interwork" \ |
---|
121 | "normal interwork" \ |
---|
122 | "" \ |
---|
123 | "" |
---|
124 | } |
---|
125 | configure.args-append --enable-interwork |
---|
126 | } |
---|
127 | |
---|
128 | variant under description {leading underscore multilib support} { |
---|
129 | post-patch { |
---|
130 | multilibpatch_enable \ |
---|
131 | "fno-leading-underscore/fleading-underscore" \ |
---|
132 | "eabi under" \ |
---|
133 | "" \ |
---|
134 | "" |
---|
135 | } |
---|
136 | configure.args-append --enable-underscore |
---|
137 | } |
---|
138 | |
---|
139 | variant nofmult description {no fpu multiplication multilib support} { |
---|
140 | post-patch { |
---|
141 | multilibpatch_enable \ |
---|
142 | "mcpu=arm7" \ |
---|
143 | "nofmult" \ |
---|
144 | "*mthumb*/*mcpu=arm7*" \ |
---|
145 | "" |
---|
146 | } |
---|
147 | configure.args-append --enable-nofmult |
---|
148 | } |
---|
149 | |
---|
150 | # Use llvm-gcc-4.2, doesn't build with clang |
---|
151 | configure.compiler llvm-gcc-4.2 |
---|
152 | |
---|
153 | # Build in a different directory, as advised in the README file. |
---|
154 | pre-configure { |
---|
155 | file mkdir "${workpath}/build" |
---|
156 | } |
---|
157 | configure.dir ${workpath}/build |
---|
158 | configure.cmd ${workpath}/gcc-${version}/configure |
---|
159 | configure.cc-append -I${prefix}/include |
---|
160 | configure.env ${environment} |
---|
161 | configure.args --infodir='${prefix}/share/info' \ |
---|
162 | --mandir='${prefix}/share/man' \ |
---|
163 | --target=${crossgcc-target} \ |
---|
164 | --program-prefix=${crossgcc-target}- \ |
---|
165 | --program-suffix=-${branch} \ |
---|
166 | --without-included-gettext \ |
---|
167 | --enable-obsolete \ |
---|
168 | --with-newlib \ |
---|
169 | --disable-__cxa_atexit \ |
---|
170 | --enable-multilib \ |
---|
171 | --enable-biendian \ |
---|
172 | --disable-libgfortran \ |
---|
173 | --with-gxx-include-dir=${prefix}/${crossgcc-target}/include/c++/${version}/ \ |
---|
174 | ${default-languages} |
---|
175 | configure.cc_archflags |
---|
176 | configure.cxx_archflags |
---|
177 | configure.objc_archflags |
---|
178 | configure.ld_archflags |
---|
179 | if {${os.platform} == "darwin" && ($build_arch == "x86_64" || $build_arch == "ppc64")} { |
---|
180 | configure.args-append --build=${build_arch}-apple-darwin${os.major} |
---|
181 | } |
---|
182 | |
---|
183 | build.dir ${workpath}/build |
---|
184 | |
---|
185 | build.args ${environment} |
---|
186 | destroot.args ${environment} |
---|
187 | |
---|
188 | post-patch { |
---|
189 | namespace eval crossgcc {} |
---|
190 | |
---|
191 | # Fix the info pages and related stuff. |
---|
192 | # |
---|
193 | # path: path to the doc directory (e.g. gas/doc/) |
---|
194 | # makefile: path to Makefile.in (e.g. gas/doc/Makefile.in) |
---|
195 | # name: name of the info page (e.g. as) |
---|
196 | # suffix: suffix of the souce page (texinfo or texi) |
---|
197 | proc crossgcc::fixinfo { path makefile name suffix } { |
---|
198 | global crossgcc-target worksrcpath |
---|
199 | |
---|
200 | # Fix the source |
---|
201 | reinplace "s|setfilename ${name}.info|setfilename ${crossgcc-target}-${name}.info|g" \ |
---|
202 | ${worksrcpath}/${path}/${name}.${suffix} |
---|
203 | reinplace "s|(${name})|(${crossgcc-target}-${name})|g" \ |
---|
204 | ${worksrcpath}/${path}/${name}.${suffix} |
---|
205 | reinplace "s|@file{${name}}|@file{${crossgcc-target}-${name}}|g" \ |
---|
206 | ${worksrcpath}/${path}/${name}.${suffix} |
---|
207 | |
---|
208 | # Fix the Makefile |
---|
209 | reinplace "s| ${name}.info| ${crossgcc-target}-${name}.info|g" \ |
---|
210 | ${worksrcpath}/${makefile} |
---|
211 | reinplace "s|/${name}.info|/${crossgcc-target}-${name}.info|g" \ |
---|
212 | ${worksrcpath}/${makefile} |
---|
213 | reinplace "s|^${name}.info|${crossgcc-target}-${name}.info|g" \ |
---|
214 | ${worksrcpath}/${makefile} |
---|
215 | reinplace "s| ${name}.pod| ${crossgcc-target}-${name}.pod|g" \ |
---|
216 | ${worksrcpath}/${makefile} |
---|
217 | reinplace "s|/${name}.pod|/${crossgcc-target}-${name}.pod|g" \ |
---|
218 | ${worksrcpath}/${makefile} |
---|
219 | reinplace "s|^${name}.pod|${crossgcc-target}-${name}.pod|g" \ |
---|
220 | ${worksrcpath}/${makefile} |
---|
221 | reinplace "s| ${name}.${suffix}| ${crossgcc-target}-${name}.${suffix}|g" \ |
---|
222 | ${worksrcpath}/${makefile} |
---|
223 | reinplace "s|/${name}.${suffix}|/${crossgcc-target}-${name}.${suffix}|g" \ |
---|
224 | ${worksrcpath}/${makefile} |
---|
225 | reinplace "s|^${name}.${suffix}|${crossgcc-target}-${name}.${suffix}|g" \ |
---|
226 | ${worksrcpath}/${makefile} |
---|
227 | |
---|
228 | # Rename the source |
---|
229 | file rename ${worksrcpath}/${path}/${name}.${suffix} \ |
---|
230 | ${worksrcpath}/${path}/${crossgcc-target}-${name}.${suffix} |
---|
231 | |
---|
232 | # Fix install-info's dir. |
---|
233 | # (note: this may be effectless if there was no info dir to be fixed) |
---|
234 | reinplace "s|--info-dir=\$(DESTDIR)\$(infodir)|--dir-file=\$(DESTDIR)\$(infodir)/${crossgcc-target}-gcc-dir|g" \ |
---|
235 | "${worksrcpath}/${makefile}" |
---|
236 | } |
---|
237 | |
---|
238 | # Fix the gettext files and related stuff. |
---|
239 | # |
---|
240 | # module: name of the module (e.g. gas) |
---|
241 | proc crossgcc::fixgettext { module } { |
---|
242 | global crossgcc-target worksrcpath |
---|
243 | |
---|
244 | if { [ file exists "${worksrcpath}/${module}/Makefile.in" ] } { |
---|
245 | reinplace "s|@PACKAGE@|${crossgcc-target}-@PACKAGE@|g" \ |
---|
246 | "${worksrcpath}/${module}/Makefile.in" |
---|
247 | reinplace "s|${module}\.mo|${crossgcc-target}-${module}.mo|g" \ |
---|
248 | "${worksrcpath}/${module}/Makefile.in" |
---|
249 | } |
---|
250 | if { [ file exists "${worksrcpath}/${module}/doc/Makefile.in" ] } { |
---|
251 | reinplace "s|@PACKAGE@|${crossgcc-target}-@PACKAGE@|g" \ |
---|
252 | "${worksrcpath}/${module}/doc/Makefile.in" |
---|
253 | } |
---|
254 | } |
---|
255 | |
---|
256 | # gcc/doc/cpp.texi |
---|
257 | crossgcc::fixinfo gcc/doc/ gcc/Makefile.in cpp texi |
---|
258 | |
---|
259 | # gcc/doc/cppinternals.texi |
---|
260 | crossgcc::fixinfo gcc/doc/ gcc/Makefile.in cppinternals texi |
---|
261 | |
---|
262 | # gcc/doc/gcc.texi |
---|
263 | crossgcc::fixinfo gcc/doc/ gcc/Makefile.in gcc texi |
---|
264 | |
---|
265 | # gcc/doc/gccint.texi |
---|
266 | crossgcc::fixinfo gcc/doc/ gcc/Makefile.in gccint texi |
---|
267 | |
---|
268 | # gcc/fortran/gfortran.texi |
---|
269 | crossgcc::fixinfo gcc/fortran/ gcc/fortran/Make-lang.in gfortran texi |
---|
270 | |
---|
271 | # gcc/java/gcj.texi |
---|
272 | crossgcc::fixinfo gcc/java/ gcc/java/Make-lang.in gcj texi |
---|
273 | |
---|
274 | # gcc/doc/gccinstall.info |
---|
275 | crossgcc::fixinfo gcc/doc/ gcc/Makefile.in gccinstall info |
---|
276 | |
---|
277 | # gettext stuff. |
---|
278 | crossgcc::fixgettext gcc |
---|
279 | crossgcc::fixgettext libcpp |
---|
280 | } |
---|
281 | |
---|
282 | pre-destroot { |
---|
283 | # gcc needs the cross directory structure to be present |
---|
284 | # in order to fill it during installation. |
---|
285 | file mkdir "${destroot}${prefix}/${crossgcc-target}/bin" |
---|
286 | file mkdir "${destroot}${prefix}/${crossgcc-target}/lib" |
---|
287 | } |
---|
288 | |
---|
289 | post-destroot { |
---|
290 | namespace eval crossgcc {} |
---|
291 | |
---|
292 | # Rename a man page if it exists. |
---|
293 | # |
---|
294 | # section: section of the man page (e.g. 1) |
---|
295 | # manpage: name of the man page (e.g. cpp) |
---|
296 | proc crossgcc::rename_man_page { section manpage } { |
---|
297 | global crossgcc-target destroot prefix |
---|
298 | |
---|
299 | set manpage_path "${destroot}${prefix}/share/man/man${section}/${manpage}.${section}" |
---|
300 | if { [ file exists ${manpage_path} ] } { |
---|
301 | file rename ${manpage_path} \ |
---|
302 | "${destroot}${prefix}/share/man/man${section}/${crossgcc-target}-${manpage}.${section}" |
---|
303 | } |
---|
304 | } |
---|
305 | |
---|
306 | # Stuff I don't want (either because they're in the system |
---|
307 | # or because they would conflict with other FSF ports) |
---|
308 | # (it's easier for maintainability purposes to fix things here) |
---|
309 | |
---|
310 | # aliases for locales (should be on the system) |
---|
311 | file delete "${destroot}${prefix}/share/locale/locale.alias" |
---|
312 | |
---|
313 | # FSF propaganda (should already be there or would conflict) |
---|
314 | file delete -force "${destroot}${prefix}/share/man/man7" |
---|
315 | |
---|
316 | # (host) libiberty |
---|
317 | foreach f [glob -directory "${destroot}${prefix}/lib" libiberty.a */libiberty.a] { |
---|
318 | file delete $f |
---|
319 | } |
---|
320 | |
---|
321 | # aliases for charsets (should already be there) |
---|
322 | file delete "${destroot}${prefix}/lib/charset.alias" |
---|
323 | |
---|
324 | # Remove man pages for tools that are not built as part of cross-gcc |
---|
325 | file delete "${destroot}${prefix}/share/man/man1/rmic.1" |
---|
326 | file delete "${destroot}${prefix}/share/man/man1/rmiregistry.1" |
---|
327 | file delete "${destroot}${prefix}/share/man/man1/jv-convert.1" |
---|
328 | file delete "${destroot}${prefix}/share/man/man1/gij.1" |
---|
329 | |
---|
330 | # For some reason, some man pages are not prefixed while they should have been |
---|
331 | # (to avoid conflicting). |
---|
332 | crossgcc::rename_man_page 1 cpp |
---|
333 | crossgcc::rename_man_page 1 gcjh |
---|
334 | crossgcc::rename_man_page 1 gcov |
---|
335 | crossgcc::rename_man_page 1 jcf-dump |
---|
336 | crossgcc::rename_man_page 1 jv-scan |
---|
337 | |
---|
338 | # There is a bug in gcc/Makefile::install-driver |
---|
339 | # For cross compilers, $(GCC_INSTALL_NAME) is equal to |
---|
340 | # $(target_noncanonical)-gcc-$(version) |
---|
341 | # and hence the driver isn't installed. |
---|
342 | xinstall -c "${workpath}/build/gcc/xgcc" \ |
---|
343 | "${destroot}${prefix}/bin/${crossgcc-target}-gcc-${version}" |
---|
344 | } |
---|
345 | |
---|
346 | livecheck.type regex |
---|
347 | livecheck.url http://gcc.gnu.org/releases.html |
---|
348 | livecheck.regex {<tr><td><a href="gcc-.*/">GCC (.*)</a></td> <td>.*</td></tr>} |
---|