Ticket #2129: fix build with static GLib.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
Andrew Borodin 2013-07-09 10:41:35 +04:00
parent 86fc45dd40
commit 9645d3f256
14 changed files with 88 additions and 61 deletions

View File

@ -145,7 +145,6 @@ dnl Check for main libraies
dnl ############################################################################
AC_CHECK_GLIB
AC_G_MODULE_SUPPORTED
MC_WITH_SCREEN
MC_CHECK_SEARCH_TYPE
dnl X11 support. Used to read keyboard modifiers when running under X11.
@ -314,7 +313,7 @@ linux*)
[AC_DEFINE(HAVE_LIBGPM, 1,
[Define to enable gpm mouse support on Linux])
mouse_lib="gpm and xterm"
MCLIBS="$MCLIBS -lgpm"],
MCLIBS="$MCLIBS -lgpm -ltinfo"],
if test "x$with_gpm_mouse" = "xyes"; then
[AC_MSG_ERROR([libgpm is missing or older than 0.18])]
else

View File

@ -63,12 +63,10 @@ libmc_la_LIBADD = \
vfs/libmcvfs.la \
widget/libmcwidget.la
libmc_la_LIBADD += $(MCLIBS) $(SLANGLIB)
if HAVE_GMODULE
libmc_la_LIBADD += $(GMODULE_LIBS)
else
libmc_la_LIBADD += $(GLIB_LIBS)
endif
libmc_la_LIBADD += $(PCRE_LIBS) $(LIBICONV) $(INTLLIBS)
libmc_la_LIBADD += \
$(MCLIBS) \
$(SLANGLIB) \
$(GLIB_LIBS) \
$(PCRE_LIBS) \
$(LIBICONV) \
$(INTLLIBS)

View File

@ -25,11 +25,4 @@ endif
libmctty_la_SOURCES = $(TTY_SRC) $(TTY_SCREEN_SRC)
AM_CPPFLAGS = -I$(top_srcdir)
if HAVE_GMODULE
AM_CPPFLAGS += $(GMODULE_CFLAGS)
else
AM_CPPFLAGS += $(GLIB_CFLAGS)
endif
AM_CPPFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS)

View File

@ -3,48 +3,72 @@ dnl Check whether the g_module_* family of functions works
dnl on this system. We need to know that at the compile time to
dnl decide whether to link with X11.
dnl
AC_DEFUN([AC_G_MODULE_SUPPORTED], [
AC_DEFUN([mc_GMODULE_SUPPORTED], [
g_module_supported=""
found_gmodule=no
PKG_CHECK_MODULES(GMODULE, [gmodule-no-export-2.0 >= 2.12], [found_gmodule=yes], [:])
if test x"$found_gmodule" = xyes; then
g_module_supported="gmodule-no-export-2.0"
if test x$with_glib_static = xyes; then
AC_MSG_WARN([Static build is enabled... Cannot use GModule])
else
dnl try fallback to the generic gmodule
PKG_CHECK_MODULES(GMODULE, [gmodule-2.0 >= 2.12], [found_gmodule=yes], [:])
found_gmodule=no
PKG_CHECK_MODULES(GMODULE, [gmodule-no-export-2.0 >= 2.12], [found_gmodule=yes], [:])
if test x"$found_gmodule" = xyes; then
g_module_supported="gmodule-2.0"
g_module_supported="gmodule-no-export-2.0"
else
dnl try fallback to the generic gmodule
PKG_CHECK_MODULES(GMODULE, [gmodule-2.0 >= 2.12], [found_gmodule=yes], [:])
if test x"$found_gmodule" = xyes; then
g_module_supported="gmodule-2.0"
fi
fi
case x"$g_module_supported" in
xgmodule-no-export-2.0|xgmodule-2.0)
if test x`$PKG_CONFIG --variable=gmodule_supported "$g_module_supported"` = xtrue; then
AC_DEFINE([HAVE_GMODULE], [1], [Defined if gmodule functionality is supported])
else
g_module_supported=""
fi
;;
*)
g_module_supported=""
;;
esac
if test x"$g_module_supported" != x; then
GLIB_LIBS="$GMODULE_LIBS"
GLIB_CFLAGS="$GMODULE_CFLAGS"
fi
fi
case x"$g_module_supported" in
xgmodule-no-export-2.0|xgmodule-2.0)
if test x`$PKG_CONFIG --variable=gmodule_supported "$g_module_supported"` = xtrue; then
AC_DEFINE([HAVE_GMODULE], [1], [Defined if gmodule functionality is supported])
else
g_module_supported=""
fi
;;
*)
g_module_supported=""
;;
esac
AM_CONDITIONAL([HAVE_GMODULE], [test x"$g_module_supported" != x])
])
AC_DEFUN([mc_CHECK_STATIC_GLIB], [
dnl
dnl Try to find static libraries for glib and gmodule.
dnl
AC_ARG_WITH([glib_static],
AS_HELP_STRING([--with-glib-static], [Link glib statically @<:@no@:>@]),
[
if test x$withval = xno; then
with_glib_static=no
else
with_glib_static=yes
fi
],
[with_glib_static=no])
if test x$with_glib_static = xyes; then
dnl Redefine GLIB_LIBS using --static option to define linker flags for static linking
GLIB_LIBS=`pkg-config --libs --static glib-2.0`
GLIB_LIBDIR=`pkg-config --variable=libdir glib-2.0`
new_GLIB_LIBS=
for i in $GLIB_LIBS; do
case x$i in
x-lglib*)
lib=glib ;;
x-lgmodule*)
lib=gmodule ;;
*)
lib=
add="$i" ;;
@ -66,7 +90,6 @@ AC_DEFUN([AC_G_MODULE_SUPPORTED], [
done
GLIB_LIBS="$new_GLIB_LIBS"
fi
])
AC_DEFUN([AC_CHECK_GLIB], [
@ -76,14 +99,13 @@ AC_DEFUN([AC_CHECK_GLIB], [
dnl without any glib won't have their time wasted by other checks.
dnl
AC_ARG_WITH([glib_static],
AS_HELP_STRING([--with-glib-static], [Link glib statically @<:@no@:>@]))
glib_found=no
PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.12], [glib_found=yes], [:])
if test x"$glib_found" = xno; then
AC_MSG_ERROR([glib-2.0 not found or version too old (must be >= 2.12)])
fi
mc_CHECK_STATIC_GLIB
mc_GMODULE_SUPPORTED
])

View File

@ -45,7 +45,9 @@ libinternal_la_LIBADD = \
mc_LDADD = \
libinternal.la \
$(top_builddir)/lib/libmc.la
$(top_builddir)/lib/libmc.la \
$(GLIB_LIBS) \
$(PCRE_LIBS)
if ENABLE_VFS_SMB
# this is a hack for linking with own samba library in simple way

View File

@ -4,7 +4,9 @@ AM_CPPFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir) @CHECK_CFLAGS@
AM_LDFLAGS = @TESTS_LDFLAGS@
LIBS = @CHECK_LIBS@ $(top_builddir)/lib/libmc.la
LIBS = @CHECK_LIBS@ \
$(top_builddir)/lib/libmc.la \
$(GLIB_LIBS)
EXTRA_DIST = utilunix__my_system-common.c

View File

@ -7,7 +7,9 @@ AM_CPPFLAGS = \
AM_LDFLAGS = @TESTS_LDFLAGS@
LIBS=@CHECK_LIBS@ $(top_builddir)/lib/libmc.la
LIBS = @CHECK_LIBS@ \
$(top_builddir)/lib/libmc.la \
$(GLIB_LIBS)
TESTS = \
config_string \

View File

@ -5,7 +5,9 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/lib/search \
@CHECK_CFLAGS@
LIBS = @CHECK_LIBS@ $(top_builddir)/lib/libmc.la
LIBS = @CHECK_LIBS@ \
$(top_builddir)/lib/libmc.la \
$(GLIB_LIBS)
TESTS = \
regex_replace_esc_seq \

View File

@ -5,7 +5,9 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/lib/search \
@CHECK_CFLAGS@
LIBS = @CHECK_LIBS@ $(top_builddir)/lib/libmc.la
LIBS = @CHECK_LIBS@ \
$(top_builddir)/lib/libmc.la \
$(GLIB_LIBS)
TESTS = \
replace__str_replace_all \

View File

@ -10,8 +10,9 @@ AM_LDFLAGS = @TESTS_LDFLAGS@
EXTRA_DIST = mc.charsets
LIBS=@CHECK_LIBS@ \
$(top_builddir)/lib/libmc.la
LIBS = @CHECK_LIBS@ \
$(top_builddir)/lib/libmc.la \
$(GLIB_LIBS)
TESTS = \
canonicalize_pathname \

View File

@ -7,8 +7,9 @@ AM_CPPFLAGS = \
AM_LDFLAGS = @TESTS_LDFLAGS@
LIBS=@CHECK_LIBS@ \
$(top_builddir)/lib/libmc.la
LIBS = @CHECK_LIBS@ \
$(top_builddir)/lib/libmc.la \
$(GLIB_LIBS)
TESTS = \
complete_engine

View File

@ -12,9 +12,10 @@ AM_CPPFLAGS = \
AM_LDFLAGS = @TESTS_LDFLAGS@
LIBS=@CHECK_LIBS@ \
LIBS = @CHECK_LIBS@ \
$(top_builddir)/src/libinternal.la \
$(top_builddir)/lib/libmc.la
$(top_builddir)/lib/libmc.la \
$(GLIB_LIBS)
if ENABLE_VFS_SMB
# this is a hack for linking with own samba library in simple way

View File

@ -6,9 +6,10 @@ AM_CPPFLAGS = \
AM_LDFLAGS = @TESTS_LDFLAGS@
LIBS=@CHECK_LIBS@ \
LIBS = @CHECK_LIBS@ \
$(top_builddir)/src/libinternal.la \
$(top_builddir)/lib/libmc.la
$(top_builddir)/lib/libmc.la \
$(GLIB_LIBS)
if ENABLE_VFS_SMB
# this is a hack for linking with own samba library in simple way

View File

@ -7,9 +7,10 @@ AM_CPPFLAGS = \
AM_LDFLAGS = @TESTS_LDFLAGS@
LIBS=@CHECK_LIBS@ \
LIBS = @CHECK_LIBS@ \
$(top_builddir)/src/libinternal.la \
$(top_builddir)/lib/libmc.la
$(top_builddir)/lib/libmc.la \
$(GLIB_LIBS)
if ENABLE_VFS_SMB
# this is a hack for linking with own samba library in simple way