]> Pileus Git - ~andy/gtk/blob - configure.in
preserve automake CFLAGS.
[~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
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 # 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 # Find the X11 include and library directories
132 AC_PATH_X
133 AC_PATH_XTRA
134
135 if test "x$x_includes" = "x"; then
136   x_includes="/usr/include"
137 fi
138
139 saved_cflags="$CFLAGS"
140 saved_ldflags="$LDFLAGS"
141
142 CFLAGS="$X_CFLAGS"
143 LDFLAGS="$X_LDFLAGS $X_LIBS"
144
145 # Checks for libraries.
146 # Check for the X11 library
147 AC_CHECK_LIB(X11, XOpenDisplay, x_libs="-lX11 $X_EXTRA_LIBS", no_x11_lib=yes, $X_EXTRA_LIBS)
148
149 if test "x$enable_shm" = "xyes"; then
150   # Check for the Xext library (needed for XShm extention)
151   AC_CHECK_LIB(Xext, XShmAttach, 
152       x_libs="-lXext $x_libs", 
153       # On AIX, it is in XextSam instead, but we still need -lXext
154       AC_CHECK_LIB(XextSam, XShmAttach, 
155           x_libs="-lXextSam -lXext $x_libs", 
156           no_xext_lib=yes, $x_libs),
157       $x_libs)
158 fi
159
160 # Check for shaped window extension
161
162 AC_CHECK_LIB(Xext, XShapeCombineMask,
163       if test -z "`echo $x_libs | grep "\-lXext" 2> /dev/null`"; then
164            $x_libs="-lXext $x_libs"
165       fi
166       AC_DEFINE(HAVE_SHAPE_EXT),
167       ,
168       $x_libs)
169
170 x_cflags="$X_CFLAGS"
171 x_ldflags="$X_LDFLAGS $X_LIBS"
172
173 # set up things for XInput
174
175 if test "x$with_xinput" = "xgxi" || test "x$with_xinput" = "xyes"; then
176   AC_DEFINE(XINPUT_GXI)
177   xinput_progs=gxid
178   x_libs="-lXi $x_libs"
179 elif test "x$with_xinput" = "xxfree"; then
180   AC_DEFINE(XINPUT_XFREE)
181   x_libs="-lXi $x_libs"
182 else
183   AC_DEFINE(XINPUT_NONE)
184 fi
185
186 AC_SUBST(x_cflags)
187 AC_SUBST(x_includes)
188 AC_SUBST(x_ldflags)
189 AC_SUBST(x_libs)
190 AC_SUBST(xinput_progs)
191
192 CFLAGS="$saved_cflags"
193 LDFLAGS="$saved_ldflags"
194
195 if test "x$enable_shm" = "xyes"; then
196   # Check for shared memory
197   AC_CHECK_HEADER(sys/ipc.h, AC_DEFINE(HAVE_IPC_H), no_sys_ipc=yes)
198   AC_CHECK_HEADER(sys/shm.h, AC_DEFINE(HAVE_SHM_H), no_sys_shm=yes)
199
200   # Check whether shmctl IPC_RMID allowes subsequent attaches
201   if test "$ac_cv_header_sys_shm_h" = "yes"; then
202     AC_MSG_CHECKING(whether shmctl IPC_RMID allowes subsequent attaches)
203     AC_TRY_RUN([
204           #include <sys/types.h>
205           #include <sys/ipc.h>
206           #include <sys/shm.h>
207           int main()
208           {
209             int id;
210             char *shmaddr;
211           id = shmget (IPC_PRIVATE, 4, IPC_CREAT | 0777);
212           if (id == -1)
213             exit (2);
214             shmaddr = shmat (id, 0, 0);
215             shmctl (id, IPC_RMID, 0);
216             if ((char*) shmat (id, 0, 0) == (char*) -1)
217             {
218               shmdt (shmaddr);
219               exit (1);
220             }
221             shmdt (shmaddr);
222             shmdt (shmaddr);
223             exit (0);
224           }
225       ],
226       AC_DEFINE(IPC_RMID_DEFERRED_RELEASE)
227         AC_MSG_RESULT(yes),
228       AC_MSG_RESULT(no),
229       AC_MSG_RESULT(assuming no))
230   fi
231
232   # Check for the X shared memory extension header file
233   AC_MSG_CHECKING(X11/extensions/XShm.h)
234   if test "x$no_xext_lib" = "xyes"; then
235     AC_MSG_RESULT(no)
236     no_xshm=yes
237   else
238     if test -f "$x_includes/X11/extensions/XShm.h"; then
239       AC_MSG_RESULT(yes)
240       AC_DEFINE(HAVE_XSHM_H)
241     else
242       AC_MSG_RESULT(no)
243       no_xshm=yes
244     fi
245   fi
246 fi
247
248 # Check for private display resource base variable
249 AC_MSG_CHECKING(resource base field in XDisplay)
250 AC_CACHE_VAL(gtk_cv_display_resource_base,
251 [AC_TRY_RUN([
252 #define XLIB_ILLEGAL_ACCESS
253 #include <X11/Xlib.h>
254
255 int
256 main ()
257 {
258   Display *display;
259
260   return 0;
261
262   display->resource_base;
263 }],
264 gtk_cv_display_resource_base="resource_base",
265 gtk_cv_display_resource_base="private3")])
266 AC_MSG_RESULT($gtk_cv_display_resource_base)
267 AC_DEFINE_UNQUOTED(RESOURCE_BASE, gdk_display->$gtk_cv_display_resource_base)
268
269 # Check if X_LOCALE definition is necessary
270
271 AC_MSG_CHECKING(need -DX_LOCALE)
272
273 AC_TRY_RUN([
274 #include <stdio.h>
275 #include <locale.h>
276
277 int
278 main ()
279 {
280   return setlocale (LC_ALL, "${with_locale}") == NULL;
281 }],
282 need_x_locale=no,
283 need_x_locale=yes)
284 AC_MSG_RESULT($need_x_locale)
285
286 if test $need_x_locale = yes; then
287   CFLAGS="$CFLAGS -DX_LOCALE"
288 fi
289
290 # Checks for header files.
291 AC_HEADER_STDC
292
293 # Checks for typedefs, structures, and compiler characteristics.
294 AC_C_CONST
295
296 # Checks for library functions.
297 AC_TYPE_SIGNAL
298 AC_FUNC_MMAP
299
300 # Check for sys/select.h
301
302 AC_MSG_CHECKING([fd_set and sys/select])
303 AC_TRY_COMPILE([#include <sys/types.h>],
304         [fd_set readMask, writeMask;], gtk_ok=yes, gtk_ok=no)
305 if test $gtk_ok = no; then
306     AC_HEADER_EGREP(fd_mask, sys/select.h, gtk_ok=yes)
307     if test $gtk_ok = yes; then
308         AC_DEFINE(HAVE_SYS_SELECT_H)
309     fi
310 fi
311 AC_MSG_RESULT($gtk_ok)
312 if test $gtk_ok = no; then
313     AC_DEFINE(NO_FD_SET)
314 fi
315
316 AC_OUTPUT([
317 Makefile
318 gtk-config
319 docs/Makefile
320 gdk/Makefile
321 gtk/Makefile
322 gtk/gtkfeatures.h
323 ], [chmod +x gtk-config])