about summary refs log tree commit diff
path: root/pkgs/development/php-packages/grpc/use-pkgconfig.patch
blob: 628f54abb305fec9345f1b8f7713a9d74bf2fe11 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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"