Makefile: introduce CHARSET_LIB to link with -lcharset

On some systems, the function locale_charset() may not be exported from libiconv but is available from libcharset, and we need -lcharset when linking. Introduce a make variable CHARSET_LIB that can be set to -lcharsetlib on such systems. Also autodetect this in the configure script by first looking for the symbol in libiconv, and then libcharset. Signed-off-by: Дилян Палаузов <dilyan.palauzov@aegee.org>

Дилян Палаузов committed Feb 12, 2012 at 17:23 UTC b5225286b226759262c0637058528af03226fba6
3 files changed +16
Makefile
+5
@@ -53,6 +53,10 @@ all::
53 # FreeBSD can use either, but MinGW and some others need to use
54 # libcharset.h's locale_charset() instead.
55 #
56 +# Define CHARSET_LIB to you need to link with library other than -liconv to
57 +# use locale_charset() function. On some platforms this needs to set to
58 +# -lcharset
59 +#
60 # Define LIBC_CONTAINS_LIBINTL if your gettext implementation doesn't
61 # need -lintl when linking.
62 #
@@ -1692,6 +1696,7 @@ endif
1696
1697 ifdef HAVE_LIBCHARSET_H
1698 BASIC_CFLAGS += -DHAVE_LIBCHARSET_H
1699 + EXTLIBS += $(CHARSET_LIB)
1700 endif
1701
1702 ifdef HAVE_DEV_TTY
config.mak.in
+1
@@ -74,3 +74,4 @@ SNPRINTF_RETURNS_BOGUS=@SNPRINTF_RETURNS_BOGUS@
74 NO_PTHREADS=@NO_PTHREADS@
75 PTHREAD_CFLAGS=@PTHREAD_CFLAGS@
76 PTHREAD_LIBS=@PTHREAD_LIBS@
77 +CHARSET_LIB=@CHARSET_LIB@
configure.ac
+10
@@ -836,6 +836,16 @@ AC_CHECK_HEADER([libcharset.h],
836 [HAVE_LIBCHARSET_H=YesPlease],
837 [HAVE_LIBCHARSET_H=])
838 AC_SUBST(HAVE_LIBCHARSET_H)
839 +# Define CHARSET_LIB if libiconv does not export the locale_charset symbol
840 +# and libcharset does
841 +CHARSET_LIB=
842 +AC_CHECK_LIB([iconv], [locale_charset],
843 + [],
844 + [AC_CHECK_LIB([charset], [locale_charset],
845 + [CHARSET_LIB=-lcharset])
846 + ]
847 +)
848 +AC_SUBST(CHARSET_LIB)
849 #
850 # Define NO_STRCASESTR if you don't have strcasestr.
851 GIT_CHECK_FUNC(strcasestr,