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