From c6e99c0bc6cd045cd451a1c186bae0bdd5c4a903 Mon Sep 17 00:00:00 2001
From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Date: Fri, 22 Oct 2021 08:13:13 +0200
Subject: [PATCH] package/gstreamer1/gstd: fix static build

Fix the following static build failure raised since the addition of the
package in commit 02ea01ea22e94ef353a638bf16f62f6e3ed1208e:

/home/buildroot/autobuild/instance-1/output-1/host/opt/ext-toolchain/bin/../lib/gcc/i586-buildroot-linux-musl/9.3.0/../../../../i586-buildroot-linux-musl/bin/ld: /home/buildroot/autobuild/instance-1/output-1/host/i586-buildroot-linux-musl/sysroot/usr/lib/libreadline.a(display.o): in function `_rl_move_cursor_relative':
display.c:(.text+0xbb5): undefined reference to `tputs'

Fixes:
 - http://autobuild.buildroot.org/results/77c/77c10947ddc749c54c7c233e3143f5cdf1edc73d/build-end.log

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
 ...use-dependency-function-for-readline.patch | 51 +++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 package/gstreamer1/gstd/0005-meson.build-use-dependency-function-for-readline.patch

diff --git a/package/gstreamer1/gstd/0005-meson.build-use-dependency-function-for-readline.patch b/package/gstreamer1/gstd/0005-meson.build-use-dependency-function-for-readline.patch
new file mode 100644
index 0000000000..51422e56d6
--- /dev/null
+++ b/package/gstreamer1/gstd/0005-meson.build-use-dependency-function-for-readline.patch
@@ -0,0 +1,51 @@
+From 3ef45c41105e61efe84c9be3a9a22988dfe10db8 Mon Sep 17 00:00:00 2001
+From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+Date: Fri, 22 Oct 2021 07:33:04 +0200
+Subject: [PATCH] meson.build: use dependency function for readline
+
+Use meson dependency function to find readline instead of
+cc.find_library. This function will retrieve readline pkg-config file
+which is available since version 7 (released 5 years ago) and
+https://git.savannah.gnu.org/cgit/readline.git/commit/readline.pc.in?id=d49a9082c0e15bba8cd3d8cc0a994409cf823cac.
+readline.pc sets tinfo in Requires.Private which will avoid the
+following static build failure:
+
+/home/buildroot/autobuild/instance-1/output-1/host/opt/ext-toolchain/bin/../lib/gcc/i586-buildroot-linux-musl/9.3.0/../../../../i586-buildroot-linux-musl/bin/ld: /home/buildroot/autobuild/instance-1/output-1/host/i586-buildroot-linux-musl/sysroot/usr/lib/libreadline.a(display.o): in function `_rl_move_cursor_relative':
+display.c:(.text+0xbb5): undefined reference to `tputs'
+
+Fixes:
+ - http://autobuild.buildroot.org/results/77c10947ddc749c54c7c233e3143f5cdf1edc73d
+
+Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+[Upstream status: https://github.com/RidgeRun/gstd-1.x/pull/261]
+---
+ meson.build | 6 ++----
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+diff --git a/meson.build b/meson.build
+index 7a8690a..44ed5c2 100644
+--- a/meson.build
++++ b/meson.build
+@@ -32,8 +32,8 @@ systemd_required = get_option('enable-systemd').enabled()
+ systemd_dep = dependency('systemd', required : systemd_required, version : '>=232')
+ 
+ cc = meson.get_compiler('c')
+-readline = cc.find_library('readline', required: true)
+-if readline.found()
++readline_dep = dependency('readline')
++if readline_dep.found()
+   add_project_arguments('-DHAVE_LIBREADLINE', language: 'c')
+   add_project_arguments('-DHAVE_READLINE_HISTORY', language: 'c')
+   # Add arguments to the compiler command line. 
+@@ -48,8 +48,6 @@ if readline.found()
+   else
+     add_project_arguments('-DHAVE_HISTORY_H', language: 'c')
+   endif
+-  
+-  readline_dep = readline
+ endif
+ 
+ ## Dependencies
+-- 
+2.37.1
+