]> Pileus Git - ~andy/gtk/blob - configure.in
*** empty log message ***
[~andy/gtk] / configure.in
1 # Process this file with autoconf to produce a configure script.
2 AC_INIT(gdk/gdktypes.h)
3
4 # In the following, there are a the following variants
5 # of GLib cflags and libs variables
6 #
7 # GLIB_CFLAGS:  cflags for compiling libraries and example progs
8 # GLIB_LIBS:    libraries for linking example programs
9 # GLIB_DEPLIBS: libraries for linking libraries against
10 # glib_cflags:  cflags to store in gtk-config
11 # glib_libs:    libs to store in gtk-config
12 # glib_thread_cflags: cflags to store in gtk-config for gtk-config gthread
13 # glib_thread_libs:   libs to store in gtk-config for gtk-config gthread
14
15 # Save this value here, since automake will set cflags later
16 cflags_set=${CFLAGS+set}
17
18 dnl we to AC_DIVERT_PUSH/AC_DIVERT_POP these variable definitions so they
19 dnl are available for $ac_help expansion (don't we all *love* autoconf?)
20 AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)dnl
21 #
22 # Making releases:
23 #   GTK_MICRO_VERSION += 1;
24 #   GTK_INTERFACE_AGE += 1;
25 #   GTK_BINARY_AGE += 1;
26 # if any functions have been added, set GTK_INTERFACE_AGE to 0.
27 # if backwards compatibility has been broken,
28 # set GTK_BINARY_AGE and GTK_INTERFACE_AGE to 0.
29 #
30 GTK_MAJOR_VERSION=1
31 GTK_MINOR_VERSION=3
32 GTK_MICRO_VERSION=0
33 GTK_INTERFACE_AGE=0
34 GTK_BINARY_AGE=0
35 GTK_VERSION=$GTK_MAJOR_VERSION.$GTK_MINOR_VERSION.$GTK_MICRO_VERSION
36 dnl
37 AC_DIVERT_POP()dnl
38
39 AC_SUBST(GTK_MAJOR_VERSION)
40 AC_SUBST(GTK_MINOR_VERSION)
41 AC_SUBST(GTK_MICRO_VERSION)
42 AC_SUBST(GTK_INTERFACE_AGE)
43 AC_SUBST(GTK_BINARY_AGE)
44 AC_SUBST(GTK_VERSION)
45
46 # libtool versioning
47 LT_RELEASE=$GTK_MAJOR_VERSION.$GTK_MINOR_VERSION
48 LT_CURRENT=`expr $GTK_MICRO_VERSION - $GTK_INTERFACE_AGE`
49 LT_REVISION=$GTK_INTERFACE_AGE
50 LT_AGE=`expr $GTK_BINARY_AGE - $GTK_INTERFACE_AGE`
51 AC_SUBST(LT_RELEASE)
52 AC_SUBST(LT_CURRENT)
53 AC_SUBST(LT_REVISION)
54 AC_SUBST(LT_AGE)
55
56 # For automake.
57 VERSION=$GTK_VERSION
58 PACKAGE=gtk+
59
60 # Save this value here, since automake will set cflags later
61 cflags_set=${CFLAGS+set}
62
63 dnl Initialize automake stuff
64 AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
65
66 # Specify a configuration file
67 AM_CONFIG_HEADER(config.h)
68
69 dnl Initialize libtool
70 AM_PROG_LIBTOOL
71
72 dnl Initialize maintainer mode
73 AM_MAINTAINER_MODE
74
75 AC_CANONICAL_HOST
76
77 dnl figure debugging default, prior to $ac_help setup
78 dnl
79 AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)dnl
80 if test `expr $GTK_MINOR_VERSION \% 2` = 1 ; then
81         debug_default=yes
82 else
83         debug_default=minimum
84 fi
85 AC_DIVERT_POP()dnl
86
87 dnl declare --enable-* args and collect ac_help strings
88 AC_ARG_ENABLE(debug, [  --enable-debug=[no/minimum/yes] turn on debugging [default=$debug_default]],,enable_debug=$debug_default)
89 AC_ARG_ENABLE(shm, [  --enable-shm            support shared memory if available [default=yes]],
90                    echo $enable_shm, enable_shm="yes")
91 AC_ARG_ENABLE(ansi, [  --enable-ansi           turn on strict ansi [default=no]],
92                     , enable_ansi=no)
93 AC_ARG_WITH(glib, [  --with-glib=DIR         Use uninstalled copy of glib])
94 AC_ARG_ENABLE(xim, [  --enable-xim            support XIM [default=yes]],
95                         , enable_xim="yes")
96 AC_ARG_ENABLE(xim_inst, [  --disable-xim-inst      does not use xim instantiate callback],
97                         , enable_xim_inst="maybe")
98 AC_ARG_WITH(locale, [  --with-locale=LOCALE    locale name you want to use ])
99
100 AC_ARG_WITH(xinput, [  --with-xinput=[no/gxi/xfree] support XInput ])
101
102 if test "x$enable_debug" = "xyes"; then
103   test "$cflags_set" = set || CFLAGS="$CFLAGS -g"
104   GTK_DEBUG_FLAGS="-DG_ENABLE_DEBUG"
105 else
106   if test "x$enable_debug" = "xno"; then
107     GTK_DEBUG_FLAGS="-DG_DISABLE_ASSERT -DG_DISABLE_CHECKS -DGTK_NO_CHECK_CASTS"
108   else
109     GTK_DEBUG_FLAGS="-DGTK_NO_CHECK_CASTS"
110   fi
111 fi
112
113 AC_DEFINE_UNQUOTED(GTK_COMPILED_WITH_DEBUGGING, "${enable_debug}")
114
115 # Build time sanity check...
116 AM_SANITY_CHECK
117
118 # Checks for programs.
119 AC_PROG_CC
120 AC_ISC_POSIX
121 AM_PROG_CC_STDC
122 AC_PROG_INSTALL
123 AC_PROG_MAKE_SET
124
125 changequote(,)dnl
126 if test "x$GCC" = "xyes"; then
127   case " $CFLAGS " in
128   *[\ \ ]-Wall[\ \      ]*) ;;
129   *) CFLAGS="$CFLAGS -Wall" ;;
130   esac
131
132   if test "x$enable_ansi" = "xyes"; then
133     case " $CFLAGS " in
134     *[\ \       ]-ansi[\ \      ]*) ;;
135     *) CFLAGS="$CFLAGS -ansi" ;;
136     esac
137
138     case " $CFLAGS " in
139     *[\ \       ]-pedantic[\ \  ]*) ;;
140     *) CFLAGS="$CFLAGS -pedantic" ;;
141     esac
142   fi
143 fi
144 changequote([,])dnl
145
146 # define a MAINT-like variable REBUILD which is set if Perl
147 # and awk are found, so autogenerated sources can be rebuilt
148
149 AC_PROG_AWK
150 AC_CHECK_PROGS(PERL, perl5 perl)
151
152 # We would like indent, but don't require it.
153 AC_CHECK_PROG(INDENT, indent, indent)
154
155 REBUILD=\#
156 if test -n "$PERL" && perl -v | grep 'version 5.' > /dev/null ; then
157   if test -n "$AWK" ; then 
158     REBUILD=
159   fi
160 fi
161 AC_SUBST(REBUILD)
162
163 AC_CHECK_FUNCS(lstat)
164
165 # i18n stuff
166 ALL_LINGUAS="ca cs de es fr hr hu it ja ko nl no pl pt ru sv wa"
167 AM_GTK_GNU_GETTEXT
168 AC_CHECK_FUNC(gettext,
169         ,
170         AC_CHECK_LIB(intl, gettext)
171 )
172 # AM_GTK_GNU_GETTEXT above substs $DATADIRNAME
173 # this is the directory where the *.{mo,gmo} files are installed
174 gtklocaledir='${prefix}/${DATADIRNAME}/locale'
175 AC_SUBST(gtklocaledir)
176
177 dnl The DU4 header files don't provide library prototypes unless 
178 dnl -std1 is given to the native cc.
179 AC_MSG_CHECKING([for extra flags to get ANSI library prototypes])
180
181 gtk_save_LIBS=$LIBS
182 LIBS="$LIBS -lm"
183 AC_TRY_RUN([#include <math.h>
184              int main (void) { return (log(1) != log(1.)); }],
185      AC_MSG_RESULT(none needed),
186      gtk_save_CFLAGS=$CFLAGS
187      CFLAGS="$CFLAGS -std1"
188      AC_TRY_RUN([#include <math.h>
189                  int main (void) { return (log(1) != log(1.)); }],
190          AC_MSG_RESULT(-std1),
191          AC_MSG_RESULT()
192          CFLAGS=$gtk_save_CFLAGS
193          AC_MSG_WARN(
194                 [No ANSI prototypes found in library. (-std1 didn't work.)])
195      )
196 )
197 LIBS=$gtk_save_LIBS
198
199 dnl NeXTStep cc seems to need this
200 AC_MSG_CHECKING([for extra flags for POSIX compliance])
201 AC_TRY_COMPILE([#include <dirent.h>], [DIR *dir;],
202   AC_MSG_RESULT(none needed),
203   gtk_save_CFLAGS=$CFLAGS
204   CFLAGS="$CFLAGS -posix"
205   AC_TRY_COMPILE([#include <dirent.h>], [DIR *dir;],
206     AC_MSG_RESULT(-posix),
207     AC_MSG_RESULT()
208     CFLAGS=$gtk_save_CFLAGS
209     AC_MSG_WARN([Could not determine POSIX flag. (-posix didn't work.)])))
210
211 if test x$with_glib = xyes ; then
212   AC_MSG_ERROR([
213 *** Directory must be specified for --with-glib])
214 fi
215
216 if test x$with_glib = x ; then 
217   # Look for separately installed glib
218
219   AM_PATH_GLIB(1.3.0,,
220     AC_MSG_ERROR([
221 *** GLIB 1.3.0 or better is required. The latest version of GLIB
222 *** is always available from ftp://ftp.gtk.org/.]),
223     gmodule gthread)
224
225   # we do not want to make all gtk progs to link to thread libraries.
226   glib_cflags=`$GLIB_CONFIG glib gmodule --cflags`
227   glib_thread_cflags="$GLIB_CFLAGS"
228   glib_libs=`$GLIB_CONFIG glib gmodule --libs`
229   glib_thread_libs="$GLIB_LIBS"
230   GLIB_LIBS="$glib_libs"
231   GLIB_DEPLIBS="$glib_libs"
232 else
233   # Use uninstalled glib (assume they got the version right)
234
235   GLIB_CONFIG=$with_glib/glib-config
236   if test -x $GLIB_CONFIG ; then 
237     :
238   else
239     AC_MSG_ERROR([GLIB directory ($with_glib) not present or not configured])
240   fi
241
242   # For use in gtk-config
243   glib_cflags=`$GLIB_CONFIG --cflags gmodule`
244   glib_thread_cflags=`$GLIB_CONFIG --cflags gmodule gthread`
245   glib_libs=`$GLIB_CONFIG --libs gmodule`
246   glib_thread_libs=`$GLIB_CONFIG --libs gmodule gthread`
247
248   glib_release=`$GLIB_CONFIG --version | sed 's%\\.[[0-9]]*$%%'`
249
250   # canonicalize relative paths
251   case $with_glib in 
252     /*)
253       glib_dir=$with_glib
254       ;;
255     *)
256       glib_dir="\$(top_builddir)/$with_glib"
257       ;;
258   esac
259
260   GLIB_CFLAGS="-I$glib_dir -I$glib_dir/gmodule"
261   GLIB_LIBS="$glib_dir/libglib.la $glib_dir/gmodule/libgmodule.la"
262   GLIB_DEPLIBS=
263
264   AC_SUBST(GLIB_CFLAGS)
265   AC_SUBST(GLIB_LIBS)
266 fi
267
268 AC_SUBST(glib_cflags)
269 AC_SUBST(glib_libs)
270 AC_SUBST(glib_thread_cflags)
271 AC_SUBST(glib_thread_libs)
272 AC_SUBST(GLIB_DEPLIBS)
273
274 AC_CHECK_HEADERS(dirent.h, AC_DEFINE(HAVE_DIRENT_H))
275 AC_CHECK_HEADERS(pwd.h, AC_DEFINE(HAVE_PWD_H))
276 AC_CHECK_HEADERS(sys/time.h, AC_DEFINE(HAVE_SYS_TIME_H))
277
278 # Find the X11 include and library directories
279 AC_PATH_X
280 AC_PATH_XTRA
281
282 if test "x$x_includes" = "x"; then
283   x_includes="/usr/include"
284 fi
285
286 saved_cflags="$CFLAGS"
287 saved_ldflags="$LDFLAGS"
288
289 CFLAGS="$CFLAGS $X_CFLAGS"
290 LDFLAGS="$LDFLAGS $X_LDFLAGS $X_LIBS"
291
292 if test "x$no_x" = "xyes"; then 
293   AC_MSG_ERROR([
294 *** X libraries or include files not found. Check 'config.log' for 
295 *** more details.])
296 fi
297
298 # Checks for libraries.
299 # Check for the X11 library
300 AC_CHECK_LIB(X11, XOpenDisplay, x_libs="-lX11 $X_EXTRA_LIBS", 
301   AC_MSG_ERROR([*** libX11 not found. Check 'config.log' for more details.]),
302   $X_EXTRA_LIBS)
303
304 if test "x$enable_shm" = "xyes"; then
305   # Check for the Xext library (needed for XShm extention)
306   AC_CHECK_LIB(Xext, XShmAttach, 
307       x_libs="-lXext $x_libs", 
308       # On AIX, it is in XextSam instead, but we still need -lXext
309       AC_CHECK_LIB(XextSam, XShmAttach, 
310           x_libs="-lXextSam -lXext $x_libs", 
311           no_xext_lib=yes, $x_libs),
312       $x_libs)
313 fi
314
315 # Check for shaped window extension
316
317 AC_CHECK_LIB(Xext, XShapeCombineMask,
318       if test -z "`echo $x_libs | grep "\-lXext" 2> /dev/null`"; then
319            x_libs="-lXext $x_libs"
320       fi
321       AC_DEFINE(HAVE_SHAPE_EXT),
322       ,
323       $x_libs)
324
325 # Check for XConvertCase (X11R6 specific)
326
327 AC_CHECK_LIB(X11, XConvertCase,
328       AC_DEFINE(HAVE_XCONVERTCASE),
329       ,
330       $x_libs)
331
332 # Check for XIM support.
333
334 AC_CHECK_LIB(X11, XUnregisterIMInstantiateCallback,
335             : ,
336             enable_xim_inst="no",
337             $x_libs)
338
339 # On Solaris, calling XRegisterIMInstantiateCallback seems to
340 # cause an immediate segfault, so we disable it, unless
341 # the user specifically forces it to be on.
342
343 if test x$enable_xim_inst = xmaybe ; then
344   case host in
345         *-*-solaris*)
346             enable_xim_inst="no"
347             ;;
348         *)
349             enable_xim_inst="yes"
350             ;;
351   esac
352 fi
353
354 if test "x$enable_xim" = "xyes"; then
355   GTK_XIM_FLAGS="-DUSE_XIM"
356   if test "x$enable_xim_inst" = "xyes"; then
357     AC_DEFINE(USE_X11R6_XIM)
358   fi
359 fi
360
361 x_cflags="$X_CFLAGS"
362 x_ldflags="$X_LDFLAGS $X_LIBS"
363
364 # set up things for XInput
365
366 if test "x$with_xinput" = "xgxi" || test "x$with_xinput" = "xyes"; then
367   AC_DEFINE(XINPUT_GXI)
368   xinput_progs=gxid
369   x_libs="-lXi $x_libs"
370 elif test "x$with_xinput" = "xxfree"; then
371   AC_DEFINE(XINPUT_XFREE)
372   x_libs="-lXi $x_libs"
373 else
374   AC_DEFINE(XINPUT_NONE)
375 fi
376
377 CFLAGS="$saved_cflags"
378 LDFLAGS="$saved_ldflags"
379
380 AC_SUBST(x_cflags)
381 AC_SUBST(x_includes)
382 AC_SUBST(x_ldflags)
383 AC_SUBST(x_libs)
384 AC_SUBST(xinput_progs)
385
386 if test "x$enable_shm" = "xyes"; then
387   # Check for shared memory
388   AC_CHECK_HEADER(sys/ipc.h, AC_DEFINE(HAVE_IPC_H), no_sys_ipc=yes)
389   AC_CHECK_HEADER(sys/shm.h, AC_DEFINE(HAVE_SHM_H), no_sys_shm=yes)
390
391   # Check for the X shared memory extension header file
392   AC_MSG_CHECKING(X11/extensions/XShm.h)
393   if test "x$no_xext_lib" = "xyes"; then
394     AC_MSG_RESULT(no)
395     no_xshm=yes
396   else
397     if test -f "$x_includes/X11/extensions/XShm.h"; then
398       AC_MSG_RESULT(yes)
399       AC_DEFINE(HAVE_XSHM_H)
400     else
401       AC_MSG_RESULT(no)
402       no_xshm=yes
403     fi
404   fi
405 fi
406
407 # Check if X_LOCALE definition is necessary
408
409 AC_MSG_CHECKING(need -DX_LOCALE)
410
411 AC_TRY_RUN([
412 #include <stdio.h>
413 #include <locale.h>
414
415 int
416 main ()
417 {
418   return setlocale (LC_ALL, "${with_locale}") == NULL;
419 }],
420 need_x_locale=no,
421 need_x_locale=yes)
422 AC_MSG_RESULT($need_x_locale)
423
424 if test $need_x_locale = yes; then
425   GTK_LOCALE_CFLAGS="-DX_LOCALE"
426 fi
427
428 # Checks for header files.
429 AC_HEADER_STDC
430
431 # Checks for typedefs, structures, and compiler characteristics.
432 AC_C_CONST
433
434 # Checks for library functions.
435 AC_TYPE_SIGNAL
436 AC_FUNC_MMAP
437
438 # Check if <sys/select.h> needs to be included for fd_set
439 AC_MSG_CHECKING([for fd_set])
440 AC_TRY_COMPILE([#include <sys/types.h>],
441         [fd_set readMask, writeMask;], gtk_ok=yes, gtk_ok=no)
442 if test $gtk_ok = yes; then
443     AC_MSG_RESULT([yes, found in sys/types.h])
444 else
445     AC_HEADER_EGREP(fd_mask, sys/select.h, gtk_ok=yes)
446     if test $gtk_ok = yes; then
447         AC_DEFINE(HAVE_SYS_SELECT_H)
448         AC_MSG_RESULT([yes, found in sys/select.h])
449     else
450         AC_DEFINE(NO_FD_SET)
451         AC_MSG_RESULT(no)
452     fi
453 fi
454
455 # `widechar' tests for gdki18n.h
456 AC_MSG_CHECKING(for wchar.h)
457 AC_TRY_CPP([#include <wchar.h>], gdk_wchar_h=yes, gdk_wchar_h=no)
458 if test $gdk_wchar_h = yes; then
459    AC_DEFINE(HAVE_WCHAR_H,1,[Have wchar.h include file])
460 fi
461 AC_MSG_RESULT($gdk_wchar_h)
462
463 # Check for wctype.h (for iswalnum)
464 AC_MSG_CHECKING(for wctype.h)
465 AC_TRY_CPP([#include <wctype.h>], gdk_wctype_h=yes, gdk_wctype_h=no)
466 if test $gdk_wctype_h = yes; then
467    AC_DEFINE(HAVE_WCTYPE_H,1,[Have wctype.h include file])
468 fi
469 AC_MSG_RESULT($gdk_wctype_h)
470
471 # in Solaris 2.5, `iswalnum' is in -lw
472 GDK_WLIBS=
473 AC_CHECK_FUNC(iswalnum,,[AC_CHECK_LIB(w,iswalnum,GDK_WLIBS=-lw)])
474
475 oLIBS="$LIBS"
476 LIBS="$LIBS $GDK_WLIBS"
477 # The following is necessary for Linux libc-5.4.38
478 AC_MSG_CHECKING(if iswalnum() and friends are properly defined)
479 AC_TRY_LINK([#include <stdlib.h>],[
480 #if (defined(HAVE_WCTYPE_H) || defined(HAVE_WCHAR_H))
481 #  ifdef HAVE_WCTYPE_H
482 #    include <wctype.h>
483 #  else
484 #    ifdef HAVE_WCHAR_H
485 #      include <wchar.h>
486 #    endif
487 #  endif
488 #else
489 #  define iswalnum(c) ((wchar_t)(c) <= 0xFF && isalnum(c))
490 #endif
491 iswalnum((wchar_t) 0);
492 ], gdk_working_wctype=yes, gdk_working_wctype=no)
493 LIBS="$oLIBS"
494
495 if test $gdk_working_wctype = no; then
496    AC_DEFINE(HAVE_BROKEN_WCTYPE,1,[Is the wctype implementation broken])
497    GDK_WLIBS=
498 fi
499 AC_MSG_RESULT($gdk_working_wctype)
500 AC_SUBST(GDK_WLIBS)
501
502 AC_SUBST(GTK_DEBUG_FLAGS)
503 AC_SUBST(GTK_XIM_FLAGS)
504 AC_SUBST(GTK_LOCALE_FLAGS)
505
506 AC_OUTPUT_COMMANDS([
507
508 ## Generate `gdk/gdkconfig.h' in two cases
509 ## 1. `config.status' is run either explicitly, or via configure.
510 ##     Esp. not when it is run in `Makefile' to generate makefiles and
511 ##     config.h
512 ## 2. CONFIG_OTHER is set explicitly
513 ##
514 ## Case 1 is difficult.  We know that `automake' sets one of
515 ## CONFIG_FILES or CONFIG_HEADERS to empty.  This heuristic works
516 ## only when AM_CONFIG_HEADER is set, however.
517
518 if test -n "${CONFIG_FILES}" && test -n "${CONFIG_HEADERS}"; then
519   # Both CONFIG_FILES and CONFIG_HEADERS are non-empty ==> Case 1
520   CONFIG_OTHER=${CONFIG_OTHER:-gdk/gdkconfig.h}
521 fi
522 case "$CONFIG_OTHER" in
523 *gdk/gdkconfig.h*)
524         echo creating gdk/gdkconfig.h
525         outfile=gdkconfig.h-tmp
526         cat > $outfile <<\_______EOF
527 /* gdkconfig.h
528  *
529  * This is a generated file.  Please modify `configure.in'
530  */
531
532 #ifndef GDKCONFIG_H
533 #define GDKCONFIG_H
534
535 #ifdef __cplusplus
536 extern "C" {
537 #endif /* __cplusplus */
538
539 _______EOF
540
541         cat >>$outfile <<_______EOF
542 $gdk_windowing
543 $gdk_wc
544 _______EOF
545
546         cat >>$outfile <<_______EOF
547
548 #ifdef __cplusplus
549 }
550 #endif /* __cplusplus */
551
552 #endif /* GDKCONFIG_H */
553 _______EOF
554
555
556         if cmp -s $outfile gdk/gdkconfig.h; then
557           echo gdk/gdkconfig.h is unchanged
558           rm -f $outfile
559         else
560           mv $outfile gdk/gdkconfig.h
561         fi ;;
562 esac
563 ],[
564 # Currently we always use X11 on those systems where we run configure...
565 gdk_windowing='
566 #define GDK_WINDOWING GDK_WINDOWING_X11'
567 if test x$gdk_wchar_h = xyes; then
568   gdk_wc='
569 #define GDK_HAVE_WCHAR_H 1'
570 fi
571 if test x$gdk_wctype_h = xyes; then
572   gdk_wc="\$gdk_wc
573 #define GDK_HAVE_WCTYPE_H 1"
574 fi
575 if test x$gdk_working_wctype = xno; then
576   gdk_wc="\$gdk_wc
577 #define GDK_HAVE_BROKEN_WCTYPE 1"
578 fi
579
580
581 ])
582
583 AC_OUTPUT([
584 gtk+.spec
585 Makefile
586 gtk-config
587 po/Makefile.in
588 docs/Makefile
589 gdk/Makefile
590 gtk/Makefile
591 gtk/gtkcompat.h
592 ], [chmod +x gtk-config])