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