commit:     71c382f745b42db23de0e3a1e3adb3ba9d4cda3c
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Wed Sep 14 23:50:07 2022 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Wed Sep 14 23:53:11 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=71c382f7

net-libs/rpcsvc-proto: search for a valid 'cpp' command

Closes: https://bugs.gentoo.org/870061
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>

 net-libs/rpcsvc-proto/rpcsvc-proto-1.4.3-r1.ebuild | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/net-libs/rpcsvc-proto/rpcsvc-proto-1.4.3-r1.ebuild 
b/net-libs/rpcsvc-proto/rpcsvc-proto-1.4.3-r1.ebuild
index f7687c8b7eca..480e738d5930 100644
--- a/net-libs/rpcsvc-proto/rpcsvc-proto-1.4.3-r1.ebuild
+++ b/net-libs/rpcsvc-proto/rpcsvc-proto-1.4.3-r1.ebuild
@@ -3,8 +3,6 @@
 
 EAPI=8
 
-inherit toolchain-funcs
-
 DESCRIPTION="rpcsvc protocol definitions from glibc"
 HOMEPAGE="https://github.com/thkukuk/rpcsvc-proto";
 
SRC_URI="https://github.com/thkukuk/rpcsvc-proto/releases/download/v${PV}/${P}.tar.xz";
@@ -21,9 +19,18 @@ BDEPEND="sys-devel/gettext"
 src_prepare() {
        default
 
-       # Use ${CHOST}-cpp, not 'cpp': bug #718138
-       # Ideally we should use @CPP@ but rpcgen makes it hard to use 
'${CHOST}-gcc -E'
-       sed -i -s "s/CPP = \"cpp\";/CPP = \"$(tc-getPROG CPP cpp)\";/" 
rpcgen/rpc_main.c || die
+       # Search for a valid 'cpp' command.
+       # The CPP envvar might contain '${CC} -E', which does not work for 
rpcgen.
+       # Bug 718138, 870031, 870061.
+       local x cpp=
+       for x in {${CHOST}-,}{,clang-}cpp; do
+               if type -P "${x}" >/dev/null; then
+                       cpp=${x}
+                       break
+               fi
+       done
+       [[ -n ${cpp} ]] || die "Unable to find cpp"
+       sed -i -e "s/CPP = \"cpp\";/CPP = \"${cpp}\";/" rpcgen/rpc_main.c || die
 }
 
 src_install() {

Reply via email to