1*4882a593SmuzhiyunFrom 8b80c4bd848ff3d71b998dc8a4bd42627ed72581 Mon Sep 17 00:00:00 2001
2*4882a593SmuzhiyunFrom: Fabrice Fontaine <fontaine.fabrice@gmail.com>
3*4882a593SmuzhiyunDate: Sat, 17 Apr 2021 11:58:19 +0200
4*4882a593SmuzhiyunSubject: [PATCH] configure.ac: fix cross-compilation with protobuf-c
5*4882a593Smuzhiyun
6*4882a593SmuzhiyunTry to retrieve the version from pkg-config to avoid the following
7*4882a593Smuzhiyunerror:
8*4882a593Smuzhiyun
9*4882a593Smuzhiyunchecking protobuf-c version... configure: error: in `/home/fabrice/buildroot/output/build/postgis-3.1.1':
10*4882a593Smuzhiyunconfigure: error: cannot run test program while cross compiling
11*4882a593Smuzhiyun
12*4882a593SmuzhiyunSigned-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
13*4882a593Smuzhiyun[Retrieved from:
14*4882a593Smuzhiyunhttps://github.com/postgis/postgis/commit/8b80c4bd848ff3d71b998dc8a4bd42627ed72581]
15*4882a593Smuzhiyun---
16*4882a593Smuzhiyun configure.ac | 6 +++++-
17*4882a593Smuzhiyun 1 file changed, 5 insertions(+), 1 deletion(-)
18*4882a593Smuzhiyun
19*4882a593Smuzhiyundiff --git a/configure.ac b/configure.ac
20*4882a593Smuzhiyunindex 48ba070a40..df75fe6601 100644
21*4882a593Smuzhiyun--- a/configure.ac
22*4882a593Smuzhiyun+++ b/configure.ac
23*4882a593Smuzhiyun@@ -1004,6 +1004,7 @@ if test "$CHECK_PROTOBUF" != "no"; then
24*4882a593Smuzhiyun 		PKG_CHECK_MODULES([PROTOBUFC], [libprotobuf-c >= 1.1.0], [
25*4882a593Smuzhiyun 				PROTOBUF_CPPFLAGS="$PROTOBUFC_CFLAGS";
26*4882a593Smuzhiyun 				PROTOBUF_LDFLAGS="$PROTOBUFC_LIBS";
27*4882a593Smuzhiyun+				PROTOC_VERSION=`$PKG_CONFIG libprotobuf-c --modversion | sed 's/\([[0-9]]\).*\([[0-9]]\).*\([[0-9]]\)/\100\200\3/'`
28*4882a593Smuzhiyun 			], [
29*4882a593Smuzhiyun 				AC_MSG_RESULT([libprotobuf-c not found in pkg-config])
30*4882a593Smuzhiyun 			])
31*4882a593Smuzhiyun@@ -1054,7 +1055,10 @@ if test "$CHECK_PROTOBUF" != "no"; then
32*4882a593Smuzhiyun 		[])
33*4882a593Smuzhiyun
34*4882a593Smuzhiyun 	AC_MSG_CHECKING([protobuf-c version])
35*4882a593Smuzhiyun-	AC_PROTOBUFC_VERSION([PROTOC_VERSION])
36*4882a593Smuzhiyun+	dnl Return the protobuf-c version number if not detected by pkg-config
37*4882a593Smuzhiyun+	if test "x$PROTOC_VERSION" = "x"; then
38*4882a593Smuzhiyun+		AC_PROTOBUFC_VERSION([PROTOC_VERSION])
39*4882a593Smuzhiyun+	fi
40*4882a593Smuzhiyun         if test ! "$PROTOC_VERSION" -ge 1001000; then
41*4882a593Smuzhiyun                 AC_MSG_ERROR("Old protobuf-c release found but 1.1.0 is required. You can disable MVT and Geobuf support using --without-protobuf")
42*4882a593Smuzhiyun         fi
43