Ticket #30767: Portfile

File Portfile, 10.9 KB (added by yann.sionneau@…, 13 years ago)

Portfile for lm32-rtems-gcc

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