Skip to content

Commit

Permalink
Makefile: introduce CHARSET_LIB to link with -lcharset
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Дилян Палаузов authored and gitster committed Feb 13, 2012
1 parent 828ea97 commit b522528
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ all::
# FreeBSD can use either, but MinGW and some others need to use
# libcharset.h's locale_charset() instead.
#
# Define CHARSET_LIB to you need to link with library other than -liconv to
# use locale_charset() function. On some platforms this needs to set to
# -lcharset
#
# Define LIBC_CONTAINS_LIBINTL if your gettext implementation doesn't
# need -lintl when linking.
#
Expand Down Expand Up @@ -1692,6 +1696,7 @@ endif

ifdef HAVE_LIBCHARSET_H
BASIC_CFLAGS += -DHAVE_LIBCHARSET_H
EXTLIBS += $(CHARSET_LIB)
endif

ifdef HAVE_DEV_TTY
Expand Down
1 change: 1 addition & 0 deletions config.mak.in
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,4 @@ SNPRINTF_RETURNS_BOGUS=@SNPRINTF_RETURNS_BOGUS@
NO_PTHREADS=@NO_PTHREADS@
PTHREAD_CFLAGS=@PTHREAD_CFLAGS@
PTHREAD_LIBS=@PTHREAD_LIBS@
CHARSET_LIB=@CHARSET_LIB@
10 changes: 10 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,16 @@ AC_CHECK_HEADER([libcharset.h],
[HAVE_LIBCHARSET_H=YesPlease],
[HAVE_LIBCHARSET_H=])
AC_SUBST(HAVE_LIBCHARSET_H)
# Define CHARSET_LIB if libiconv does not export the locale_charset symbol
# and libcharset does
CHARSET_LIB=
AC_CHECK_LIB([iconv], [locale_charset],
[],
[AC_CHECK_LIB([charset], [locale_charset],
[CHARSET_LIB=-lcharset])
]
)
AC_SUBST(CHARSET_LIB)
#
# Define NO_STRCASESTR if you don't have strcasestr.
GIT_CHECK_FUNC(strcasestr,
Expand Down

0 comments on commit b522528

Please sign in to comment.