1# Configure paths for GTK+ 2# Owen Taylor 97-11-3 3 4dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]]) 5dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS 6dnl 7AC_DEFUN([AM_PATH_GTK], 8[dnl 9dnl Get the cflags and libraries from the gtk-config script 10dnl 11AC_ARG_WITH(gtk-prefix, 12 AS_HELP_STRING([--with-gtk-prefix=PFX], 13 [Prefix where GTK is installed (optional)]), 14 [gtk_config_prefix="$withval"], [gtk_config_prefix=""]) 15AC_ARG_WITH(gtk-exec-prefix, 16 AS_HELP_STRING([--with-gtk-exec-prefix=PFX], 17 [Exec prefix where GTK is installed (optional)]), 18 [gtk_config_exec_prefix="$withval"], [gtk_config_exec_prefix=""]) 19AC_ARG_ENABLE(gtktest, 20 AS_HELP_STRING([--disable-gtktest], 21 [Do not try to compile and run a test GTK program]), 22 , [enable_gtktest=yes]) 23 24 for module in . $4 25 do 26 case "$module" in 27 gthread) 28 gtk_config_args="$gtk_config_args gthread" 29 ;; 30 esac 31 done 32 33 if test x$gtk_config_exec_prefix != x ; then 34 gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix" 35 if test x${GTK_CONFIG+set} != xset ; then 36 GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config 37 fi 38 fi 39 if test x$gtk_config_prefix != x ; then 40 gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix" 41 if test x${GTK_CONFIG+set} != xset ; then 42 GTK_CONFIG=$gtk_config_prefix/bin/gtk-config 43 fi 44 fi 45 46 AC_PATH_PROG(GTK_CONFIG, gtk-config, no) 47 min_gtk_version=ifelse([$1], ,0.99.7,$1) 48 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version) 49 no_gtk="" 50 if test "$GTK_CONFIG" = "no" ; then 51 no_gtk=yes 52 else 53 GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags` 54 GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs` 55 gtk_config_major_version=`$GTK_CONFIG $gtk_config_args --version | \ 56 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` 57 gtk_config_minor_version=`$GTK_CONFIG $gtk_config_args --version | \ 58 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` 59 gtk_config_micro_version=`$GTK_CONFIG $gtk_config_args --version | \ 60 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` 61 if test "x$enable_gtktest" = "xyes" ; then 62 ac_save_CFLAGS="$CFLAGS" 63 ac_save_LIBS="$LIBS" 64 CFLAGS="$CFLAGS $GTK_CFLAGS" 65 LIBS="$GTK_LIBS $LIBS" 66dnl 67dnl Now check if the installed GTK is sufficiently new. (Also sanity 68dnl checks the results of gtk-config to some extent 69dnl 70 rm -f conf.gtktest 71 AC_TRY_RUN([ 72#include <gtk/gtk.h> 73#include <stdio.h> 74#include <stdlib.h> 75 76int 77main () 78{ 79 int major, minor, micro; 80 char *tmp_version; 81 82 system ("touch conf.gtktest"); 83 84 /* HP/UX 9 (%@#!) writes to sscanf strings */ 85 tmp_version = g_strdup("$min_gtk_version"); 86 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { 87 printf("%s, bad version string\n", "$min_gtk_version"); 88 exit(1); 89 } 90 91 if ((gtk_major_version != $gtk_config_major_version) || 92 (gtk_minor_version != $gtk_config_minor_version) || 93 (gtk_micro_version != $gtk_config_micro_version)) 94 { 95 printf("\n*** 'gtk-config --version' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n", 96 $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version, 97 gtk_major_version, gtk_minor_version, gtk_micro_version); 98 printf ("*** was found! If gtk-config was correct, then it is best\n"); 99 printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n"); 100 printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n"); 101 printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n"); 102 printf("*** required on your system.\n"); 103 printf("*** If gtk-config was wrong, set the environment variable GTK_CONFIG\n"); 104 printf("*** to point to the correct copy of gtk-config, and remove the file config.cache\n"); 105 printf("*** before re-running configure\n"); 106 } 107#if defined (GTK_MAJOR_VERSION) && defined (GTK_MINOR_VERSION) && defined (GTK_MICRO_VERSION) 108 else if ((gtk_major_version != GTK_MAJOR_VERSION) || 109 (gtk_minor_version != GTK_MINOR_VERSION) || 110 (gtk_micro_version != GTK_MICRO_VERSION)) 111 { 112 printf("*** GTK+ header files (version %d.%d.%d) do not match\n", 113 GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION); 114 printf("*** library (version %d.%d.%d)\n", 115 gtk_major_version, gtk_minor_version, gtk_micro_version); 116 } 117#endif /* defined (GTK_MAJOR_VERSION) ... */ 118 else 119 { 120 if ((gtk_major_version > major) || 121 ((gtk_major_version == major) && (gtk_minor_version > minor)) || 122 ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro))) 123 { 124 return 0; 125 } 126 else 127 { 128 printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n", 129 gtk_major_version, gtk_minor_version, gtk_micro_version); 130 printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n", 131 major, minor, micro); 132 printf("*** GTK+ 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 gtk-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 GTK+, but you can also set the GTK_CONFIG environment to point to the\n"); 138 printf("*** correct copy of gtk-config. (In this case, you will have to\n"); 139 printf("*** modify your LD_LIBRARY_PATH enviroment 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_gtk=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_gtk" = x ; then 151 AC_MSG_RESULT(yes) 152 ifelse([$2], , :, [$2]) 153 else 154 AC_MSG_RESULT(no) 155 if test "$GTK_CONFIG" = "no" ; then 156 echo "*** The gtk-config script installed by GTK could not be found" 157 echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in" 158 echo "*** your path, or set the GTK_CONFIG environment variable to the" 159 echo "*** full path to gtk-config." 160 else 161 if test -f conf.gtktest ; then 162 : 163 else 164 echo "*** Could not run GTK test program, checking why..." 165 CFLAGS="$CFLAGS $GTK_CFLAGS" 166 LIBS="$LIBS $GTK_LIBS" 167 AC_TRY_LINK([ 168#include <gtk/gtk.h> 169#include <stdio.h> 170], [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_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 GTK or finding the wrong" 173 echo "*** version of GTK. If it is not finding GTK, 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 occured. This usually means GTK was incorrectly installed" 187 echo "*** or that you have moved GTK since it was installed. In the latter case, you" 188 echo "*** may want to edit the gtk-config script: $GTK_CONFIG" ]) 189 CFLAGS="$ac_save_CFLAGS" 190 LIBS="$ac_save_LIBS" 191 fi 192 fi 193 GTK_CFLAGS="" 194 GTK_LIBS="" 195 ifelse([$3], , :, [$3]) 196 fi 197 AC_SUBST(GTK_CFLAGS) 198 AC_SUBST(GTK_LIBS) 199 rm -f conf.gtktest 200]) 201