source: trunk/dports/cross/arm-elf-gcc/Portfile

Last change on this file was 125270, checked in by ryandesign@…, 3 years ago

arm-elf-gcc: new maintainer (#44949)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 13.0 KB
Line 
1# -*- 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
2# $Id: Portfile 125270 2014-09-12 07:50:10Z ryandesign@macports.org $
3
4PortSystem          1.0
5
6name                arm-elf-gcc
7version             4.7.3
8set branch          [join [lrange [split ${version} .] 0 1] .]
9conflicts           arm-elf-gcc3
10
11# Parameters for this port.
12set newlibversion   1.20.0
13set crossgcc-target arm-elf
14set default-languages --enable-languages="c,c++,objc"
15
16description         gcc cross-compilers for arm-elf, with newlib runtime library.
17long_description    gnu compilers collection (including c++ and objc) for \
18                    arm-elf, with newlib runtime library.
19homepage            http://gcc.gnu.org/
20platforms           darwin
21categories          cross devel
22maintainers         gmail.com:stuartwesterman openmaintainer
23# an exception in the license allows dependents to not be GPL
24license             {GPL-3+ Permissive}
25master_sites        gnu:gcc/gcc-${version}/:gcc \
26                    ftp://sources.redhat.com/pub/newlib/:newlib \
27                    http://www.mirrorservice.org/sites/sourceware.org/pub/newlib/:newlib
28distfiles           gcc-${version}.tar.bz2:gcc newlib-${newlibversion}.tar.gz:newlib
29worksrcdir          gcc-${version}
30
31checksums           gcc-${version}.tar.bz2 \
32                    rmd160  b4ba153b098cad726ecd28195ee445aa542d37ae \
33                    sha256  2f7c37eb4fc14422ff2358a9ef59c974a75ab41204ef0e49fc34ab1d8981a9c3 \
34                    newlib-${newlibversion}.tar.gz \
35                    rmd160  e36c5337a74633456b47d09594974c7dd7a9cc3e \
36                    sha256  c644b2847244278c57bec2ddda69d8fab5a7c767f3b9af69aa7aa3da823ff692
37
38patchfiles          patch-gcc-config-arm-t-arm-elf.diff
39
40# All cross ports violate the mtree layout.
41destroot.violate_mtree  yes
42
43# Download everything to gcc/
44dist_subdir         gcc
45
46depends_lib         port:${crossgcc-target}-binutils \
47                    port:gmp \
48                    port:mpfr \
49                    port:gettext \
50                    port:libmpc
51
52# arm-elf-binutils is not universal
53universal_variant   no
54
55# gcc is .bz2, newlib is .gz.
56# let's extract only gcc with MacPorts infrastructure, we'll do newlib manually.
57use_bzip2           yes
58extract.only        gcc-${version}.tar.bz2
59
60# Extract newlib and create a symlink of newlib/newlib in gcc directory.
61post-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
72set 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
78proc 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
86variant 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
96variant 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
106variant 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
117variant 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
128variant under description {leading underscore multilib support} {
129    post-patch {
130        multilibpatch_enable \
131            "fno-leading-underscore/fleading-underscore" \
132            "elf under" \
133            "" \
134            ""
135    }
136    configure.args-append   --enable-underscore
137}
138
139variant 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# Fails to build with llvm-gcc, at least in Xcode 4.1; use clang (#29551)
151compiler.blacklist-append  *llvm-gcc-4.2
152
153# Build in a different directory, as advised in the README file.
154pre-configure   {
155    file mkdir "${workpath}/build"
156}
157configure.dir   ${workpath}/build
158configure.cmd   ${workpath}/gcc-${version}/configure
159configure.cc-append    -I${prefix}/include
160configure.env   ${environment}
161configure.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}
175configure.cc_archflags
176configure.cxx_archflags
177configure.objc_archflags
178configure.ld_archflags
179if {${os.platform} eq "darwin" && (${build_arch} eq "x86_64" || ${build_arch} eq "ppc64")} {
180    configure.args-append --build=${build_arch}-apple-darwin${os.major}
181}
182
183# the bootstrap compiler doesn't accept -stdlib
184configure.cxx_stdlib
185
186build.dir       ${workpath}/build
187
188build.args      ${environment}
189destroot.args   ${environment}
190
191post-patch {
192    namespace eval crossgcc {}
193
194    # Fix the info pages and related stuff.
195    #
196    # path: path to the doc directory (e.g. gas/doc/)
197    # makefile: path to Makefile.in (e.g. gas/doc/Makefile.in)
198    # name: name of the info page (e.g. as)
199    # suffix: suffix of the souce page (texinfo or texi)
200    proc crossgcc::fixinfo { path makefile name suffix } {
201        global crossgcc-target worksrcpath
202
203        # Fix the source
204        reinplace "s|setfilename ${name}.info|setfilename ${crossgcc-target}-${name}.info|g" \
205            ${worksrcpath}/${path}/${name}.${suffix}
206        reinplace "s|(${name})|(${crossgcc-target}-${name})|g" \
207            ${worksrcpath}/${path}/${name}.${suffix}
208        reinplace "s|@file{${name}}|@file{${crossgcc-target}-${name}}|g" \
209            ${worksrcpath}/${path}/${name}.${suffix}
210
211        # Fix the Makefile
212        reinplace "s| ${name}.info| ${crossgcc-target}-${name}.info|g" \
213            ${worksrcpath}/${makefile}
214        reinplace "s|/${name}.info|/${crossgcc-target}-${name}.info|g" \
215            ${worksrcpath}/${makefile}
216        reinplace "s|^${name}.info|${crossgcc-target}-${name}.info|g" \
217            ${worksrcpath}/${makefile}
218        reinplace "s| ${name}.pod| ${crossgcc-target}-${name}.pod|g" \
219            ${worksrcpath}/${makefile}
220        reinplace "s|/${name}.pod|/${crossgcc-target}-${name}.pod|g" \
221            ${worksrcpath}/${makefile}
222        reinplace "s|^${name}.pod|${crossgcc-target}-${name}.pod|g" \
223            ${worksrcpath}/${makefile}
224        reinplace "s| ${name}.${suffix}| ${crossgcc-target}-${name}.${suffix}|g" \
225            ${worksrcpath}/${makefile}
226        reinplace "s|/${name}.${suffix}|/${crossgcc-target}-${name}.${suffix}|g" \
227            ${worksrcpath}/${makefile}
228        reinplace "s|^${name}.${suffix}|${crossgcc-target}-${name}.${suffix}|g" \
229            ${worksrcpath}/${makefile}
230
231        # Rename the source
232        file rename ${worksrcpath}/${path}/${name}.${suffix} \
233            ${worksrcpath}/${path}/${crossgcc-target}-${name}.${suffix}
234
235        # Fix install-info's dir.
236        # (note: this may be effectless if there was no info dir to be fixed)
237        reinplace "s|--info-dir=\$(DESTDIR)\$(infodir)|--dir-file=\$(DESTDIR)\$(infodir)/${crossgcc-target}-gcc-dir|g" \
238            "${worksrcpath}/${makefile}"
239    }
240
241    # Fix the gettext files and related stuff.
242    #
243    # module: name of the module (e.g. gas)
244    proc crossgcc::fixgettext { module } {
245        global crossgcc-target worksrcpath
246
247        if { [ file exists "${worksrcpath}/${module}/Makefile.in" ] } {
248            reinplace "s|@PACKAGE@|${crossgcc-target}-@PACKAGE@|g" \
249                "${worksrcpath}/${module}/Makefile.in"
250            reinplace "s|${module}\.mo|${crossgcc-target}-${module}.mo|g" \
251                "${worksrcpath}/${module}/Makefile.in"
252        }
253        if { [ file exists "${worksrcpath}/${module}/doc/Makefile.in" ] } {
254            reinplace "s|@PACKAGE@|${crossgcc-target}-@PACKAGE@|g" \
255                "${worksrcpath}/${module}/doc/Makefile.in"
256        }
257    }
258
259    # gcc/doc/cpp.texi
260    crossgcc::fixinfo gcc/doc/ gcc/Makefile.in cpp texi
261
262    # gcc/doc/cppinternals.texi
263    crossgcc::fixinfo gcc/doc/ gcc/Makefile.in cppinternals texi
264
265    # gcc/doc/gcc.texi
266    crossgcc::fixinfo gcc/doc/ gcc/Makefile.in gcc texi
267
268    # gcc/doc/gccint.texi
269    crossgcc::fixinfo gcc/doc/ gcc/Makefile.in gccint texi
270
271    # gcc/fortran/gfortran.texi
272    crossgcc::fixinfo gcc/fortran/ gcc/fortran/Make-lang.in gfortran texi
273
274    # gcc/java/gcj.texi
275    crossgcc::fixinfo gcc/java/ gcc/java/Make-lang.in gcj texi
276
277    # gcc/doc/gccinstall.info
278    crossgcc::fixinfo gcc/doc/ gcc/Makefile.in gccinstall info
279
280    # gettext stuff.
281    crossgcc::fixgettext gcc
282    crossgcc::fixgettext libcpp
283}
284
285pre-destroot {
286    # gcc needs the cross directory structure to be present
287    # in order to fill it during installation.
288    file mkdir "${destroot}${prefix}/${crossgcc-target}/bin"
289    file mkdir "${destroot}${prefix}/${crossgcc-target}/lib"
290}
291
292post-destroot {
293    namespace eval crossgcc {}
294
295    # Rename a man page if it exists.
296    #
297    # section: section of the man page (e.g. 1)
298    # manpage: name of the man page (e.g. cpp)
299    proc crossgcc::rename_man_page { section manpage } {
300        global crossgcc-target destroot prefix
301
302        set manpage_path "${destroot}${prefix}/share/man/man${section}/${manpage}.${section}"
303        if { [ file exists ${manpage_path} ] } {
304            file rename ${manpage_path} \
305                "${destroot}${prefix}/share/man/man${section}/${crossgcc-target}-${manpage}.${section}"
306        }
307    }
308
309    # Stuff I don't want (either because they're in the system
310    # or because they would conflict with other FSF ports)
311    # (it's easier for maintainability purposes to fix things here)
312
313    # aliases for locales (should be on the system)
314    file delete "${destroot}${prefix}/share/locale/locale.alias"
315
316    # FSF propaganda (should already be there or would conflict)
317    file delete -force "${destroot}${prefix}/share/man/man7"
318
319    # (host) libiberty
320    foreach f [glob -directory "${destroot}${prefix}/lib" libiberty.a */libiberty.a] {
321        file delete $f
322    }
323
324    # aliases for charsets (should already be there)
325    file delete "${destroot}${prefix}/lib/charset.alias"
326
327    # Remove man pages for tools that are not built as part of cross-gcc
328    file delete "${destroot}${prefix}/share/man/man1/rmic.1"
329    file delete "${destroot}${prefix}/share/man/man1/rmiregistry.1"
330    file delete "${destroot}${prefix}/share/man/man1/jv-convert.1"
331    file delete "${destroot}${prefix}/share/man/man1/gij.1"
332
333    # For some reason, some man pages are not prefixed while they should have been
334    # (to avoid conflicting).
335    crossgcc::rename_man_page 1 cpp
336    crossgcc::rename_man_page 1 gcjh
337    crossgcc::rename_man_page 1 gcov
338    crossgcc::rename_man_page 1 jcf-dump
339    crossgcc::rename_man_page 1 jv-scan
340
341    # There is a bug in gcc/Makefile::install-driver
342    # For cross compilers, $(GCC_INSTALL_NAME) is equal to
343    # $(target_noncanonical)-gcc-$(version)
344    # and hence the driver isn't installed.
345    xinstall -c "${workpath}/build/gcc/xgcc" \
346        "${destroot}${prefix}/bin/${crossgcc-target}-gcc-${version}"
347}
348
349livecheck.type      regex
350livecheck.url       http://gcc.gnu.org/releases.html
351livecheck.regex     {<tr><td><a href="gcc-.*/">GCC (.*)</a></td>   <td>.*</td></tr>}
Note: See TracBrowser for help on using the repository browser.