Removes liconv LDFLAG and fixes ICONV_FULL.
Signed-off-by: Rosen Penev <redacted>
PKG_NAME:=mpd
PKG_VERSION:=0.21.25
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=https://www.musicpd.org/download/mpd/0.21/
/etc/avahi/services/mpd.service
endef
-TARGET_LDFLAGS += \
- -liconv \
- $(if $(CONFIG_USE_GLIBC),-lpthread)
-
ifeq ($(CONFIG_AUDIO_SUPPORT),y)
TARGET_LDFLAGS += -Wl,-rpath-link=$(STAGING_DIR)/usr/lib/pulseaudio
endif
+From 90fcdb5b02e08b3faf2e321b081798cc18d35b15 Mon Sep 17 00:00:00 2001
+From: Rosen Penev <rosenp@gmail.com>
+Date: Thu, 30 Jul 2020 14:34:07 -0700
+Subject: [PATCH] icu/meson: link against iconv when used externally
+
+This basically adds -liconv to LDFLAGS, fixing a linking issue when
+iconv is missing in the libc.
+
+The previous commit fixed finding iconv but did not fix linking.
+
+Switched to using c_compiler for iconv. It seems compiler does not work
+properly.
+
+Signed-off-by: Rosen Penev <rosenp@gmail.com>
+---
+ src/lib/icu/meson.build | 14 ++++++++++++--
+ 1 file changed, 12 insertions(+), 2 deletions(-)
+
+diff --git a/src/lib/icu/meson.build b/src/lib/icu/meson.build
+index bd6e30944..132e15b89 100644
--- a/src/lib/icu/meson.build
+++ b/src/lib/icu/meson.build
-@@ -18,7 +18,7 @@ if icu_dep.found()
+@@ -18,8 +18,18 @@ if icu_dep.found()
'Init.cxx',
]
elif not get_option('iconv').disabled()
- have_iconv = compiler.has_function('iconv')
-+ have_iconv = compiler.has_function('iconv', prefix : '#include <iconv.h>')
- conf.set('HAVE_ICONV', have_iconv)
+- conf.set('HAVE_ICONV', have_iconv)
++ have_iconv = c_compiler.has_header_symbol('iconv.h', 'iconv')
++ if have_iconv
++ libiconv = c_compiler.find_library('iconv')
++ conf.set('HAVE_ICONV', have_iconv)
++ libiconv_dep = static_library('iconv', icu_sources, include_directories: inc, dependencies: libiconv)
++ icu_dep = declare_dependency(link_with: libiconv_dep, dependencies: util_dep)
++ endif
++ if not have_iconv and c_compiler.has_function('iconv')
++ libiconv = []
++ have_iconv = true
++ conf.set('HAVE_ICONV', have_iconv)
++ endif
if not have_iconv and get_option('iconv').enabled()
error('iconv() not available')
+ endif
+--
+2.17.1
+
--- /dev/null
+From c2da1d47eeaf83d3683555b965a16654561f14b3 Mon Sep 17 00:00:00 2001
+From: Rosen Penev <rosenp@gmail.com>
+Date: Thu, 30 Jul 2020 16:27:02 -0700
+Subject: [PATCH] icu: fix compilation with const char iconv
+
+libiconv uses const char. Test for it and use it properly to fix
+compilation.
+
+Signed-off-by: Rosen Penev <rosenp@gmail.com>
+---
+ src/lib/icu/Converter.cxx | 2 +-
+ src/lib/icu/meson.build | 10 ++++++++++
+ 2 files changed, 11 insertions(+), 1 deletion(-)
+
+diff --git a/src/lib/icu/Converter.cxx b/src/lib/icu/Converter.cxx
+index b03543a82..4c459e57e 100644
+--- a/src/lib/icu/Converter.cxx
++++ b/src/lib/icu/Converter.cxx
+@@ -83,7 +83,7 @@ DoConvert(iconv_t conv, const char *src)
+ {
+ // TODO: dynamic buffer?
+ char buffer[4096];
+- char *in = const_cast<char *>(src);
++ ICONV_CONST char *in = (ICONV_CONST char *)(src);
+ char *out = buffer;
+ size_t in_left = strlen(src);
+ size_t out_left = sizeof(buffer);
+diff --git a/src/lib/icu/meson.build b/src/lib/icu/meson.build
+index 132e15b89..ac7d1b72a 100644
+--- a/src/lib/icu/meson.build
++++ b/src/lib/icu/meson.build
+@@ -30,6 +30,16 @@ elif not get_option('iconv').disabled()
+ have_iconv = true
+ conf.set('HAVE_ICONV', have_iconv)
+ endif
++ if have_iconv
++ iconvconsttest = '''#include <iconv.h>
++size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
++'''
++ if c_compiler.compiles(iconvconsttest, dependencies : libiconv)
++ conf.set('ICONV_CONST', '')
++ else
++ conf.set('ICONV_CONST', 'const')
++ endif
++ endif
+ if not have_iconv and get_option('iconv').enabled()
+ error('iconv() not available')
+ endif
+--
+2.17.1
+