source: trunk/dports/cross/mips-elf-gcc/Portfile

Last change on this file was 114328, checked in by ryandesign@…, 4 years ago

use eq and ne instead of == and != when comparing ${os.arch}, ${configure.build_arch}, ${build_arch}, and some port-specific variables for referring to architectures

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 9.8 KB
Line 
1# $Id: Portfile 114328 2013-12-05 10:21:52Z ryandesign@macports.org $
2
3PortSystem                      1.0
4
5name                    mips-elf-gcc
6version                 3.4.6
7
8# Parameters for this port.
9set newlibversion       1.15.0
10set crossgcc-target mips-elf
11set default-languages --enable-languages="c,c++,f77,objc"
12
13description             gcc cross-compilers for mips-elf, with newlib runtime library.
14long_description        gnu compilers collection (including c++, fortran and objc) for \
15                                        mips-elf, with newlib runtime library.
16homepage                        http://gcc.gnu.org/
17platforms               darwin
18categories              cross devel
19license                 GPL-2+
20maintainers             nomaintainer
21master_sites            gnu:gcc/gcc-${version}/:gcc \
22                                        ftp://sources.redhat.com/pub/newlib/:newlib \
23                                        ftp://ftp.mirror.ac.uk/sites/sources.redhat.com/pub/newlib/:newlib
24distfiles                       gcc-${version}.tar.bz2:gcc newlib-${newlibversion}.tar.gz:newlib
25worksrcdir                      gcc-${version}
26checksums                       gcc-${version}.tar.bz2 \
27                                                md5 4a21ac777d4b5617283ce488b808da7b \
28                                                sha1 97b290fdc572c8e490b3b39f243e69bacad23c2b \
29                                                rmd160 b15003368cedc7964f6ceaee0c39ddc43a46c442 \
30                                        newlib-${newlibversion}.tar.gz \
31                                                md5 4020004b1b7a56ca4cf7f6d35b40a4cb \
32                                                sha1 f6860b36e48fb831a30bab491230bbc7ce2669a2 \
33                                                rmd160 e57cbb5b3f007ec26a4ec62f5652e23523357001
34patchfiles                      patch-gcc-Makefile.in
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
43depends_build           port:gettext
44
45# gcc is .bz2, newlib is .gz.
46# let's extract only gcc with MacPorts infrastructure, we'll do newlib manually.
47use_bzip2                       yes
48extract.only            gcc-${version}.tar.bz2
49
50# Extract newlib and create a symlink of newlib/newlib in gcc directory.
51post-extract    {
52        system "cd ${workpath} && gzip -dc ${distpath}/newlib-${newlibversion}.tar.gz | tar -xf -"
53        system "ln -s ${workpath}/newlib-${newlibversion}/newlib ${workpath}/gcc-${version}/"
54}
55
56# Since we don't build gcc and binutils at the same time, gcc's Makefile will try to transform
57# program names as gcc's name (add -${version} with ${version} being the version of gcc).
58# But it won't work because binutils binaries don't have the ${version} suffix, and even if they
59# had, they would actually have the binutils' version suffix (and not gcc's version).
60# So let's tell gcc's Makefile not to do that mistake.
61
62set environment [list AR_FOR_TARGET=${crossgcc-target}-ar \
63                                AS_FOR_TARGET=${crossgcc-target}-as \
64                                LD_FOR_TARGET=${crossgcc-target}-ld \
65                                NM_FOR_TARGET=${crossgcc-target}-nm \
66                                RANLIB_FOR_TARGET=${crossgcc-target}-ranlib]
67
68# Build in a different directory, as advised in the README file.
69pre-configure   {
70        file mkdir "${workpath}/build"
71}
72configure.dir   ${workpath}/build
73configure.cmd   ${workpath}/gcc-${version}/configure
74configure.env   ${environment}
75configure.pipe  no
76configure.cflags-append -DLIBICONV_PLUG
77configure.args  --infodir='${prefix}/share/info' \
78                                --mandir='${prefix}/share/man' \
79                                --target=${crossgcc-target} \
80                                --program-prefix=${crossgcc-target}- \
81                                --program-suffix=-${version} \
82                                --with-included-gettext \
83                                --enable-obsolete \
84                                --with-newlib \
85                                --enable-multilib \
86                                --with-gxx-include-dir=${prefix}/${crossgcc-target}/include/c++/${version}/ \
87                                ${default-languages}
88
89# the generated compiler doesn't accept -arch
90configure.cc_archflags
91configure.cxx_archflags
92configure.objc_archflags
93configure.ld_archflags
94platform darwin {
95        if {${build_arch} eq "i386"} {
96                configure.args-append --build=i686-apple-${os.platform}${os.version} \
97                                                          --host=i686-apple-${os.platform}${os.version}
98        } else {
99                configure.args-append --build=${build_arch}-apple-${os.platform}${os.version} \
100                                                          --host=${build_arch}-apple-${os.platform}${os.version}
101        }
102}
103
104build.dir       ${workpath}/build
105
106build.args              ${environment}
107destroot.args   ${environment}
108
109# Variant to include java tools.
110# I'm not exactly sure what the interest of this variant is except to measure
111# the speed of your Xserve G5 farm. Or your patience if you don't have such
112# a farm.
113variant java {
114        configure.args-delete ${default-languages}
115}
116
117post-patch {
118        namespace eval crossgcc {}
119
120        # Fix the info pages and related stuff.
121        #       
122        # path: path to the doc directory (e.g. gas/doc/)
123        # makefile: path to Makefile.in (e.g. gas/doc/Makefile.in)
124        # name: name of the info page (e.g. as)
125        # suffix: suffix of the souce page (texinfo or texi)
126        proc crossgcc::fixinfo { path makefile name suffix } {
127                global crossgcc-target worksrcpath
128
129                # Fix the source
130                reinplace "s|setfilename ${name}.info|setfilename ${crossgcc-target}-${name}.info|g" \
131                        ${worksrcpath}/${path}/${name}.${suffix}
132                reinplace "s|(${name})|(${crossgcc-target}-${name})|g" \
133                        ${worksrcpath}/${path}/${name}.${suffix}
134                reinplace "s|@file{${name}}|@file{${crossgcc-target}-${name}}|g" \
135                        ${worksrcpath}/${path}/${name}.${suffix}
136               
137                # Fix the Makefile
138                reinplace "s| ${name}.info| ${crossgcc-target}-${name}.info|g" \
139                        ${worksrcpath}/${makefile}
140                reinplace "s|/${name}.info|/${crossgcc-target}-${name}.info|g" \
141                        ${worksrcpath}/${makefile}
142                reinplace "s|^${name}.info|${crossgcc-target}-${name}.info|g" \
143                        ${worksrcpath}/${makefile}
144                reinplace "s| ${name}.pod| ${crossgcc-target}-${name}.pod|g" \
145                        ${worksrcpath}/${makefile}
146                reinplace "s|/${name}.pod|/${crossgcc-target}-${name}.pod|g" \
147                        ${worksrcpath}/${makefile}
148                reinplace "s|^${name}.pod|${crossgcc-target}-${name}.pod|g" \
149                        ${worksrcpath}/${makefile}
150                reinplace "s| ${name}.${suffix}| ${crossgcc-target}-${name}.${suffix}|g" \
151                        ${worksrcpath}/${makefile}
152                reinplace "s|/${name}.${suffix}|/${crossgcc-target}-${name}.${suffix}|g" \
153                        ${worksrcpath}/${makefile}
154                reinplace "s|^${name}.${suffix}|${crossgcc-target}-${name}.${suffix}|g" \
155                        ${worksrcpath}/${makefile}
156               
157                # Rename the source
158                file rename ${worksrcpath}/${path}/${name}.${suffix} \
159                        ${worksrcpath}/${path}/${crossgcc-target}-${name}.${suffix}
160               
161                # Fix install-info's dir.
162                # (note: this may be effectless if there was no info dir to be fixed)
163                reinplace "s|--info-dir=\$(DESTDIR)\$(infodir)|--dir-file=\$(DESTDIR)\$(infodir)/${crossgcc-target}-gcc-dir|g" \
164                        "${worksrcpath}/${makefile}"
165        }
166
167        # Fix the gettext files and related stuff.
168        #       
169        # module: name of the module (e.g. gas)
170        proc crossgcc::fixgettext { module } {
171                global crossgcc-target worksrcpath
172
173                if { [ file exists "${worksrcpath}/${module}/Makefile.in" ] } {
174                        reinplace "s|@PACKAGE@|${crossgcc-target}-@PACKAGE@|g" \
175                                "${worksrcpath}/${module}/Makefile.in"
176                }
177                if { [ file exists "${worksrcpath}/${module}/doc/Makefile.in" ] } {
178                        reinplace "s|@PACKAGE@|${crossgcc-target}-@PACKAGE@|g" \
179                                "${worksrcpath}/${module}/doc/Makefile.in"
180                }
181                if { [ file exists "${worksrcpath}/${module}/po/Make-in" ] } {
182                        reinplace "s|@PACKAGE@|${crossgcc-target}-@PACKAGE@|g" \
183                                "${worksrcpath}/${module}/po/Make-in"
184                }
185        }
186
187        # gcc/doc/cpp.texi
188        crossgcc::fixinfo gcc/doc/ gcc/Makefile.in cpp texi
189
190        # gcc/doc/cppinternals.texi
191        crossgcc::fixinfo gcc/doc/ gcc/Makefile.in cppinternals texi
192
193        # gcc/doc/gcc.texi
194        crossgcc::fixinfo gcc/doc/ gcc/Makefile.in gcc texi
195
196        # gcc/doc/gccint.texi
197        crossgcc::fixinfo gcc/doc/ gcc/Makefile.in gccint texi
198
199        # gcc/f/g77.texi
200        crossgcc::fixinfo gcc/f/ gcc/f/Make-lang.in g77 texi
201
202        # gcc/java/gcj.texi
203        crossgcc::fixinfo gcc/java/ gcc/java/Make-lang.in gcj texi
204
205        # fastjar/fastjar.texi
206        crossgcc::fixinfo fastjar/ fastjar/Makefile.in fastjar 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 fastjar
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.