Ticket #26223: Portfile.2.2

File Portfile.2.2, 11.5 KB (added by tcwan (TC Wan), 14 years ago)

arm-none-eabi-gcc Portfile

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