]> Pileus Git - ~andy/gtk/blob - configure.in
define the version variables in config.h.
[~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 GTK_MAJOR_VERSION=0
8 GTK_MINOR_VERSION=99
9 GTK_MICRO_VERSION=4
10 GTK_VERSION=$GTK_MAJOR_VERSION.$GTK_MINOR_VERSION.$GTK_MICRO_VERSION
11
12 # For automake.
13 VERSION=$GTK_VERSION
14 PACKAGE=gtk+
15
16 # Configure glib
17 AC_CONFIG_SUBDIRS(glib)
18
19 # Save this value here, since automake will set cflags later
20 cflags_set=${CFLAGS+set}
21
22 dnl Initialize automake stuff
23 AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
24
25 # Specify a configuration file
26 AM_CONFIG_HEADER(config.h)
27
28 dnl Initialize libtool
29 AM_PROG_LIBTOOL
30
31 dnl Initialize maintainer mode
32 AM_MAINTAINER_MODE
33
34 AC_CANONICAL_HOST
35
36 AC_ARG_ENABLE(shm, [  --enable-shm            support shared memory if available [default=yes]],
37                    echo $enable_shm, enable_shm="yes")
38 AC_ARG_ENABLE(debug, [  --enable-debug=[no/minimum/yes] turn on debugging [default=minimum]],,enable_debug=minimum)
39 AC_ARG_ENABLE(ansi, [  --enable-ansi           turn on strict ansi [default=no]],
40                     , enable_ansi=no)
41 AC_ARG_ENABLE(xim, [  --enable-xim            support XIM [default=yes]],
42                         echo $enable_xim, enable_xim="yes")
43 AC_ARG_WITH(locale, [  --with-locale=LOCALE    locale name you want to use ])
44
45 AC_ARG_WITH(xinput, [  --with-xinput=[no/gxi/xfree] support XInput ])
46
47 if test "x$enable_debug" = "xyes"; then
48   test "$cflags_set" = set || CFLAGS="-g"
49   CFLAGS="$CFLAGS -DG_ENABLE_DEBUG"
50 else
51   if test "x$enable_debug" = "xno"; then
52     CFLAGS="$CFLAGS -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS -DGTK_NO_CHECK_CASTS"
53   else
54     CFLAGS="$CFLAGS -DGTK_NO_CHECK_CASTS"
55   fi
56 fi
57
58 # Build time sanity check...
59 AM_SANITY_CHECK
60
61 # Checks for programs.
62 AC_PROG_CC
63 AM_PROG_CC_STDC
64 AC_PROG_INSTALL
65 AC_PROG_MAKE_SET
66
67 if test "x$GCC" = "xyes"; then
68   if test -z "`echo "$CFLAGS" | grep "\-Wall" 2> /dev/null`" ; then
69     CFLAGS="$CFLAGS -Wall"
70   fi
71
72   if test "x$enable_ansi" = "xyes"; then
73     if test -z "`echo "$CFLAGS" | grep "\-ansi" 2> /dev/null`" ; then
74       CFLAGS="$CFLAGS -ansi"
75     fi
76
77     if test -z "`echo "$CFLAGS" | grep "\-pedantic" 2> /dev/null`" ; then
78       CFLAGS="$CFLAGS -pedantic"
79     fi
80   fi
81 fi
82
83 if test "x$enable_xim" = "xyes"; then
84   CFLAGS="$CFLAGS -DUSE_XIM"
85 fi
86
87 AC_DEFINE_UNQUOTED(GTK_MAJOR_VERSION, $GTK_MAJOR_VERSION)
88 AC_DEFINE_UNQUOTED(GTK_MINOR_VERSION, $GTK_MINOR_VERSION)
89 AC_DEFINE_UNQUOTED(GTK_MICRO_VERSION, $GTK_MICRO_VERSION)
90 AC_DEFINE_UNQUOTED(GTK_VERSION, "$GTK_VERSION")
91
92 # Find the X11 include and library directories
93 AC_PATH_X
94 AC_PATH_XTRA
95
96 if test "x$x_includes" = "x"; then
97   x_includes="/usr/include"
98 fi
99
100 saved_cflags="$CFLAGS"
101 saved_ldflags="$LDFLAGS"
102
103 CFLAGS="$X_CFLAGS"
104 LDFLAGS="$X_LDFLAGS $X_LIBS"
105
106 # Checks for libraries.
107 # Check for the X11 library
108 AC_CHECK_LIB(X11, XOpenDisplay, x_libs="-lX11 $X_EXTRA_LIBS", no_x11_lib=yes, $X_EXTRA_LIBS)
109
110 if test "x$enable_shm" = "xyes"; then
111   # Check for the Xext library (needed for XShm extention)
112   AC_CHECK_LIB(Xext, XShmAttach, x_libs="-lXext $x_libs", no_xext_lib=yes, $x_libs)
113 fi
114
115 x_cflags="$X_CFLAGS"
116 x_ldflags="$X_LDFLAGS $X_LIBS"
117
118 # set up things for XInput
119
120 if test "x$with_xinput" = "xgxi" || test "x$with_xinput" = "xyes"; then
121   AC_DEFINE(XINPUT_GXI)
122   xinput_progs=gxid
123   x_libs="-lXi $x_libs"
124 elif test "x$with_xinput" = "xxfree"; then
125   AC_DEFINE(XINPUT_XFREE)
126   x_libs="-lXi $x_libs"
127 else
128   AC_DEFINE(XINPUT_NONE)
129 fi
130
131
132 AC_SUBST(x_cflags)
133 AC_SUBST(x_includes)
134 AC_SUBST(x_ldflags)
135 AC_SUBST(x_libs)
136 AC_SUBST(xinput_progs)
137
138 CFLAGS="$saved_cflags"
139 LDFLAGS="$saved_ldflags"
140
141 if test "x$enable_shm" = "xyes"; then
142   # Check for shared memory
143   AC_CHECK_HEADER(sys/ipc.h, AC_DEFINE(HAVE_IPC_H), no_sys_ipc=yes)
144   AC_CHECK_HEADER(sys/shm.h, AC_DEFINE(HAVE_SHM_H), no_sys_shm=yes)
145
146   # Check whether shmctl IPC_RMID allowes subsequent attaches
147   if test "$ac_cv_header_sys_shm_h" = "yes"; then
148     AC_MSG_CHECKING(whether shmctl IPC_RMID allowes subsequent attaches)
149     AC_TRY_RUN([
150           #include <sys/types.h>
151           #include <sys/ipc.h>
152           #include <sys/shm.h>
153           int main()
154           {
155             int id;
156             char *shmaddr;
157           id = shmget (IPC_PRIVATE, 4, IPC_CREAT | 0777);
158           if (id == -1)
159             exit (2);
160             shmaddr = shmat (id, 0, 0);
161             shmctl (id, IPC_RMID, 0);
162             if ((char*) shmat (id, 0, 0) == (char*) -1)
163             {
164               shmdt (shmaddr);
165               exit (1);
166             }
167             shmdt (shmaddr);
168             shmdt (shmaddr);
169             exit (0);
170           }
171       ],
172       AC_DEFINE(IPC_RMID_DEFERRED_RELEASE)
173         AC_MSG_RESULT(yes),
174       AC_MSG_RESULT(no),
175       AC_MSG_RESULT(assuming no))
176   fi
177
178   # Check for the X shared memory extension header file
179   AC_MSG_CHECKING(X11/extensions/XShm.h)
180   if test "x$no_xext_lib" = "xyes"; then
181     AC_MSG_RESULT(no)
182     no_xshm=yes
183   else
184     if test -f "$x_includes/X11/extensions/XShm.h"; then
185       AC_MSG_RESULT(yes)
186       AC_DEFINE(HAVE_XSHM_H)
187     else
188       AC_MSG_RESULT(no)
189       no_xshm=yes
190     fi
191   fi
192 fi
193
194 # Check for private display resource base variable
195 AC_MSG_CHECKING(resource base field in XDisplay)
196 AC_CACHE_VAL(gtk_cv_display_resource_base,
197 [AC_TRY_RUN([
198 #define XLIB_ILLEGAL_ACCESS
199 #include <X11/Xlib.h>
200
201 int
202 main ()
203 {
204   Display *display;
205
206   return 0;
207
208   display->resource_base;
209 }],
210 gtk_cv_display_resource_base="resource_base",
211 gtk_cv_display_resource_base="private3")])
212 AC_MSG_RESULT($gtk_cv_display_resource_base)
213 AC_DEFINE_UNQUOTED(RESOURCE_BASE, gdk_display->$gtk_cv_display_resource_base)
214
215 # Check if X_LOCALE definition is necessary
216
217 AC_MSG_CHECKING(need -DX_LOCALE)
218
219 AC_TRY_RUN([
220 #include <stdio.h>
221 #include <locale.h>
222
223 int
224 main ()
225 {
226   return setlocale (LC_ALL, "${with_locale}") == NULL;
227 }],
228 need_x_locale=no,
229 need_x_locale=yes)
230 AC_MSG_RESULT($need_x_locale)
231
232 if test $need_x_locale = yes; then
233   CFLAGS="$CFLAGS -DX_LOCALE"
234 fi
235
236 # Checks for header files.
237 AC_HEADER_STDC
238
239 # Checks for typedefs, structures, and compiler characteristics.
240 AC_C_CONST
241 AC_C_INLINE
242
243 # Checks for library functions.
244 AC_TYPE_SIGNAL
245 AC_FUNC_MMAP
246
247 # Check for sys/select.h
248
249 AC_MSG_CHECKING([fd_set and sys/select])
250 AC_TRY_COMPILE([#include <sys/types.h>],
251         [fd_set readMask, writeMask;], gtk_ok=yes, gtk_ok=no)
252 if test $gtk_ok = no; then
253     AC_HEADER_EGREP(fd_mask, sys/select.h, gtk_ok=yes)
254     if test $gtk_ok = yes; then
255         AC_DEFINE(HAVE_SYS_SELECT_H)
256     fi
257 fi
258 AC_MSG_RESULT($gtk_ok)
259 if test $gtk_ok = no; then
260     AC_DEFINE(NO_FD_SET)
261 fi
262
263 AC_OUTPUT(Makefile gtk+.xconfig docs/Makefile gdk/Makefile gtk/Makefile)