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.
21 tarname=${program}-${version}.tar.gz
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"
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}"
45 MACHTYPE="$(cc -dumpmachine)"
51 unpack "${tardir}/$tarname"
55 # Apply specific patches for the support in musl.
57 # http://port70.net/~nsz/musl/gcc-trunk/
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
70 ../${program}-${version}/configure SED=sed \
71 CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" LDFLAGS="$QILDFLAGS" \
75 --libdir=/usr/lib${libSuffix} \
79 --enable-languages=c,c++,objc,obj-c++,fortran \
80 --enable-clocale=generic \
81 --enable-threads=posix \
85 --enable-libstdcxx-time \
86 --enable-checking=release \
87 --enable-fully-dynamic-string \
90 --disable-gnu-indirect-function \
91 --disable-libstdcxx-pch \
92 --disable-libmudflap \
93 --disable-libsanitizer \
95 --disable-libcilkrts \
101 make -j${jobs} BOOT_LDFLAGS="$QILDFLAGS" \
102 BOOT_CFLAGS="$QICFLAGS" \
103 BOOT_CXXFLAGS="$QICXXFLAGS"
105 make -j${jobs} DESTDIR="$destdir" install-strip
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
122 cd "${destdir}/usr/bin" || exit 1
123 mv gcc gcc-${version}
124 ln -sf gcc-${version} gcc
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++
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
152 mkdir -p "${destdir}/lib" && \
153 cd "${destdir}/lib" && ln -sf ../usr/bin/cpp .
156 # Compress info documents deleting index file for the package
157 if test -d "${destdir}/$infodir"
159 rm -f "${destdir}/${infodir}/dir"
160 lzip -9 "${destdir}/${infodir}"/*
163 # Compress and link man pages (if needed)
164 if test -d "${destdir}/$mandir"
167 cd "${destdir}/$mandir"
168 find . -type f -exec lzip -9 '{}' +
169 find . -type l | while read -r file
171 ln -sf "$(readlink -- "$file").lz" "${file}.lz"
178 mkdir -p "${destdir}${docsdir}"
182 cp -p $file "${destdir}${docsdir}"
185 # Delete temporary build directory
187 if test -d ./gcc-build