Ticket #26223: Portfile.2

File Portfile.2, 11.4 KB (added by tcwan (TC Wan), 14 years ago)

arm-none-eabi-gcc Portfile (Revert to t-arm-elf config file, update gcc to version 4.5.1)

Line 
1# $Id: Portfile 70291 2010-08-05 08:27:58Z ryandesign@macports.org $
2
3PortSystem                      1.0
4
5name                    arm-none-eabi-gcc
6version                 4.5.1
7set branch              [join [lrange [split ${version} .] 0 1] .]
8revision                4
9
10# Parameters for this port.
11set newlibversion       1.18.0
12set crossgcc-target arm-none-eabi
13set default-languages --enable-languages="c,c++,objc"
14
15description             gcc cross-compilers for arm-none-eabi, with newlib runtime library.
16long_description        gnu compilers collection (including c++ and objc) for \
17                                        arm-none-eabi, with newlib runtime library.
18homepage                        http://gcc.gnu.org/
19platforms               darwin
20categories              cross devel
21maintainers             nomaintainer
22master_sites            gnu:gcc/gcc-${version}/:gcc \
23                                        ftp://sources.redhat.com/pub/newlib/:newlib \
24                                        ftp://ftp.mirror.ac.uk/sites/sources.redhat.com/pub/newlib/:newlib \
25                                        http://www.mirrorservice.org/sites/sourceware.org/pub/newlib/:newlib
26distfiles                       gcc-${version}.tar.bz2:gcc newlib-${newlibversion}.tar.gz:newlib
27worksrcdir                      gcc-${version}
28checksums                       gcc-${version}.tar.bz2 \
29                                                md5     48231a8e33ed6e058a341c53b819de1a \
30                                                sha1    78809acdaef48e74165efe3289cb1a3cb344e406 \
31                                                rmd160  848c254dafa3e432cca2814aa8bf450db38bbb14 \
32                                        newlib-${newlibversion}.tar.gz \
33                                                md5     3dae127d4aa659d72f8ea8c0ff2a7a20 \
34                                                sha1    a47d3b8a508304143334b36bdb5b33786a61ce94 \
35                                                rmd160  69d96fd323a23857072f30cb51899040099857cd
36
37patchfiles                              patch-gcc-config-arm-t-arm-elf.diff
38
39
40
41# All cross ports violate the mtree layout.
42destroot.violate_mtree  yes
43
44# Download everything to gcc/
45dist_subdir                     gcc
46
47depends_lib                     port:${crossgcc-target}-binutils \
48                    port:gmp \
49                    port:mpfr \
50                    port:gettext \
51                    port:libmpc
52
53# gcc is .bz2, newlib is .gz.
54# let's extract only gcc with MacPorts infrastructure, we'll do newlib manually.
55use_bzip2                       yes
56extract.only            gcc-${version}.tar.bz2
57
58# Extract newlib and create a symlink of newlib/newlib in gcc directory.
59post-extract    {
60        system "cd ${workpath} && gzip -dc ${distpath}/newlib-${newlibversion}.tar.gz | tar -xf -"
61        system "ln -s ${workpath}/newlib-${newlibversion}/newlib ${workpath}/gcc-${version}/"
62}
63
64
65# Since we don't build gcc and binutils at the same time, gcc's Makefile will try to transform
66# program names as gcc's name (add -${version} with ${version} being the version of gcc).
67# But it won't work because binutils binaries don't have the ${version} suffix, and even if they
68# had, they would actually have the binutils' version suffix (and not gcc's version).
69# So let's tell gcc's Makefile not to do that mistake.
70
71set environment [list AR_FOR_TARGET=${crossgcc-target}-ar \
72                                AS_FOR_TARGET=${crossgcc-target}-as \
73                                LD_FOR_TARGET=${crossgcc-target}-ld \
74                                NM_FOR_TARGET=${crossgcc-target}-nm \
75                                RANLIB_FOR_TARGET=${crossgcc-target}-ranlib]
76
77# Although we're building for t-arm-none-eabi, the config still refers to t-arm-elf
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                        "none-eabi 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
151# Build in a different directory, as advised in the README file.
152pre-configure   {
153        file mkdir "${workpath}/build"
154}
155configure.dir   ${workpath}/build
156configure.cmd   ${workpath}/gcc-${version}/configure
157configure.cc-append    -I${prefix}/include
158configure.env   ${environment}
159
160configure.args  --infodir='${prefix}/share/info' \
161                                --mandir='${prefix}/share/man' \
162                                --target=${crossgcc-target} \
163                                --program-prefix=${crossgcc-target}- \
164                                --program-suffix=-${branch} \
165                                --without-included-gettext \
166                                --enable-obsolete \
167                                --with-newlib \
168                                --enable-multilib \
169                                --enable-biendian \
170                                --disable-libgfortran \
171                                --with-gxx-include-dir=${prefix}/${crossgcc-target}/include/c++/${version}/ \
172                                ${default-languages}
173
174configure.cc_archflags
175configure.cxx_archflags
176configure.objc_archflags
177if {[info exists configure.ld_archflags]} {
178    configure.ld_archflags
179}
180if {${os.platform} == "darwin" && ($build_arch == "x86_64" || $build_arch == "ppc64")} {
181    configure.args-append --build=${build_arch}-apple-darwin${os.major}
182}
183
184build.dir       ${workpath}/build
185
186build.args              ${environment}
187destroot.args   ${environment}
188
189post-patch {
190        namespace eval crossgcc {}
191
192        # Fix the info pages and related stuff.
193        #       
194        # path: path to the doc directory (e.g. gas/doc/)
195        # makefile: path to Makefile.in (e.g. gas/doc/Makefile.in)
196        # name: name of the info page (e.g. as)
197        # suffix: suffix of the souce page (texinfo or texi)
198        proc crossgcc::fixinfo { path makefile name suffix } {
199                global crossgcc-target worksrcpath
200
201                # Fix the source
202                reinplace "s|setfilename ${name}.info|setfilename ${crossgcc-target}-${name}.info|g" \
203                        ${worksrcpath}/${path}/${name}.${suffix}
204                reinplace "s|(${name})|(${crossgcc-target}-${name})|g" \
205                        ${worksrcpath}/${path}/${name}.${suffix}
206                reinplace "s|@file{${name}}|@file{${crossgcc-target}-${name}}|g" \
207                        ${worksrcpath}/${path}/${name}.${suffix}
208               
209                # Fix the Makefile
210                reinplace "s| ${name}.info| ${crossgcc-target}-${name}.info|g" \
211                        ${worksrcpath}/${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}.pod| ${crossgcc-target}-${name}.pod|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}.${suffix}| ${crossgcc-target}-${name}.${suffix}|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               
229                # Rename the source
230                file rename ${worksrcpath}/${path}/${name}.${suffix} \
231                        ${worksrcpath}/${path}/${crossgcc-target}-${name}.${suffix}
232               
233                # Fix install-info's dir.
234                # (note: this may be effectless if there was no info dir to be fixed)
235                reinplace "s|--info-dir=\$(DESTDIR)\$(infodir)|--dir-file=\$(DESTDIR)\$(infodir)/${crossgcc-target}-gcc-dir|g" \
236                        "${worksrcpath}/${makefile}"
237        }
238
239        # Fix the gettext files and related stuff.
240        #       
241        # module: name of the module (e.g. gas)
242        proc crossgcc::fixgettext { module } {
243                global crossgcc-target worksrcpath
244
245                if { [ file exists "${worksrcpath}/${module}/Makefile.in" ] } {
246                        reinplace "s|@PACKAGE@|${crossgcc-target}-@PACKAGE@|g" \
247                                "${worksrcpath}/${module}/Makefile.in"
248                        reinplace "s|${module}\.mo|${crossgcc-target}-${module}.mo|g" \
249                                "${worksrcpath}/${module}/Makefile.in"
250                }
251                if { [ file exists "${worksrcpath}/${module}/doc/Makefile.in" ] } {
252                        reinplace "s|@PACKAGE@|${crossgcc-target}-@PACKAGE@|g" \
253                                "${worksrcpath}/${module}/doc/Makefile.in"
254                }
255        }
256
257        # gcc/doc/cpp.texi
258        crossgcc::fixinfo gcc/doc/ gcc/Makefile.in cpp texi
259
260        # gcc/doc/cppinternals.texi
261        crossgcc::fixinfo gcc/doc/ gcc/Makefile.in cppinternals texi
262
263        # gcc/doc/gcc.texi
264        crossgcc::fixinfo gcc/doc/ gcc/Makefile.in gcc texi
265
266        # gcc/doc/gccint.texi
267        crossgcc::fixinfo gcc/doc/ gcc/Makefile.in gccint texi
268
269        # gcc/fortran/gfortran.texi
270        crossgcc::fixinfo gcc/fortran/ gcc/fortran/Make-lang.in gfortran texi
271
272        # gcc/java/gcj.texi
273        crossgcc::fixinfo gcc/java/ gcc/java/Make-lang.in gcj texi
274
275        # gcc/doc/gccinstall.info
276        crossgcc::fixinfo gcc/doc/ gcc/Makefile.in gccinstall info
277
278        # gettext stuff.
279        crossgcc::fixgettext gcc
280        crossgcc::fixgettext libcpp
281}
282
283pre-destroot {
284        # gcc needs the cross directory structure to be present
285        # in order to fill it during installation.
286        file mkdir "${destroot}/${prefix}/${crossgcc-target}/bin"
287        file mkdir "${destroot}/${prefix}/${crossgcc-target}/lib"
288}
289
290post-destroot {
291        namespace eval crossgcc {}
292
293        # Rename a man page if it exists.
294        #
295        # section: section of the man page (e.g. 1)
296        # manpage: name of the man page (e.g. cpp)
297        proc crossgcc::rename_man_page { section manpage } {
298                global crossgcc-target destroot prefix
299
300                set manpage_path "${destroot}/${prefix}/share/man/man${section}/${manpage}.${section}"
301                if { [ file exists ${manpage_path} ] } {
302                        file rename ${manpage_path} \
303                                "${destroot}/${prefix}/share/man/man${section}/${crossgcc-target}-${manpage}.${section}"
304                }
305        }
306
307        # Stuff I don't want (either because they're in the system
308        # or because they would conflict with other FSF ports)
309        # (it's easier for maintainability purposes to fix things here)
310
311        # aliases for locales (should be on the system)
312        file delete "${destroot}/${prefix}/share/locale/locale.alias"
313       
314        # FSF propaganda (should already be there or would conflict)
315        file delete -force "${destroot}/${prefix}/share/man/man7"
316
317        # (host) libiberty
318        file delete "${destroot}/${prefix}/lib/libiberty.a"
319
320        # aliases for charsets (should already be there)
321        file delete "${destroot}/${prefix}/lib/charset.alias"
322       
323        # Remove man pages for tools that are not built as part of cross-gcc
324        file delete "${destroot}/${prefix}/share/man/man1/rmic.1"
325        file delete "${destroot}/${prefix}/share/man/man1/rmiregistry.1"
326        file delete "${destroot}/${prefix}/share/man/man1/jv-convert.1"
327        file delete "${destroot}/${prefix}/share/man/man1/gij.1"
328       
329        # For some reason, some man pages are not prefixed while they should have been
330        # (to avoid conflicting).
331        crossgcc::rename_man_page 1 cpp
332        crossgcc::rename_man_page 1 gcjh
333        crossgcc::rename_man_page 1 gcov
334        crossgcc::rename_man_page 1 jcf-dump
335        crossgcc::rename_man_page 1 jv-scan
336       
337        # There is a bug in gcc/Makefile::install-driver
338        # For cross compilers, $(GCC_INSTALL_NAME) is equal to
339        # $(target_noncanonical)-gcc-$(version)
340        # and hence the driver isn't installed.
341        xinstall -c "${workpath}/build/gcc/xgcc" \
342                "${destroot}/${prefix}/bin/${crossgcc-target}-gcc-${version}"
343}
344
345livecheck.type  regex
346livecheck.url   http://gcc.gnu.org/releases.html
347livecheck.regex {<tr><td><a href="gcc-.*/">GCC (.*)</a></td>   <td>.*</td></tr>}