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

Last change on this file was 124574, checked in by jmr@…, 3 years ago

arm-rtems-gcc: clear configure.cxx_stdlib

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 10.6 KB
Line 
1# $Id: Portfile 124574 2014-08-25 23:28:42Z ryandesign@macports.org $
2
3PortSystem                      1.0
4
5name                    arm-rtems-gcc
6version                 4.2.3
7
8# Parameters for this port.
9set newlibversion       1.16.0
10set crossgcc-target arm-rtems
11set rtemsversion        4.9
12set default-languages --enable-languages="c,c++,objc"
13
14description             gcc cross-compilers for arm-rtems, with newlib runtime library.
15long_description        gnu compilers collection (c, c++, fortran and objc) for \
16                                        arm-rtems cross-development (ARM v7 and above).
17homepage                        http://gcc.gnu.org/
18platforms               darwin
19categories              cross devel
20license                 GPL-3+
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                                        ftp://ftp.rtems.com/pub/rtems/SOURCES/${rtemsversion}/:rtems \
26                                        freebsd::rtems
27distfiles                       gcc-${version}.tar.bz2:gcc \
28                                        newlib-${newlibversion}.tar.gz:newlib \
29                                        gcc-core-${version}-rtems4.9-20080205.diff:rtems \
30                                        newlib-${newlibversion}-rtems4.9-20080302.diff:rtems
31extract.only            gcc-${version}.tar.gz newlib-${newlibversion}.tar.gz
32worksrcdir                      gcc-${version}
33checksums                       gcc-${version}.tar.bz2 \
34                    md5     ef2a4d9991b3644115456ea05b2b8163 \
35                    sha1    80b0df13fc9e311868022a3e86e673177397a917 \
36                    rmd160  70b589b79b97967857f2ec70ff8b2017c84c464d \
37                                        newlib-${newlibversion}.tar.gz \
38                    md5     bf8f1f9e3ca83d732c00a79a6ef29bc4 \
39                    sha1    841edec33d19a9e549984982fb92445ee967e265 \
40                    rmd160  fa40ff43e858da3093c9f3b5b203724b9b327696 \
41                                        gcc-core-${version}-rtems4.9-20080205.diff \
42                    md5     d5a6a8c5973024476f0df6356b5e0424 \
43                    sha1    20d0ada57ad44d9f060e60e26acee57e46137ad6 \
44                    rmd160  c87a5703959dc319fad8e8b4804b8d4803cddc99 \
45                                        newlib-${newlibversion}-rtems4.9-20080302.diff \
46                    md5     a227456d0850e24a839634096b879c30 \
47                    sha1    4f8cd12ada4865b271eb4d4c7d80b520fb8d2bc6 \
48                    rmd160  81c76c584a6c76c9ea706bf9f0f2ba149303b289
49patchfiles                      patch-newlib-libc-configure.diff
50
51# All cross ports violate the mtree layout.
52destroot.violate_mtree  yes
53
54# Download everything to gcc/
55dist_subdir                     gcc
56
57depends_lib                     bin:${crossgcc-target}-ar:${crossgcc-target}-binutils \
58                                        bin:${crossgcc-target}-as:${crossgcc-target}-binutils \
59                                        bin:${crossgcc-target}-ld:${crossgcc-target}-binutils \
60                                        bin:${crossgcc-target}-nm:${crossgcc-target}-binutils \
61                                        bin:${crossgcc-target}-ranlib:${crossgcc-target}-binutils
62depends_build           bin:msgfmt:gettext
63
64# gcc is .bz2, newlib is .gz.
65# let's extract only gcc with MacPorts infrastructure, we'll do newlib manually.
66use_bzip2                       yes
67extract.only            gcc-${version}.tar.bz2
68
69# Extract newlib and create a symlink of newlib/newlib in gcc directory.
70post-extract    {
71        system "cd ${workpath} && gzip -dc ${distpath}/newlib-${newlibversion}.tar.gz | tar -xf -"
72        system "ln -s ${workpath}/newlib-${newlibversion}/newlib ${workpath}/gcc-${version}/"
73}
74
75# Since we don't build gcc and binutils at the same time, gcc's Makefile will try to transform
76# program names as gcc's name (add -${version} with ${version} being the version of gcc).
77# But it won't work because binutils binaries don't have the ${version} suffix, and even if they
78# had, they would actually have the binutils' version suffix (and not gcc's version).
79# So let's tell gcc's Makefile not to do that mistake.
80
81set environment [list AR_FOR_TARGET=${crossgcc-target}-ar \
82                                AS_FOR_TARGET=${crossgcc-target}-as \
83                                LD_FOR_TARGET=${crossgcc-target}-ld \
84                                NM_FOR_TARGET=${crossgcc-target}-nm \
85                                RANLIB_FOR_TARGET=${crossgcc-target}-ranlib]
86
87# Build in a different directory, as advised in the README file.
88pre-configure   {
89        file mkdir "${workpath}/build"
90}
91configure.dir   ${workpath}/build
92configure.cmd   ${workpath}/gcc-${version}/configure
93configure.env   ${environment}
94configure.args  --infodir='${prefix}/share/info' \
95                                --mandir='${prefix}/share/man' \
96                                --target=${crossgcc-target} \
97                                --program-prefix=${crossgcc-target}- \
98                                --program-suffix=-${version} \
99                                --with-included-gettext \
100                                --enable-obsolete \
101                                --with-newlib \
102                                --with-gxx-include-dir=${prefix}/${crossgcc-target}/include/c++/${version}/ \
103                                ${default-languages}
104
105configure.cflags-append -std=gnu89
106# the generated compiler doesn't accept -arch
107configure.cc_archflags
108configure.cxx_archflags
109configure.objc_archflags
110configure.ld_archflags
111# or -stdlib
112configure.cxx_stdlib
113
114build.dir       ${workpath}/build
115
116build.args              ${environment}
117destroot.args   ${environment}
118
119pre-patch {
120        # Additional patches for rtems.
121        system "cd ${workpath}/gcc-${version} && \
122                patch -p1 < ${distpath}/gcc-core-${version}-rtems4.9-20080205.diff"
123        system "cd ${workpath}/newlib-${newlibversion} && \
124                patch -p1 < ${distpath}/newlib-${newlibversion}-rtems4.9-20080302.diff"
125}
126
127post-patch {
128        namespace eval crossgcc {}
129
130        # Fix the info pages and related stuff.
131        #
132        # path: path to the doc directory (e.g. gas/doc/)
133        # makefile: path to Makefile.in (e.g. gas/doc/Makefile.in)
134        # name: name of the info page (e.g. as)
135        # suffix: suffix of the souce page (texinfo or texi)
136        proc crossgcc::fixinfo { path makefile name suffix } {
137                global crossgcc-target worksrcpath
138
139                # Fix the source
140                reinplace "s|setfilename ${name}.info|setfilename ${crossgcc-target}-${name}.info|g" \
141                        ${worksrcpath}/${path}/${name}.${suffix}
142                reinplace "s|(${name})|(${crossgcc-target}-${name})|g" \
143                        ${worksrcpath}/${path}/${name}.${suffix}
144                reinplace "s|@file{${name}}|@file{${crossgcc-target}-${name}}|g" \
145                        ${worksrcpath}/${path}/${name}.${suffix}
146               
147                # Fix the Makefile
148                reinplace "s| ${name}.info| ${crossgcc-target}-${name}.info|g" \
149                        ${worksrcpath}/${makefile}
150                reinplace "s|/${name}.info|/${crossgcc-target}-${name}.info|g" \
151                        ${worksrcpath}/${makefile}
152                reinplace "s|^${name}.info|${crossgcc-target}-${name}.info|g" \
153                        ${worksrcpath}/${makefile}
154                reinplace "s| ${name}.pod| ${crossgcc-target}-${name}.pod|g" \
155                        ${worksrcpath}/${makefile}
156                reinplace "s|/${name}.pod|/${crossgcc-target}-${name}.pod|g" \
157                        ${worksrcpath}/${makefile}
158                reinplace "s|^${name}.pod|${crossgcc-target}-${name}.pod|g" \
159                        ${worksrcpath}/${makefile}
160                reinplace "s| ${name}.${suffix}| ${crossgcc-target}-${name}.${suffix}|g" \
161                        ${worksrcpath}/${makefile}
162                reinplace "s|/${name}.${suffix}|/${crossgcc-target}-${name}.${suffix}|g" \
163                        ${worksrcpath}/${makefile}
164                reinplace "s|^${name}.${suffix}|${crossgcc-target}-${name}.${suffix}|g" \
165                        ${worksrcpath}/${makefile}
166               
167                # Rename the source
168                file rename ${worksrcpath}/${path}/${name}.${suffix} \
169                        ${worksrcpath}/${path}/${crossgcc-target}-${name}.${suffix}
170               
171                # Fix install-info's dir.
172                # (note: this may be effectless if there was no info dir to be fixed)
173                reinplace "s|--info-dir=\$(DESTDIR)\$(infodir)|--dir-file=\$(DESTDIR)\$(infodir)/${crossgcc-target}-gcc-dir|g" \
174                        "${worksrcpath}/${makefile}"
175        }
176
177        # Fix the gettext files and related stuff.
178        #
179        # module: name of the module (e.g. gas)
180        proc crossgcc::fixgettext { module } {
181                global crossgcc-target worksrcpath
182
183                if { [ file exists "${worksrcpath}/${module}/Makefile.in" ] } {
184                        reinplace "s|@PACKAGE@|${crossgcc-target}-@PACKAGE@|g" \
185                                "${worksrcpath}/${module}/Makefile.in"
186                }
187                if { [ file exists "${worksrcpath}/${module}/doc/Makefile.in" ] } {
188                        reinplace "s|@PACKAGE@|${crossgcc-target}-@PACKAGE@|g" \
189                                "${worksrcpath}/${module}/doc/Makefile.in"
190                }
191                if { [ file exists "${worksrcpath}/${module}/po/Make-in" ] } {
192                        reinplace "s|@PACKAGE@|${crossgcc-target}-@PACKAGE@|g" \
193                                "${worksrcpath}/${module}/po/Make-in"
194                }
195        }
196
197        # gcc/doc/cpp.texi
198        crossgcc::fixinfo gcc/doc/ gcc/Makefile.in cpp texi
199
200        # gcc/doc/cppinternals.texi
201        crossgcc::fixinfo gcc/doc/ gcc/Makefile.in cppinternals texi
202
203        # gcc/doc/gcc.texi
204        crossgcc::fixinfo gcc/doc/ gcc/Makefile.in gcc texi
205
206        # gcc/doc/gccint.texi
207        crossgcc::fixinfo gcc/doc/ gcc/Makefile.in gccint texi
208
209        # gcc/f/g77.texi
210        crossgcc::fixinfo gcc/fortran/ gcc/fortran/Make-lang.in gfortran texi
211
212        # gcc/java/gcj.texi
213        crossgcc::fixinfo gcc/java/ gcc/java/Make-lang.in gcj texi
214
215        # gcc/doc/gccinstall.info
216        crossgcc::fixinfo gcc/doc/ gcc/Makefile.in gccinstall info
217
218        # gettext stuff.
219        crossgcc::fixgettext gcc
220        crossgcc::fixgettext libcpp
221}
222
223pre-destroot {
224        # gcc needs the cross directory structure to be present
225        # in order to fill it during installation.
226        file mkdir "${destroot}${prefix}/${crossgcc-target}/bin"
227        file mkdir "${destroot}${prefix}/${crossgcc-target}/lib"
228}
229
230post-destroot {
231        namespace eval crossgcc {}
232
233        # Rename a man page if it exists.
234        #
235        # section: section of the man page (e.g. 1)
236        # manpage: name of the man page (e.g. cpp)
237        proc crossgcc::rename_man_page { section manpage } {
238                global crossgcc-target destroot prefix
239
240                set manpage_path "${destroot}${prefix}/share/man/man${section}/${manpage}.${section}"
241                if { [ file exists ${manpage_path} ] } {
242                        file rename ${manpage_path} \
243                                "${destroot}${prefix}/share/man/man${section}/${crossgcc-target}-${manpage}.${section}"
244                }
245        }
246
247        # Stuff I don't want (either because they're in the system
248        # or because they would conflict with other FSF ports)
249        # (it's easier for maintainability purposes to fix things here)
250
251        # aliases for locales (should be on the system)
252        file delete "${destroot}${prefix}/share/locale/locale.alias"
253       
254        # FSF propaganda (should already be there or would conflict)
255        file delete -force "${destroot}${prefix}/share/man/man7"
256
257        # (host) libiberty
258        foreach f [glob -directory "${destroot}${prefix}/lib" libiberty.a */libiberty.a] {
259        file delete $f
260    }
261
262        # aliases for charsets (should already be there)
263        file delete "${destroot}${prefix}/lib/charset.alias"
264       
265        # Remove man pages for tools that are not built as part of cross-gcc
266        file delete "${destroot}${prefix}/share/man/man1/rmic.1"
267        file delete "${destroot}${prefix}/share/man/man1/rmiregistry.1"
268        file delete "${destroot}${prefix}/share/man/man1/jv-convert.1"
269        file delete "${destroot}${prefix}/share/man/man1/gij.1"
270       
271        # For some reason, some man pages are not prefixed while they should have been
272        # (to avoid conflicting).
273        crossgcc::rename_man_page 1 cpp
274        crossgcc::rename_man_page 1 gcjh
275        crossgcc::rename_man_page 1 gcov
276        crossgcc::rename_man_page 1 jcf-dump
277        crossgcc::rename_man_page 1 jv-scan
278       
279        # There is a bug in gcc/Makefile::install-driver
280        # For cross compilers, $(GCC_INSTALL_NAME) is equal to
281        # $(target_noncanonical)-gcc-$(version)
282        # and hence the driver isn't installed.
283        xinstall -c "${workpath}/build/gcc/xgcc" \
284                "${destroot}${prefix}/bin/${crossgcc-target}-gcc-${version}"
285}
286
287livecheck.type  regex
288livecheck.url   http://gcc.gnu.org/releases.html
289livecheck.regex {<tr><td><a href="gcc-.*/">GCC (.*)</a></td>   <td>.*</td></tr>}
Note: See TracBrowser for help on using the repository browser.