]> Pileus Git - ~andy/gtk/blob - configure.in
Require GLib 1.1.4
[~andy/gtk] / configure.in
1 # Process this file with autoconf to produce a configure script.
2 AC_INIT(gdk/gdktypes.h)
3
4 # Save this value here, since automake will set cflags later
5 cflags_set=${CFLAGS+set}
6
7 # Making releases:
8 #   GTK_MICRO_VERSION += 1;
9 #   GTK_INTERFACE_AGE += 1;
10 #   GTK_BINARY_AGE += 1;
11 # if any functions have been added, set GTK_INTERFACE_AGE to 0.
12 # if backwards compatibility has been broken,
13 # set GTK_BINARY_AGE and GTK_INTERFACE_AGE to 0.
14 #
15 GTK_MAJOR_VERSION=1
16 GTK_MINOR_VERSION=1
17 GTK_MICRO_VERSION=3
18 GTK_INTERFACE_AGE=0
19 GTK_BINARY_AGE=0
20 GTK_VERSION=$GTK_MAJOR_VERSION.$GTK_MINOR_VERSION.$GTK_MICRO_VERSION
21 AC_SUBST(GTK_MAJOR_VERSION)
22 AC_SUBST(GTK_MINOR_VERSION)
23 AC_SUBST(GTK_MICRO_VERSION)
24 AC_SUBST(GTK_INTERFACE_AGE)
25 AC_SUBST(GTK_BINARY_AGE)
26 AC_SUBST(GTK_VERSION)
27
28 # libtool versioning
29 LT_RELEASE=$GTK_MAJOR_VERSION.$GTK_MINOR_VERSION
30 LT_CURRENT=`expr $GTK_MICRO_VERSION - $GTK_INTERFACE_AGE`
31 LT_REVISION=$GTK_INTERFACE_AGE
32 LT_AGE=`expr $GTK_BINARY_AGE - $GTK_INTERFACE_AGE`
33 AC_SUBST(LT_RELEASE)
34 AC_SUBST(LT_CURRENT)
35 AC_SUBST(LT_REVISION)
36 AC_SUBST(LT_AGE)
37
38 # For automake.
39 VERSION=$GTK_VERSION
40 PACKAGE=gtk+
41
42 # Save this value here, since automake will set cflags later
43 cflags_set=${CFLAGS+set}
44
45 dnl Initialize automake stuff
46 AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
47
48 # Specify a configuration file
49 AM_CONFIG_HEADER(config.h)
50
51 dnl Initialize libtool
52 AM_PROG_LIBTOOL
53
54 dnl Initialize maintainer mode
55 AM_MAINTAINER_MODE
56
57 AC_CANONICAL_HOST
58
59 AC_ARG_ENABLE(shm, [  --enable-shm            support shared memory if available [default=yes]],
60                    echo $enable_shm, enable_shm="yes")
61 AC_ARG_ENABLE(debug, [  --enable-debug=[no/minimum/yes] turn on debugging [default=minimum]],,enable_debug=minimum)
62 AC_ARG_ENABLE(ansi, [  --enable-ansi           turn on strict ansi [default=no]],
63                     , enable_ansi=no)
64 AC_ARG_WITH(glib, [  --with-glib=DIR         Use uninstalled copy of glib])
65 AC_ARG_ENABLE(xim, [  --enable-xim            support XIM [default=yes]],
66                         echo $enable_xim, enable_xim="yes")
67 AC_ARG_WITH(locale, [  --with-locale=LOCALE    locale name you want to use ])
68
69 AC_ARG_WITH(xinput, [  --with-xinput=[no/gxi/xfree] support XInput ])
70 AC_ARG_WITH(threads, [  --with-threads=[posix] support threading ])
71
72 if test "x$enable_debug" = "xyes"; then
73   test "$cflags_set" = set || CFLAGS="$CFLAGS -g"
74   CFLAGS="$CFLAGS -DG_ENABLE_DEBUG"
75 else
76   if test "x$enable_debug" = "xno"; then
77     CFLAGS="$CFLAGS -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS -DGTK_NO_CHECK_CASTS"
78   else
79     CFLAGS="$CFLAGS -DGTK_NO_CHECK_CASTS"
80   fi
81 fi
82
83 AC_DEFINE_UNQUOTED(GTK_COMPILED_WITH_DEBUGGING, "${enable_debug}")
84
85 # Build time sanity check...
86 AM_SANITY_CHECK
87
88 # Checks for programs.
89 AC_PROG_CC
90 AM_PROG_CC_STDC
91 AC_PROG_INSTALL
92 AC_PROG_MAKE_SET
93
94 if test "x$GCC" = "xyes"; then
95   if test -z "`echo "$CFLAGS" | grep "\-Wall" 2> /dev/null`" ; then
96     CFLAGS="$CFLAGS -Wall"
97   fi
98
99   if test "x$enable_ansi" = "xyes"; then
100     if test -z "`echo "$CFLAGS" | grep "\-ansi" 2> /dev/null`" ; then
101       CFLAGS="$CFLAGS -ansi"
102     fi
103
104     if test -z "`echo "$CFLAGS" | grep "\-pedantic" 2> /dev/null`" ; then
105       CFLAGS="$CFLAGS -pedantic"
106     fi
107   fi
108 fi
109
110 # define a MAINT-like variable REBUILD which is set if Perl
111 # and awk are found, so autogenerated sources can be rebuilt
112
113 AC_PROG_AWK
114 AC_CHECK_PROGS(PERL, perl5 perl)
115
116 # We would like indent, but don't require it.
117 AC_CHECK_PROG(INDENT, indent, indent)
118
119 REBUILD=\#
120 if test -n "$PERL" && perl -v | grep 'version 5.' > /dev/null ; then
121   if test -n "$AWK" ; then 
122     REBUILD=
123   fi
124 fi
125 AC_SUBST(REBUILD)
126
127 dnl The DU4 header files don't provide library prototypes unless 
128 dnl -std1 is given to the native cc.
129 AC_MSG_CHECKING([for extra flags to get ANSI library prototypes])
130
131 gtk_save_LIBS=$LIBS
132 LIBS="$LIBS -lm"
133 AC_TRY_RUN([#include <math.h>
134              int main (void) { return (log(1) != log(1.)); }],
135      AC_MSG_RESULT(none needed),
136      gtk_save_CFLAGS=$CFLAGS
137      CFLAGS="$CFLAGS -std1"
138      AC_TRY_RUN([#include <math.h>
139                  int main (void) { return (log(1) != log(1.)); }],
140          AC_MSG_RESULT(-std1),
141          AC_MSG_RESULT()
142          CFLAGS=$gtk_save_CFLAGS
143          AC_MSG_WARN(
144                 [No ANSI prototypes found in library. (-std1 didn't work.)])
145      )
146 )
147 LIBS=$gtk_save_LIBS
148
149 dnl NeXTStep cc seems to need this
150 AC_MSG_CHECKING([for extra flags for POSIX compliance])
151 AC_TRY_COMPILE([#include <dirent.h>], [DIR *dir;],
152   AC_MSG_RESULT(none needed),
153   gtk_save_CFLAGS=$CFLAGS
154   CFLAGS="$CFLAGS -posix"
155   AC_TRY_COMPILE([#include <dirent.h>], [DIR *dir;],
156     AC_MSG_RESULT(-posix),
157     AC_MSG_RESULT()
158     CFLAGS=$gtk_save_CFLAGS
159     AC_MSG_WARN([Could not determine POSIX flag. (-posix didn't work.)])))
160
161 if test "x$enable_xim" = "xyes"; then
162   CFLAGS="$CFLAGS -DUSE_XIM"
163 fi
164
165 if test x$with_glib = xyes ; then
166   AC_MSG_ERROR([
167 *** Directory must be specified for --with-glib])
168 fi
169
170 if test x$with_glib = x ; then 
171   # Look for separately installed glib
172
173   AM_PATH_GLIB(1.1.4,,
174     AC_MSG_ERROR([
175 *** GLIB 1.1.4 or better is required. The latest version of GLIB
176 *** is always available from ftp://ftp.gtk.org.]),
177     gmodule)
178
179   glib_cflags=$GLIB_CFLAGS
180   glib_libs=$GLIB_LIBS
181 else
182   # Use uninstalled glib (assume they got the version right)
183
184   if test -x $with_glib/glib-config ; then 
185     :
186   else
187     AC_MSG_ERROR([GLIB directory ($with_glib) not present or not configured])
188   fi
189
190   # For use in gtk-config
191   glib_cflags=`$with_glib/glib-config --cflags`
192   glib_libs=`$with_glib/glib-config --libs`
193
194   glib_release=`$with_glib/glib-config --version | sed 's%\\.[[0-9]]*$%%'`
195
196   # canonicalize relative paths
197   case $with_glib in 
198     /*)
199       glib_dir=$with_glib
200       ;;
201     *)
202       glib_dir="\$(top_builddir)/$with_glib"
203       ;;
204   esac
205
206   GLIB_CFLAGS="-I$glib_dir"
207   GLIB_LIBS=$glib_dir/libglib-$glib_release.la
208
209   AC_SUBST(GLIB_CFLAGS)
210   AC_SUBST(GLIB_LIBS)
211 fi
212
213 AC_SUBST(glib_cflags)
214 AC_SUBST(glib_libs)
215
216 # Find the X11 include and library directories
217 AC_PATH_X
218 AC_PATH_XTRA
219
220 if test "x$x_includes" = "x"; then
221   x_includes="/usr/include"
222 fi
223
224 saved_cflags="$CFLAGS"
225 saved_ldflags="$LDFLAGS"
226
227 CFLAGS="$CFLAGS $X_CFLAGS"
228 LDFLAGS="$LDFLAGS $X_LDFLAGS $X_LIBS"
229
230 if test "x$no_x" = "xyes"; then 
231   AC_MSG_ERROR([
232 *** X libraries or include files not found. Check 'config.log' for 
233 *** more details.])
234 fi
235
236 # Checks for libraries.
237 # Check for the X11 library
238 AC_CHECK_LIB(X11, XOpenDisplay, x_libs="-lX11 $X_EXTRA_LIBS", 
239   AC_MSG_ERROR([*** libX11 not found. Check 'config.log' for more details.]),
240   $X_EXTRA_LIBS)
241
242 if test "x$enable_shm" = "xyes"; then
243   # Check for the Xext library (needed for XShm extention)
244   AC_CHECK_LIB(Xext, XShmAttach, 
245       x_libs="-lXext $x_libs", 
246       # On AIX, it is in XextSam instead, but we still need -lXext
247       AC_CHECK_LIB(XextSam, XShmAttach, 
248           x_libs="-lXextSam -lXext $x_libs", 
249           no_xext_lib=yes, $x_libs),
250       $x_libs)
251 fi
252
253 # Check for shaped window extension
254
255 AC_CHECK_LIB(Xext, XShapeCombineMask,
256       if test -z "`echo $x_libs | grep "\-lXext" 2> /dev/null`"; then
257            x_libs="-lXext $x_libs"
258       fi
259       AC_DEFINE(HAVE_SHAPE_EXT),
260       ,
261       $x_libs)
262
263 # Check for XConvertCase (X11R6 specific)
264
265 AC_CHECK_LIB(X11, XConvertCase,
266       AC_DEFINE(HAVE_XCONVERTCASE),
267       ,
268       $x_libs)
269
270 x_cflags="$X_CFLAGS"
271 x_ldflags="$X_LDFLAGS $X_LIBS"
272
273 # set up things for XInput
274
275 if test "x$with_xinput" = "xgxi" || test "x$with_xinput" = "xyes"; then
276   AC_DEFINE(XINPUT_GXI)
277   xinput_progs=gxid
278   x_libs="-lXi $x_libs"
279 elif test "x$with_xinput" = "xxfree"; then
280   AC_DEFINE(XINPUT_XFREE)
281   x_libs="-lXi $x_libs"
282 else
283   AC_DEFINE(XINPUT_NONE)
284 fi
285
286 # Threads
287
288 if test "x$with_threads" = "xposix" || test "x$with_threads" = "xyes"; then
289   AC_CHECK_LIB(pthread, pthread_attr_init, 
290     AC_DEFINE(USE_PTHREADS)
291     x_libs="$x_libs -lpthread"
292     CFLAGS="$CFLAGS -D_REENTRANT") 
293 fi
294
295 AC_SUBST(x_cflags)
296 AC_SUBST(x_includes)
297 AC_SUBST(x_ldflags)
298 AC_SUBST(x_libs)
299 AC_SUBST(xinput_progs)
300
301 CFLAGS="$saved_cflags"
302 LDFLAGS="$saved_ldflags"
303
304 if test "x$enable_shm" = "xyes"; then
305   # Check for shared memory
306   AC_CHECK_HEADER(sys/ipc.h, AC_DEFINE(HAVE_IPC_H), no_sys_ipc=yes)
307   AC_CHECK_HEADER(sys/shm.h, AC_DEFINE(HAVE_SHM_H), no_sys_shm=yes)
308
309   # Check whether shmctl IPC_RMID allowes subsequent attaches
310   if test "$ac_cv_header_sys_shm_h" = "yes"; then
311     AC_MSG_CHECKING(whether shmctl IPC_RMID allowes subsequent attaches)
312     AC_TRY_RUN([
313           #include <sys/types.h>
314           #include <sys/ipc.h>
315           #include <sys/shm.h>
316           int main()
317           {
318             int id;
319             char *shmaddr;
320           id = shmget (IPC_PRIVATE, 4, IPC_CREAT | 0777);
321           if (id == -1)
322             exit (2);
323             shmaddr = shmat (id, 0, 0);
324             shmctl (id, IPC_RMID, 0);
325             if ((char*) shmat (id, 0, 0) == (char*) -1)
326             {
327               shmdt (shmaddr);
328               exit (1);
329             }
330             shmdt (shmaddr);
331             shmdt (shmaddr);
332             exit (0);
333           }
334       ],
335       AC_DEFINE(IPC_RMID_DEFERRED_RELEASE)
336         AC_MSG_RESULT(yes),
337       AC_MSG_RESULT(no),
338       AC_MSG_RESULT(assuming no))
339   fi
340
341   # Check for the X shared memory extension header file
342   AC_MSG_CHECKING(X11/extensions/XShm.h)
343   if test "x$no_xext_lib" = "xyes"; then
344     AC_MSG_RESULT(no)
345     no_xshm=yes
346   else
347     if test -f "$x_includes/X11/extensions/XShm.h"; then
348       AC_MSG_RESULT(yes)
349       AC_DEFINE(HAVE_XSHM_H)
350     else
351       AC_MSG_RESULT(no)
352       no_xshm=yes
353     fi
354   fi
355 fi
356
357 # Check for private display resource base variable
358 AC_MSG_CHECKING(resource base field in XDisplay)
359 AC_CACHE_VAL(gtk_cv_display_resource_base,
360 [AC_TRY_RUN([
361 #define XLIB_ILLEGAL_ACCESS
362 #include <X11/Xlib.h>
363
364 int
365 main ()
366 {
367   Display *display;
368
369   return 0;
370
371   display->resource_base;
372 }],
373 gtk_cv_display_resource_base="resource_base",
374 gtk_cv_display_resource_base="private3")])
375 AC_MSG_RESULT($gtk_cv_display_resource_base)
376 AC_DEFINE_UNQUOTED(RESOURCE_BASE, gdk_display->$gtk_cv_display_resource_base)
377
378 # Check if X_LOCALE definition is necessary
379
380 AC_MSG_CHECKING(need -DX_LOCALE)
381
382 AC_TRY_RUN([
383 #include <stdio.h>
384 #include <locale.h>
385
386 int
387 main ()
388 {
389   return setlocale (LC_ALL, "${with_locale}") == NULL;
390 }],
391 need_x_locale=no,
392 need_x_locale=yes)
393 AC_MSG_RESULT($need_x_locale)
394
395 if test $need_x_locale = yes; then
396   CFLAGS="$CFLAGS -DX_LOCALE"
397 fi
398
399 # Checks for header files.
400 AC_HEADER_STDC
401
402 # Checks for typedefs, structures, and compiler characteristics.
403 AC_C_CONST
404
405 # Checks for endianness (needed by GdkRgb).
406 AC_C_BIGENDIAN
407
408 # Checks for library functions.
409 AC_TYPE_SIGNAL
410 AC_FUNC_MMAP
411
412 # Check if <sys/select.h> needs to be included for fd_set
413 AC_MSG_CHECKING([for fd_set])
414 AC_TRY_COMPILE([#include <sys/types.h>],
415         [fd_set readMask, writeMask;], gtk_ok=yes, gtk_ok=no)
416 if test $gtk_ok = yes; then
417     AC_MSG_RESULT([yes, found in sys/types.h])
418 else
419     AC_HEADER_EGREP(fd_mask, sys/select.h, gtk_ok=yes)
420     if test $gtk_ok = yes; then
421         AC_DEFINE(HAVE_SYS_SELECT_H)
422         AC_MSG_RESULT([yes, found in sys/select.h])
423     else
424         AC_DEFINE(NO_FD_SET)
425         AC_MSG_RESULT(no)
426     fi
427 fi
428
429 AC_OUTPUT([
430 Makefile
431 gtk-config
432 docs/Makefile
433 gdk/Makefile
434 gtk/Makefile
435 gtk/gtkfeatures.h
436 ], [chmod +x gtk-config])