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

Last change on this file since 78994 was 78994, checked in by ryandesign@…, 6 years ago

arm-elf-gcc, arm-elf-gcc3: disable universal variant

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 11.3 KB
Line 
1# $Id: Portfile 78994 2011-05-29 07:14:56Z ryandesign@macports.org $
2
3PortSystem                      1.0
4
5name                    arm-elf-gcc
6version                 4.5.0
7set branch              [join [lrange [split ${version} .] 0 1] .]
8revision                2
9
10# Parameters for this port.
11set newlibversion       1.18.0
12set crossgcc-target arm-elf
13set default-languages --enable-languages="c,c++,objc"
14
15description             gcc cross-compilers for arm-elf, with newlib runtime library.
16long_description        gnu compilers collection (including c++ and objc) for \
17                                        arm-elf, 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-elf.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# arm-elf-binutils is not universal
52universal_variant       no
53
54# gcc is .bz2, newlib is .gz.
55# let's extract only gcc with MacPorts infrastructure, we'll do newlib manually.
56use_bzip2                       yes
57extract.only            gcc-${version}.tar.bz2
58
59# Extract newlib and create a symlink of newlib/newlib in gcc directory.
60post-extract    {
61        system "cd ${workpath} && gzip -dc ${distpath}/newlib-${newlibversion}.tar.gz | tar -xf -"
62        system "ln -s ${workpath}/newlib-${newlibversion}/newlib ${workpath}/gcc-${version}/"
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-elf"
80        system "echo 'MULTILIB_DIRNAMES += ${dirnames}' >> ${worksrcpath}/gcc/config/arm/t-arm-elf"
81        system "echo 'MULTILIB_EXCEPTIONS += ${exceptions}' >> ${worksrcpath}/gcc/config/arm/t-arm-elf"
82        system "echo 'MULTILIB_MATCHES += ${matches}' >> ${worksrcpath}/gcc/config/arm/t-arm-elf"
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                        "elf 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                                --disable-__cxa_atexit \
166                                --enable-multilib \
167                                --enable-biendian \
168                                --disable-libgfortran \
169                                --with-gxx-include-dir=${prefix}/${crossgcc-target}/include/c++/${version}/ \
170                                ${default-languages}
171configure.cc_archflags
172configure.cxx_archflags
173configure.objc_archflags
174configure.ld_archflags
175if {${os.platform} == "darwin" && ($build_arch == "x86_64" || $build_arch == "ppc64")} {
176    configure.args-append --build=${build_arch}-apple-darwin${os.major}
177}
178
179build.dir       ${workpath}/build
180
181build.args              ${environment}
182destroot.args   ${environment}
183
184post-patch {
185        namespace eval crossgcc {}
186
187        # Fix the info pages and related stuff.
188        #       
189        # path: path to the doc directory (e.g. gas/doc/)
190        # makefile: path to Makefile.in (e.g. gas/doc/Makefile.in)
191        # name: name of the info page (e.g. as)
192        # suffix: suffix of the souce page (texinfo or texi)
193        proc crossgcc::fixinfo { path makefile name suffix } {
194                global crossgcc-target worksrcpath
195
196                # Fix the source
197                reinplace "s|setfilename ${name}.info|setfilename ${crossgcc-target}-${name}.info|g" \
198                        ${worksrcpath}/${path}/${name}.${suffix}
199                reinplace "s|(${name})|(${crossgcc-target}-${name})|g" \
200                        ${worksrcpath}/${path}/${name}.${suffix}
201                reinplace "s|@file{${name}}|@file{${crossgcc-target}-${name}}|g" \
202                        ${worksrcpath}/${path}/${name}.${suffix}
203               
204                # Fix the Makefile
205                reinplace "s| ${name}.info| ${crossgcc-target}-${name}.info|g" \
206                        ${worksrcpath}/${makefile}
207                reinplace "s|/${name}.info|/${crossgcc-target}-${name}.info|g" \
208                        ${worksrcpath}/${makefile}
209                reinplace "s|^${name}.info|${crossgcc-target}-${name}.info|g" \
210                        ${worksrcpath}/${makefile}
211                reinplace "s| ${name}.pod| ${crossgcc-target}-${name}.pod|g" \
212                        ${worksrcpath}/${makefile}
213                reinplace "s|/${name}.pod|/${crossgcc-target}-${name}.pod|g" \
214                        ${worksrcpath}/${makefile}
215                reinplace "s|^${name}.pod|${crossgcc-target}-${name}.pod|g" \
216                        ${worksrcpath}/${makefile}
217                reinplace "s| ${name}.${suffix}| ${crossgcc-target}-${name}.${suffix}|g" \
218                        ${worksrcpath}/${makefile}
219                reinplace "s|/${name}.${suffix}|/${crossgcc-target}-${name}.${suffix}|g" \
220                        ${worksrcpath}/${makefile}
221                reinplace "s|^${name}.${suffix}|${crossgcc-target}-${name}.${suffix}|g" \
222                        ${worksrcpath}/${makefile}
223               
224                # Rename the source
225                file rename ${worksrcpath}/${path}/${name}.${suffix} \
226                        ${worksrcpath}/${path}/${crossgcc-target}-${name}.${suffix}
227               
228                # Fix install-info's dir.
229                # (note: this may be effectless if there was no info dir to be fixed)
230                reinplace "s|--info-dir=\$(DESTDIR)\$(infodir)|--dir-file=\$(DESTDIR)\$(infodir)/${crossgcc-target}-gcc-dir|g" \
231                        "${worksrcpath}/${makefile}"
232        }
233
234        # Fix the gettext files and related stuff.
235        #       
236        # module: name of the module (e.g. gas)
237        proc crossgcc::fixgettext { module } {
238                global crossgcc-target worksrcpath
239
240                if { [ file exists "${worksrcpath}/${module}/Makefile.in" ] } {
241                        reinplace "s|@PACKAGE@|${crossgcc-target}-@PACKAGE@|g" \
242                                "${worksrcpath}/${module}/Makefile.in"
243                        reinplace "s|${module}\.mo|${crossgcc-target}-${module}.mo|g" \
244                                "${worksrcpath}/${module}/Makefile.in"
245                }
246                if { [ file exists "${worksrcpath}/${module}/doc/Makefile.in" ] } {
247                        reinplace "s|@PACKAGE@|${crossgcc-target}-@PACKAGE@|g" \
248                                "${worksrcpath}/${module}/doc/Makefile.in"
249                }
250        }
251
252        # gcc/doc/cpp.texi
253        crossgcc::fixinfo gcc/doc/ gcc/Makefile.in cpp texi
254
255        # gcc/doc/cppinternals.texi
256        crossgcc::fixinfo gcc/doc/ gcc/Makefile.in cppinternals texi
257
258        # gcc/doc/gcc.texi
259        crossgcc::fixinfo gcc/doc/ gcc/Makefile.in gcc texi
260
261        # gcc/doc/gccint.texi
262        crossgcc::fixinfo gcc/doc/ gcc/Makefile.in gccint texi
263
264        # gcc/fortran/gfortran.texi
265        crossgcc::fixinfo gcc/fortran/ gcc/fortran/Make-lang.in gfortran texi
266
267        # gcc/java/gcj.texi
268        crossgcc::fixinfo gcc/java/ gcc/java/Make-lang.in gcj texi
269
270        # gcc/doc/gccinstall.info
271        crossgcc::fixinfo gcc/doc/ gcc/Makefile.in gccinstall info
272
273        # gettext stuff.
274        crossgcc::fixgettext gcc
275        crossgcc::fixgettext libcpp
276}
277
278pre-destroot {
279        # gcc needs the cross directory structure to be present
280        # in order to fill it during installation.
281        file mkdir "${destroot}${prefix}/${crossgcc-target}/bin"
282        file mkdir "${destroot}${prefix}/${crossgcc-target}/lib"
283}
284
285post-destroot {
286        namespace eval crossgcc {}
287
288        # Rename a man page if it exists.
289        #
290        # section: section of the man page (e.g. 1)
291        # manpage: name of the man page (e.g. cpp)
292        proc crossgcc::rename_man_page { section manpage } {
293                global crossgcc-target destroot prefix
294
295                set manpage_path "${destroot}${prefix}/share/man/man${section}/${manpage}.${section}"
296                if { [ file exists ${manpage_path} ] } {
297                        file rename ${manpage_path} \
298                                "${destroot}${prefix}/share/man/man${section}/${crossgcc-target}-${manpage}.${section}"
299                }
300        }
301
302        # Stuff I don't want (either because they're in the system
303        # or because they would conflict with other FSF ports)
304        # (it's easier for maintainability purposes to fix things here)
305
306        # aliases for locales (should be on the system)
307        file delete "${destroot}${prefix}/share/locale/locale.alias"
308       
309        # FSF propaganda (should already be there or would conflict)
310        file delete -force "${destroot}${prefix}/share/man/man7"
311
312        # (host) libiberty
313        foreach f [glob -directory "${destroot}${prefix}/lib" libiberty.a */libiberty.a] {
314        file delete $f
315    }
316
317        # aliases for charsets (should already be there)
318        file delete "${destroot}${prefix}/lib/charset.alias"
319       
320        # Remove man pages for tools that are not built as part of cross-gcc
321        file delete "${destroot}${prefix}/share/man/man1/rmic.1"
322        file delete "${destroot}${prefix}/share/man/man1/rmiregistry.1"
323        file delete "${destroot}${prefix}/share/man/man1/jv-convert.1"
324        file delete "${destroot}${prefix}/share/man/man1/gij.1"
325       
326        # For some reason, some man pages are not prefixed while they should have been
327        # (to avoid conflicting).
328        crossgcc::rename_man_page 1 cpp
329        crossgcc::rename_man_page 1 gcjh
330        crossgcc::rename_man_page 1 gcov
331        crossgcc::rename_man_page 1 jcf-dump
332        crossgcc::rename_man_page 1 jv-scan
333       
334        # There is a bug in gcc/Makefile::install-driver
335        # For cross compilers, $(GCC_INSTALL_NAME) is equal to
336        # $(target_noncanonical)-gcc-$(version)
337        # and hence the driver isn't installed.
338        xinstall -c "${workpath}/build/gcc/xgcc" \
339                "${destroot}${prefix}/bin/${crossgcc-target}-gcc-${version}"
340}
341
342livecheck.type  regex
343livecheck.url   http://gcc.gnu.org/releases.html
344livecheck.regex {<tr><td><a href="gcc-.*/">GCC (.*)</a></td>   <td>.*</td></tr>}
Note: See TracBrowser for help on using the repository browser.