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