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

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

group/crossgcc-1.0:
Whitespace only

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