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

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

group/crossgcc-1.0:
Use a single tarball for gcc sources (default distribution since 4.7.x, also available for 4.6.x).
Compilation with llvm-gcc-4.2 is supposed to work with Xcode >= 4.3.
Parallel building is already the default.

  • 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 100350 2012-12-09 02:12:30Z 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
79        depends_build   port:gettext
80
81        # Extract gcc distfiles only. libc tarball might be available as gzip only;
82        # handled below in post-extract in the variant.
83        extract.only    gcc-${version}.tar.bz2
84
85        # Build in a different directory, as advised in the README file.
86        post-extract {
87            file mkdir "${workpath}/build"
88        }
89
90        post-patch {
91                # Fix the info pages and related stuff.
92                #
93                # path: path to the doc directory (e.g. gas/doc/)
94                # makefile: path to Makefile.in (e.g. gas/doc/Makefile.in)
95                # name: name of the info page (e.g. as)
96                # suffix: suffix of the source page (texinfo or texi)
97                # path makefile name suffix
98                set infopages {
99                    gcc/doc/ gcc/Makefile.in cpp texi
100                    gcc/doc/ gcc/Makefile.in cppinternals texi
101                    gcc/doc/ gcc/Makefile.in gcc texi
102                    gcc/doc/ gcc/Makefile.in gccint texi
103                    gcc/doc/ gcc/Makefile.in gccinstall info
104                    libquadmath libquadmath/Makefile.in libquadmath info
105                }
106
107                foreach { path makefile name suffix } $infopages {
108                    set src      ${worksrcpath}/${path}/${name}.${suffix}
109                    set makefile ${worksrcpath}/${makefile}
110                    # If the makefile doesn't exists, skip it.
111                    if { ! [file exists ${makefile}] } {continue}
112
113                    # Fix the source
114                    reinplace "s|setfilename ${name}.info|setfilename ${crossgcc.target}-${name}.info|g" ${src}
115                    reinplace "s|(${name})|(${crossgcc.target}-${name})|g" ${src}
116                    reinplace "s|@file{${name}}|@file{${crossgcc.target}-${name}}|g" ${src}
117
118                    # Rename the source
119                    file rename ${worksrcpath}/${path}/${name}.${suffix} \
120                                ${worksrcpath}/${path}/${crossgcc.target}-${name}.${suffix}
121
122                    # Fix the Makefile
123                    reinplace -E "s:\[\[:<:\]\]${name}\\.(info|pod|${suffix}):${crossgcc.target}-&:g" ${makefile}
124
125                    # Fix install-info's dir.
126                    # (note: this may be effectless if there was no info dir to be fixed)
127                    reinplace "s|--info-dir=\$(DESTDIR)\$(infodir)|--dir-file=\$(DESTDIR)\$(infodir)/${crossgcc.target}-gcc-dir|g" ${makefile}
128                }
129
130                # Do not install libiberty
131                reinplace {/^install:/s/ .*//} ${worksrcpath}/libiberty/Makefile.in
132        }
133
134        # the generated compiler doesn't accept -arch
135        configure.cc_archflags
136        configure.cxx_archflags
137        configure.objc_archflags
138        configure.ld_archflags
139
140        # We don't need system includes(this prevents xgcc to include system-wide
141        # unwind.h if it is present)!
142        compiler.cpath
143
144        configure.dir   ${workpath}/build
145        configure.cmd   ${worksrcpath}/configure
146        configure.args  --target=${crossgcc.target} \
147                        --enable-languages="c,objc,c++,obj-c++" \
148                        --infodir=${prefix}/share/info \
149                        --mandir=${prefix}/share/man \
150                        --datarootdir=${prefix}/share/${name} \
151                        --with-system-zlib \
152                        --with-gmp=${prefix} \
153                        --with-mpfr=${prefix} \
154                        --with-mpc=${prefix} \
155                        --enable-stage1-checking \
156                        --enable-multilib
157
158        configure.env-append \
159            AR_FOR_TARGET=${crossgcc.target}-ar \
160            AS_FOR_TARGET=${crossgcc.target}-as \
161            LD_FOR_TARGET=${crossgcc.target}-ld \
162            NM_FOR_TARGET=${crossgcc.target}-nm \
163            OBJDUMP_FOR_TARGET=${crossgcc.target}-objdump \
164            RANLIB_FOR_TARGET=${crossgcc.target}-ranlib \
165            STRIP_FOR_TARGET=${crossgcc.target}-strip
166
167        # http://trac.macports.org/ticket/29104
168        # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48301
169        if {[vercmp ${xcodeversion} 4.3] < 0} {
170            compiler.blacklist llvm-gcc-4.2
171        }
172
173        universal_variant no
174
175        build.dir               ${workpath}/build
176
177        # this port installs files to ${prefix}/${crossgcc.target}
178        destroot.violate_mtree yes
179
180        pre-destroot {
181                # gcc needs the cross directory structure to be present
182                # in order to fill it during installation.
183                file mkdir "${destroot}/${prefix}/${crossgcc.target}/bin"
184                file mkdir "${destroot}/${prefix}/${crossgcc.target}/lib"
185        }
186
187        post-destroot {
188                # FSF propaganda (should already be there or would conflict)
189                file delete -force "${destroot}/${prefix}/share/man/man7"
190        }
191
192        livecheck.type  regex
193        livecheck.url   http://gcc.gnu.org/releases.html
194        livecheck.regex {<tr><td><a href="gcc-.*/">GCC (.*)</a></td>   <td>.*</td></tr>}
195    # uplevel
196    }
197# crossgcc.setup
198}
199
200proc crossgcc.setup_libc {libc_name libc_version} {
201    global crossgcc.libc_name crossgcc.libc_version
202
203    set crossgcc.libc_name $libc_name
204    set crossgcc.libc_version $libc_version
205
206    switch -exact $libc_name {
207        newlib {
208            uplevel {
209                set dnewlib newlib-${crossgcc.libc_version}.tar.gz
210
211                master_sites-append ftp://sources.redhat.com/pub/newlib/:newlib
212                distfiles-append ${dnewlib}:newlib
213
214                post-extract {
215                    system -W ${workpath} "tar -xzf ${distpath}/newlib-${crossgcc.libc_version}.tar.gz"
216                    ln -s ${workpath}/newlib-${crossgcc.libc_version}/newlib ${workpath}/gcc-${version}/
217                }
218
219                configure.args-append --with-newlib
220            }
221        }
222        default {
223            pre-fetch {
224                ui_error "libc $libc_name is not supported by port group crossgcc"
225                return -code error "unsupported libc"
226            }
227        }
228    }
229}
Note: See TracBrowser for help on using the repository browser.