source: trunk/dports/cross/arm-elf-gcc3/Portfile @ 71533

Last change on this file since 71533 was 71533, checked in by ryandesign@…, 9 years ago

In the interest that all portfiles exemplify correct portfile writing techniques, remove slash before ${prefix} which is not needed because ${prefix} already begins with a slash

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