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