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

Last change on this file was 108477, checked in by jmr@…, 4 years ago

powerpc-rtems-gcc: license

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