From 9645d3f256bf6d3b3cc8b78366b7e1b361df605a Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Tue, 9 Jul 2013 10:41:35 +0400 Subject: [PATCH] Ticket #2129: fix build with static GLib. Signed-off-by: Andrew Borodin Signed-off-by: Slava Zanko --- configure.ac | 3 +- lib/Makefile.am | 16 ++++----- lib/tty/Makefile.am | 9 +---- m4.include/ac-glib.m4 | 74 +++++++++++++++++++++++++-------------- src/Makefile.am | 4 ++- tests/lib/Makefile.am | 4 ++- tests/lib/mcconfig/Makefile.am | 4 ++- tests/lib/search/Makefile.am | 4 ++- tests/lib/strutil/Makefile.am | 4 ++- tests/lib/vfs/Makefile.am | 5 +-- tests/lib/widget/Makefile.am | 5 +-- tests/src/Makefile.am | 5 +-- tests/src/editor/Makefile.am | 5 +-- tests/src/filemanager/Makefile.am | 5 +-- 14 files changed, 87 insertions(+), 60 deletions(-) diff --git a/configure.ac b/configure.ac index c12c2e779..6c363111b 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/lib/Makefile.am b/lib/Makefile.am index 18bf8362b..d43198b90 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -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) diff --git a/lib/tty/Makefile.am b/lib/tty/Makefile.am index 30ba3051e..e172860e0 100644 --- a/lib/tty/Makefile.am +++ b/lib/tty/Makefile.am @@ -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) diff --git a/m4.include/ac-glib.m4 b/m4.include/ac-glib.m4 index 9d35d1c29..ff907fef3 100644 --- a/m4.include/ac-glib.m4 +++ b/m4.include/ac-glib.m4 @@ -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 - 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 + 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="" - fi - ;; - *) - g_module_supported="" - ;; - esac + ;; + esac + + if test x"$g_module_supported" != x; then + GLIB_LIBS="$GMODULE_LIBS" + GLIB_CFLAGS="$GMODULE_CFLAGS" + fi + fi 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 ]) diff --git a/src/Makefile.am b/src/Makefile.am index 13edbab0d..951272609 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 diff --git a/tests/lib/Makefile.am b/tests/lib/Makefile.am index f1ca1443e..a5735a71d 100644 --- a/tests/lib/Makefile.am +++ b/tests/lib/Makefile.am @@ -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 diff --git a/tests/lib/mcconfig/Makefile.am b/tests/lib/mcconfig/Makefile.am index 522902e91..8f0c43764 100644 --- a/tests/lib/mcconfig/Makefile.am +++ b/tests/lib/mcconfig/Makefile.am @@ -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 \ diff --git a/tests/lib/search/Makefile.am b/tests/lib/search/Makefile.am index aa428fabf..897e7ac2a 100644 --- a/tests/lib/search/Makefile.am +++ b/tests/lib/search/Makefile.am @@ -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 \ diff --git a/tests/lib/strutil/Makefile.am b/tests/lib/strutil/Makefile.am index 609dba0f6..c42f54082 100644 --- a/tests/lib/strutil/Makefile.am +++ b/tests/lib/strutil/Makefile.am @@ -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 \ diff --git a/tests/lib/vfs/Makefile.am b/tests/lib/vfs/Makefile.am index 58146f127..b3f8abf10 100644 --- a/tests/lib/vfs/Makefile.am +++ b/tests/lib/vfs/Makefile.am @@ -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 \ diff --git a/tests/lib/widget/Makefile.am b/tests/lib/widget/Makefile.am index 37a91efab..45e84aadb 100644 --- a/tests/lib/widget/Makefile.am +++ b/tests/lib/widget/Makefile.am @@ -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 diff --git a/tests/src/Makefile.am b/tests/src/Makefile.am index 0d31c3b85..fbb8c6831 100644 --- a/tests/src/Makefile.am +++ b/tests/src/Makefile.am @@ -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 diff --git a/tests/src/editor/Makefile.am b/tests/src/editor/Makefile.am index c0ee705c2..44a1a205f 100644 --- a/tests/src/editor/Makefile.am +++ b/tests/src/editor/Makefile.am @@ -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 diff --git a/tests/src/filemanager/Makefile.am b/tests/src/filemanager/Makefile.am index 0629d39bd..78664d692 100644 --- a/tests/src/filemanager/Makefile.am +++ b/tests/src/filemanager/Makefile.am @@ -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 -- 2.11.4.GIT