source: trunk/dports/_resources/port1.0/group/crossgcc-1.0.tcl @ 100352

Last change on this file since 100352 was 100352, checked in by raimue@…, 7 years ago

group/crossgcc-1.0:
Add missing dependency on zlib.
No revision bump of ports using this port group right now; another change
demanding a revision bump will follow.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 8.9 KB
Line 
1# $Id: crossgcc-1.0.tcl 100352 2012-12-09 02:16:16Z raimue@macports.org $
2#
3# Copyright (c) 2011 The MacPorts Project
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are
8# met:
9#
10# 1. Redistributions of source code must retain the above copyright
11#    notice, this list of conditions and the following disclaimer.
12# 2. Redistributions in binary form must reproduce the above copyright
13#    notice, this list of conditions and the following disclaimer in the
14#    documentation and/or other materials provided with the distribution.
15# 3. Neither the name of The MacPorts Project nor the names of its
16#    contributors may be used to endorse or promote products derived from
17#    this software without specific prior written permission.
18#
19# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30#
31#
32# This PortGroup automatically sets all the fields of the various cross gcc
33# ports (e.g. arm-none-eabi-gcc).
34#
35# Usage:
36#
37#   PortGroup           crossgcc 1.0
38#
39#   crossgcc.setup      arm-none-eabi 4.6.1
40#   # Optional
41#   crossgcc.setup_libc newlib 1.19.0
42
43options crossgcc.target
44
45proc crossgcc.setup {target version} {
46    global crossgcc.target crossgcc.version
47
48    set crossgcc.target $target
49    set crossgcc.version $version
50
51    uplevel {
52        name            ${crossgcc.target}-gcc
53        version         ${crossgcc.version}
54        categories      cross devel
55        platforms       darwin
56        license         GPL-3+
57        maintainers     nomaintainer
58
59        description     The GNU compiler collection for ${crossgcc.target}
60        long_description \
61            The GNU compiler collection, including front ends for C, C++, Objective-C \
62            and Objective-C++ for cross development for ${crossgcc.target}.
63
64        homepage        http://gcc.gnu.org/
65        master_sites    gnu:gcc/gcc-${version}/:gcc
66        use_bzip2       yes
67
68        dist_subdir     gcc
69        distfiles       gcc-${version}.tar.bz2:gcc
70
71        worksrcdir      gcc-${version}
72
73        depends_lib     port:${crossgcc.target}-binutils \
74                        port:gmp \
75                        port:mpfr \
76                        port:libiconv \
77                        port:libmpc \
78                        port:zlib
79
80        depends_build   port:gettext
81
82        # Extract gcc distfiles only. libc tarball might be available as gzip only;
83        # handled below in post-extract in the variant.
84        extract.only    gcc-${version}.tar.bz2
85
86        # Build in a different directory, as advised in the README file.
87        post-extract {
88            file mkdir "${workpath}/build"
89        }
90
91        post-patch {
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 source page (texinfo or texi)
98                # path makefile name suffix
99                set infopages {
100                    gcc/doc/ gcc/Makefile.in cpp texi
101                    gcc/doc/ gcc/Makefile.in cppinternals texi
102                    gcc/doc/ gcc/Makefile.in gcc texi
103                    gcc/doc/ gcc/Makefile.in gccint texi
104                    gcc/doc/ gcc/Makefile.in gccinstall info
105                    libquadmath libquadmath/Makefile.in libquadmath info
106                }
107
108                foreach { path makefile name suffix } $infopages {
109                    set src      ${worksrcpath}/${path}/${name}.${suffix}
110                    set makefile ${worksrcpath}/${makefile}
111                    # If the makefile doesn't exists, skip it.
112                    if { ! [file exists ${makefile}] } {continue}
113
114                    # Fix the source
115                    reinplace "s|setfilename ${name}.info|setfilename ${crossgcc.target}-${name}.info|g" ${src}
116                    reinplace "s|(${name})|(${crossgcc.target}-${name})|g" ${src}
117                    reinplace "s|@file{${name}}|@file{${crossgcc.target}-${name}}|g" ${src}
118
119                    # Rename the source
120                    file rename ${worksrcpath}/${path}/${name}.${suffix} \
121                                ${worksrcpath}/${path}/${crossgcc.target}-${name}.${suffix}
122
123                    # Fix the Makefile
124                    reinplace -E "s:\[\[:<:\]\]${name}\\.(info|pod|${suffix}):${crossgcc.target}-&:g" ${makefile}
125
126                    # Fix install-info's dir.
127                    # (note: this may be effectless if there was no info dir to be fixed)
128                    reinplace "s|--info-dir=\$(DESTDIR)\$(infodir)|--dir-file=\$(DESTDIR)\$(infodir)/${crossgcc.target}-gcc-dir|g" ${makefile}
129                }
130
131                # Do not install libiberty
132                reinplace {/^install:/s/ .*//} ${worksrcpath}/libiberty/Makefile.in
133        }
134
135        # the generated compiler doesn't accept -arch
136        configure.cc_archflags
137        configure.cxx_archflags
138        configure.objc_archflags
139        configure.ld_archflags
140
141        # We don't need system includes(this prevents xgcc to include system-wide
142        # unwind.h if it is present)!
143        compiler.cpath
144
145        configure.dir   ${workpath}/build
146        configure.cmd   ${worksrcpath}/configure
147        configure.args  --target=${crossgcc.target} \
148                        --enable-languages="c,objc,c++,obj-c++" \
149                        --infodir=${prefix}/share/info \
150                        --mandir=${prefix}/share/man \
151                        --datarootdir=${prefix}/share/${name} \
152                        --with-system-zlib \
153                        --with-gmp=${prefix} \
154                        --with-mpfr=${prefix} \
155                        --with-mpc=${prefix} \
156                        --enable-stage1-checking \
157                        --enable-multilib
158
159        configure.env-append \
160            AR_FOR_TARGET=${crossgcc.target}-ar \
161            AS_FOR_TARGET=${crossgcc.target}-as \
162            LD_FOR_TARGET=${crossgcc.target}-ld \
163            NM_FOR_TARGET=${crossgcc.target}-nm \
164            OBJDUMP_FOR_TARGET=${crossgcc.target}-objdump \
165            RANLIB_FOR_TARGET=${crossgcc.target}-ranlib \
166            STRIP_FOR_TARGET=${crossgcc.target}-strip
167
168        # http://trac.macports.org/ticket/29104
169        # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48301
170        if {[vercmp ${xcodeversion} 4.3] < 0} {
171            compiler.blacklist llvm-gcc-4.2
172        }
173
174        universal_variant no
175
176        build.dir               ${workpath}/build
177
178        # this port installs files to ${prefix}/${crossgcc.target}
179        destroot.violate_mtree yes
180
181        pre-destroot {
182            # gcc needs the cross directory structure to be present
183            # in order to fill it during installation.
184            file mkdir "${destroot}/${prefix}/${crossgcc.target}/bin"
185            file mkdir "${destroot}/${prefix}/${crossgcc.target}/lib"
186        }
187
188        post-destroot {
189            # FSF propaganda (should already be there or would conflict)
190            file delete -force "${destroot}/${prefix}/share/man/man7"
191        }
192
193        livecheck.type  regex
194        livecheck.url   http://gcc.gnu.org/releases.html
195        livecheck.regex {<tr><td><a href="gcc-.*/">GCC (.*)</a></td>   <td>.*</td></tr>}
196    # uplevel
197    }
198# crossgcc.setup
199}
200
201proc crossgcc.setup_libc {libc_name libc_version} {
202    global crossgcc.libc_name crossgcc.libc_version
203
204    set crossgcc.libc_name $libc_name
205    set crossgcc.libc_version $libc_version
206
207    switch -exact $libc_name {
208        newlib {
209            uplevel {
210                set dnewlib newlib-${crossgcc.libc_version}.tar.gz
211
212                master_sites-append ftp://sources.redhat.com/pub/newlib/:newlib
213                distfiles-append ${dnewlib}:newlib
214
215                post-extract {
216                    system -W ${workpath} "tar -xzf ${distpath}/newlib-${crossgcc.libc_version}.tar.gz"
217                    ln -s ${workpath}/newlib-${crossgcc.libc_version}/newlib ${workpath}/gcc-${version}/
218                }
219
220                configure.args-append --with-newlib
221            }
222        }
223        default {
224            pre-fetch {
225                ui_error "libc $libc_name is not supported by port group crossgcc"
226                return -code error "unsupported libc"
227            }
228        }
229    }
230}
Note: See TracBrowser for help on using the repository browser.