From: Olliver Schinagl Date: Thu, 23 Feb 2023 17:49:44 +0000 (+0100) Subject: iconv: Allow using GNU libiconv X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=21a5c6399aaba600886f1bc1ad0ce79d454b8ba8;p=thirdparty%2Ftvheadend.git iconv: Allow using GNU libiconv TVHeadend has a hard-dependency on libiconv. Lets make this a little bit more flexible by also allowing gnu-libiconv. This helps with musl-based systems, such as Alpine Linux. Contributes to #4940. Signed-off-by: Olliver Schinagl --- diff --git a/Makefile b/Makefile index a56a2fbdf..c4aeab5d5 100644 --- a/Makefile +++ b/Makefile @@ -67,6 +67,10 @@ LDFLAGS += -Wl,-z,now ifeq ($(CONFIG_LIBICONV),yes) LDFLAGS += -liconv endif +ifeq ($(CONFIG_GNU_LIBICONV),yes) +CFLAGS += -D_GNU_LIBICONV +LDFLAGS += -liconv +endif ifeq ($(PLATFORM), darwin) LDFLAGS += -framework CoreServices else diff --git a/configure b/configure index 8ce559fa7..82c0efb60 100755 --- a/configure +++ b/configure @@ -325,9 +325,19 @@ int test(void) } ' -# a check for the external iconv library +# a check for the external (gnu)iconv library # for build-in libc iconv routines this check should fail # note that iconv routines are mandatory +check_cc_snippet gnu_libiconv ' +#include +#define TEST test +int test(void) +{ + iconv_t ic = iconv_open("ASCII", "ASCII"); + return 0; +} +' -liconv + check_cc_snippet libiconv ' #include #define TEST test @@ -338,7 +348,9 @@ int test(void) } ' -liconv -if enabled libiconv; then +if enabled gnu_libiconv; then + printf " ^ using gnu libiconv library\n" +elif enabled libiconv; then printf " ^ using external iconv library\n" else printf " ^ using build-in glibc iconv routines\n" diff --git a/src/intlconv.c b/src/intlconv.c index 48a11ec81..617341f55 100644 --- a/src/intlconv.c +++ b/src/intlconv.c @@ -1,4 +1,8 @@ +#ifdef _GNU_LIBICONV +#include +#else #include +#endif #include "tvheadend.h" #include "intlconv.h"