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