Ticket #2409: fix of GModule detection and usage.

Don't mix GLib and GModule compiler and linker options.

Use gmodule-no-export if present to avoid use -Wl,--export-dynamic
option with some linkers. If gmodule-no-export is not available,
use generic gmodule.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2010-11-30 22:13:16 +03:00
parent 4c356e3dd3
commit 62c05d62f3
4 changed files with 60 additions and 49 deletions

View File

@ -59,13 +59,6 @@ if test x"$glib_found" = xno; then
AC_MSG_ERROR([glib-2.0 not found or version too old (must be >= 2.8)]) AC_MSG_ERROR([glib-2.0 not found or version too old (must be >= 2.8)])
fi fi
PKG_CHECK_MODULES(GMODULE, [gmodule-2.0], [gmodule_found=yes])
GLIB_LIBDIR="`$PKG_CONFIG --variable=libdir glib-2.0`"
if test "x$gmodule_found" = "xyes" ; then
dnl Check if the gmodule functionality supported on this system.
AC_G_MODULE_SUPPORTED
fi
AC_HEADER_MAJOR AC_HEADER_MAJOR
AC_C_CONST AC_C_CONST
@ -225,27 +218,10 @@ AC_FUNC_STRCOLL
dnl dnl
dnl X11 support. dnl X11 support.
dnl Used to read keyboard modifiers when running under X11. dnl Used to read keyboard modifiers when running under X11.
dnl
AC_PATH_XTRA AC_PATH_XTRA
if test "x$no_x" = xyes; then dnl
textmode_x11_support="no" dnl Check if the gmodule functionality supported on this system.
else AC_G_MODULE_SUPPORTED
CPPFLAGS="$CPPFLAGS $X_CFLAGS"
if test "x$mc_cv_g_module_supported" = "xyes" ; then
dnl Replace the contents of GLIB_CFLAGS and GLIB_LIBS with those of
dnl GMODULE_CFLAGS and GMODULE_LIBS, only if X is available and gmodule
dnl functionality is supported on the system. This way, mc will be
dnl linked against the gmodule library only when it's really required.
GLIB_CFLAGS="$GMODULE_CFLAGS"
GLIB_LIBS="$GMODULE_LIBS"
else
MCLIBS="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
fi
AC_DEFINE(HAVE_TEXTMODE_X11_SUPPORT, 1,
[Define to enable getting events from X Window System])
textmode_x11_support="yes"
fi
dnl dnl
dnl Try to find static libraries for glib and gmodule. dnl Try to find static libraries for glib and gmodule.

View File

@ -22,6 +22,13 @@ TTY_SRC = \
libmctty_la_SOURCES = $(TTY_SRC) $(TTY_SCREEN_SRC) libmctty_la_SOURCES = $(TTY_SRC) $(TTY_SCREEN_SRC)
libmctty_la_CFLAGS = -I$(top_srcdir) \ libmctty_la_CFLAGS = -I$(top_srcdir)
$(GLIB_CFLAGS) \
-DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" if HAVE_GMODULE
libmctty_la_CFLAGS += $(GMODULE_CFLAGS)
else
libmctty_la_CFLAGS += $(GLIB_CFLAGS)
endif
libmctty_la_CFLAGS += -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\"

View File

@ -4,22 +4,42 @@ dnl on this system. We need to know that at the compile time to
dnl decide whether to link with X11. dnl decide whether to link with X11.
dnl dnl
AC_DEFUN([AC_G_MODULE_SUPPORTED], [ AC_DEFUN([AC_G_MODULE_SUPPORTED], [
AC_CACHE_CHECK([if gmodule functionality is supported],
[mc_cv_g_module_supported],
[
mc_cv_g_module_supported=no;
PKG_CHECK_MODULES(GMODULE, [gmodule-2.0 >= 2.8], [found_gmodule=yes], [:])
if test x"$found_gmodule" = "xyes"; then
mc_cv_g_module_supported=yes
fi
])
if test x"$mc_cv_g_module_supported" = "xyes"; then g_module_supported=""
if test x`$PKG_CONFIG --variable=gmodule_supported gmodule-2.0` = xtrue; then if test x"$no_x" = xyes; then
GLIB_LIBS="$GMODULE_LIBS $GLIB_LIBS" textmode_x11_support="no"
CFLAGS="$GMODULE_CFLAGS $CFLAGS" else
AC_DEFINE([HAVE_GMODULE], [1], found_gmodule=no
[Defined if gmodule functionality is supported]) PKG_CHECK_MODULES(GMODULE, [gmodule-no-export-2.0 >= 2.8], [found_gmodule=yes], [:])
if test x"$found_gmodule" = xyes; then
g_module_supported="gmodule-no-export-2.0"
else
dnl try fallback to the generic gmodule
PKG_CHECK_MODULES(GMODULE, [gmodule-2.0 >= 2.8], [found_gmodule=yes], [:])
if test x"$found_gmodule" = xyes; then
g_module_supported="gmodule-2.0"
fi fi
fi fi
CPPFLAGS="$CPPFLAGS $X_CFLAGS"
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
;;
*)
MCLIBS="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
g_module_supported=""
;;
esac
AC_DEFINE([HAVE_TEXTMODE_X11_SUPPORT], [1],
[Define to enable getting events from X Window System])
textmode_x11_support="yes"
fi
AM_CONDITIONAL([HAVE_GMODULE], [test x"$g_module_supported" != x])
]) ])

View File

@ -37,15 +37,23 @@ mc_LDADD = \
viewer/libmcviewer.la \ viewer/libmcviewer.la \
filemanager/libmcfilemanager.la \ filemanager/libmcfilemanager.la \
$(DIFFLIB) $(EDITLIB) \ $(DIFFLIB) $(EDITLIB) \
../lib/libmc.la \ ../lib/libmc.la
$(MCLIBS) $(SLANGLIB) $(GLIB_LIBS) \
$(PCRE_LIBS) $(LIBICONV) $(INTLLIBS)
if ENABLE_VFS_SMB if ENABLE_VFS_SMB
# this is a hack for linking with own samba library in simple way # this is a hack for linking with own samba library in simple way
mc_LDADD += ../lib/vfs/mc-vfs/samba/libsamba.a mc_LDADD += ../lib/vfs/mc-vfs/samba/libsamba.a
endif endif
mc_LDADD += $(MCLIBS) $(SLANGLIB)
if HAVE_GMODULE
mc_LDADD += $(GMODULE_LIBS)
else
mc_LDADD += $(GLIB_LIBS)
endif
mc_LDADD += $(PCRE_LIBS) $(LIBICONV) $(INTLLIBS)
SRC_mc_conssaver = \ SRC_mc_conssaver = \
cons.handler.c consaver/cons.saver.h cons.handler.c consaver/cons.saver.h