qi: remove adding the depends.order into the meta file
[dragora.git] / recipes / devel / gcc / recipe
blob97c06fdb4f0d22cb36b3349a5bf1b4644f580dfd
1 # Build recipe for GCC.
3 # Copyright (c) 2015-2017 Matias Fonzo, <selk@dragora.org>.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 #    http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 program=gcc
18 version=6.4.0
19 release=1
21 tarname=${program}-${version}.tar.gz
23 # Remote source(s)
24 fetch=http://gnu.c3sl.ufpr.br/ftp/gcc/gcc-${version}/$tarname
26 homepage=http://www.gnu.org/software/gcc
27 license="GPLv2+, GPLv3+, LGPLv2.1, LGPLv3 + GCC runtime library exception"
29 description="
30 The GNU C Compiler Collection.
32 The GNU Compiler Collection (GCC) is a compiler system produced by the
33 GNU Project supporting various programming languages.  GCC is a key
34 component of the GNU toolchain.  The Free Software Foundation (FSF)
35 distributes GCC under the GNU General Public License (GNU GPL).
37 For more information about GCC, visit:  $homepage
40 # Source documentation
41 docs="COPYING* README"
42 docsdir="${docdir}/${program}-${version}"
44 # System-dependent
45 MACHTYPE="$(cc -dumpmachine)"
47 build()
49     set -e
51     unpack "${tardir}/$tarname"
53     cd "$srcdir"
55     # Apply specific patches for the support in musl.
56     #
57     # http://port70.net/~nsz/musl/gcc-trunk/
58     #
59     patch -Np1 -i "${worktree}/patches/gcc/0001-libgcc_s.patch"
60     patch -Np1 -i "${worktree}/patches/gcc/0005-libatomic-test-fix.patch"
61     patch -Np1 -i "${worktree}/patches/gcc/0006-libgomp-test-fix.patch"
62     patch -Np1 -i "${worktree}/patches/gcc/0007-libitm-test-fix.patch"
63     patch -Np1 -i "${worktree}/patches/gcc/0008-libvtv-test-fix.patch"
65     # Create a separate build directory
66     rm -rf ../gcc-build
67     mkdir ../gcc-build
68     cd ../gcc-build
70     ../${program}-${version}/configure SED=sed \
71     CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" LDFLAGS="$QILDFLAGS" \
72      $configure_args \
73      $multilib_options \
74      $gcc_options \
75      --libdir=/usr/lib${libSuffix} \
76      --mandir=$mandir \
77      --infodir=$infodir \
78      --enable-bootstrap \
79      --enable-languages=c,c++,objc,obj-c++,fortran \
80      --enable-clocale=generic \
81      --enable-threads=posix \
82      --enable-tls \
83      --enable-nls \
84      --enable-lto \
85      --enable-libstdcxx-time \
86      --enable-checking=release \
87      --enable-fully-dynamic-string \
88      --disable-symvers \
89      --disable-libitm \
90      --disable-gnu-indirect-function \
91      --disable-libstdcxx-pch \
92      --disable-libmudflap \
93      --disable-libsanitizer \
94      --disable-libmpx \
95      --disable-libcilkrts \
96      --with-system-zlib \
97      --build=$MACHTYPE \
98      --host=$MACHTYPE \
99      --target=$MACHTYPE
101     make -j${jobs} BOOT_LDFLAGS="$QILDFLAGS" \
102                    BOOT_CFLAGS="$QICFLAGS" \
103                    BOOT_CXXFLAGS="$QICXXFLAGS"
105     make -j${jobs} DESTDIR="$destdir" install-strip
107     # Back to source dir
108     cd .. && cd "$srcdir"
110     # Add compatibility for building programs with LTO (Link Time Optimization)
111     mkdir -p "${destdir}/usr/lib${libSuffix}/bfd-plugins"
112     ln -sf ../../libexec/gcc/${MACHTYPE}/${version}/liblto_plugin.so \
113            "${destdir}/usr/lib${libSuffix}/bfd-plugins/"
115     # Move misplaced file(s) for GDB
116     mkdir -p "${destdir}/usr/share/gdb/auto-load/usr/lib${libSuffix}"
117     mv "${destdir}/usr/lib${libSuffix}"/*-gdb.py \
118        "${destdir}/usr/share/gdb/auto-load/usr/lib${libSuffix}"
120     # Provide compatibility and make soft links for package size
121     (
122         cd "${destdir}/usr/bin" || exit 1
123         mv gcc gcc-${version}
124         ln -sf gcc-${version} gcc
125         ln -sf gcc cc
126         ln -sf gcc-${version} ${MACHTYPE}-gcc
127         ln -sf gcc-${version} ${MACHTYPE}-gcc-${version}
129         mv g++ g++-gcc-${version}
130         ln -sf g++-gcc-${version} g++
131         ln -sf g++ c++
132         ln -sf g++-gcc-${version} ${MACHTYPE}-g++
133         ln -sf g++-gcc-${version} ${MACHTYPE}-c++
135         mv gfortran gfortran-${version}
136         ln -sf gfortran-${version} gfortran
137         ln -sf gfortran-${version} ${MACHTYPE}-gfortran
139         mv gcc-ar gcc-ar-${version}
140         ln -sf gcc-ar-${version} gcc-ar
141         ln -sf gcc-ar-${version} ${MACHTYPE}-gcc-ar
143         mv gcc-nm gcc-nm-${version}
144         ln -sf gcc-nm-${version} gcc-nm
145         ln -sf gcc-nm-${version} ${MACHTYPE}-gcc-nm
147         mv gcc-ranlib gcc-ranlib-${version}
148         ln -sf gcc-ranlib-${version} gcc-ranlib
149         ln -sf gcc-ranlib-${version} ${MACHTYPE}-gcc-ranlib
150     )
151     (
152         mkdir -p "${destdir}/lib" && \
153         cd "${destdir}/lib" && ln -sf ../usr/bin/cpp .
154     )
156     # Compress info documents deleting index file for the package
157     if test -d "${destdir}/$infodir"
158     then
159         rm -f "${destdir}/${infodir}/dir"
160         lzip -9 "${destdir}/${infodir}"/*
161     fi
163     # Compress and link man pages (if needed)
164     if test -d "${destdir}/$mandir"
165     then
166         (
167             cd "${destdir}/$mandir"
168             find . -type f -exec lzip -9 '{}' +
169             find . -type l | while read -r file
170             do
171                 ln -sf "$(readlink -- "$file").lz" "${file}.lz"
172                 rm -- "$file"
173             done
174         )
175     fi
177     # Copy documentation
178     mkdir -p "${destdir}${docsdir}"
180     for file in $docs
181     do
182         cp -p $file "${destdir}${docsdir}"
183     done
185     # Delete temporary build directory
186     cd -- "$TMPDIR"
187     if test -d ./gcc-build
188     then
189         rm -rf ./gcc-build
190     fi