1 # Configure paths for IMLIB
3 # stolen from Manish Singh
4 # Shamelessly stolen from Owen Taylor
6 dnl AM_PATH_IMLIB([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
7 dnl Test for IMLIB, and define IMLIB_CFLAGS and IMLIB_LIBS
9 AC_DEFUN([AM_PATH_IMLIB],
11 dnl Get the cflags and libraries from the imlib-config script
13 AC_ARG_WITH(imlib-prefix,[ --with-imlib-prefix=PFX Prefix where IMLIB is installed (optional)],
14 imlib_prefix="$withval", imlib_prefix="")
15 AC_ARG_WITH(imlib-exec-prefix,[ --with-imlib-exec-prefix=PFX Exec prefix where IMLIB is installed (optional)],
16 imlib_exec_prefix="$withval", imlib_exec_prefix="")
17 AC_ARG_ENABLE(imlibtest, [ --disable-imlibtest Do not try to compile and run a test IMLIB program],
18 , enable_imlibtest=yes)
20 if test x$imlib_exec_prefix != x ; then
21 imlib_args="$imlib_args --exec-prefix=$imlib_exec_prefix"
22 if test x${IMLIB_CONFIG+set} != xset ; then
23 IMLIB_CONFIG=$imlib_exec_prefix/bin/imlib-config
26 if test x$imlib_prefix != x ; then
27 imlib_args="$imlib_args --prefix=$imlib_prefix"
28 if test x${IMLIB_CONFIG+set} != xset ; then
29 IMLIB_CONFIG=$imlib_prefix/bin/imlib-config
33 AC_PATH_PROG(IMLIB_CONFIG, imlib-config, no)
34 min_imlib_version=ifelse([$1], ,1.8.2,$1)
35 AC_MSG_CHECKING(for IMLIB - version >= $min_imlib_version)
37 if test "$IMLIB_CONFIG" = "no" ; then
40 IMLIB_CFLAGS=`$IMLIB_CONFIG $imlibconf_args --cflags`
41 IMLIB_LIBS=`$IMLIB_CONFIG $imlibconf_args --libs`
43 imlib_major_version=`$IMLIB_CONFIG $imlib_args --version | \
44 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
45 imlib_minor_version=`$IMLIB_CONFIG $imlib_args --version | \
46 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
47 imlib_micro_version=`$IMLIB_CONFIG $imlib_args --version | \
48 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
49 if test "x$enable_imlibtest" = "xyes" ; then
50 ac_save_CFLAGS="$CFLAGS"
52 CFLAGS="$CFLAGS $IMLIB_CFLAGS"
53 LIBS="$LIBS $IMLIB_LIBS"
55 dnl Now check if the installed IMLIB is sufficiently new. (Also sanity
56 dnl checks the results of imlib-config to some extent
72 new_str = malloc ((strlen (str) + 1) * sizeof(char));
73 strcpy (new_str, str);
83 int major, minor, micro;
86 system ("touch conf.imlibtest");
88 /* HP/UX 9 (%@#!) writes to sscanf strings */
89 tmp_version = my_strdup("$min_imlib_version");
90 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
91 printf("%s, bad version string\n", "$min_imlib_version");
95 if (($imlib_major_version > major) ||
96 (($imlib_major_version == major) && ($imlib_minor_version > minor)) ||
97 (($imlib_major_version == major) && ($imlib_minor_version == minor) &&
98 ($imlib_micro_version >= micro)))
104 printf("\n*** 'imlib-config --version' returned %d.%d, but the minimum version\n", $imlib_major_version, $imlib_minor_version);
105 printf("*** of IMLIB required is %d.%d. If imlib-config is correct, then it is\n", major, minor);
106 printf("*** best to upgrade to the required version.\n");
107 printf("*** If imlib-config was wrong, set the environment variable IMLIB_CONFIG\n");
108 printf("*** to point to the correct copy of imlib-config, and remove the file\n");
109 printf("*** config.cache before re-running configure\n");
114 ],, no_imlib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
115 CFLAGS="$ac_save_CFLAGS"
119 if test "x$no_imlib" = x ; then
121 ifelse([$2], , :, [$2])
124 if test "$IMLIB_CONFIG" = "no" ; then
125 echo "*** The imlib-config script installed by IMLIB could not be found"
126 echo "*** If IMLIB was installed in PREFIX, make sure PREFIX/bin is in"
127 echo "*** your path, or set the IMLIB_CONFIG environment variable to the"
128 echo "*** full path to imlib-config."
130 if test -f conf.imlibtest ; then
133 echo "*** Could not run IMLIB test program, checking why..."
134 CFLAGS="$CFLAGS $IMLIB_CFLAGS"
135 LIBS="$LIBS $IMLIB_LIBS"
140 [ echo "*** The test program compiled, but did not run. This usually means"
141 echo "*** that the run-time linker is not finding IMLIB or finding the wrong"
142 echo "*** version of IMLIB. If it is not finding IMLIB, you'll need to set your"
143 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
144 echo "*** to the installed location Also, make sure you have run ldconfig if that"
145 echo "*** is required on your system"
147 echo "*** If you have an old version installed, it is best to remove it, although"
148 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
149 [ echo "*** The test program failed to compile or link. See the file config.log for the"
150 echo "*** exact error that occured. This usually means IMLIB was incorrectly installed"
151 echo "*** or that you have moved IMLIB since it was installed. In the latter case, you"
152 echo "*** may want to edit the imlib-config script: $IMLIB_CONFIG" ])
153 CFLAGS="$ac_save_CFLAGS"
159 ifelse([$3], , :, [$3])
161 AC_SUBST(IMLIB_CFLAGS)
166 # Check for gdk-imlib
167 AC_DEFUN(AM_PATH_GDK_IMLIB,
169 dnl Get the cflags and libraries from the imlib-config script
171 AC_ARG_WITH(imlib-prefix,[ --with-imlib-prefix=PFX Prefix where IMLIB is installed (optional)],
172 imlib_prefix="$withval", imlib_prefix="")
173 AC_ARG_WITH(imlib-exec-prefix,[ --with-imlib-exec-prefix=PFX Exec prefix where IMLIB is installed (optional)],
174 imlib_exec_prefix="$withval", imlib_exec_prefix="")
175 AC_ARG_ENABLE(imlibtest, [ --disable-imlibtest Do not try to compile and run a test IMLIB program],
176 , enable_imlibtest=yes)
178 if test x$imlib_exec_prefix != x ; then
179 imlib_args="$imlib_args --exec-prefix=$imlib_exec_prefix"
180 if test x${IMLIB_CONFIG+set} != xset ; then
181 IMLIB_CONFIG=$imlib_exec_prefix/bin/imlib-config
184 if test x$imlib_prefix != x ; then
185 imlib_args="$imlib_args --prefix=$imlib_prefix"
186 if test x${IMLIB_CONFIG+set} != xset ; then
187 IMLIB_CONFIG=$imlib_prefix/bin/imlib-config
191 AC_PATH_PROG(IMLIB_CONFIG, imlib-config, no)
192 min_imlib_version=ifelse([$1], ,1.8.2,$1)
193 AC_MSG_CHECKING(for IMLIB - version >= $min_imlib_version)
195 if test "$IMLIB_CONFIG" = "no" ; then
198 GDK_IMLIB_CFLAGS=`$IMLIB_CONFIG $imlibconf_args --cflags-gdk`
199 GDK_IMLIB_LIBS=`$IMLIB_CONFIG $imlibconf_args --libs-gdk`
201 imlib_major_version=`$IMLIB_CONFIG $imlib_args --version | \
202 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
203 imlib_minor_version=`$IMLIB_CONFIG $imlib_args --version | \
204 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
205 if test "x$enable_imlibtest" = "xyes" ; then
206 ac_save_CFLAGS="$CFLAGS"
208 CFLAGS="$CFLAGS $GDK_IMLIB_CFLAGS"
209 LIBS="$LIBS $GDK_IMLIB_LIBS"
211 dnl Now check if the installed IMLIB is sufficiently new. (Also sanity
212 dnl checks the results of imlib-config to some extent
218 #include <gdk_imlib.h>
225 system ("touch conf.gdkimlibtest");
227 /* HP/UX 9 (%@#!) writes to sscanf strings */
228 tmp_version = g_strdup("$min_imlib_version");
229 if (sscanf(tmp_version, "%d.%d", &major, &minor) != 2) {
230 printf("%s, bad version string\n", "$min_imlib_version");
234 if (($imlib_major_version > major) ||
235 (($imlib_major_version == major) && ($imlib_minor_version >= minor)))
241 printf("\n*** 'imlib-config --version' returned %d.%d, but the minimum version\n", $imlib_major_version, $imlib_minor_version);
242 printf("*** of IMLIB required is %d.%d. If imlib-config is correct, then it is\n", major, minor);
243 printf("*** best to upgrade to the required version.\n");
244 printf("*** If imlib-config was wrong, set the environment variable IMLIB_CONFIG\n");
245 printf("*** to point to the correct copy of imlib-config, and remove the file\n");
246 printf("*** config.cache before re-running configure\n");
251 ],, no_imlib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
252 CFLAGS="$ac_save_CFLAGS"
256 if test "x$no_imlib" = x ; then
258 ifelse([$2], , :, [$2])
261 if test "$IMLIB_CONFIG" = "no" ; then
262 echo "*** The imlib-config script installed by IMLIB could not be found"
263 echo "*** If IMLIB was installed in PREFIX, make sure PREFIX/bin is in"
264 echo "*** your path, or set the IMLIB_CONFIG environment variable to the"
265 echo "*** full path to imlib-config."
267 if test -f conf.gdkimlibtest ; then
270 echo "*** Could not run IMLIB test program, checking why..."
271 CFLAGS="$CFLAGS $GDK_IMLIB_CFLAGS"
272 LIBS="$LIBS $GDK_IMLIB_LIBS"
275 #include <gdk_imlib.h>
277 [ echo "*** The test program compiled, but did not run. This usually means"
278 echo "*** that the run-time linker is not finding IMLIB or finding the wrong"
279 echo "*** version of IMLIB. If it is not finding IMLIB, you'll need to set your"
280 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
281 echo "*** to the installed location Also, make sure you have run ldconfig if that"
282 echo "*** is required on your system"
284 echo "*** If you have an old version installed, it is best to remove it, although"
285 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
286 [ echo "*** The test program failed to compile or link. See the file config.log for the"
287 echo "*** exact error that occured. This usually means IMLIB was incorrectly installed"
288 echo "*** or that you have moved IMLIB since it was installed. In the latter case, you"
289 echo "*** may want to edit the imlib-config script: $IMLIB_CONFIG" ])
290 CFLAGS="$ac_save_CFLAGS"
296 ifelse([$3], , :, [$3])
298 AC_SUBST(GDK_IMLIB_CFLAGS)
299 AC_SUBST(GDK_IMLIB_LIBS)
300 rm -f conf.gdkimlibtest