]> Pileus Git - ~andy/gtk/blob - configure.in
configure.in: require GLib 1.1.5
[~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=5
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 changequote(,)dnl
95 if test "x$GCC" = "xyes"; then
96   case " $CFLAGS " in
97   *[\ \ ]-Wall[\ \      ]*) ;;
98   *) CFLAGS="$CFLAGS -Wall" ;;
99   esac
100
101   if test "x$enable_ansi" = "xyes"; then
102     case " $CFLAGS " in
103     *[\ \       ]-ansi[\ \      ]*) ;;
104     *) CFLAGS="$CFLAGS -ansi" ;;
105     esac
106
107     case " $CFLAGS " in
108     *[\ \       ]-pedantic[\ \  ]*) ;;
109     *) CFLAGS="$CFLAGS -pedantic" ;;
110     esac
111   fi
112 fi
113 changequote([,])dnl
114
115 # define a MAINT-like variable REBUILD which is set if Perl
116 # and awk are found, so autogenerated sources can be rebuilt
117
118 AC_PROG_AWK
119 AC_CHECK_PROGS(PERL, perl5 perl)
120
121 # We would like indent, but don't require it.
122 AC_CHECK_PROG(INDENT, indent, indent)
123
124 REBUILD=\#
125 if test -n "$PERL" && perl -v | grep 'version 5.' > /dev/null ; then
126   if test -n "$AWK" ; then 
127     REBUILD=
128   fi
129 fi
130 AC_SUBST(REBUILD)
131
132 dnl The DU4 header files don't provide library prototypes unless 
133 dnl -std1 is given to the native cc.
134 AC_MSG_CHECKING([for extra flags to get ANSI library prototypes])
135
136 gtk_save_LIBS=$LIBS
137 LIBS="$LIBS -lm"
138 AC_TRY_RUN([#include <math.h>
139              int main (void) { return (log(1) != log(1.)); }],
140      AC_MSG_RESULT(none needed),
141      gtk_save_CFLAGS=$CFLAGS
142      CFLAGS="$CFLAGS -std1"
143      AC_TRY_RUN([#include <math.h>
144                  int main (void) { return (log(1) != log(1.)); }],
145          AC_MSG_RESULT(-std1),
146          AC_MSG_RESULT()
147          CFLAGS=$gtk_save_CFLAGS
148          AC_MSG_WARN(
149                 [No ANSI prototypes found in library. (-std1 didn't work.)])
150      )
151 )
152 LIBS=$gtk_save_LIBS
153
154 dnl NeXTStep cc seems to need this
155 AC_MSG_CHECKING([for extra flags for POSIX compliance])
156 AC_TRY_COMPILE([#include <dirent.h>], [DIR *dir;],
157   AC_MSG_RESULT(none needed),
158   gtk_save_CFLAGS=$CFLAGS
159   CFLAGS="$CFLAGS -posix"
160   AC_TRY_COMPILE([#include <dirent.h>], [DIR *dir;],
161     AC_MSG_RESULT(-posix),
162     AC_MSG_RESULT()
163     CFLAGS=$gtk_save_CFLAGS
164     AC_MSG_WARN([Could not determine POSIX flag. (-posix didn't work.)])))
165
166 if test "x$enable_xim" = "xyes"; then
167   CFLAGS="$CFLAGS -DUSE_XIM"
168 fi
169
170 if test x$with_glib = xyes ; then
171   AC_MSG_ERROR([
172 *** Directory must be specified for --with-glib])
173 fi
174
175 if test x$with_glib = x ; then 
176   # Look for separately installed glib
177
178   AM_PATH_GLIB(1.1.5,,
179     AC_MSG_ERROR([
180 *** GLIB 1.1.5 or better is required. The latest version of GLIB
181 *** is always available from ftp://ftp.gtk.org.]),
182     gmodule)
183
184   glib_cflags=$GLIB_CFLAGS
185   glib_libs=$GLIB_LIBS
186 else
187   # Use uninstalled glib (assume they got the version right)
188
189   GLIB_CONFIG=$with_glib/glib-config
190   if test -x $GLIB_CONFIG ; then 
191     :
192   else
193     AC_MSG_ERROR([GLIB directory ($with_glib) not present or not configured])
194   fi
195
196   # For use in gtk-config
197   glib_cflags=`$GLIB_CONFIG --cflags`
198   glib_libs=`$GLIB_CONFIG --libs`
199
200   glib_release=`$GLIB_CONFIG --version | sed 's%\\.[[0-9]]*$%%'`
201
202   # canonicalize relative paths
203   case $with_glib in 
204     /*)
205       glib_dir=$with_glib
206       ;;
207     *)
208       glib_dir="\$(top_builddir)/$with_glib"
209       ;;
210   esac
211
212   GLIB_CFLAGS="-I$glib_dir"
213   GLIB_LIBS=$glib_dir/libglib-$glib_release.la
214
215   AC_SUBST(GLIB_CFLAGS)
216   AC_SUBST(GLIB_LIBS)
217 fi
218
219 AC_SUBST(glib_cflags)
220 AC_SUBST(glib_libs)
221
222 # Find the X11 include and library directories
223 AC_PATH_X
224 AC_PATH_XTRA
225
226 if test "x$x_includes" = "x"; then
227   x_includes="/usr/include"
228 fi
229
230 saved_cflags="$CFLAGS"
231 saved_ldflags="$LDFLAGS"
232
233 CFLAGS="$CFLAGS $X_CFLAGS"
234 LDFLAGS="$LDFLAGS $X_LDFLAGS $X_LIBS"
235
236 if test "x$no_x" = "xyes"; then 
237   AC_MSG_ERROR([
238 *** X libraries or include files not found. Check 'config.log' for 
239 *** more details.])
240 fi
241
242 # Checks for libraries.
243 # Check for the X11 library
244 AC_CHECK_LIB(X11, XOpenDisplay, x_libs="-lX11 $X_EXTRA_LIBS", 
245   AC_MSG_ERROR([*** libX11 not found. Check 'config.log' for more details.]),
246   $X_EXTRA_LIBS)
247
248 if test "x$enable_shm" = "xyes"; then
249   # Check for the Xext library (needed for XShm extention)
250   AC_CHECK_LIB(Xext, XShmAttach, 
251       x_libs="-lXext $x_libs", 
252       # On AIX, it is in XextSam instead, but we still need -lXext
253       AC_CHECK_LIB(XextSam, XShmAttach, 
254           x_libs="-lXextSam -lXext $x_libs", 
255           no_xext_lib=yes, $x_libs),
256       $x_libs)
257 fi
258
259 # Check for shaped window extension
260
261 AC_CHECK_LIB(Xext, XShapeCombineMask,
262       if test -z "`echo $x_libs | grep "\-lXext" 2> /dev/null`"; then
263            x_libs="-lXext $x_libs"
264       fi
265       AC_DEFINE(HAVE_SHAPE_EXT),
266       ,
267       $x_libs)
268
269 # Check for XConvertCase (X11R6 specific)
270
271 AC_CHECK_LIB(X11, XConvertCase,
272       AC_DEFINE(HAVE_XCONVERTCASE),
273       ,
274       $x_libs)
275
276 x_cflags="$X_CFLAGS"
277 x_ldflags="$X_LDFLAGS $X_LIBS"
278
279 # set up things for XInput
280
281 if test "x$with_xinput" = "xgxi" || test "x$with_xinput" = "xyes"; then
282   AC_DEFINE(XINPUT_GXI)
283   xinput_progs=gxid
284   x_libs="-lXi $x_libs"
285 elif test "x$with_xinput" = "xxfree"; then
286   AC_DEFINE(XINPUT_XFREE)
287   x_libs="-lXi $x_libs"
288 else
289   AC_DEFINE(XINPUT_NONE)
290 fi
291
292 # Threads
293
294 CFLAGS="$saved_cflags"
295 LDFLAGS="$saved_ldflags"
296
297 if test "x$with_threads" = "xposix" || test "x$with_threads" = "xyes"; then
298   AC_CHECK_LIB(pthread, pthread_attr_init, 
299     [AC_DEFINE(USE_PTHREADS)
300     x_libs="$x_libs -lpthread"
301     CFLAGS="$CFLAGS -D_REENTRANT"],
302     # AIX has libpthreads, cause they're special. Special friends (TM)
303     AC_CHECK_LIB(pthreads, pthread_attr_init,
304       [AC_DEFINE(USE_PTHREADS)
305       x_libs="$x_libs -lpthreads"
306       CFLAGS="$CFLAGS -D_REENTRANT -D_THREAD_SAFE"]))
307 fi
308
309 AC_SUBST(x_cflags)
310 AC_SUBST(x_includes)
311 AC_SUBST(x_ldflags)
312 AC_SUBST(x_libs)
313 AC_SUBST(xinput_progs)
314
315 if test "x$enable_shm" = "xyes"; then
316   # Check for shared memory
317   AC_CHECK_HEADER(sys/ipc.h, AC_DEFINE(HAVE_IPC_H), no_sys_ipc=yes)
318   AC_CHECK_HEADER(sys/shm.h, AC_DEFINE(HAVE_SHM_H), no_sys_shm=yes)
319
320   # Check whether shmctl IPC_RMID allowes subsequent attaches
321   if test "$ac_cv_header_sys_shm_h" = "yes"; then
322     AC_MSG_CHECKING(whether shmctl IPC_RMID allowes subsequent attaches)
323     AC_TRY_RUN([
324           #include <sys/types.h>
325           #include <sys/ipc.h>
326           #include <sys/shm.h>
327           int main()
328           {
329             int id;
330             char *shmaddr;
331           id = shmget (IPC_PRIVATE, 4, IPC_CREAT | 0777);
332           if (id == -1)
333             exit (2);
334             shmaddr = shmat (id, 0, 0);
335             shmctl (id, IPC_RMID, 0);
336             if ((char*) shmat (id, 0, 0) == (char*) -1)
337             {
338               shmdt (shmaddr);
339               exit (1);
340             }
341             shmdt (shmaddr);
342             shmdt (shmaddr);
343             exit (0);
344           }
345       ],
346       AC_DEFINE(IPC_RMID_DEFERRED_RELEASE)
347         AC_MSG_RESULT(yes),
348       AC_MSG_RESULT(no),
349       AC_MSG_RESULT(assuming no))
350   fi
351
352   # Check for the X shared memory extension header file
353   AC_MSG_CHECKING(X11/extensions/XShm.h)
354   if test "x$no_xext_lib" = "xyes"; then
355     AC_MSG_RESULT(no)
356     no_xshm=yes
357   else
358     if test -f "$x_includes/X11/extensions/XShm.h"; then
359       AC_MSG_RESULT(yes)
360       AC_DEFINE(HAVE_XSHM_H)
361     else
362       AC_MSG_RESULT(no)
363       no_xshm=yes
364     fi
365   fi
366 fi
367
368 # Check for private display resource base variable
369 AC_MSG_CHECKING(resource base field in XDisplay)
370 AC_CACHE_VAL(gtk_cv_display_resource_base,
371 [AC_TRY_RUN([
372 #define XLIB_ILLEGAL_ACCESS
373 #include <X11/Xlib.h>
374
375 int
376 main ()
377 {
378   Display *display;
379
380   return 0;
381
382   display->resource_base;
383 }],
384 gtk_cv_display_resource_base="resource_base",
385 gtk_cv_display_resource_base="private3")])
386 AC_MSG_RESULT($gtk_cv_display_resource_base)
387 AC_DEFINE_UNQUOTED(RESOURCE_BASE, gdk_display->$gtk_cv_display_resource_base)
388
389 # Check if X_LOCALE definition is necessary
390
391 AC_MSG_CHECKING(need -DX_LOCALE)
392
393 AC_TRY_RUN([
394 #include <stdio.h>
395 #include <locale.h>
396
397 int
398 main ()
399 {
400   return setlocale (LC_ALL, "${with_locale}") == NULL;
401 }],
402 need_x_locale=no,
403 need_x_locale=yes)
404 AC_MSG_RESULT($need_x_locale)
405
406 if test $need_x_locale = yes; then
407   CFLAGS="$CFLAGS -DX_LOCALE"
408 fi
409
410 # Checks for header files.
411 AC_HEADER_STDC
412
413 # Checks for typedefs, structures, and compiler characteristics.
414 AC_C_CONST
415
416 # Checks for library functions.
417 AC_TYPE_SIGNAL
418 AC_FUNC_MMAP
419
420 # Check if <sys/select.h> needs to be included for fd_set
421 AC_MSG_CHECKING([for fd_set])
422 AC_TRY_COMPILE([#include <sys/types.h>],
423         [fd_set readMask, writeMask;], gtk_ok=yes, gtk_ok=no)
424 if test $gtk_ok = yes; then
425     AC_MSG_RESULT([yes, found in sys/types.h])
426 else
427     AC_HEADER_EGREP(fd_mask, sys/select.h, gtk_ok=yes)
428     if test $gtk_ok = yes; then
429         AC_DEFINE(HAVE_SYS_SELECT_H)
430         AC_MSG_RESULT([yes, found in sys/select.h])
431     else
432         AC_DEFINE(NO_FD_SET)
433         AC_MSG_RESULT(no)
434     fi
435 fi
436
437 # Duplicate `widechar' tests from `glib'.
438 # Check for wchar.h
439 if test x = y; then
440   # will not be executed
441   # hack so as not to update `acconfig.h'
442   AC_CHECK_HEADERS(wchar.h wctype.h)
443   AC_CHECK_FUNCS(broken_wctype)
444 fi
445
446 AC_MSG_CHECKING(for wchar.h)
447 AC_TRY_CPP([#include <wchar.h>], gtk_ok=yes, gtk_ok=no)
448 if test $gtk_ok = yes; then
449    ac_kludge=HAVE_WCHAR_H
450    AC_DEFINE($ac_kludge)
451 fi
452 AC_MSG_RESULT($gtk_ok)
453
454 # Check for wctype.h (for iswalnum)
455
456 AC_MSG_CHECKING(for wctype.h)
457 AC_TRY_CPP([#include <wctype.h>], gtk_ok=yes, gtk_ok=no)
458 if test $gtk_ok = yes; then
459    ac_kludge=HAVE_WCTYPE_H
460    AC_DEFINE($ac_kludge)
461 fi
462 AC_MSG_RESULT($gtk_ok)
463
464 # in Solaris 2.5, `iswalnum' is in -lw
465 GDK_WLIBS=
466 AC_CHECK_FUNC(iswalnum,,[AC_CHECK_LIB(w,iswalnum,GDK_WLIBS=-lw)])
467
468 # The following is necessary for Linux libc-5.4.38
469 oLIBS="$LIBS"
470 LIBS="$LIBS $GDK_WLIBS"
471 AC_MSG_CHECKING(if iswalnum() and friends are properly defined)
472 AC_TRY_LINK([#include <stdlib.h>],[
473 #if (defined(HAVE_WCTYPE_H) || defined(HAVE_WCHAR_H))
474 #  ifdef HAVE_WCTYPE_H
475 #    include <wctype.h>
476 #  else
477 #    ifdef HAVE_WCHAR_H
478 #      include <wchar.h>
479 #    endif
480 #  endif
481 #else
482 #  define iswalnum(c) ((wchar_t)(c) <= 0xFF && isalnum(c))
483 #endif
484 iswalnum((wchar_t) 0);
485 ], gtk_ok=yes, gtk_ok=no)
486 LIBS="$oLIBS"
487
488 if test $gtk_ok = no; then
489    ac_kludge=HAVE_BROKEN_WCTYPE
490    AC_DEFINE($ac_kludge)
491    GDK_WLIBS=
492 fi
493 AC_MSG_RESULT($gtk_ok)
494 AC_SUBST(GDK_WLIBS)
495
496 AC_OUTPUT([
497 Makefile
498 gtk-config
499 docs/Makefile
500 gdk/Makefile
501 gtk/Makefile
502 gtk/gtkfeatures.h
503 ], [chmod +x gtk-config])