]> Pileus Git - ~andy/gtk/blob - configure.in
added da file
[~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 da de el es eu fr ga hr hu it ja ko nl no pl pt ru sk sl sv wa zh_TW.Big5"
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 MATH_LIB=-lm
200 GTK_LIBS_EXTRA=
201 AC_MSG_CHECKING(for the BeOS)
202 case $host in
203   *-*-beos*)
204     GTK_LIBS_EXTRA="-L\$(top_builddir_full)/gdk/.libs -lgdk"
205     MATH_LIB=
206   ;;
207   default)
208   ;;
209 esac
210 AC_SUBST(MATH_LIB)
211 AC_SUBST(GTK_LIBS_EXTRA)
212
213 dnl NeXTStep cc seems to need this
214 AC_MSG_CHECKING([for extra flags for POSIX compliance])
215 AC_TRY_COMPILE([#include <dirent.h>], [DIR *dir;],
216   AC_MSG_RESULT(none needed),
217   gtk_save_CFLAGS=$CFLAGS
218   CFLAGS="$CFLAGS -posix"
219   AC_TRY_COMPILE([#include <dirent.h>], [DIR *dir;],
220     AC_MSG_RESULT(-posix),
221     AC_MSG_RESULT()
222     CFLAGS=$gtk_save_CFLAGS
223     AC_MSG_WARN([Could not determine POSIX flag. (-posix didn't work.)])))
224
225 if test x$with_glib = xyes ; then
226   AC_MSG_ERROR([
227 *** Directory must be specified for --with-glib])
228 fi
229
230 if test x$with_glib = x ; then 
231   # Look for separately installed glib
232
233   AM_PATH_GLIB(1.3.0,,
234     AC_MSG_ERROR([
235 *** GLIB 1.3.0 or better is required. The latest version of GLIB
236 *** is always available from ftp://ftp.gtk.org/.]),
237     gmodule gthread)
238
239   # we do not want to make all gtk progs to link to thread libraries.
240   glib_cflags=`$GLIB_CONFIG glib gmodule --cflags`
241   glib_thread_cflags="$GLIB_CFLAGS"
242   glib_libs=`$GLIB_CONFIG glib gmodule --libs`
243   glib_thread_libs="$GLIB_LIBS"
244   GLIB_LIBS="$glib_libs"
245   GLIB_DEPLIBS="$glib_libs"
246 else
247   # Use uninstalled glib (assume they got the version right)
248
249   GLIB_CONFIG=$with_glib/glib-config
250   if test -x $GLIB_CONFIG ; then 
251     :
252   else
253     AC_MSG_ERROR([GLIB directory ($with_glib) not present or not configured])
254   fi
255
256   # For use in gtk-config
257   glib_cflags=`$GLIB_CONFIG --cflags gmodule`
258   glib_thread_cflags=`$GLIB_CONFIG --cflags gmodule gthread`
259   glib_libs=`$GLIB_CONFIG --libs gmodule`
260   glib_thread_libs=`$GLIB_CONFIG --libs gmodule gthread`
261
262   glib_release=`$GLIB_CONFIG --version | sed 's%\\.[[0-9]]*$%%'`
263
264   # canonicalize relative paths
265   case $with_glib in 
266     /*)
267       glib_dir=$with_glib
268       ;;
269     *)
270       glib_dir="\$(top_builddir)/$with_glib"
271       ;;
272   esac
273
274   GLIB_CFLAGS="-I$glib_dir -I$glib_dir/gmodule"
275   GLIB_LIBS="$glib_dir/libglib.la $glib_dir/gmodule/libgmodule.la"
276   GLIB_DEPLIBS=
277
278   AC_SUBST(GLIB_CFLAGS)
279   AC_SUBST(GLIB_LIBS)
280 fi
281
282 AC_SUBST(glib_cflags)
283 AC_SUBST(glib_libs)
284 AC_SUBST(glib_thread_cflags)
285 AC_SUBST(glib_thread_libs)
286 AC_SUBST(GLIB_DEPLIBS)
287
288 AC_CHECK_HEADERS(dirent.h, AC_DEFINE(HAVE_DIRENT_H))
289 AC_CHECK_HEADERS(pwd.h, AC_DEFINE(HAVE_PWD_H))
290 AC_CHECK_HEADERS(sys/time.h, AC_DEFINE(HAVE_SYS_TIME_H))
291
292 # Find the X11 include and library directories
293 AC_PATH_X
294 AC_PATH_XTRA
295
296 if test "x$x_includes" = "x"; then
297   x_includes="/usr/include"
298 fi
299
300 saved_cflags="$CFLAGS"
301 saved_ldflags="$LDFLAGS"
302
303 CFLAGS="$CFLAGS $X_CFLAGS"
304 LDFLAGS="$LDFLAGS $X_LDFLAGS $X_LIBS"
305
306 if test "x$no_x" = "xyes"; then 
307   AC_MSG_ERROR([
308 *** X libraries or include files not found. Check 'config.log' for 
309 *** more details.])
310 fi
311
312 # Checks for libraries.
313 # Check for the X11 library
314 AC_CHECK_LIB(X11, XOpenDisplay, x_libs="-lX11 $X_EXTRA_LIBS", 
315   AC_MSG_ERROR([*** libX11 not found. Check 'config.log' for more details.]),
316   $X_EXTRA_LIBS)
317
318 if test "x$enable_shm" = "xyes"; then
319   # Check for the Xext library (needed for XShm extention)
320   AC_CHECK_LIB(Xext, XShmAttach, 
321       x_libs="-lXext $x_libs", 
322       # On AIX, it is in XextSam instead, but we still need -lXext
323       AC_CHECK_LIB(XextSam, XShmAttach, 
324           x_libs="-lXextSam -lXext $x_libs", 
325           no_xext_lib=yes, $x_libs),
326       $x_libs)
327 fi
328
329 # Check for shaped window extension
330
331 AC_CHECK_LIB(Xext, XShapeCombineMask,
332       if test -z "`echo $x_libs | grep "\-lXext" 2> /dev/null`"; then
333            x_libs="-lXext $x_libs"
334       fi
335       AC_DEFINE(HAVE_SHAPE_EXT),
336       ,
337       $x_libs)
338
339 # Check for XConvertCase (X11R6 specific)
340
341 AC_CHECK_LIB(X11, XConvertCase,
342       AC_DEFINE(HAVE_XCONVERTCASE),
343       ,
344       $x_libs)
345
346 # Check for XIM support.
347
348 AC_CHECK_LIB(X11, XUnregisterIMInstantiateCallback,
349             : ,
350             enable_xim_inst="no",
351             $x_libs)
352
353 # On Solaris, calling XRegisterIMInstantiateCallback seems to
354 # cause an immediate segfault, so we disable it, unless
355 # the user specifically forces it to be on.
356
357 if test x$enable_xim_inst = xmaybe ; then
358   case host in
359         *-*-solaris*)
360             enable_xim_inst="no"
361             ;;
362         *)
363             enable_xim_inst="yes"
364             ;;
365   esac
366 fi
367
368 if test "x$enable_xim" = "xyes"; then
369   GTK_XIM_FLAGS="-DUSE_XIM"
370   if test "x$enable_xim_inst" = "xyes"; then
371     AC_DEFINE(USE_X11R6_XIM)
372   fi
373 fi
374
375 x_cflags="$X_CFLAGS"
376 x_ldflags="$X_LDFLAGS $X_LIBS"
377
378 # set up things for XInput
379
380 if test "x$with_xinput" = "xgxi" || test "x$with_xinput" = "xyes"; then
381   AC_DEFINE(XINPUT_GXI)
382   xinput_progs=gxid
383   x_libs="-lXi $x_libs"
384 elif test "x$with_xinput" = "xxfree"; then
385   AC_DEFINE(XINPUT_XFREE)
386   x_libs="-lXi $x_libs"
387 else
388   AC_DEFINE(XINPUT_NONE)
389 fi
390
391 CFLAGS="$saved_cflags"
392 LDFLAGS="$saved_ldflags"
393
394 AC_SUBST(x_cflags)
395 AC_SUBST(x_includes)
396 AC_SUBST(x_ldflags)
397 AC_SUBST(x_libs)
398 AC_SUBST(xinput_progs)
399
400 if test "x$enable_shm" = "xyes"; then
401   # Check for shared memory
402   AC_CHECK_HEADER(sys/ipc.h, AC_DEFINE(HAVE_IPC_H), no_sys_ipc=yes)
403   AC_CHECK_HEADER(sys/shm.h, AC_DEFINE(HAVE_SHM_H), no_sys_shm=yes)
404
405   # Check for the X shared memory extension header file
406   AC_MSG_CHECKING(X11/extensions/XShm.h)
407   if test "x$no_xext_lib" = "xyes"; then
408     AC_MSG_RESULT(no)
409     no_xshm=yes
410   else
411     if test -f "$x_includes/X11/extensions/XShm.h"; then
412       AC_MSG_RESULT(yes)
413       AC_DEFINE(HAVE_XSHM_H)
414     else
415       AC_MSG_RESULT(no)
416       no_xshm=yes
417     fi
418   fi
419 fi
420
421 # Check if X_LOCALE definition is necessary
422
423 AC_MSG_CHECKING(need -DX_LOCALE)
424
425 AC_TRY_RUN([
426 #include <stdio.h>
427 #include <locale.h>
428
429 int
430 main ()
431 {
432   return setlocale (LC_ALL, "${with_locale}") == NULL;
433 }],
434 need_x_locale=no,
435 need_x_locale=yes)
436 AC_MSG_RESULT($need_x_locale)
437
438 if test $need_x_locale = yes; then
439   GTK_LOCALE_CFLAGS="-DX_LOCALE"
440 fi
441
442 # Checks for header files.
443 AC_HEADER_STDC
444
445 # Checks for typedefs, structures, and compiler characteristics.
446 AC_C_CONST
447
448 # Checks for library functions.
449 AC_TYPE_SIGNAL
450 AC_FUNC_MMAP
451
452 # Check if <sys/select.h> needs to be included for fd_set
453 AC_MSG_CHECKING([for fd_set])
454 AC_TRY_COMPILE([#include <sys/types.h>],
455         [fd_set readMask, writeMask;], gtk_ok=yes, gtk_ok=no)
456 if test $gtk_ok = yes; then
457     AC_MSG_RESULT([yes, found in sys/types.h])
458 else
459     AC_HEADER_EGREP(fd_mask, sys/select.h, gtk_ok=yes)
460     if test $gtk_ok = yes; then
461         AC_DEFINE(HAVE_SYS_SELECT_H)
462         AC_MSG_RESULT([yes, found in sys/select.h])
463     else
464         AC_DEFINE(NO_FD_SET)
465         AC_MSG_RESULT(no)
466     fi
467 fi
468
469 # `widechar' tests for gdki18n.h
470 AC_MSG_CHECKING(for wchar.h)
471 AC_TRY_CPP([#include <wchar.h>], gdk_wchar_h=yes, gdk_wchar_h=no)
472 if test $gdk_wchar_h = yes; then
473    AC_DEFINE(HAVE_WCHAR_H,1,[Have wchar.h include file])
474 fi
475 AC_MSG_RESULT($gdk_wchar_h)
476
477 # Check for wctype.h (for iswalnum)
478 AC_MSG_CHECKING(for wctype.h)
479 AC_TRY_CPP([#include <wctype.h>], gdk_wctype_h=yes, gdk_wctype_h=no)
480 if test $gdk_wctype_h = yes; then
481    AC_DEFINE(HAVE_WCTYPE_H,1,[Have wctype.h include file])
482 fi
483 AC_MSG_RESULT($gdk_wctype_h)
484
485 # in Solaris 2.5, `iswalnum' is in -lw
486 GDK_WLIBS=
487 AC_CHECK_FUNC(iswalnum,,[AC_CHECK_LIB(w,iswalnum,GDK_WLIBS=-lw)])
488
489 oLIBS="$LIBS"
490 LIBS="$LIBS $GDK_WLIBS"
491 # The following is necessary for Linux libc-5.4.38
492 AC_MSG_CHECKING(if iswalnum() and friends are properly defined)
493 AC_TRY_LINK([#include <stdlib.h>],[
494 #if (defined(HAVE_WCTYPE_H) || defined(HAVE_WCHAR_H))
495 #  ifdef HAVE_WCTYPE_H
496 #    include <wctype.h>
497 #  else
498 #    ifdef HAVE_WCHAR_H
499 #      include <wchar.h>
500 #    endif
501 #  endif
502 #else
503 #  define iswalnum(c) ((wchar_t)(c) <= 0xFF && isalnum(c))
504 #endif
505 iswalnum((wchar_t) 0);
506 ], gdk_working_wctype=yes, gdk_working_wctype=no)
507 LIBS="$oLIBS"
508
509 if test $gdk_working_wctype = no; then
510    AC_DEFINE(HAVE_BROKEN_WCTYPE,1,[Is the wctype implementation broken])
511    GDK_WLIBS=
512 fi
513 AC_MSG_RESULT($gdk_working_wctype)
514 AC_SUBST(GDK_WLIBS)
515
516 AC_SUBST(GTK_DEBUG_FLAGS)
517 AC_SUBST(GTK_XIM_FLAGS)
518 AC_SUBST(GTK_LOCALE_FLAGS)
519
520 AC_OUTPUT_COMMANDS([
521
522 ## Generate `gdk/gdkconfig.h' in two cases
523 ## 1. `config.status' is run either explicitly, or via configure.
524 ##     Esp. not when it is run in `Makefile' to generate makefiles and
525 ##     config.h
526 ## 2. CONFIG_OTHER is set explicitly
527 ##
528 ## Case 1 is difficult.  We know that `automake' sets one of
529 ## CONFIG_FILES or CONFIG_HEADERS to empty.  This heuristic works
530 ## only when AM_CONFIG_HEADER is set, however.
531
532 if test -n "${CONFIG_FILES}" && test -n "${CONFIG_HEADERS}"; then
533   # Both CONFIG_FILES and CONFIG_HEADERS are non-empty ==> Case 1
534   CONFIG_OTHER=${CONFIG_OTHER:-gdk/gdkconfig.h}
535 fi
536 case "$CONFIG_OTHER" in
537 *gdk/gdkconfig.h*)
538         echo creating gdk/gdkconfig.h
539         outfile=gdkconfig.h-tmp
540         cat > $outfile <<\_______EOF
541 /* gdkconfig.h
542  *
543  * This is a generated file.  Please modify `configure.in'
544  */
545
546 #ifndef GDKCONFIG_H
547 #define GDKCONFIG_H
548
549 #ifdef __cplusplus
550 extern "C" {
551 #endif /* __cplusplus */
552
553 _______EOF
554
555         cat >>$outfile <<_______EOF
556 $gdk_windowing
557 $gdk_wc
558 _______EOF
559
560         cat >>$outfile <<_______EOF
561
562 #ifdef __cplusplus
563 }
564 #endif /* __cplusplus */
565
566 #endif /* GDKCONFIG_H */
567 _______EOF
568
569
570         if cmp -s $outfile gdk/gdkconfig.h; then
571           echo gdk/gdkconfig.h is unchanged
572           rm -f $outfile
573         else
574           mv $outfile gdk/gdkconfig.h
575         fi ;;
576 esac
577 ],[
578 # Currently we always use X11 on those systems where we run configure...
579 gdk_windowing='
580 #define GDK_WINDOWING GDK_WINDOWING_X11'
581 if test x$gdk_wchar_h = xyes; then
582   gdk_wc='
583 #define GDK_HAVE_WCHAR_H 1'
584 fi
585 if test x$gdk_wctype_h = xyes; then
586   gdk_wc="\$gdk_wc
587 #define GDK_HAVE_WCTYPE_H 1"
588 fi
589 if test x$gdk_working_wctype = xno; then
590   gdk_wc="\$gdk_wc
591 #define GDK_HAVE_BROKEN_WCTYPE 1"
592 fi
593
594
595 ])
596
597 AC_OUTPUT([
598 gtk+.spec
599 Makefile
600 gtk-config
601 po/Makefile.in
602 docs/Makefile
603 gdk/Makefile
604 gtk/Makefile
605 gtk/gtkcompat.h
606 ], [chmod +x gtk-config])