gtk-2.0.m4 8.3 KB
Newer Older
1
2
3
# Configure paths for GTK+
# Owen Taylor     97-11-3

Owen Taylor's avatar
Owen Taylor committed
4
dnl AM_PATH_GTK_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
5
6
dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS
dnl
Owen Taylor's avatar
Owen Taylor committed
7
AC_DEFUN(AM_PATH_GTK_2_0,
8
[dnl 
Owen Taylor's avatar
Owen Taylor committed
9
dnl Get the cflags and libraries from the gtk-config-2.0 script
10
dnl
11
12
13
14
AC_ARG_WITH(gtk-prefix,[  --with-gtk-prefix=PFX   Prefix where GTK is installed (optional)],
            gtk_config_prefix="$withval", gtk_config_prefix="")
AC_ARG_WITH(gtk-exec-prefix,[  --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)],
            gtk_config_exec_prefix="$withval", gtk_config_exec_prefix="")
15
16
AC_ARG_ENABLE(gtktest, [  --disable-gtktest       Do not try to compile and run a test GTK program],
		    , enable_gtktest=yes)
17

Owen Taylor's avatar
Owen Taylor committed
18
19
20
21
  for module in . $4
  do
      case "$module" in
         gthread) 
22
             gtk_config_args="$gtk_config_args gthread"
Owen Taylor's avatar
Owen Taylor committed
23
24
25
26
         ;;
      esac
  done

27
28
  if test x$gtk_config_exec_prefix != x ; then
     gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix"
Owen Taylor's avatar
Owen Taylor committed
29
30
     if test x${GTK_CONFIG_2_0+set} != xset ; then
        GTK_CONFIG_2_0=$gtk_config_exec_prefix/bin/gtk-config-2.0
31
32
33
34
     fi
  fi
  if test x$gtk_config_prefix != x ; then
     gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix"
Owen Taylor's avatar
Owen Taylor committed
35
36
     if test x${GTK_CONFIG_2_0+set} != xset ; then
        GTK_CONFIG_2_0=$gtk_config_prefix/bin/gtk-config-2.0
37
38
39
     fi
  fi

Owen Taylor's avatar
Owen Taylor committed
40
  AC_PATH_PROG(GTK_CONFIG_2_0, gtk-config-2.0, no)
41
  min_gtk_version=ifelse([$1], ,1.3.1,$1)
42
43
  AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
  no_gtk=""
Owen Taylor's avatar
Owen Taylor committed
44
  if test "$GTK_CONFIG_2_0" = "no" ; then
45
46
    no_gtk=yes
  else
Owen Taylor's avatar
Owen Taylor committed
47
48
49
    GTK_CFLAGS=`$GTK_CONFIG_2_0 $gtk_config_args --cflags`
    GTK_LIBS=`$GTK_CONFIG_2_0 $gtk_config_args --libs`
    gtk_config_major_version=`$GTK_CONFIG_2_0 $gtk_config_args --version | \
50
           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
Owen Taylor's avatar
Owen Taylor committed
51
    gtk_config_minor_version=`$GTK_CONFIG_2_0 $gtk_config_args --version | \
52
           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
Owen Taylor's avatar
Owen Taylor committed
53
    gtk_config_micro_version=`$GTK_CONFIG_2_0 $gtk_config_args --version | \
54
55
56
57
58
           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
    if test "x$enable_gtktest" = "xyes" ; then
      ac_save_CFLAGS="$CFLAGS"
      ac_save_LIBS="$LIBS"
      CFLAGS="$CFLAGS $GTK_CFLAGS"
59
      LIBS="$GTK_LIBS $LIBS"
60
61
dnl
dnl Now check if the installed GTK is sufficiently new. (Also sanity
Owen Taylor's avatar
Owen Taylor committed
62
dnl checks the results of gtk-config-2.0 to some extent
63
dnl
64
65
      rm -f conf.gtktest
      AC_TRY_RUN([
66
67
#include <gtk/gtk.h>
#include <stdio.h>
Owen Taylor's avatar
Owen Taylor committed
68
#include <stdlib.h>
69
70
71
72
73

int 
main ()
{
  int major, minor, micro;
Tim Janik's avatar
Tim Janik committed
74
  char *tmp_version;
75

76
77
  system ("touch conf.gtktest");

Tim Janik's avatar
Tim Janik committed
78
79
80
  /* HP/UX 9 (%@#!) writes to sscanf strings */
  tmp_version = g_strdup("$min_gtk_version");
  if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
81
82
83
84
     printf("%s, bad version string\n", "$min_gtk_version");
     exit(1);
   }

85
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))
    {
Owen Taylor's avatar
Owen Taylor committed
89
      printf("\n*** 'gtk-config-2.0 --version' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n", 
90
91
             $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
92
      printf ("*** was found! If gtk-config-2.0 was correct, then it is best\n");
93
94
95
96
      printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
      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
97
98
      printf("*** If gtk-config-2.0 was wrong, set the environment variable GTK_CONFIG_2_0\n");
      printf("*** to point to the correct copy of gtk-config-2.0, and remove the file config.cache\n");
99
100
      printf("*** before re-running configure\n");
    } 
101
#if defined (GTK_MAJOR_VERSION) && defined (GTK_MINOR_VERSION) && defined (GTK_MICRO_VERSION)
Owen Taylor's avatar
Owen Taylor committed
102
103
104
105
106
107
108
109
110
  else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
	   (gtk_minor_version != GTK_MINOR_VERSION) ||
           (gtk_micro_version != GTK_MICRO_VERSION))
    {
      printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
	     GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
      printf("*** library (version %d.%d.%d)\n",
	     gtk_major_version, gtk_minor_version, gtk_micro_version);
    }
111
#endif /* defined (GTK_MAJOR_VERSION) ... */
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
  else
    {
      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)))
      {
        return 0;
       }
     else
      {
        printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
               gtk_major_version, gtk_minor_version, gtk_micro_version);
        printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
	       major, minor, micro);
        printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
        printf("***\n");
        printf("*** If you have already installed a sufficiently new version, this error\n");
Owen Taylor's avatar
Owen Taylor committed
129
        printf("*** probably means that the wrong copy of the gtk-config-2.0 shell script is\n");
130
        printf("*** being found. The easiest way to fix this is to remove the old version\n");
Owen Taylor's avatar
Owen Taylor committed
131
132
        printf("*** of GTK+, but you can also set the GTK_CONFIG_2_0 environment to point to the\n");
        printf("*** correct copy of gtk-config-2.0. (In this case, you will have to\n");
133
134
135
136
137
        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;
138
139
}
],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
140
141
142
       CFLAGS="$ac_save_CFLAGS"
       LIBS="$ac_save_LIBS"
     fi
143
  fi
144
  if test "x$no_gtk" = x ; then
145
     AC_MSG_RESULT(yes (version $gtk_config_major_version.$gtk_config_minor_version.$gtk_config_micro_version))
146
147
148
     ifelse([$2], , :, [$2])     
  else
     AC_MSG_RESULT(no)
Owen Taylor's avatar
Owen Taylor committed
149
150
     if test "$GTK_CONFIG_2_0" = "no" ; then
       echo "*** The gtk-config-2.0 script installed by GTK could not be found"
151
       echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in"
Owen Taylor's avatar
Owen Taylor committed
152
153
       echo "*** your path, or set the GTK_CONFIG_2_0 environment variable to the"
       echo "*** full path to gtk-config-2.0."
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
     else
       if test -f conf.gtktest ; then
        :
       else
          echo "*** Could not run GTK test program, checking why..."
          CFLAGS="$CFLAGS $GTK_CFLAGS"
          LIBS="$LIBS $GTK_LIBS"
          AC_TRY_LINK([
#include <gtk/gtk.h>
#include <stdio.h>
],      [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
        [ echo "*** The test program compiled, but did not run. This usually means"
          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"
          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"
          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
          echo "***"
          echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
          echo "*** came with the system with the command"
          echo "***"
          echo "***    rpm --erase --nodeps gtk gtk-devel" ],
        [ echo "*** The test program failed to compile or link. See the file config.log for the"
          echo "*** exact error that occured. This usually means GTK was incorrectly installed"
          echo "*** or that you have moved GTK since it was installed. In the latter case, you"
Owen Taylor's avatar
Owen Taylor committed
182
          echo "*** may want to edit the gtk-config-2.0 script: $GTK_CONFIG_2_0" ])
183
184
185
186
          CFLAGS="$ac_save_CFLAGS"
          LIBS="$ac_save_LIBS"
       fi
     fi
187
188
189
190
191
192
     GTK_CFLAGS=""
     GTK_LIBS=""
     ifelse([$3], , :, [$3])
  fi
  AC_SUBST(GTK_CFLAGS)
  AC_SUBST(GTK_LIBS)
193
  rm -f conf.gtktest
194
])