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

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

In the interest that all portfiles exemplify correct portfile writing techniques, remove slash before ${prefix} which is not needed because ${prefix} already begins with a slash

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 11.2 KB
Line 
1# $Id: Portfile 71533 2010-09-15 20:26:12Z 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                1
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# 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        system "cd ${workpath} && gzip -dc ${distpath}/newlib-${newlibversion}.tar.gz | tar -xf -"
59        system "ln -s ${workpath}/newlib-${newlibversion}/newlib ${workpath}/gcc-${version}/"
60}
61
62# Since we don't build gcc and binutils at the same time, gcc's Makefile will try to transform
63# program names as gcc's name (add -${version} with ${version} being the version of gcc).
64# But it won't work because binutils binaries don't have the ${version} suffix, and even if they
65# had, they would actually have the binutils' version suffix (and not gcc's version).
66# So let's tell gcc's Makefile not to do that mistake.
67
68set environment [list AR_FOR_TARGET=${crossgcc-target}-ar \
69                                AS_FOR_TARGET=${crossgcc-target}-as \
70                                LD_FOR_TARGET=${crossgcc-target}-ld \
71                                NM_FOR_TARGET=${crossgcc-target}-nm \
72                                RANLIB_FOR_TARGET=${crossgcc-target}-ranlib]
73
74proc multilibpatch_enable { options dirnames exceptions matches } {
75        global worksrcpath
76        system "echo 'MULTILIB_OPTIONS += ${options}' >> ${worksrcpath}/gcc/config/arm/t-arm-elf"
77        system "echo 'MULTILIB_DIRNAMES += ${dirnames}' >> ${worksrcpath}/gcc/config/arm/t-arm-elf"
78        system "echo 'MULTILIB_EXCEPTIONS += ${exceptions}' >> ${worksrcpath}/gcc/config/arm/t-arm-elf"
79        system "echo 'MULTILIB_MATCHES += ${matches}' >> ${worksrcpath}/gcc/config/arm/t-arm-elf"
80}
81
82variant be description {big endian multilib support} {
83        post-patch {
84                multilibpatch_enable \
85                        "mlittle-endian/mbig-endian" \
86                        "le be" \
87                        "" \
88                        "mbig-endian=mbe mlittle-endian=mle"
89        }
90}
91
92variant ep9312 description {ep9312 multilib support} {
93        post-patch {
94                multilibpatch_enable \
95                        "mcpu=ep9312" \
96                        "ep9312" \
97                        "*mthumb/*mcpu=ep9312* *mcpu=ep9312*/*mhard-float*" \
98                        ""
99        }
100}
101
102variant fpu description {fpu multilib support} {
103        post-patch {
104                multilibpatch_enable \
105                        "mhard-float/msoft-float" \
106                        "fpu soft" \
107                        "*mthumb/*mhard-float*" \
108                        ""
109        }
110        configure.args-append   --enable-fpu
111}
112
113variant interwork description {thumb interwork multilib support} {
114        post-patch {
115                multilibpatch_enable \
116                        "mno-thumb-interwork/mthumb-interwork" \
117                        "normal interwork" \
118                        "" \
119                        ""
120        }
121        configure.args-append   --enable-interwork
122}
123
124variant under description {leading underscore multilib support} {
125        post-patch {
126                multilibpatch_enable \
127                        "fno-leading-underscore/fleading-underscore" \
128                        "elf under" \
129                        "" \
130                        ""
131        }
132        configure.args-append   --enable-underscore
133}
134
135variant nofmult description {no fpu multiplication multilib support} {
136        post-patch {
137                multilibpatch_enable \
138                        "mcpu=arm7" \
139                        "nofmult" \
140                        "*mthumb*/*mcpu=arm7*" \
141                        ""
142        }
143        configure.args-append   --enable-nofmult
144}
145
146# Build in a different directory, as advised in the README file.
147pre-configure   {
148        file mkdir "${workpath}/build"
149}
150configure.dir   ${workpath}/build
151configure.cmd   ${workpath}/gcc-${version}/configure
152configure.cc-append    -I${prefix}/include
153configure.env   ${environment}
154configure.args  --infodir='${prefix}/share/info' \
155                                --mandir='${prefix}/share/man' \
156                                --target=${crossgcc-target} \
157                                --program-prefix=${crossgcc-target}- \
158                                --program-suffix=-${branch} \
159                                --without-included-gettext \
160                                --enable-obsolete \
161                                --with-newlib \
162                                --enable-multilib \
163                                --enable-biendian \
164                                --disable-libgfortran \
165                                --with-gxx-include-dir=${prefix}/${crossgcc-target}/include/c++/${version}/ \
166                                ${default-languages}
167configure.cc_archflags
168configure.cxx_archflags
169configure.objc_archflags
170if {[info exists configure.ld_archflags]} {
171    configure.ld_archflags
172}
173if {${os.platform} == "darwin" && ($build_arch == "x86_64" || $build_arch == "ppc64")} {
174    configure.args-append --build=${build_arch}-apple-darwin${os.major}
175}
176
177build.dir       ${workpath}/build
178
179build.args              ${environment}
180destroot.args   ${environment}
181
182post-patch {
183        namespace eval crossgcc {}
184
185        # Fix the info pages and related stuff.
186        #       
187        # path: path to the doc directory (e.g. gas/doc/)
188        # makefile: path to Makefile.in (e.g. gas/doc/Makefile.in)
189        # name: name of the info page (e.g. as)
190        # suffix: suffix of the souce page (texinfo or texi)
191        proc crossgcc::fixinfo { path makefile name suffix } {
192                global crossgcc-target worksrcpath
193
194                # Fix the source
195                reinplace "s|setfilename ${name}.info|setfilename ${crossgcc-target}-${name}.info|g" \
196                        ${worksrcpath}/${path}/${name}.${suffix}
197                reinplace "s|(${name})|(${crossgcc-target}-${name})|g" \
198                        ${worksrcpath}/${path}/${name}.${suffix}
199                reinplace "s|@file{${name}}|@file{${crossgcc-target}-${name}}|g" \
200                        ${worksrcpath}/${path}/${name}.${suffix}
201               
202                # Fix the Makefile
203                reinplace "s| ${name}.info| ${crossgcc-target}-${name}.info|g" \
204                        ${worksrcpath}/${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}.pod| ${crossgcc-target}-${name}.pod|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}.${suffix}| ${crossgcc-target}-${name}.${suffix}|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               
222                # Rename the source
223                file rename ${worksrcpath}/${path}/${name}.${suffix} \
224                        ${worksrcpath}/${path}/${crossgcc-target}-${name}.${suffix}
225               
226                # Fix install-info's dir.
227                # (note: this may be effectless if there was no info dir to be fixed)
228                reinplace "s|--info-dir=\$(DESTDIR)\$(infodir)|--dir-file=\$(DESTDIR)\$(infodir)/${crossgcc-target}-gcc-dir|g" \
229                        "${worksrcpath}/${makefile}"
230        }
231
232        # Fix the gettext files and related stuff.
233        #       
234        # module: name of the module (e.g. gas)
235        proc crossgcc::fixgettext { module } {
236                global crossgcc-target worksrcpath
237
238                if { [ file exists "${worksrcpath}/${module}/Makefile.in" ] } {
239                        reinplace "s|@PACKAGE@|${crossgcc-target}-@PACKAGE@|g" \
240                                "${worksrcpath}/${module}/Makefile.in"
241                        reinplace "s|${module}\.mo|${crossgcc-target}-${module}.mo|g" \
242                                "${worksrcpath}/${module}/Makefile.in"
243                }
244                if { [ file exists "${worksrcpath}/${module}/doc/Makefile.in" ] } {
245                        reinplace "s|@PACKAGE@|${crossgcc-target}-@PACKAGE@|g" \
246                                "${worksrcpath}/${module}/doc/Makefile.in"
247                }
248        }
249
250        # gcc/doc/cpp.texi
251        crossgcc::fixinfo gcc/doc/ gcc/Makefile.in cpp texi
252
253        # gcc/doc/cppinternals.texi
254        crossgcc::fixinfo gcc/doc/ gcc/Makefile.in cppinternals texi
255
256        # gcc/doc/gcc.texi
257        crossgcc::fixinfo gcc/doc/ gcc/Makefile.in gcc texi
258
259        # gcc/doc/gccint.texi
260        crossgcc::fixinfo gcc/doc/ gcc/Makefile.in gccint texi
261
262        # gcc/fortran/gfortran.texi
263        crossgcc::fixinfo gcc/fortran/ gcc/fortran/Make-lang.in gfortran texi
264
265        # gcc/java/gcj.texi
266        crossgcc::fixinfo gcc/java/ gcc/java/Make-lang.in gcj texi
267
268        # gcc/doc/gccinstall.info
269        crossgcc::fixinfo gcc/doc/ gcc/Makefile.in gccinstall info
270
271        # gettext stuff.
272        crossgcc::fixgettext gcc
273        crossgcc::fixgettext libcpp
274}
275
276pre-destroot {
277        # gcc needs the cross directory structure to be present
278        # in order to fill it during installation.
279        file mkdir "${destroot}${prefix}/${crossgcc-target}/bin"
280        file mkdir "${destroot}${prefix}/${crossgcc-target}/lib"
281}
282
283post-destroot {
284        namespace eval crossgcc {}
285
286        # Rename a man page if it exists.
287        #
288        # section: section of the man page (e.g. 1)
289        # manpage: name of the man page (e.g. cpp)
290        proc crossgcc::rename_man_page { section manpage } {
291                global crossgcc-target destroot prefix
292
293                set manpage_path "${destroot}${prefix}/share/man/man${section}/${manpage}.${section}"
294                if { [ file exists ${manpage_path} ] } {
295                        file rename ${manpage_path} \
296                                "${destroot}${prefix}/share/man/man${section}/${crossgcc-target}-${manpage}.${section}"
297                }
298        }
299
300        # Stuff I don't want (either because they're in the system
301        # or because they would conflict with other FSF ports)
302        # (it's easier for maintainability purposes to fix things here)
303
304        # aliases for locales (should be on the system)
305        file delete "${destroot}${prefix}/share/locale/locale.alias"
306       
307        # FSF propaganda (should already be there or would conflict)
308        file delete -force "${destroot}${prefix}/share/man/man7"
309
310        # (host) libiberty
311        file delete "${destroot}${prefix}/lib/libiberty.a"
312
313        # aliases for charsets (should already be there)
314        file delete "${destroot}${prefix}/lib/charset.alias"
315       
316        # Remove man pages for tools that are not built as part of cross-gcc
317        file delete "${destroot}${prefix}/share/man/man1/rmic.1"
318        file delete "${destroot}${prefix}/share/man/man1/rmiregistry.1"
319        file delete "${destroot}${prefix}/share/man/man1/jv-convert.1"
320        file delete "${destroot}${prefix}/share/man/man1/gij.1"
321       
322        # For some reason, some man pages are not prefixed while they should have been
323        # (to avoid conflicting).
324        crossgcc::rename_man_page 1 cpp
325        crossgcc::rename_man_page 1 gcjh
326        crossgcc::rename_man_page 1 gcov
327        crossgcc::rename_man_page 1 jcf-dump
328        crossgcc::rename_man_page 1 jv-scan
329       
330        # There is a bug in gcc/Makefile::install-driver
331        # For cross compilers, $(GCC_INSTALL_NAME) is equal to
332        # $(target_noncanonical)-gcc-$(version)
333        # and hence the driver isn't installed.
334        xinstall -c "${workpath}/build/gcc/xgcc" \
335                "${destroot}${prefix}/bin/${crossgcc-target}-gcc-${version}"
336}
337
338livecheck.type  regex
339livecheck.url   http://gcc.gnu.org/releases.html
340livecheck.regex {<tr><td><a href="gcc-.*/">GCC (.*)</a></td>   <td>.*</td></tr>}
Note: See TracBrowser for help on using the repository browser.