1# Configure paths for gdk-pixbuf 2# Elliot Lee 2000-01-10 3# stolen from Raph Levien 98-11-18 4# stolen from Manish Singh 98-9-30 5# stolen back from Frank Belew 6# stolen from Manish Singh 7# Shamelessly stolen from Owen Taylor 8 9dnl AM_PATH_GDK_PIXBUF([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) 10dnl Test for GDK_PIXBUF, and define GDK_PIXBUF_CFLAGS and GDK_PIXBUF_LIBS 11dnl 12AC_DEFUN([AM_PATH_GDK_PIXBUF], 13[dnl 14dnl Get the cflags and libraries from the gdk-pixbuf-config script 15dnl 16AC_ARG_WITH(gdk-pixbuf-prefix,[ --with-gdk-pixbuf-prefix=PFX Prefix where GDK_PIXBUF is installed (optional)], 17 gdk_pixbuf_prefix="$withval", gdk_pixbuf_prefix="") 18AC_ARG_WITH(gdk-pixbuf-exec-prefix,[ --with-gdk-pixbuf-exec-prefix=PFX Exec prefix where GDK_PIXBUF is installed (optional)], 19 gdk_pixbuf_exec_prefix="$withval", gdk_pixbuf_exec_prefix="") 20AC_ARG_ENABLE(gdk_pixbuftest, [ --disable-gdk_pixbuftest Do not try to compile and run a test GDK_PIXBUF program], 21 , enable_gdk_pixbuftest=yes) 22 23 if test x$gdk_pixbuf_exec_prefix != x ; then 24 gdk_pixbuf_args="$gdk_pixbuf_args --exec-prefix=$gdk_pixbuf_exec_prefix" 25 if test x${GDK_PIXBUF_CONFIG+set} = xset ; then 26 GDK_PIXBUF_CONFIG=$gdk_pixbuf_exec_prefix/gdk-pixbuf-config 27 fi 28 fi 29 if test x$gdk_pixbuf_prefix != x ; then 30 gdk_pixbuf_args="$gdk_pixbuf_args --prefix=$gdk_pixbuf_prefix" 31 if test x${GDK_PIXBUF_CONFIG+set} = xset ; then 32 GDK_PIXBUF_CONFIG=$gdk_pixbuf_prefix/bin/gdk-pixbuf-config 33 fi 34 fi 35 36 AC_PATH_PROG(GDK_PIXBUF_CONFIG, gdk-pixbuf-config, no) 37 min_gdk_pixbuf_version=ifelse([$1], ,0.2.5,$1) 38 AC_MSG_CHECKING(for GDK_PIXBUF - version >= $min_gdk_pixbuf_version) 39 no_gdk_pixbuf="" 40 if test "$GDK_PIXBUF_CONFIG" = "no" ; then 41 no_gdk_pixbuf=yes 42 else 43 GDK_PIXBUF_CFLAGS=`$GDK_PIXBUF_CONFIG $gdk_pixbufconf_args --cflags` 44 GDK_PIXBUF_LIBS=`$GDK_PIXBUF_CONFIG $gdk_pixbufconf_args --libs` 45 46 gdk_pixbuf_major_version=`$GDK_PIXBUF_CONFIG $gdk_pixbuf_args --version | \ 47 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` 48 gdk_pixbuf_minor_version=`$GDK_PIXBUF_CONFIG $gdk_pixbuf_args --version | \ 49 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` 50 gdk_pixbuf_micro_version=`$GDK_PIXBUF_CONFIG $gdk_pixbuf_config_args --version | \ 51 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` 52 if test "x$enable_gdk_pixbuftest" = "xyes" ; then 53 ac_save_CFLAGS="$CFLAGS" 54 ac_save_LIBS="$LIBS" 55 CFLAGS="$CFLAGS $GDK_PIXBUF_CFLAGS" 56 LIBS="$LIBS $GDK_PIXBUF_LIBS" 57dnl 58dnl Now check if the installed GDK_PIXBUF is sufficiently new. (Also sanity 59dnl checks the results of gdk-pixbuf-config to some extent 60dnl 61 rm -f conf.gdk_pixbuftest 62 AC_TRY_RUN([ 63#include <stdio.h> 64#include <stdlib.h> 65#include <string.h> 66#include <gdk-pixbuf/gdk-pixbuf.h> 67 68char* 69my_strdup (char *str) 70{ 71 char *new_str; 72 73 if (str) 74 { 75 new_str = malloc ((strlen (str) + 1) * sizeof(char)); 76 strcpy (new_str, str); 77 } 78 else 79 new_str = NULL; 80 81 return new_str; 82} 83 84int main () 85{ 86 int major, minor, micro; 87 char *tmp_version; 88 89 system ("touch conf.gdk_pixbuftest"); 90 91 /* HP/UX 9 (%@#!) writes to sscanf strings */ 92 tmp_version = my_strdup("$min_gdk_pixbuf_version"); 93 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { 94 printf("%s, bad version string\n", "$min_gdk_pixbuf_version"); 95 exit(1); 96 } 97 98 if (($gdk_pixbuf_major_version > major) || 99 (($gdk_pixbuf_major_version == major) && ($gdk_pixbuf_minor_version > minor)) || 100 (($gdk_pixbuf_major_version == major) && ($gdk_pixbuf_minor_version == minor) && ($gdk_pixbuf_micro_version >= micro))) 101 { 102 return 0; 103 } 104 else 105 { 106 printf("\n*** 'gdk-pixbuf-config --version' returned %d.%d.%d, but the minimum version\n", $gdk_pixbuf_major_version, $gdk_pixbuf_minor_version, $gdk_pixbuf_micro_version); 107 printf("*** of GDK_PIXBUF required is %d.%d.%d. If gdk-pixbuf-config is correct, then it is\n", major, minor, micro); 108 printf("*** best to upgrade to the required version.\n"); 109 printf("*** If gdk-pixbuf-config was wrong, set the environment variable GDK_PIXBUF_CONFIG\n"); 110 printf("*** to point to the correct copy of gdk-pixbuf-config, and remove the file\n"); 111 printf("*** config.cache before re-running configure\n"); 112 return 1; 113 } 114} 115 116],, no_gdk_pixbuf=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) 117 CFLAGS="$ac_save_CFLAGS" 118 LIBS="$ac_save_LIBS" 119 fi 120 fi 121 if test "x$no_gdk_pixbuf" = x ; then 122 AC_MSG_RESULT(yes) 123 ifelse([$2], , :, [$2]) 124 else 125 AC_MSG_RESULT(no) 126 if test "$GDK_PIXBUF_CONFIG" = "no" ; then 127 echo "*** The gdk-pixbuf-config script installed by GDK_PIXBUF could not be found" 128 echo "*** If GDK_PIXBUF was installed in PREFIX, make sure PREFIX/bin is in" 129 echo "*** your path, or set the GDK_PIXBUF_CONFIG environment variable to the" 130 echo "*** full path to gdk-pixbuf-config." 131 else 132 if test -f conf.gdk_pixbuftest ; then 133 : 134 else 135 echo "*** Could not run GDK_PIXBUF test program, checking why..." 136 CFLAGS="$CFLAGS $GDK_PIXBUF_CFLAGS" 137 LIBS="$LIBS $GDK_PIXBUF_LIBS" 138 AC_TRY_LINK([ 139#include <stdio.h> 140#include <gdk-pixbuf/gdk-pixbuf.h> 141], [ return 0; ], 142 [ echo "*** The test program compiled, but did not run. This usually means" 143 echo "*** that the run-time linker is not finding GDK_PIXBUF or finding the wrong" 144 echo "*** version of GDK_PIXBUF. If it is not finding GDK_PIXBUF, you'll need to set your" 145 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" 146 echo "*** to the installed location Also, make sure you have run ldconfig if that" 147 echo "*** is required on your system" 148 echo "***" 149 echo "*** If you have an old version installed, it is best to remove it, although" 150 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], 151 [ echo "*** The test program failed to compile or link. See the file config.log for the" 152 echo "*** exact error that occured. This usually means GDK_PIXBUF was incorrectly installed" 153 echo "*** or that you have moved GDK_PIXBUF since it was installed. In the latter case, you" 154 echo "*** may want to edit the gdk-pixbuf-config script: $GDK_PIXBUF_CONFIG" ]) 155 CFLAGS="$ac_save_CFLAGS" 156 LIBS="$ac_save_LIBS" 157 fi 158 fi 159 GDK_PIXBUF_CFLAGS="" 160 GDK_PIXBUF_LIBS="" 161 ifelse([$3], , :, [$3]) 162 fi 163 AC_SUBST(GDK_PIXBUF_CFLAGS) 164 AC_SUBST(GDK_PIXBUF_LIBS) 165 rm -f conf.gdk_pixbuftest 166]) 167