source: trunk/dports/cross/i386-elf-gcc/Portfile @ 90749

Last change on this file since 90749 was 90749, checked in by jmr@…, 8 years ago

i386-elf-gcc: use correct compiler and build with -std=gnu89 (fixes #28912)

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