ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/m4/gtk.m4
Revision: 1.1
Committed: 2005-07-01T05:54:20Z (19 years, 5 months ago) by gbeauche
Branch: MAIN
CVS Tags: nigel-build-17
Log Message:
Import m4 macros for external packages in case one would want to regenerate
a configure script without having those installed (e.g. on MacOS X).

File Contents

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