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

View File

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

View File

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

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 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([mc_GMODULE_SUPPORTED], [
g_module_supported="" g_module_supported=""
found_gmodule=no if test x$with_glib_static = xyes; then
PKG_CHECK_MODULES(GMODULE, [gmodule-no-export-2.0 >= 2.12], [found_gmodule=yes], [:]) AC_MSG_WARN([Static build is enabled... Cannot use GModule])
if test x"$found_gmodule" = xyes; then
g_module_supported="gmodule-no-export-2.0"
else else
dnl try fallback to the generic gmodule found_gmodule=no
PKG_CHECK_MODULES(GMODULE, [gmodule-2.0 >= 2.12], [found_gmodule=yes], [:]) PKG_CHECK_MODULES(GMODULE, [gmodule-no-export-2.0 >= 2.12], [found_gmodule=yes], [:])
if test x"$found_gmodule" = xyes; then 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
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]) AM_CONDITIONAL([HAVE_GMODULE], [test x"$g_module_supported" != x])
])
AC_DEFUN([mc_CHECK_STATIC_GLIB], [
dnl dnl
dnl Try to find static libraries for glib and gmodule. dnl Try to find static libraries for glib and gmodule.
dnl 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 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= new_GLIB_LIBS=
for i in $GLIB_LIBS; do for i in $GLIB_LIBS; do
case x$i in case x$i in
x-lglib*) x-lglib*)
lib=glib ;; lib=glib ;;
x-lgmodule*)
lib=gmodule ;;
*) *)
lib= lib=
add="$i" ;; add="$i" ;;
@ -66,7 +90,6 @@ AC_DEFUN([AC_G_MODULE_SUPPORTED], [
done done
GLIB_LIBS="$new_GLIB_LIBS" GLIB_LIBS="$new_GLIB_LIBS"
fi fi
]) ])
AC_DEFUN([AC_CHECK_GLIB], [ 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 without any glib won't have their time wasted by other checks.
dnl dnl
AC_ARG_WITH([glib_static],
AS_HELP_STRING([--with-glib-static], [Link glib statically @<:@no@:>@]))
glib_found=no glib_found=no
PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.12], [glib_found=yes], [:]) PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.12], [glib_found=yes], [:])
if test x"$glib_found" = xno; then if test x"$glib_found" = xno; then
AC_MSG_ERROR([glib-2.0 not found or version too old (must be >= 2.12)]) AC_MSG_ERROR([glib-2.0 not found or version too old (must be >= 2.12)])
fi fi
mc_CHECK_STATIC_GLIB
mc_GMODULE_SUPPORTED
]) ])

View File

@ -45,7 +45,9 @@ libinternal_la_LIBADD = \
mc_LDADD = \ mc_LDADD = \
libinternal.la \ libinternal.la \
$(top_builddir)/lib/libmc.la $(top_builddir)/lib/libmc.la \
$(GLIB_LIBS) \
$(PCRE_LIBS)
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

View File

@ -4,7 +4,9 @@ AM_CPPFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir) @CHECK_CFLAGS@
AM_LDFLAGS = @TESTS_LDFLAGS@ 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 EXTRA_DIST = utilunix__my_system-common.c

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -12,9 +12,10 @@ AM_CPPFLAGS = \
AM_LDFLAGS = @TESTS_LDFLAGS@ AM_LDFLAGS = @TESTS_LDFLAGS@
LIBS=@CHECK_LIBS@ \ LIBS = @CHECK_LIBS@ \
$(top_builddir)/src/libinternal.la \ $(top_builddir)/src/libinternal.la \
$(top_builddir)/lib/libmc.la $(top_builddir)/lib/libmc.la \
$(GLIB_LIBS)
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

View File

@ -6,9 +6,10 @@ AM_CPPFLAGS = \
AM_LDFLAGS = @TESTS_LDFLAGS@ AM_LDFLAGS = @TESTS_LDFLAGS@
LIBS=@CHECK_LIBS@ \ LIBS = @CHECK_LIBS@ \
$(top_builddir)/src/libinternal.la \ $(top_builddir)/src/libinternal.la \
$(top_builddir)/lib/libmc.la $(top_builddir)/lib/libmc.la \
$(GLIB_LIBS)
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

View File

@ -7,9 +7,10 @@ AM_CPPFLAGS = \
AM_LDFLAGS = @TESTS_LDFLAGS@ AM_LDFLAGS = @TESTS_LDFLAGS@
LIBS=@CHECK_LIBS@ \ LIBS = @CHECK_LIBS@ \
$(top_builddir)/src/libinternal.la \ $(top_builddir)/src/libinternal.la \
$(top_builddir)/lib/libmc.la $(top_builddir)/lib/libmc.la \
$(GLIB_LIBS)
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