gtk--.m4 revision 1.1.1.1
1# Configure paths for GTK-- 2# Erik Andersen 30 May 1998 3# Modified by Tero Pulkkinen (added the compiler checks... I hope they work..) 4# Modified by Thomas Langen 16 Jan 2000 (corrected CXXFLAGS) 5 6dnl Test for GTKMM, and define GTKMM_CFLAGS and GTKMM_LIBS 7dnl to be used as follows: 8dnl AM_PATH_GTKMM([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) 9dnl 10AC_DEFUN([AM_PATH_GTKMM], 11[dnl 12dnl Get the cflags and libraries from the gtkmm-config script 13dnl 14AC_ARG_WITH(gtkmm-prefix,[ --with-gtkmm-prefix=PREFIX 15 Prefix where GTK-- is installed (optional)], 16 gtkmm_config_prefix="$withval", gtkmm_config_prefix="") 17AC_ARG_WITH(gtkmm-exec-prefix,[ --with-gtkmm-exec-prefix=PREFIX 18 Exec prefix where GTK-- is installed (optional)], 19 gtkmm_config_exec_prefix="$withval", gtkmm_config_exec_prefix="") 20AC_ARG_ENABLE(gtkmmtest, [ --disable-gtkmmtest Do not try to compile and run a test GTK-- program], 21 , enable_gtkmmtest=yes) 22 23 if test x$gtkmm_config_exec_prefix != x ; then 24 gtkmm_config_args="$gtkmm_config_args --exec-prefix=$gtkmm_config_exec_prefix" 25 if test x${GTKMM_CONFIG+set} != xset ; then 26 GTKMM_CONFIG=$gtkmm_config_exec_prefix/bin/gtkmm-config 27 fi 28 fi 29 if test x$gtkmm_config_prefix != x ; then 30 gtkmm_config_args="$gtkmm_config_args --prefix=$gtkmm_config_prefix" 31 if test x${GTKMM_CONFIG+set} != xset ; then 32 GTKMM_CONFIG=$gtkmm_config_prefix/bin/gtkmm-config 33 fi 34 fi 35 36 AC_PATH_PROG(GTKMM_CONFIG, gtkmm-config, no) 37 min_gtkmm_version=ifelse([$1], ,0.10.0,$1) 38 39 AC_MSG_CHECKING(for GTK-- - version >= $min_gtkmm_version) 40 AC_LANG_SAVE 41 no_gtkmm="" 42 if test "$GTKMM_CONFIG" = "no" ; then 43 no_gtkmm=yes 44 else 45 AC_LANG_CPLUSPLUS 46 47 GTKMM_CFLAGS=`$GTKMM_CONFIG $gtkmm_config_args --cflags` 48 GTKMM_LIBS=`$GTKMM_CONFIG $gtkmm_config_args --libs` 49 gtkmm_config_major_version=`$GTKMM_CONFIG $gtkmm_config_args --version | \ 50 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` 51 gtkmm_config_minor_version=`$GTKMM_CONFIG $gtkmm_config_args --version | \ 52 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` 53 gtkmm_config_micro_version=`$GTKMM_CONFIG $gtkmm_config_args --version | \ 54 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` 55 if test "x$enable_gtkmmtest" = "xyes" ; then 56 ac_save_CXXFLAGS="$CXXFLAGS" 57 ac_save_LIBS="$LIBS" 58 CXXFLAGS="$CXXFLAGS $GTKMM_CFLAGS" 59 LIBS="$LIBS $GTKMM_LIBS" 60dnl 61dnl Now check if the installed GTK-- is sufficiently new. (Also sanity 62dnl checks the results of gtkmm-config to some extent 63dnl 64 rm -f conf.gtkmmtest 65 AC_TRY_RUN([ 66#include <gtk--.h> 67#include <stdio.h> 68#include <stdlib.h> 69 70int 71main () 72{ 73 int major, minor, micro; 74 char *tmp_version; 75 76 system ("touch conf.gtkmmtest"); 77 78 /* HP/UX 0 (%@#!) writes to sscanf strings */ 79 tmp_version = g_strdup("$min_gtkmm_version"); 80 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { 81 printf("%s, bad version string\n", "$min_gtkmm_version"); 82 exit(1); 83 } 84 85 if ((gtkmm_major_version != $gtkmm_config_major_version) || 86 (gtkmm_minor_version != $gtkmm_config_minor_version) || 87 (gtkmm_micro_version != $gtkmm_config_micro_version)) 88 { 89 printf("\n*** 'gtkmm-config --version' returned %d.%d.%d, but GTK-- (%d.%d.%d)\n", 90 $gtkmm_config_major_version, $gtkmm_config_minor_version, $gtkmm_config_micro_version, 91 gtkmm_major_version, gtkmm_minor_version, gtkmm_micro_version); 92 printf ("*** was found! If gtkmm-config was correct, then it is best\n"); 93 printf ("*** to remove the old version of GTK--. You may also be able to fix the error\n"); 94 printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n"); 95 printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n"); 96 printf("*** required on your system.\n"); 97 printf("*** If gtkmm-config was wrong, set the environment variable GTKMM_CONFIG\n"); 98 printf("*** to point to the correct copy of gtkmm-config, and remove the file config.cache\n"); 99 printf("*** before re-running configure\n"); 100 } 101/* GTK-- does not have the GTKMM_*_VERSION constants */ 102/* 103 else if ((gtkmm_major_version != GTKMM_MAJOR_VERSION) || 104 (gtkmm_minor_version != GTKMM_MINOR_VERSION) || 105 (gtkmm_micro_version != GTKMM_MICRO_VERSION)) 106 { 107 printf("*** GTK-- header files (version %d.%d.%d) do not match\n", 108 GTKMM_MAJOR_VERSION, GTKMM_MINOR_VERSION, GTKMM_MICRO_VERSION); 109 printf("*** library (version %d.%d.%d)\n", 110 gtkmm_major_version, gtkmm_minor_version, gtkmm_micro_version); 111 } 112*/ 113 else 114 { 115 if ((gtkmm_major_version > major) || 116 ((gtkmm_major_version == major) && (gtkmm_minor_version > minor)) || 117 ((gtkmm_major_version == major) && (gtkmm_minor_version == minor) && (gtkmm_micro_version >= micro))) 118 { 119 return 0; 120 } 121 else 122 { 123 printf("\n*** An old version of GTK-- (%d.%d.%d) was found.\n", 124 gtkmm_major_version, gtkmm_minor_version, gtkmm_micro_version); 125 printf("*** You need a version of GTK-- newer than %d.%d.%d. The latest version of\n", 126 major, minor, micro); 127 printf("*** GTK-- is always available from ftp://ftp.gtk.org.\n"); 128 printf("***\n"); 129 printf("*** If you have already installed a sufficiently new version, this error\n"); 130 printf("*** probably means that the wrong copy of the gtkmm-config shell script is\n"); 131 printf("*** being found. The easiest way to fix this is to remove the old version\n"); 132 printf("*** of GTK--, but you can also set the GTKMM_CONFIG environment to point to the\n"); 133 printf("*** correct copy of gtkmm-config. (In this case, you will have to\n"); 134 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); 135 printf("*** so that the correct libraries are found at run-time))\n"); 136 } 137 } 138 return 1; 139} 140],, no_gtkmm=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) 141 CXXFLAGS="$ac_save_CXXFLAGS" 142 LIBS="$ac_save_LIBS" 143 fi 144 fi 145 if test "x$no_gtkmm" = x ; then 146 AC_MSG_RESULT(yes) 147 ifelse([$2], , :, [$2]) 148 else 149 AC_MSG_RESULT(no) 150 if test "$GTKMM_CONFIG" = "no" ; then 151 echo "*** The gtkmm-config script installed by GTK-- could not be found" 152 echo "*** If GTK-- was installed in PREFIX, make sure PREFIX/bin is in" 153 echo "*** your path, or set the GTKMM_CONFIG environment variable to the" 154 echo "*** full path to gtkmm-config." 155 echo "*** The gtkmm-config script was not available in GTK-- versions" 156 echo "*** prior to 0.9.12. Perhaps you need to update your installed" 157 echo "*** version to 0.9.12 or later" 158 else 159 if test -f conf.gtkmmtest ; then 160 : 161 else 162 echo "*** Could not run GTK-- test program, checking why..." 163 CXXFLAGS="$CXXFLAGS $GTKMM_CFLAGS" 164 LIBS="$LIBS $GTKMM_LIBS" 165 AC_TRY_LINK([ 166#include <gtk--.h> 167#include <stdio.h> 168], [ return ((gtkmm_major_version) || (gtkmm_minor_version) || (gtkmm_micro_version)); ], 169 [ echo "*** The test program compiled, but did not run. This usually means" 170 echo "*** that the run-time linker is not finding GTK-- or finding the wrong" 171 echo "*** version of GTK--. If it is not finding GTK--, you'll need to set your" 172 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" 173 echo "*** to the installed location Also, make sure you have run ldconfig if that" 174 echo "*** is required on your system" 175 echo "***" 176 echo "*** If you have an old version installed, it is best to remove it, although" 177 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ], 178 [ echo "*** The test program failed to compile or link. See the file config.log for the" 179 echo "*** exact error that occured. This usually means GTK-- was incorrectly installed" 180 echo "*** or that you have moved GTK-- since it was installed. In the latter case, you" 181 echo "*** may want to edit the gtkmm-config script: $GTKMM_CONFIG" ]) 182 CXXFLAGS="$ac_save_CXXFLAGS" 183 LIBS="$ac_save_LIBS" 184 fi 185 fi 186 GTKMM_CFLAGS="" 187 GTKMM_LIBS="" 188 ifelse([$3], , :, [$3]) 189 fi 190 AC_LANG_RESTORE 191 AC_SUBST(GTKMM_CFLAGS) 192 AC_SUBST(GTKMM_LIBS) 193 rm -f conf.gtkmmtest 194]) 195 196