diff --git a/ChangeLog b/ChangeLog index 27150665a..74251dfb0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2003-02-22 Pavel Tsekov + + * acinclude.m4 [AC_G_MODULE_SUPPORTED]: New macro. + * configure.in: Test for gmodule. Don't link mc with libX11 if + gmodule is supported. + 2003-02-22 Pavel Roskin * configure.in: Add --with-glib12 option to confugure to force diff --git a/acinclude.m4 b/acinclude.m4 index 3c6a19f4c..886206156 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -858,3 +858,36 @@ AC_DEFUN([AC_EXT2_UNDEL], [ dnl The next line is for compatibility with gettext 0.10.x AC_DEFUN([AM_GNU_GETTEXT_VERSION], []) +dnl +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_CACHE_CHECK([if gmodule functionality is supported], mc_cv_g_module_supported, [ + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $GMODULE_CFLAGS" + LIBS="$GMODULE_LIBS $LIBS" + AC_TRY_RUN([ +#include + +int main () +{ + int ret = (g_module_supported () == TRUE) ? 0 : 1; + return ret; +} + ], + [mc_cv_g_module_supported=yes], + [mc_cv_g_module_supported=no], + [mc_cv_g_module_supported=no] + ) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + ]) + +if test "$mc_cv_g_module_supported" = yes; then + AC_DEFINE(HAVE_GMODULE, 1, + [Define if gmodule functionality is supported]) +fi +]) diff --git a/configure.in b/configure.in index 8b8d2e2fd..e36123932 100644 --- a/configure.in +++ b/configure.in @@ -44,8 +44,26 @@ if test "x$glib_found" != "xyes" ; then AC_ARG_VAR([GLIB_CONFIG], [Path to glib-config (version 1.2.x only)]) AM_PATH_GLIB(1.2.6, , [AC_MSG_ERROR([Test for glib failed. GNU Midnight Commander requires glib 1.2.6 or above.])]) + dnl Save GLIB_CFLAGS and GLIB_LIBS, since the following call to + dnl AM_PATH_GLIB will overwrite them. + save_GLIB_CFLAGS="$GLIB_CFLAGS" + save_GLIB_LIBS="$GLIB_LIBS" + dnl Check for gmodule. Store the flags necessary to compile and + dnl link programs using gmodule functionality in GMODULE_CFLAGS + dnl and GMODULE_LIBS. + AM_PATH_GLIB(1.2.6, [gmodule_found=yes], , [gmodule]) + GMODULE_CFLAGS="$GLIB_CFLAGS" + GMODULE_LIBS="$GLIB_LIBS" + GLIB_CFLAGS="$save_GLIB_CFLAGS" + GLIB_LIBS="$save_GLIB_LIBS" +else + PKG_CHECK_MODULES(GMODULE, [gmodule-2.0], [gmodule_found=yes]) fi +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_C_CONST @@ -221,7 +239,16 @@ if test "x$no_x" = xyes; then textmode_x11_support="no" else CPPFLAGS="$CPPFLAGS $X_CFLAGS" - MCLIBS="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS" + 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"