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