Ticket #30767: Portfile.2

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