source: trunk/dports/cross/avr-gcc/Portfile @ 61919

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

avr-gcc: apply the usual gcc build_arch fix (doesn't fix #20839 though)

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