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