freeswitch-stable: backport iconv fixes
authorSebastian Kemper <sebastian_ml@gmx.net>
Sun, 22 Jul 2018 07:11:40 +0000 (09:11 +0200)
committerSebastian Kemper <sebastian_ml@gmx.net>
Sun, 22 Jul 2018 07:21:38 +0000 (09:21 +0200)
Backport iconv fixes from master.

- Include nls.mk and remove the uclibc iconv hack.

- The above change pointed to an issue with the unimrcp sed script. It
  is missing brackets, which causes follow-up breakage when APR_SETVAR
  is called, because the latter uses commas to separate its arguments -
  commas that TARGET_LDFLAGS contains when nls.mk is included. So add
  the missing brackets.

- mod_gsmopen is unable to detect whether iconv's inbuf is const. Update
  the patch so the Makefile can pass this information on to mod_gsmopen.

Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
net/freeswitch-stable/Makefile
net/freeswitch-stable/patches/270-fix-uclibc-iconv-in-gsmopen.patch

index e3258c34275a15f15d5c04757436674e4c2e9c28..b22ef456ad47299b8041f47d515a65634ab1d404 100644 (file)
@@ -239,6 +239,19 @@ PKG_CONFIG_DEPENDS:= \
 
 include $(INCLUDE_DIR)/uclibc++.mk
 include $(INCLUDE_DIR)/package.mk
+# iconv support
+include $(INCLUDE_DIR)/nls.mk
+#######################################################
+# mod_gsmopen can't detect if iconv's inbuf is const. #
+#                                                     #
+#                  musl    uclibc                     #
+# libiconv-stub    -       -                          #
+# libiconv-full    -       const                      #
+#                                                     #
+#######################################################
+ifeq ($(ICONV_FULL)$(CONFIG_USE_UCLIBC),1y)
+TARGET_CFLAGS+=-DFS_STABLE_ICONV_INBUF_CONST
+endif
 
 FS_STABLE_PERL_FEED:=$(TOPDIR)/feeds/packages/lang/perl
 
@@ -251,14 +264,6 @@ FS_STABLE_PERL_LIBS:=$(shell grep "^libs=" \
 
 FS_STABLE_PYTHON_SITE_DIR:=$(FS_STABLE_LIB_DIR)/python$(PYTHON_VERSION)/site-packages
 
-# musl and glibc include their own iconv, but uclibc does not
-ifneq ($(CONFIG_USE_UCLIBC),)
-TARGET_CPPFLAGS+= \
-       -I$(STAGING_DIR)/usr/lib/libiconv-full/include
-TARGET_LDFLAGS += \
-       -L$(STAGING_DIR)/usr/lib/libiconv-full/lib
-endif
-
 define Download/files
 define Download/$(1)
   FILE:=$(2)
@@ -361,11 +366,11 @@ $(call Package/$(PKG_NAME)/Default)
   USERID:=$(PRG_NAME)=372:$(PRG_NAME)=372
   DEPENDS:= \
          $(CXX_DEPENDS) \
+         $(ICONV_DEPENDS) \
          +FS_STABLE_WITH_FREETYPE:libfreetype \
          +FS_STABLE_WITH_ODBC:unixodbc \
          +FS_STABLE_WITH_PGSQL:libpq \
          +FS_STABLE_WITH_PNG:libpng \
-         +USE_UCLIBC:libiconv-full \
          +libcurl \
          +libedit \
          +libopenssl \
@@ -911,7 +916,7 @@ define Build/Prepare
        echo '#codecs/mod_yuv' >> $(PKG_BUILD_DIR)/modules.conf
        echo '#event_handlers/mod_event_test' >> $(PKG_BUILD_DIR)/modules.conf
 
-       $(SED) 's|$(FS_STABLE_ANCHOR)|APR_SETVAR(LDFLAGS,$(FS_STABLE_APR_LIBS) $(TARGET_LDFLAGS))|' \
+       $(SED) 's|$(FS_STABLE_ANCHOR)|APR_SETVAR(LDFLAGS,[$(FS_STABLE_APR_LIBS) $(TARGET_LDFLAGS)])|' \
                $(PKG_BUILD_DIR)/libs/unimrcp/build/acmacros/apr.m4
 endef
 
index 7170f7b1d09838877d7bd35b6dae3c985dcd7d4c..c4a9cd4b6b11339492c101eeaf6bfc0ff3a1b5b2 100644 (file)
@@ -1,62 +1,67 @@
 --- a/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp
 +++ b/src/mod/endpoints/mod_gsmopen/gsmopen_protocol.cpp
-@@ -2521,11 +2521,11 @@ int ucs2_to_utf8(private_t *tech_pvt, ch
+@@ -104,6 +104,12 @@ int gettimeofday(struct timeval *tv, str
+ /***************/
+ #endif /* WIN32 */
++#if defined(FS_STABLE_ICONV_INBUF_CONST)
++#define ICONV_INBUF_TYPE const char **
++#else
++#define ICONV_INBUF_TYPE char **
++#endif
++
+ int gsmopen_serial_init(private_t *tech_pvt, int controldevice_speed)
+ {
+       if (!tech_pvt)
+@@ -2521,11 +2527,7 @@ int ucs2_to_utf8(private_t *tech_pvt, ch
        DEBUGA_GSMOPEN("1 ciao in=%s, inleft=%d, out=%s, outleft=%d, converted=%s, utf8_out=%s\n",
                                   GSMOPEN_P_LOG, inbuf, (int) inbytesleft, outbuf, (int) outbytesleft, converted, utf8_out);
  
 -#ifdef WIN32
-+#ifdef __UCLIBC__ // libiconv-full needs this conversion
-       iconv_res = iconv(iconv_format, (const char **) &inbuf, &inbytesleft, &outbuf, &outbytesleft);
+-      iconv_res = iconv(iconv_format, (const char **) &inbuf, &inbytesleft, &outbuf, &outbytesleft);
 -#else // WIN32
-+#else
-       iconv_res = iconv(iconv_format, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
+-      iconv_res = iconv(iconv_format, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
 -#endif // WIN32
-+#endif
++      iconv_res = iconv(iconv_format, (ICONV_INBUF_TYPE)&inbuf, &inbytesleft, &outbuf, &outbytesleft);
        if (iconv_res == (size_t) -1) {
                DEBUGA_GSMOPEN("2 ciao in=%s, inleft=%d, out=%s, outleft=%d, converted=%s, utf8_out=%s\n",
                                           GSMOPEN_P_LOG, inbuf, (int) inbytesleft, outbuf, (int) outbytesleft, converted, utf8_out);
-@@ -2560,11 +2560,11 @@ int utf8_to_iso_8859_1(private_t *tech_p
+@@ -2560,11 +2562,7 @@ int utf8_to_iso_8859_1(private_t *tech_p
  
        DEBUGA_GSMOPEN("in=%s, inleft=%d, out=%s, outleft=%d, utf8_in=%s, iso_8859_1_out=%s\n",
                                   GSMOPEN_P_LOG, inbuf, (int) inbytesleft, outbuf, (int) outbytesleft, utf8_in, iso_8859_1_out);
 -#ifdef WIN32
-+#ifdef __UCLIBC__
-       iconv_res = iconv(iconv_format, (const char **) &inbuf, &inbytesleft, &outbuf, &outbytesleft);
+-      iconv_res = iconv(iconv_format, (const char **) &inbuf, &inbytesleft, &outbuf, &outbytesleft);
 -#else // WIN32
-+#else
-       iconv_res = iconv(iconv_format, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
+-      iconv_res = iconv(iconv_format, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
 -#endif // WIN32
-+#endif
++      iconv_res = iconv(iconv_format, (ICONV_INBUF_TYPE)&inbuf, &inbytesleft, &outbuf, &outbytesleft);
        if (iconv_res == (size_t) -1) {
                DEBUGA_GSMOPEN("cannot translate in iso_8859_1 error: %s (errno: %d)\n", GSMOPEN_P_LOG, strerror(errno), errno);
                return -1;
-@@ -2597,11 +2597,11 @@ int iso_8859_1_to_utf8(private_t *tech_p
+@@ -2597,11 +2595,7 @@ int iso_8859_1_to_utf8(private_t *tech_p
        }
  
        inbytesleft = strlen(iso_8859_1_in) * 2;
 -#ifdef WIN32
-+#ifdef __UCLIBC__
-       iconv_res = iconv(iconv_format, (const char **) &inbuf, &inbytesleft, &outbuf, &outbytesleft);
+-      iconv_res = iconv(iconv_format, (const char **) &inbuf, &inbytesleft, &outbuf, &outbytesleft);
 -#else // WIN32
-+#else
-       iconv_res = iconv(iconv_format, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
+-      iconv_res = iconv(iconv_format, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
 -#endif // WIN32
-+#endif
++      iconv_res = iconv(iconv_format, (ICONV_INBUF_TYPE)&inbuf, &inbytesleft, &outbuf, &outbytesleft);
        if (iconv_res == (size_t) -1) {
                DEBUGA_GSMOPEN("ciao in=%s, inleft=%d, out=%s, outleft=%d, utf8_out=%s\n",
                                           GSMOPEN_P_LOG, inbuf, (int) inbytesleft, outbuf, (int) outbytesleft, utf8_out);
-@@ -2642,11 +2642,11 @@ int utf8_to_ucs2(private_t *tech_pvt, ch
+@@ -2642,11 +2636,7 @@ int utf8_to_ucs2(private_t *tech_pvt, ch
  
        DEBUGA_GSMOPEN("in=%s, inleft=%d, out=%s, outleft=%d, utf8_in=%s, converted=%s\n",
                                   GSMOPEN_P_LOG, inbuf, (int) inbytesleft, outbuf, (int) outbytesleft, utf8_in, converted);
 -#ifdef WIN32
-+#ifdef __UCLIBC__
-       iconv_res = iconv(iconv_format, (const char **) &inbuf, &inbytesleft, &outbuf, &outbytesleft);
+-      iconv_res = iconv(iconv_format, (const char **) &inbuf, &inbytesleft, &outbuf, &outbytesleft);
 -#else // WIN32
-+#else
-       iconv_res = iconv(iconv_format, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
+-      iconv_res = iconv(iconv_format, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
 -#endif // WIN32
-+#endif
++      iconv_res = iconv(iconv_format, (ICONV_INBUF_TYPE)&inbuf, &inbytesleft, &outbuf, &outbytesleft);
        if (iconv_res == (size_t) -1) {
                ERRORA("error: %s %d\n", GSMOPEN_P_LOG, strerror(errno), errno);
                return -1;