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

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

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