PageRenderTime 30ms CodeModel.GetById 16ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/build/autoconf/glib.m4

http://github.com/zpao/v8monkey
m4 | 200 lines | 184 code | 9 blank | 7 comment | 0 complexity | 722ef7349731343e2887c941b3443500 MD5 | raw file
  1# Configure paths for GLIB
  2# Owen Taylor     97-11-3
  3
  4dnl AM_PATH_GLIB([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
  5dnl Test for GLIB, and define GLIB_CFLAGS and GLIB_LIBS, if "gmodule" or 
  6dnl gthread is specified in MODULES, pass to glib-config
  7dnl
  8AC_DEFUN([AM_PATH_GLIB],
  9[dnl 
 10dnl Get the cflags and libraries from the glib-config script
 11dnl
 12AC_ARG_WITH(glib-prefix,[  --with-glib-prefix=PFX  Prefix where GLIB is installed (optional)],
 13            glib_config_prefix="$withval", glib_config_prefix="")
 14AC_ARG_WITH(glib-exec-prefix,[  --with-glib-exec-prefix=PFX
 15                          Exec prefix where GLIB is installed (optional)],
 16            glib_config_exec_prefix="$withval", glib_config_exec_prefix="")
 17AC_ARG_ENABLE(glibtest, [  --disable-glibtest      Do not try to compile and run a test GLIB program],
 18		    , enable_glibtest=yes)
 19
 20  if test x$glib_config_exec_prefix != x ; then
 21     glib_config_args="$glib_config_args --exec-prefix=$glib_config_exec_prefix"
 22     if test x${GLIB_CONFIG+set} != xset ; then
 23        GLIB_CONFIG=$glib_config_exec_prefix/bin/glib-config
 24     fi
 25  fi
 26  if test x$glib_config_prefix != x ; then
 27     glib_config_args="$glib_config_args --prefix=$glib_config_prefix"
 28     if test x${GLIB_CONFIG+set} != xset ; then
 29        GLIB_CONFIG=$glib_config_prefix/bin/glib-config
 30     fi
 31  fi
 32
 33  for module in . $4
 34  do
 35      case "$module" in
 36         gmodule) 
 37             glib_config_args="$glib_config_args gmodule"
 38         ;;
 39         gthread) 
 40             glib_config_args="$glib_config_args gthread"
 41         ;;
 42      esac
 43  done
 44
 45  dnl Force a version check to keep upgraded versions from being overridden by the cached value.
 46  unset ac_cv_path_GLIB_CONFIG
 47
 48  AC_PATH_PROG(GLIB_CONFIG, glib-config, no)
 49  min_glib_version=ifelse([$1], ,0.99.7,$1)
 50  AC_MSG_CHECKING(for GLIB - version >= $min_glib_version)
 51  no_glib=""
 52  if test "$GLIB_CONFIG" = "no" ; then
 53    no_glib=yes
 54  else
 55    GLIB_CFLAGS=`$GLIB_CONFIG $glib_config_args --cflags`
 56    GLIB_LIBS=`$GLIB_CONFIG $glib_config_args --libs`
 57    glib_config_major_version=`$GLIB_CONFIG $glib_config_args --version | \
 58           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
 59    glib_config_minor_version=`$GLIB_CONFIG $glib_config_args --version | \
 60           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
 61    glib_config_micro_version=`$GLIB_CONFIG $glib_config_args --version | \
 62           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
 63    if test "x$enable_glibtest" = "xyes" ; then
 64      ac_save_CFLAGS="$CFLAGS"
 65      ac_save_LIBS="$LIBS"
 66      CFLAGS="$CFLAGS $GLIB_CFLAGS"
 67      LIBS="$GLIB_LIBS $LIBS"
 68dnl
 69dnl Now check if the installed GLIB is sufficiently new. (Also sanity
 70dnl checks the results of glib-config to some extent
 71dnl
 72      rm -f conf.glibtest
 73      AC_TRY_RUN([
 74#include <glib.h>
 75#include <stdio.h>
 76#include <stdlib.h>
 77
 78int 
 79main ()
 80{
 81  int major, minor, micro;
 82  char *tmp_version;
 83
 84  system ("touch conf.glibtest");
 85
 86  /* HP/UX 9 (%@#!) writes to sscanf strings */
 87  tmp_version = g_strdup("$min_glib_version");
 88  if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
 89     printf("%s, bad version string\n", "$min_glib_version");
 90     exit(1);
 91   }
 92
 93  if ((glib_major_version != $glib_config_major_version) ||
 94      (glib_minor_version != $glib_config_minor_version) ||
 95      (glib_micro_version != $glib_config_micro_version))
 96    {
 97      printf("\n*** 'glib-config --version' returned %d.%d.%d, but GLIB (%d.%d.%d)\n", 
 98             $glib_config_major_version, $glib_config_minor_version, $glib_config_micro_version,
 99             glib_major_version, glib_minor_version, glib_micro_version);
100      printf ("*** was found! If glib-config was correct, then it is best\n");
101      printf ("*** to remove the old version of GLIB. You may also be able to fix the error\n");
102      printf("*** by modifying your LD_LIBRARY_PATH environment variable, or by editing\n");
103      printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
104      printf("*** required on your system.\n");
105      printf("*** If glib-config was wrong, set the environment variable GLIB_CONFIG\n");
106      printf("*** to point to the correct copy of glib-config, and remove the file config.cache\n");
107      printf("*** before re-running configure\n");
108    } 
109  else if ((glib_major_version != GLIB_MAJOR_VERSION) ||
110	   (glib_minor_version != GLIB_MINOR_VERSION) ||
111           (glib_micro_version != GLIB_MICRO_VERSION))
112    {
113      printf("*** GLIB header files (version %d.%d.%d) do not match\n",
114	     GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION);
115      printf("*** library (version %d.%d.%d)\n",
116	     glib_major_version, glib_minor_version, glib_micro_version);
117    }
118  else
119    {
120      if ((glib_major_version > major) ||
121        ((glib_major_version == major) && (glib_minor_version > minor)) ||
122        ((glib_major_version == major) && (glib_minor_version == minor) && (glib_micro_version >= micro)))
123      {
124        return 0;
125       }
126     else
127      {
128        printf("\n*** An old version of GLIB (%d.%d.%d) was found.\n",
129               glib_major_version, glib_minor_version, glib_micro_version);
130        printf("*** You need a version of GLIB newer than %d.%d.%d. The latest version of\n",
131	       major, minor, micro);
132        printf("*** GLIB is always available from ftp://ftp.gtk.org.\n");
133        printf("***\n");
134        printf("*** If you have already installed a sufficiently new version, this error\n");
135        printf("*** probably means that the wrong copy of the glib-config shell script is\n");
136        printf("*** being found. The easiest way to fix this is to remove the old version\n");
137        printf("*** of GLIB, but you can also set the GLIB_CONFIG environment to point to the\n");
138        printf("*** correct copy of glib-config. (In this case, you will have to\n");
139        printf("*** modify your LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf\n");
140        printf("*** so that the correct libraries are found at run-time))\n");
141      }
142    }
143  return 1;
144}
145],, no_glib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
146       CFLAGS="$ac_save_CFLAGS"
147       LIBS="$ac_save_LIBS"
148     fi
149  fi
150  if test "x$no_glib" = x ; then
151     AC_MSG_RESULT(yes)
152     ifelse([$2], , :, [$2])     
153  else
154     AC_MSG_RESULT(no)
155     if test "$GLIB_CONFIG" = "no" ; then
156       echo "*** The glib-config script installed by GLIB could not be found"
157       echo "*** If GLIB was installed in PREFIX, make sure PREFIX/bin is in"
158       echo "*** your path, or set the GLIB_CONFIG environment variable to the"
159       echo "*** full path to glib-config."
160     else
161       if test -f conf.glibtest ; then
162        :
163       else
164          echo "*** Could not run GLIB test program, checking why..."
165          CFLAGS="$CFLAGS $GLIB_CFLAGS"
166          LIBS="$LIBS $GLIB_LIBS"
167          AC_TRY_LINK([
168#include <glib.h>
169#include <stdio.h>
170],      [ return ((glib_major_version) || (glib_minor_version) || (glib_micro_version)); ],
171        [ echo "*** The test program compiled, but did not run. This usually means"
172          echo "*** that the run-time linker is not finding GLIB or finding the wrong"
173          echo "*** version of GLIB. If it is not finding GLIB, you'll need to set your"
174          echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
175          echo "*** to the installed location  Also, make sure you have run ldconfig if that"
176          echo "*** is required on your system"
177	  echo "***"
178          echo "*** If you have an old version installed, it is best to remove it, although"
179          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
180          echo "***"
181          echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
182          echo "*** came with the system with the command"
183          echo "***"
184          echo "***    rpm --erase --nodeps gtk gtk-devel" ],
185        [ echo "*** The test program failed to compile or link. See the file config.log for the"
186          echo "*** exact error that occurred. This usually means GLIB was incorrectly installed"
187          echo "*** or that you have moved GLIB since it was installed. In the latter case, you"
188          echo "*** may want to edit the glib-config script: $GLIB_CONFIG" ])
189          CFLAGS="$ac_save_CFLAGS"
190          LIBS="$ac_save_LIBS"
191       fi
192     fi
193     GLIB_CFLAGS=""
194     GLIB_LIBS=""
195     ifelse([$3], , :, [$3])
196  fi
197  AC_SUBST(GLIB_CFLAGS)
198  AC_SUBST(GLIB_LIBS)
199  rm -f conf.glibtest
200])