tglib-2.0.m4 - vaccinewars - be a doctor and try to vaccinate the world
 (HTM) git clone git://src.adamsgaard.dk/vaccinewars
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
       tglib-2.0.m4 (8316B)
       ---
            1 # Configure paths for GLIB
            2 # Owen Taylor     1997-2001
            3 
            4 # Increment this whenever this file is changed.
            5 #serial 3
            6 
            7 dnl AM_PATH_GLIB_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
            8 dnl Test for GLIB, and define GLIB_CFLAGS and GLIB_LIBS, if gmodule, gobject,
            9 dnl gthread, or gio is specified in MODULES, pass to pkg-config
           10 dnl
           11 AC_DEFUN([AM_PATH_GLIB_2_0],
           12 [dnl 
           13 dnl Get the cflags and libraries from pkg-config
           14 dnl
           15 
           16 dnl We can't use PKG_PREREQ because that needs 0.29.
           17 m4_ifndef([PKG_PROG_PKG_CONFIG],
           18           [pkg.m4 version 0.28 or later is required])
           19 
           20 AC_ARG_ENABLE(glibtest, [  --disable-glibtest      do not try to compile and run a test GLIB program],
           21                     , enable_glibtest=yes)
           22 
           23   min_glib_version=ifelse([$1], [], [2.0.0], [$1])
           24   pkg_config_args="glib-2.0 >= $min_glib_version"
           25   for module in . $4
           26   do
           27       case "$module" in
           28          gmodule) 
           29              pkg_config_args="$pkg_config_args gmodule-2.0"
           30          ;;
           31          gmodule-no-export) 
           32              pkg_config_args="$pkg_config_args gmodule-no-export-2.0"
           33          ;;
           34          gobject) 
           35              pkg_config_args="$pkg_config_args gobject-2.0"
           36          ;;
           37          gthread) 
           38              pkg_config_args="$pkg_config_args gthread-2.0"
           39          ;;
           40          gio*) 
           41              pkg_config_args="$pkg_config_args $module-2.0"
           42          ;;
           43       esac
           44   done
           45 
           46   PKG_PROG_PKG_CONFIG([0.16])
           47 
           48   no_glib=""
           49 
           50   if test "x$PKG_CONFIG" = x ; then
           51     no_glib=yes
           52     PKG_CONFIG=no
           53   fi
           54 
           55   dnl For GLIB_CFLAGS and GLIB_LIBS
           56   PKG_CHECK_MODULES([GLIB], [$pkg_config_args], [:], [:])
           57 
           58   dnl For the tools
           59   PKG_CHECK_VAR([GLIB_GENMARSHAL], [glib-2.0], [glib_genmarshal])
           60   PKG_CHECK_VAR([GOBJECT_QUERY], [glib-2.0], [gobject_query])
           61   PKG_CHECK_VAR([GLIB_MKENUMS], [glib-2.0], [glib_mkenums])
           62   PKG_CHECK_VAR([GLIB_COMPILE_RESOURCES], [gio-2.0], [glib_compile_resources])
           63 
           64   AC_MSG_CHECKING(for GLIB - version >= $min_glib_version)
           65 
           66   if test x$PKG_CONFIG != xno ; then
           67     ## don't try to run the test against uninstalled libtool libs
           68     if $PKG_CONFIG --uninstalled $pkg_config_args; then
           69           echo "Will use uninstalled version of GLib found in PKG_CONFIG_PATH"
           70           enable_glibtest=no
           71     fi
           72 
           73     if $PKG_CONFIG --atleast-version $min_glib_version $pkg_config_args; then
           74           :
           75     else
           76           no_glib=yes
           77     fi
           78   fi
           79 
           80   if test x"$no_glib" = x ; then
           81     glib_config_major_version=`$PKG_CONFIG --modversion glib-2.0 | \
           82            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
           83     glib_config_minor_version=`$PKG_CONFIG --modversion glib-2.0 | \
           84            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
           85     glib_config_micro_version=`$PKG_CONFIG --modversion glib-2.0 | \
           86            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
           87     if test "x$enable_glibtest" = "xyes" ; then
           88       ac_save_CFLAGS="$CFLAGS"
           89       ac_save_LIBS="$LIBS"
           90       CFLAGS="$CFLAGS $GLIB_CFLAGS"
           91       LIBS="$GLIB_LIBS $LIBS"
           92 dnl
           93 dnl Now check if the installed GLIB is sufficiently new. (Also sanity
           94 dnl checks the results of pkg-config to some extent)
           95 dnl
           96       rm -f conf.glibtest
           97       AC_TRY_RUN([
           98 #include <glib.h>
           99 #include <stdio.h>
          100 #include <stdlib.h>
          101 
          102 int 
          103 main (void)
          104 {
          105   unsigned int major, minor, micro;
          106 
          107   fclose (fopen ("conf.glibtest", "w"));
          108 
          109   if (sscanf("$min_glib_version", "%u.%u.%u", &major, &minor, &micro) != 3) {
          110      printf("%s, bad version string\n", "$min_glib_version");
          111      exit(1);
          112    }
          113 
          114   if ((glib_major_version != $glib_config_major_version) ||
          115       (glib_minor_version != $glib_config_minor_version) ||
          116       (glib_micro_version != $glib_config_micro_version))
          117     {
          118       printf("\n*** 'pkg-config --modversion glib-2.0' returned %d.%d.%d, but GLIB (%d.%d.%d)\n", 
          119              $glib_config_major_version, $glib_config_minor_version, $glib_config_micro_version,
          120              glib_major_version, glib_minor_version, glib_micro_version);
          121       printf ("*** was found! If pkg-config was correct, then it is best\n");
          122       printf ("*** to remove the old version of GLib. You may also be able to fix the error\n");
          123       printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
          124       printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
          125       printf("*** required on your system.\n");
          126       printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
          127       printf("*** to point to the correct configuration files\n");
          128     } 
          129   else if ((glib_major_version != GLIB_MAJOR_VERSION) ||
          130            (glib_minor_version != GLIB_MINOR_VERSION) ||
          131            (glib_micro_version != GLIB_MICRO_VERSION))
          132     {
          133       printf("*** GLIB header files (version %d.%d.%d) do not match\n",
          134              GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION);
          135       printf("*** library (version %d.%d.%d)\n",
          136              glib_major_version, glib_minor_version, glib_micro_version);
          137     }
          138   else
          139     {
          140       if ((glib_major_version > major) ||
          141         ((glib_major_version == major) && (glib_minor_version > minor)) ||
          142         ((glib_major_version == major) && (glib_minor_version == minor) && (glib_micro_version >= micro)))
          143       {
          144         return 0;
          145        }
          146      else
          147       {
          148         printf("\n*** An old version of GLIB (%u.%u.%u) was found.\n",
          149                glib_major_version, glib_minor_version, glib_micro_version);
          150         printf("*** You need a version of GLIB newer than %u.%u.%u. The latest version of\n",
          151                major, minor, micro);
          152         printf("*** GLIB is always available from ftp://ftp.gtk.org.\n");
          153         printf("***\n");
          154         printf("*** If you have already installed a sufficiently new version, this error\n");
          155         printf("*** probably means that the wrong copy of the pkg-config shell script is\n");
          156         printf("*** being found. The easiest way to fix this is to remove the old version\n");
          157         printf("*** of GLIB, but you can also set the PKG_CONFIG environment to point to the\n");
          158         printf("*** correct copy of pkg-config. (In this case, you will have to\n");
          159         printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
          160         printf("*** so that the correct libraries are found at run-time))\n");
          161       }
          162     }
          163   return 1;
          164 }
          165 ],, no_glib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
          166        CFLAGS="$ac_save_CFLAGS"
          167        LIBS="$ac_save_LIBS"
          168      fi
          169   fi
          170   if test "x$no_glib" = x ; then
          171      AC_MSG_RESULT(yes (version $glib_config_major_version.$glib_config_minor_version.$glib_config_micro_version))
          172      ifelse([$2], , :, [$2])     
          173   else
          174      AC_MSG_RESULT(no)
          175      if test "$PKG_CONFIG" = "no" ; then
          176        echo "*** A new enough version of pkg-config was not found."
          177        echo "*** See http://www.freedesktop.org/software/pkgconfig/"
          178      else
          179        if test -f conf.glibtest ; then
          180         :
          181        else
          182           echo "*** Could not run GLIB test program, checking why..."
          183           ac_save_CFLAGS="$CFLAGS"
          184           ac_save_LIBS="$LIBS"
          185           CFLAGS="$CFLAGS $GLIB_CFLAGS"
          186           LIBS="$LIBS $GLIB_LIBS"
          187           AC_TRY_LINK([
          188 #include <glib.h>
          189 #include <stdio.h>
          190 ],      [ return ((glib_major_version) || (glib_minor_version) || (glib_micro_version)); ],
          191         [ echo "*** The test program compiled, but did not run. This usually means"
          192           echo "*** that the run-time linker is not finding GLIB or finding the wrong"
          193           echo "*** version of GLIB. If it is not finding GLIB, you'll need to set your"
          194           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
          195           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
          196           echo "*** is required on your system"
          197           echo "***"
          198           echo "*** If you have an old version installed, it is best to remove it, although"
          199           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
          200         [ echo "*** The test program failed to compile or link. See the file config.log for the"
          201           echo "*** exact error that occured. This usually means GLIB is incorrectly installed."])
          202           CFLAGS="$ac_save_CFLAGS"
          203           LIBS="$ac_save_LIBS"
          204        fi
          205      fi
          206      GLIB_CFLAGS=""
          207      GLIB_LIBS=""
          208      GLIB_GENMARSHAL=""
          209      GOBJECT_QUERY=""
          210      GLIB_MKENUMS=""
          211      GLIB_COMPILE_RESOURCES=""
          212      ifelse([$3], , :, [$3])
          213   fi
          214   rm -f conf.glibtest
          215 ])