mpd: fixup iconv support
authorRosen Penev <redacted>
Thu, 30 Jul 2020 23:40:11 +0000 (16:40 -0700)
committerRosen Penev <redacted>
Fri, 31 Jul 2020 06:21:09 +0000 (23:21 -0700)
Removes liconv LDFLAG and fixes ICONV_FULL.

Signed-off-by: Rosen Penev <redacted>
sound/mpd/Makefile
sound/mpd/patches/010-iconv.patch
sound/mpd/patches/020-iconv-const.patch [new file with mode: 0644]

index 41dab43b5b32fe94ad926b62c48419bc9af7ffd4..00a4879ae887361f46d8aca4875b08b1593b5155 100644 (file)
@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
 
 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/
@@ -97,10 +97,6 @@ define Package/mpd-avahi-service/conffiles
 /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
index 730b27108a0e1b62e996a40a6a8f3854f5160300..c7dad5fd5da18377c85af06e57c3ee4c30b276b4 100644 (file)
@@ -1,11 +1,46 @@
+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
+
diff --git a/sound/mpd/patches/020-iconv-const.patch b/sound/mpd/patches/020-iconv-const.patch
new file mode 100644 (file)
index 0000000..82f19dd
--- /dev/null
@@ -0,0 +1,51 @@
+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
+
git clone https://git.99rst.org/PROJECT