gtk-3.0.m4 7.93 KB
Newer Older
1
# Configure paths for GTK+
Owen Taylor's avatar
Owen Taylor committed
2
# Owen Taylor     1997-2001
3

Matthias Clasen's avatar
Matthias Clasen committed
4
dnl AM_PATH_GTK_3_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
5 6
dnl Test for GTK+, and define GTK_CFLAGS and GTK_LIBS, if gthread is specified in MODULES, 
dnl pass to pkg-config
7
dnl
Matthias Clasen's avatar
Matthias Clasen committed
8
AC_DEFUN([AM_PATH_GTK_3_0],
9
[m4_warn([obsolete], [AM_PATH_GTK_3_0 is deprecated, use PKG_CHECK_MODULES([GTK], [gtk+-3.0]) instead])
10
dnl Get the cflags and libraries from pkg-config
11
dnl
12
AC_ARG_ENABLE(gtktest, [  --disable-gtktest       do not try to compile and run a test GTK+ program],
13
		    , enable_gtktest=yes)
14
  min_gtk_version=ifelse([$1], [], [3.0.0], [$1])
15

16
  pkg_config_args="gtk+-3.0 >= $min_gtk_version"
17 18 19
  for module in . $4
  do
      case "$module" in
Matthias Clasen's avatar
Matthias Clasen committed
20
         gthread)
Owen Taylor's avatar
Owen Taylor committed
21
             pkg_config_args="$pkg_config_args gthread-2.0"
22 23 24 25
         ;;
      esac
  done

26
  no_gtk=""
Owen Taylor's avatar
Owen Taylor committed
27

28
  PKG_PROG_PKG_CONFIG([0.16])
Owen Taylor's avatar
Owen Taylor committed
29

30
  if test -z "$PKG_CONFIG"; then
31
    no_gtk=yes
32 33 34 35
  fi

  AC_MSG_CHECKING(for GTK+ - version >= $min_gtk_version)

36
  if test -n "$PKG_CONFIG"; then
37 38 39 40 41
    ## don't try to run the test against uninstalled libtool libs
    if $PKG_CONFIG --uninstalled $pkg_config_args; then
	  echo "Will use uninstalled version of GTK+ found in PKG_CONFIG_PATH"
	  enable_gtktest=no
    fi
42

43
    if $PKG_CONFIG $pkg_config_args; then
44 45 46 47
	  :
    else
	  no_gtk=yes
    fi
48 49
  fi

50 51 52
  if test x"$no_gtk" = x ; then
    GTK_CFLAGS=`$PKG_CONFIG $pkg_config_args --cflags`
    GTK_LIBS=`$PKG_CONFIG $pkg_config_args --libs`
Matthias Clasen's avatar
Matthias Clasen committed
53
    gtk_config_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
54
           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
Matthias Clasen's avatar
Matthias Clasen committed
55
    gtk_config_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
56
           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
Matthias Clasen's avatar
Matthias Clasen committed
57
    gtk_config_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
58
           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
59
    if test "x$enable_gtktest" = "xyes" ; then
60 61
      ac_save_CFLAGS="$CFLAGS"
      ac_save_LIBS="$LIBS"
62 63
      CFLAGS="$CFLAGS $GTK_CFLAGS"
      LIBS="$GTK_LIBS $LIBS"
64
dnl
65 66
dnl Now check if the installed GTK+ is sufficiently new. (Also sanity
dnl checks the results of pkg-config to some extent)
67
dnl
68
      rm -f conf.gtktest
69
      AC_TRY_RUN([
70
#include <gtk/gtk.h>
71
#include <stdio.h>
72
#include <stdlib.h>
73 74 75 76

int 
main ()
{
77
  unsigned int major, minor, micro;
78

Javier Jardón's avatar
Javier Jardón committed
79
  fclose (fopen ("conf.gtktest", "w"));
80

81
  if (sscanf("$min_gtk_version", "%u.%u.%u", &major, &minor, &micro) != 3) {
82
     printf("%s, bad version string\n", "$min_gtk_version");
83 84 85
     exit(1);
   }

86 87 88
  if ((gtk_major_version != $gtk_config_major_version) ||
      (gtk_minor_version != $gtk_config_minor_version) ||
      (gtk_micro_version != $gtk_config_micro_version))
89
    {
Matthias Clasen's avatar
Matthias Clasen committed
90
      printf("\n*** 'pkg-config --modversion gtk+-3.0' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n", 
91 92
             $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
             gtk_major_version, gtk_minor_version, gtk_micro_version);
Owen Taylor's avatar
Owen Taylor committed
93
      printf ("*** was found! If pkg-config was correct, then it is best\n");
94
      printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
95 96 97
      printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
      printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
      printf("*** required on your system.\n");
Owen Taylor's avatar
Owen Taylor committed
98 99
      printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
      printf("*** to point to the correct configuration files\n");
100
    } 
101 102 103
  else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
	   (gtk_minor_version != GTK_MINOR_VERSION) ||
           (gtk_micro_version != GTK_MICRO_VERSION))
104
    {
105 106
      printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
	     GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
107
      printf("*** library (version %d.%d.%d)\n",
108
	     gtk_major_version, gtk_minor_version, gtk_micro_version);
109
    }
110 111
  else
    {
112 113 114
      if ((gtk_major_version > major) ||
        ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
        ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
115 116 117 118 119
      {
        return 0;
       }
     else
      {
120
        printf("\n*** An old version of GTK+ (%u.%u.%u) was found.\n",
121
               gtk_major_version, gtk_minor_version, gtk_micro_version);
122
        printf("*** You need a version of GTK+ newer than %u.%u.%u. The latest version of\n",
123
	       major, minor, micro);
124
        printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
125 126
        printf("***\n");
        printf("*** If you have already installed a sufficiently new version, this error\n");
Owen Taylor's avatar
Owen Taylor committed
127
        printf("*** probably means that the wrong copy of the pkg-config shell script is\n");
128
        printf("*** being found. The easiest way to fix this is to remove the old version\n");
129
        printf("*** of GTK+, but you can also set the PKG_CONFIG environment to point to the\n");
Owen Taylor's avatar
Owen Taylor committed
130
        printf("*** correct copy of pkg-config. (In this case, you will have to\n");
131 132 133 134 135
        printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
        printf("*** so that the correct libraries are found at run-time))\n");
      }
    }
  return 1;
136
}
137
],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
138 139 140
       CFLAGS="$ac_save_CFLAGS"
       LIBS="$ac_save_LIBS"
     fi
141
  fi
142 143
  if test "x$no_gtk" = x ; then
     AC_MSG_RESULT(yes (version $gtk_config_major_version.$gtk_config_minor_version.$gtk_config_micro_version))
Matthias Clasen's avatar
Matthias Clasen committed
144
     ifelse([$2], , :, [$2])
145 146
  else
     AC_MSG_RESULT(no)
147
     if test -z "$PKG_CONFIG"; then
Owen Taylor's avatar
Owen Taylor committed
148 149
       echo "*** A new enough version of pkg-config was not found."
       echo "*** See http://pkgconfig.sourceforge.net"
150
     else
151
       if test -f conf.gtktest ; then
152 153
        :
       else
154
          echo "*** Could not run GTK+ test program, checking why..."
155 156
	  ac_save_CFLAGS="$CFLAGS"
	  ac_save_LIBS="$LIBS"
157 158
          CFLAGS="$CFLAGS $GTK_CFLAGS"
          LIBS="$LIBS $GTK_LIBS"
159
          AC_TRY_LINK([
160
#include <gtk/gtk.h>
161
#include <stdio.h>
162
],      [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
163
        [ echo "*** The test program compiled, but did not run. This usually means"
164 165
          echo "*** that the run-time linker is not finding GTK+ or finding the wrong"
          echo "*** version of GTK+. If it is not finding GTK+, you'll need to set your"
166 167 168 169 170
          echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
          echo "*** to the installed location  Also, make sure you have run ldconfig if that"
          echo "*** is required on your system"
	  echo "***"
          echo "*** If you have an old version installed, it is best to remove it, although"
171
          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
172
        [ echo "*** The test program failed to compile or link. See the file config.log for the"
Matthias Clasen's avatar
Matthias Clasen committed
173
          echo "*** exact error that occurred. This usually means GTK+ is incorrectly installed."])
174 175 176 177
          CFLAGS="$ac_save_CFLAGS"
          LIBS="$ac_save_LIBS"
       fi
     fi
178 179
     GTK_CFLAGS=""
     GTK_LIBS=""
180 181
     ifelse([$3], , :, [$3])
  fi
182 183 184
  AC_SUBST(GTK_CFLAGS)
  AC_SUBST(GTK_LIBS)
  rm -f conf.gtktest
185
])
186

187
dnl GTK_CHECK_BACKEND(BACKEND-NAME [, MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
188 189 190
dnl   Tests for BACKEND-NAME in the GTK targets list
dnl
AC_DEFUN([GTK_CHECK_BACKEND],
191
[m4_warn([obsolete], [GTK_CHECK_BACKEND is deprecated, use PKG_CHECK_MODULES([GTK_X11], [gtk+-x11-3.0]) or similar instead])
192 193
  pkg_config_args=ifelse([$1],,gtk+-3.0, gtk+-$1-3.0)
  min_gtk_version=ifelse([$2],,3.0.0,$2)
194
  pkg_config_args="$pkg_config_args >= $min_gtk_version"
195

196 197
  PKG_PROG_PKG_CONFIG([0.16])
  AS_IF([test -z "$PKG_CONFIG"], [AC_MSG_ERROR([No pkg-config found])])
198

199
  if $PKG_CONFIG $pkg_config_args ; then
200
    target_found=yes
201
  else
202
    target_found=no
203 204 205
  fi

  if test "x$target_found" = "xno"; then
206
    ifelse([$4],,[AC_MSG_ERROR([Backend $backend not found.])],[$4])
207
  else
208
    ifelse([$3],,[:],[$3])
209 210
  fi
])