epunt-cxx.eclass 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. # @ECLASS: epunt-cxx.eclass
  4. # @MAINTAINER:
  5. # base-system@gentoo.org
  6. # @BLURB: A function to punt C++ compiler checks from autoconf
  7. # @DESCRIPTION:
  8. # Support for punting C++ compiler checks from autoconf (based
  9. # on ELT-patches).
  10. if [[ -z ${_EPUNT_CXX_ECLASS} ]]; then
  11. # TODO: replace this with 'inherit eutils' once eutils stops inheriting
  12. # us
  13. if ! declare -F eqawarn >/dev/null ; then
  14. eqawarn() {
  15. has qa ${PORTAGE_ELOG_CLASSES} && ewarn "$@"
  16. :
  17. }
  18. fi
  19. # If an overlay has eclass overrides, but doesn't actually override the
  20. # libtool.eclass, we'll have ECLASSDIR pointing to the active overlay's
  21. # eclass/ dir, but libtool.eclass is still in the main Gentoo tree. So
  22. # add a check to locate the ELT-patches/ regardless of what's going on.
  23. # Note: Duplicated in libtool.eclass.
  24. _EUTILS_ECLASSDIR_LOCAL=${BASH_SOURCE[0]%/*}
  25. eutils_elt_patch_dir() {
  26. local d="${ECLASSDIR}/ELT-patches"
  27. if [[ ! -d ${d} ]] ; then
  28. d="${_EUTILS_ECLASSDIR_LOCAL}/ELT-patches"
  29. fi
  30. echo "${d}"
  31. }
  32. # @FUNCTION: epunt_cxx
  33. # @USAGE: [dir to scan]
  34. # @DESCRIPTION:
  35. # Many configure scripts wrongly bail when a C++ compiler could not be
  36. # detected. If dir is not specified, then it defaults to ${S}.
  37. #
  38. # https://bugs.gentoo.org/73450
  39. epunt_cxx() {
  40. local dir=$1
  41. [[ -z ${dir} ]] && dir=${S}
  42. ebegin "Removing useless C++ checks"
  43. local f p any_found
  44. while IFS= read -r -d '' f; do
  45. for p in "$(eutils_elt_patch_dir)"/nocxx/*.patch ; do
  46. if patch --no-backup-if-mismatch -p1 "${f}" "${p}" >/dev/null ; then
  47. any_found=1
  48. break
  49. fi
  50. done
  51. done < <(find "${dir}" -name configure -print0)
  52. if [[ -z ${any_found} ]]; then
  53. eqawarn "epunt_cxx called unnecessarily (no C++ checks to punt)."
  54. fi
  55. eend 0
  56. }
  57. _EPUNT_CXX_ECLASS=1
  58. fi #_EPUNT_CXX_ECLASS