nixpkgs/pkgs/development/php-packages/grpc/use-pkgconfig.patch
2023-12-28 21:46:06 +01:00

83 lines
2.5 KiB
Diff

From 24b4e273bd503760a485e92ca418e4699767ec51 Mon Sep 17 00:00:00 2001
From: Shyim <github@shyim.de>
Date: Thu, 28 Dec 2023 10:38:42 +0100
Subject: [PATCH] [php]: add with-grpc-dir to configure and add pkg-config
support
---
config.m4 | 48 +++++++++++++++++++++++++-------------
1 file changed, 32 insertions(+), 16 deletions(-)
diff --git a/config.m4 b/config.m4
index 5600df34ccfa3..c2186a41d21f5 100755
--- a/config.m4
+++ b/config.m4
@@ -7,35 +7,51 @@ PHP_ARG_ENABLE(coverage, whether to include code coverage symbols,
PHP_ARG_ENABLE(tests, whether to compile helper methods for tests,
[ --enable-tests Enable tests methods], no, no)
+PHP_ARG_WITH(grpc-dir, for grpc,
+[ --with-grpc-dir[=DIR] Set the path to grpc install prefix.], yes)
+
dnl Check whether to enable tests
if test "$PHP_TESTS" != "no"; then
CPPFLAGS="$CPPFLAGS -DGRPC_PHP_DEBUG"
fi
if test "$PHP_GRPC" != "no"; then
- dnl Write more examples of tests here...
-
- dnl # --with-grpc -> check with-path
- SEARCH_PATH="/usr/local /usr" # you might want to change this
- SEARCH_FOR="include/grpc/grpc.h" # you most likely want to change this
- if test -r $PHP_GRPC/$SEARCH_FOR; then # path given as parameter
- GRPC_DIR=$PHP_GRPC
- else # search default path list
+ AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
+
+ if test "$PHP_GRPC_DIR" = "yes" -a -x $PKG_CONFIG; then
+ AC_MSG_CHECKING([for grpc using pkg-config])
+
+ if ! $PKG_CONFIG --exists grpc ; then
+ AC_MSG_ERROR([grpc not found])
+ fi
+
+ GRPC_VERSION=`$PKG_CONFIG grpc --modversion`
+ AC_MSG_RESULT([found version $GRPC_VERSION])
+
+ PHP_GRPC_LIBS=`$PKG_CONFIG grpc --libs`
+ PHP_GRPC_INCS=`$PKG_CONFIG grpc --cflags`
+
+ PHP_EVAL_LIBLINE($PHP_GRPC_LIBS, AMQP_SHARED_LIBADD)
+ PHP_EVAL_INCLINE($PHP_GRPC_INCS)
+ else
AC_MSG_CHECKING([for grpc files in default path])
+
+ SEARCH_PATH="$PHP_GRPC_DIR /usr/local /usr"
+
for i in $SEARCH_PATH ; do
- if test -r $i/$SEARCH_FOR; then
+ if test -r $i/include/grpc/grpc.h; then
GRPC_DIR=$i
AC_MSG_RESULT(found in $i)
fi
done
- fi
- if test -z "$GRPC_DIR"; then
- AC_MSG_RESULT([not found])
- AC_MSG_ERROR([Please reinstall the grpc distribution])
- fi
- dnl # --with-grpc -> add include path
- PHP_ADD_INCLUDE($GRPC_DIR/include)
+ if test -z "$GRPC_DIR"; then
+ AC_MSG_RESULT([not found])
+ AC_MSG_ERROR([Please reinstall the grpc distribution])
+ fi
+
+ PHP_ADD_INCLUDE($GRPC_DIR/include)
+ fi
LIBS="-lpthread $LIBS"