Ticket #51397: crossgcc-1.0.tcl

File crossgcc-1.0.tcl, 9.5 KB (added by denis-fr (Denis), 8 years ago)

change all gcc-${version} by gcc-${crossgcc.version}

Line 
1# $Id: crossgcc-1.0.tcl 135689 2015-04-29 21:24:41Z ryandesign@macports.org $
2#
3# Copyright (c) 2011-2015 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#
41#   # Optional: libc support
42#   crossgcc.setup_libc newlib 1.19.0
43#
44#   # Optional: additional language support (e.g. Objective-C/Objective-C++)
45#   crossgcc.languages-append objc obj-c++
46
47options crossgcc.target \
48        crossgcc.languages
49
50default crossgcc.languages {{c c++}}
51
52proc crossgcc.setup {target version} {
53    global crossgcc.target crossgcc.version
54
55    set crossgcc.target $target
56    set crossgcc.version $version
57
58    uplevel {
59        name            ${crossgcc.target}-gcc
60        version         ${crossgcc.version}
61        categories      cross devel
62        platforms       darwin
63        license         GPL-3+
64        maintainers     nomaintainer
65
66        description     The GNU compiler collection for ${crossgcc.target}
67        long_description \
68            The GNU compiler collection, including front ends for C, C++, Objective-C \
69            and Objective-C++ for cross development for ${crossgcc.target}.
70
71        homepage        http://gcc.gnu.org/
72        master_sites    gnu:gcc/gcc-${crossgcc.version}/:gcc
73        use_bzip2       yes
74
75        dist_subdir     gcc
76        distfiles       gcc-${crossgcc.version}.tar.bz2:gcc
77
78        worksrcdir      gcc-${crossgcc.version}
79
80        depends_lib     port:${crossgcc.target}-binutils \
81                        port:gmp \
82                        port:mpfr \
83                        port:libiconv \
84                        port:libmpc \
85                        port:zlib
86
87        depends_build   port:gettext
88
89        # Extract gcc distfiles only. libc tarball might be available as gzip only;
90        # handled below in post-extract in the variant.
91        extract.only    gcc-${crossgcc.version}.tar.bz2
92
93        # Build in a different directory, as advised in the README file.
94        post-extract {
95            file mkdir "${workpath}/build"
96        }
97
98        post-patch {
99                # Fix the info pages and related stuff.
100                #
101                # path: path to the doc directory (e.g. gas/doc/)
102                # makefile: path to Makefile.in (e.g. gas/doc/Makefile.in)
103                # name: name of the info page (e.g. as)
104                # suffix: suffix of the source page (texinfo or texi)
105                # path makefile name suffix
106                set infopages {
107                    gcc/doc/ gcc/Makefile.in cpp texi
108                    gcc/doc/ gcc/Makefile.in cppinternals texi
109                    gcc/doc/ gcc/Makefile.in gcc texi
110                    gcc/doc/ gcc/Makefile.in gccint texi
111                    gcc/doc/ gcc/Makefile.in gccinstall info
112                    libquadmath libquadmath/Makefile.in libquadmath info
113                }
114
115                foreach { path makefile name suffix } $infopages {
116                    set src      ${worksrcpath}/${path}/${name}.${suffix}
117                    set makefile ${worksrcpath}/${makefile}
118                    # If the makefile doesn't exists, skip it.
119                    if { ! [file exists ${makefile}] } {continue}
120
121                    # Fix the source
122                    reinplace "s|setfilename ${name}.info|setfilename ${crossgcc.target}-${name}.info|g" ${src}
123                    reinplace "s|(${name})|(${crossgcc.target}-${name})|g" ${src}
124                    reinplace "s|@file{${name}}|@file{${crossgcc.target}-${name}}|g" ${src}
125
126                    # Rename the source
127                    file rename ${worksrcpath}/${path}/${name}.${suffix} \
128                                ${worksrcpath}/${path}/${crossgcc.target}-${name}.${suffix}
129
130                    # Fix the Makefile
131                    reinplace -E "s:\[\[:<:\]\]${name}\\.(info|pod|${suffix}):${crossgcc.target}-&:g" ${makefile}
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" ${makefile}
136                }
137
138                # Do not install libiberty
139                reinplace {/^install:/s/ .*//} ${worksrcpath}/libiberty/Makefile.in
140        }
141
142        # the generated compiler doesn't accept -arch
143        configure.cc_archflags
144        configure.cxx_archflags
145        configure.objc_archflags
146        configure.ld_archflags
147
148        # the bootstrap compiler doesn't accept -stdlib
149        configure.cxx_stdlib
150
151        # We don't need system includes(this prevents xgcc to include system-wide
152        # unwind.h if it is present)!
153        compiler.cpath
154
155        configure.dir   ${workpath}/build
156        configure.cmd   ${worksrcpath}/configure
157        configure.args  --target=${crossgcc.target} \
158                        --infodir=${prefix}/share/info \
159                        --mandir=${prefix}/share/man \
160                        --datarootdir=${prefix}/share/${name} \
161                        --with-system-zlib \
162                        --with-gmp=${prefix} \
163                        --with-mpfr=${prefix} \
164                        --with-mpc=${prefix} \
165                        --enable-stage1-checking \
166                        --enable-multilib
167
168        # The Portfile may modify crossgcc.languages, thus, evaluate the option
169        # late in this pre-configure phase
170        pre-configure {
171            configure.args-append --enable-languages="[join ${crossgcc.languages} ","]"
172        }
173
174        configure.env-append \
175            AR_FOR_TARGET=${crossgcc.target}-ar \
176            AS_FOR_TARGET=${crossgcc.target}-as \
177            LD_FOR_TARGET=${crossgcc.target}-ld \
178            NM_FOR_TARGET=${crossgcc.target}-nm \
179            OBJDUMP_FOR_TARGET=${crossgcc.target}-objdump \
180            RANLIB_FOR_TARGET=${crossgcc.target}-ranlib \
181            STRIP_FOR_TARGET=${crossgcc.target}-strip
182
183        # http://trac.macports.org/ticket/29104
184        # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48301
185        if {[vercmp ${xcodeversion} 4.3] < 0} {
186            compiler.blacklist llvm-gcc-4.2
187        }
188
189        universal_variant no
190
191        build.dir               ${workpath}/build
192
193        # this port installs files to ${prefix}/${crossgcc.target}
194        destroot.violate_mtree yes
195
196        pre-destroot {
197            # gcc needs the cross directory structure to be present
198            # in order to fill it during installation.
199            file mkdir "${destroot}/${prefix}/${crossgcc.target}/bin"
200            file mkdir "${destroot}/${prefix}/${crossgcc.target}/lib"
201        }
202
203        post-destroot {
204            # FSF propaganda (should already be there or would conflict)
205            file delete -force "${destroot}/${prefix}/share/man/man7"
206        }
207
208        livecheck.type  regex
209        livecheck.url   http://ftp.gnu.org/gnu/gcc/
210        livecheck.regex gcc-(\[0-9\]+\\.\[0-9.\]+)/
211    # uplevel
212    }
213# crossgcc.setup
214}
215
216proc crossgcc.setup_libc {libc_name libc_version} {
217    global crossgcc.libc_name crossgcc.libc_version
218
219    set crossgcc.libc_name $libc_name
220    set crossgcc.libc_version $libc_version
221
222    switch -exact $libc_name {
223        newlib {
224            uplevel {
225                set dnewlib newlib-${crossgcc.libc_version}.tar.gz
226
227                master_sites-append ftp://sources.redhat.com/pub/newlib/:newlib
228                distfiles-append ${dnewlib}:newlib
229
230                post-extract {
231                    system -W ${workpath} "tar -xzf ${distpath}/newlib-${crossgcc.libc_version}.tar.gz"
232                    ln -s ${workpath}/newlib-${crossgcc.libc_version}/newlib ${workpath}/gcc-${crossgcc.version}/
233                }
234
235                configure.args-append --with-newlib
236            }
237        }
238        default {
239            pre-fetch {
240                ui_error "libc $libc_name is not supported by port group crossgcc"
241                return -code error "unsupported libc"
242            }
243        }
244    }
245}