toolchain.eclass: move gentoo patches into own helper
[gentoo.git] / eclass / epunt-cxx.eclass
1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 # @ECLASS: epunt-cxx.eclass
5 # @MAINTAINER:
6 # base-system@gentoo.org
7 # @BLURB: A function to punt C++ compiler checks from autoconf
8 # @DESCRIPTION:
9 # Support for punting C++ compiler checks from autoconf (based
10 # on ELT-patches).
11
12 if [[ -z ${_EPUNT_CXX_ECLASS} ]]; then
13
14 # eutils for eqawarn
15 inherit eutils
16
17 DEPEND=">=app-portage/elt-patches-20170317"
18
19 # @FUNCTION: epunt_cxx
20 # @USAGE: [dir to scan]
21 # @DESCRIPTION:
22 # Many configure scripts wrongly bail when a C++ compiler could not be
23 # detected.  If dir is not specified, then it defaults to ${S}.
24 #
25 # https://bugs.gentoo.org/73450
26 epunt_cxx() {
27         local dir=$1
28         [[ -z ${dir} ]] && dir=${S}
29         ebegin "Removing useless C++ checks"
30         local f p any_found
31         while IFS= read -r -d '' f; do
32                 for p in "${EPREFIX}/usr/share/elt-patches"/nocxx/*.patch ; do
33                         if patch --no-backup-if-mismatch -p1 "${f}" "${p}" >/dev/null ; then
34                                 any_found=1
35                                 break
36                         fi
37                 done
38         done < <(find "${dir}" -name configure -print0)
39
40         if [[ -z ${any_found} ]]; then
41                 eqawarn "epunt_cxx called unnecessarily (no C++ checks to punt)."
42         fi
43         eend 0
44 }
45
46 _EPUNT_CXX_ECLASS=1
47 fi #_EPUNT_CXX_ECLASS