made the check for needed underscore in module's func-names work on
[platform/upstream/glib.git] / configure.in
1 # Process this file with autoconf to produce a configure script.
2 AC_INIT(glist.c)
3
4 # Save this value here, since automake will set cflags later
5 cflags_set=${CFLAGS+set}
6
7 # The following version number definitions apply to GLib and GModule
8 # as a whole, so if changes occoured in either of them, they are both
9 # treated with the same interface and binary age.
10 #
11 # Making releases:
12 #   GLIB_MICRO_VERSION += 1;
13 #   GLIB_INTERFACE_AGE += 1;
14 #   GLIB_BINARY_AGE += 1;
15 # if any functions have been added, set GLIB_INTERFACE_AGE to 0.
16 # if backwards compatibility has been broken,
17 # set GLIB_BINARY_AGE and GLIB_INTERFACE_AGE to 0.
18 #
19 GLIB_MAJOR_VERSION=1
20 GLIB_MINOR_VERSION=1
21 GLIB_MICRO_VERSION=4
22 GLIB_INTERFACE_AGE=0
23 GLIB_BINARY_AGE=0
24 GLIB_VERSION=$GLIB_MAJOR_VERSION.$GLIB_MINOR_VERSION.$GLIB_MICRO_VERSION
25 AC_SUBST(GLIB_VERSION)
26
27 # libtool versioning
28 LT_RELEASE=$GLIB_MAJOR_VERSION.$GLIB_MINOR_VERSION
29 LT_CURRENT=`expr $GLIB_MICRO_VERSION - $GLIB_INTERFACE_AGE`
30 LT_REVISION=$GLIB_INTERFACE_AGE
31 LT_AGE=`expr $GLIB_BINARY_AGE - $GLIB_INTERFACE_AGE`
32 AC_SUBST(LT_RELEASE)
33 AC_SUBST(LT_CURRENT)
34 AC_SUBST(LT_REVISION)
35 AC_SUBST(LT_AGE)
36
37 VERSION=$GLIB_VERSION
38 PACKAGE=glib
39
40 AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
41
42 # Specify a configuration file
43 AM_CONFIG_HEADER(glibconfig.h)
44
45 AC_DEFINE_UNQUOTED(GLIB_MAJOR_VERSION, $GLIB_MAJOR_VERSION)
46 AC_DEFINE_UNQUOTED(GLIB_MINOR_VERSION, $GLIB_MINOR_VERSION)
47 AC_DEFINE_UNQUOTED(GLIB_MICRO_VERSION, $GLIB_MICRO_VERSION)
48 AC_DEFINE_UNQUOTED(GLIB_INTERFACE_AGE, $GLIB_INTERFACE_AGE)
49 AC_DEFINE_UNQUOTED(GLIB_BINARY_AGE, $GLIB_BINARY_AGE)
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(debug, [  --enable-debug=[no/minimum/yes] turn on debugging [default=minimum]],,enable_debug=minimum)
60 AC_ARG_ENABLE(mem_check, [  --enable-mem-check=[no/yes] turn on malloc/free sanity checking [default=no]],,enable_mem_check=no)
61 AC_ARG_ENABLE(mem_profile, [  --enable-mem-profile=[no/yes] turn on malloc profiling atexit [default=no]],,enable_mem_profile=no)
62
63 AC_ARG_ENABLE(ansi, [  --enable-ansi           turn on strict ansi [default=no]],
64                     , enable_ansi=no)
65
66 AC_MSG_CHECKING(whether to enable memory checking)
67 if test "x$enable_mem_check" = "xyes"; then
68   AC_DEFINE(ENABLE_MEM_CHECK, 1)
69   AC_SUBST(ENABLE_MEM_CHECK)
70   AC_MSG_RESULT(yes)
71 else
72   AC_MSG_RESULT(no)
73 fi
74
75 AC_MSG_CHECKING(whether to enable memory profiling)
76 if test "x$enable_mem_profile" = "xyes"; then
77   AC_DEFINE(ENABLE_MEM_PROFILE, 1)
78   AC_SUBST(ENABLE_MEM_PROFILE)
79   AC_MSG_RESULT(yes)
80 else
81   AC_MSG_RESULT(no)
82 fi
83
84 if test "x$enable_debug" = "xyes"; then
85   test "$cflags_set" = set || CFLAGS="$CFLAGS -g"
86   CFLAGS="$CFLAGS -DG_ENABLE_DEBUG"
87 else
88   if test "x$enable_debug" = "xno"; then
89     CFLAGS="$CFLAGS -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS"
90   fi
91 fi
92
93 AC_DEFINE_UNQUOTED(G_COMPILED_WITH_DEBUGGING, "${enable_debug}")
94
95 # Checks for programs.
96 AC_PROG_CC
97 AM_PROG_CC_STDC
98 AC_PROG_INSTALL
99
100 if eval "test x$GCC = xyes"; then
101   if eval test -z \"`echo "$CFLAGS" | grep "\-Wall" 2> /dev/null`\" ; then
102     CFLAGS="$CFLAGS -Wall"
103   fi
104
105   if eval "test x$enable_ansi = xyes"; then
106     if eval test -z \"`echo "$CFLAGS" | grep "\-ansi" 2> /dev/null`\" ; then
107       CFLAGS="$CFLAGS -ansi"
108     fi
109
110     if eval test -z \"`echo "$CFLAGS" | grep "\-pedantic" 2> /dev/null`\" ; then
111       CFLAGS="$CFLAGS -pedantic"
112     fi
113   fi
114 fi
115
116 dnl DU4 native cc currently needs -std1 for ANSI mode (instead of K&R)
117 AC_MSG_CHECKING([for extra flags to get ANSI library prototypes])
118 glib_save_LIBS=$LIBS
119 LIBS="$LIBS -lm"
120 AC_TRY_RUN([#include <math.h>
121              int main (void) { return (log(1) != log(1.)); }],
122      AC_MSG_RESULT(none needed),
123      glib_save_CFLAGS=$CFLAGS
124      CFLAGS="$CFLAGS -std1"
125      AC_TRY_RUN([#include <math.h>
126                  int main (void) { return (log(1) != log(1.)); }],
127          AC_MSG_RESULT(-std1),
128          AC_MSG_RESULT()
129          CFLAGS=$glib_save_CFLAGS
130          AC_MSG_WARN(
131                 [No ANSI prototypes found in library. (-std1 didn't work.)])
132      )
133 )
134 LIBS=$glib_save_LIBS
135
136 dnl NeXTStep cc seems to need this
137 AC_MSG_CHECKING([for extra flags for POSIX compliance])
138 AC_TRY_COMPILE([#include <dirent.h>], [DIR *dir;],
139   AC_MSG_RESULT(none needed),
140   glib_save_CFLAGS=$CFLAGS
141   CFLAGS="$CFLAGS -posix"
142   AC_TRY_COMPILE([#include <dirent.h>], [DIR *dir;],
143     AC_MSG_RESULT(-posix),
144     AC_MSG_RESULT()
145     CFLAGS=$glib_save_CFLAGS
146     AC_MSG_WARN([Could not determine POSIX flag. (-posix didn't work.)])))
147
148 # Checks for header files.
149 AC_HEADER_STDC
150
151 # Checks for library functions.
152 AC_FUNC_VPRINTF
153
154 AC_CHECK_FUNCS(atexit on_exit)
155
156 AC_CHECK_SIZEOF(char)
157 AC_CHECK_SIZEOF(short)
158 AC_CHECK_SIZEOF(long)
159 AC_CHECK_SIZEOF(int)
160 AC_CHECK_SIZEOF(void *)
161 AC_CHECK_SIZEOF(long long)
162
163 dnl long doubles were not used, and a portability problem 
164 dnl AC_C_LONG_DOUBLE
165 AC_C_CONST
166
167 dnl AC_C_INLINE is useless to us since it bails out too early, we need to
168 dnl truely know which ones of `inline', `__inline' and `__inline__' are
169 dnl actually supported.
170 AC_MSG_CHECKING(for __inline)
171 AC_CACHE_VAL(glib_cv_has__inline,[
172         AC_TRY_RUN([
173         __inline int foo () { return 0; }
174         int main () { return foo (); }
175         ],
176         glib_cv_has__inline=yes
177         ,
178         glib_cv_has__inline=no
179         ,)
180 ])
181 AC_MSG_RESULT($glib_cv_has__inline)
182 case x$glib_cv_has__inline in
183 xyes) AC_DEFINE(G_HAVE___INLINE)
184 esac
185 AC_MSG_CHECKING(for __inline__)
186 AC_CACHE_VAL(glib_cv_has__inline__,[
187         AC_TRY_RUN([
188         __inline__ int foo () { return 0; }
189         int main () { return foo (); }
190         ],
191         glib_cv_has__inline__=yes
192         ,
193         glib_cv_has__inline__=no
194         ,)
195 ])
196 AC_MSG_RESULT($glib_cv_has__inline__)
197 case x$glib_cv_has__inline__ in
198 xyes) AC_DEFINE(G_HAVE___INLINE__)
199 esac
200 AC_MSG_CHECKING(for inline)
201 AC_CACHE_VAL(glib_cv_hasinline,[
202         AC_TRY_RUN([
203         inline int foo () { return 0; }
204         int main () { return foo (); }
205         ],
206         glib_cv_hasinline=yes
207         ,
208         glib_cv_hasinline=no
209         ,)
210 ])
211 AC_MSG_RESULT($glib_cv_hasinline)
212 case x$glib_cv_hasinline in
213 xyes) AC_DEFINE(G_HAVE_INLINE)
214 esac
215
216 dnl for bytesex stuff
217 AC_C_BIGENDIAN
218
219 dnl header file checks
220 AC_CHECK_HEADERS(float.h, AC_DEFINE(HAVE_FLOAT_H))
221 AC_CHECK_HEADERS(limits.h, AC_DEFINE(HAVE_LIMITS_H))
222 AC_CHECK_HEADERS(values.h, AC_DEFINE(HAVE_VALUES_H))
223
224 # Check for strerror, strsignal, memmove, vsnprintf, and strcasecmp functions
225 AC_CHECK_FUNCS(strerror strsignal memmove vsnprintf strcasecmp)
226
227 # Check for sys_errlist
228 AC_MSG_CHECKING(for sys_errlist)
229 AC_TRY_LINK(, [
230 extern char *sys_errlist[];
231 extern int sys_nerr;
232 sys_errlist[sys_nerr-1][0] = 0;
233 ], glib_ok=yes, glib_ok=no)
234 AC_MSG_RESULT($glib_ok)
235 if test $glib_ok = no; then
236     AC_DEFINE(NO_SYS_ERRLIST)
237 fi
238
239 # Check for sys_siglist
240 AC_MSG_CHECKING(for sys_siglist)
241 AC_TRY_LINK(, [
242 extern char *sys_siglist[];
243 sys_siglist[1][0] = 0;
244 ], glib_ok=yes, glib_ok=no)
245 AC_MSG_RESULT($glib_ok)
246 if test $glib_ok = no; then
247     AC_DEFINE(NO_SYS_SIGLIST)
248 fi
249
250 # Check if <sys/select.h> needs to be included for fd_set
251 AC_MSG_CHECKING([for fd_set])
252 AC_TRY_COMPILE([#include <sys/types.h>],
253         [fd_set readMask, writeMask;], gtk_ok=yes, gtk_ok=no)
254 if test $gtk_ok = yes; then
255     AC_MSG_RESULT([yes, found in sys/types.h])
256 else
257     AC_HEADER_EGREP(fd_mask, sys/select.h, gtk_ok=yes)
258     if test $gtk_ok = yes; then
259         AC_DEFINE(HAVE_SYS_SELECT_H)
260         AC_MSG_RESULT([yes, found in sys/select.h])
261     else
262         AC_DEFINE(NO_FD_SET)
263         AC_MSG_RESULT(no)
264     fi
265 fi
266
267 # This stuff is here, only so that we can define these
268 # things in glibconfig.h. If ../config.h was installed
269 # (under some other name?) then the definitions would
270 # belong there. (They are only used in GDK)
271
272 # Check for wchar.h
273
274 AC_MSG_CHECKING(for wchar.h)
275 AC_TRY_CPP([#include <wchar.h>], gtk_ok=yes, gtk_ok=no)
276 if test $gtk_ok = yes; then
277    AC_DEFINE(HAVE_WCHAR_H)
278 fi
279 AC_MSG_RESULT($gtk_ok)
280
281 # Check for wctype.h (for iswalnum)
282
283 AC_MSG_CHECKING(for wctype.h)
284 AC_TRY_CPP([#include <wctype.h>], gtk_ok=yes, gtk_ok=no)
285 if test $gtk_ok = yes; then
286    AC_DEFINE(HAVE_WCTYPE_H)
287 fi
288 AC_MSG_RESULT($gtk_ok)
289
290 # The following is necessary for Linux libc-5.4.38
291
292 AC_MSG_CHECKING(if iswalnum() and friends are properly defined)
293 AC_TRY_LINK([#include <stdlib.h>],[
294 #if (defined(HAVE_WCTYPE_H) || defined(HAVE_WCHAR_H))
295 #  ifdef HAVE_WCTYPE_H
296 #    include <wctype.h>
297 #  else
298 #    ifdef HAVE_WCHAR_H
299 #      include <wchar.h>
300 #    endif
301 #  endif
302 #else
303 #  define iswalnum(c) ((wchar_t)(c) <= 0xFF && isalnum(c))
304 #endif
305 iswalnum((wchar_t) 0);
306 ], gtk_ok=yes, gtk_ok=no)
307
308 if test $gtk_ok = no; then
309    AC_DEFINE(HAVE_BROKEN_WCTYPE)
310 fi
311 AC_MSG_RESULT($gtk_ok)
312
313 dnl **********************
314 dnl *** va_copy checks ***
315 dnl **********************
316 dnl we currently check for all three va_copy possibilities, so we get
317 dnl all results in config.log for bug reports.
318 AC_MSG_CHECKING(for an implementation of va_copy())
319 AC_CACHE_VAL(glib_cv_va_copy,[
320         AC_TRY_RUN([
321         #include <stdarg.h>
322         void f (int i, ...) {
323         va_list args1, args2;
324         va_start (args1, i);
325         va_copy (args2, args1);
326         if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
327           exit (1);
328         va_end (args1); va_end (args2);
329         }
330         int main() {
331           f (0, 42);
332           return 0;
333         }],
334         glib_cv_va_copy=yes
335         ,
336         glib_cv_va_copy=no
337         ,)
338 ])
339 AC_MSG_RESULT($glib_cv_va_copy)
340 AC_MSG_CHECKING(for an implementation of __va_copy())
341 AC_CACHE_VAL(glib_cv___va_copy,[
342         AC_TRY_RUN([
343         #include <stdarg.h>
344         void f (int i, ...) {
345         va_list args1, args2;
346         va_start (args1, i);
347         __va_copy (args2, args1);
348         if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
349           exit (1);
350         va_end (args1); va_end (args2);
351         }
352         int main() {
353           f (0, 42);
354           return 0;
355         }],
356         glib_cv___va_copy=yes
357         ,
358         glib_cv___va_copy=no
359         ,)
360 ])
361 AC_MSG_RESULT($glib_cv___va_copy)
362 AC_MSG_CHECKING(whether va_lists can be copied by value)
363 AC_CACHE_VAL(glib_cv_va_val_copy,[
364         AC_TRY_RUN([
365         #include <stdarg.h>
366         void f (int i, ...) {
367         va_list args1, args2;
368         va_start (args1, i);
369         args2 = args1;
370         if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
371           exit (1);
372         va_end (args1); va_end (args2);
373         }
374         int main() {
375           f (0, 42);
376           return 0;
377         }],
378         glib_cv_va_val_copy=yes
379         ,
380         glib_cv_va_val_copy=no
381         ,)
382 ])
383 if test "x$glib_cv_va_copy" = "xyes"; then
384   AC_DEFINE(G_VA_COPY, va_copy)
385 else if test "x$glib_cv___va_copy" = "xyes"; then
386   AC_DEFINE(G_VA_COPY, __va_copy)
387 fi
388 fi
389 if test "x$glib_cv_va_val_copy" = "xno"; then
390   AC_DEFINE(G_VA_COPY_AS_ARRAY)
391 fi
392 AC_MSG_RESULT($glib_cv_va_val_copy)
393
394
395 dnl ***********************
396 dnl *** g_module checks ***
397 dnl ***********************
398 G_MODULE_LIBS=
399 G_MODULE_LDFLAGS=
400 G_MODULE_IMPL=
401 G_MODULE_NEED_USCORE=0
402 G_MODULE_HAVE_DLERROR=0
403 dnl *** dlopen() in system libraries
404 if test -z "$G_MODULE_IMPL"; then
405         AC_CHECK_FUNC(dlopen,
406                 G_MODULE_IMPL=G_MODULE_IMPL_DL
407         ,)
408 fi
409 dnl *** dlopen() in libdl
410 if test -z "$G_MODULE_IMPL"; then
411         AC_CHECK_LIB(dl, dlopen,
412                 G_MODULE_LIBS=-ldl
413                 G_MODULE_IMPL=G_MODULE_IMPL_DL
414         ,)
415 fi
416 dnl *** shl_load() in libdld (HP-UX)
417 if test -z "$G_MODULE_IMPL"; then
418         G_MODULE_LDFLAGS='-Wl,-E'
419         AC_CHECK_LIB(dld, shl_load,
420                 G_MODULE_LIBS=-ldld
421                 G_MODULE_IMPL=G_MODULE_IMPL_DLD
422         ,)
423 fi
424 dnl *** additional checks for G_MODULE_IMPL_DL
425 if test "$G_MODULE_IMPL" = "G_MODULE_IMPL_DL"; then
426         if test -d /usr/include/linux; then
427                 G_MODULE_LDFLAGS='-rdynamic'
428         fi
429         LIBS_orig="$LIBS"
430         LDFLAGS_orig="$LDFLAGS"
431         LIBS="$LIBS $G_MODULE_LIBS"
432         LDFLAGS="$LDFLAGS $G_MODULE_LDFLAGS"
433 dnl *** check whether we need preceeding underscores
434         AC_MSG_CHECKING(for preceeding underscore in symbols)
435         AC_CACHE_VAL(glib_cv_uscore,[
436                 echo "int glib_underscore_test (void) { return 42; }" >plugin.c
437                 ./libtool --mode=compile $CC -c plugin.c >/dev/null 2>&1
438                 AC_TRY_RUN([
439                 #include <dlfcn.h>
440                 int main() {
441                   void *f1 = (void*)0, *f2 = (void*)0, *handle;
442                   handle = dlopen ("./plugin.lo", RTLD_NOW );
443                   if (handle) {
444                     f1 = dlsym (handle, "glib_underscore_test");
445                     f2 = dlsym (handle, "_glib_underscore_test");
446                   } return (!f2 && f1);
447                 }],     
448                         glib_cv_uscore=yes,     
449                         glib_cv_uscore=no,
450                 )
451                 rm -f plugin.c plugin.o plugin.lo
452         ])
453         AC_MSG_RESULT($glib_cv_uscore)  
454         if test "x$glib_cv_uscore" = "xyes"; then
455                 G_MODULE_NEED_USCORE=1
456         else
457                 G_MODULE_NEED_USCORE=0
458         fi      
459         
460         LDFLAGS="$LDFLAGS_orig"
461 dnl *** check for having dlerror()
462         AC_CHECK_FUNC(dlerror,
463                 G_MODULE_HAVE_DLERROR=1,
464                 G_MODULE_HAVE_DLERROR=0)
465         LIBS="$LIBS_orig"
466 fi
467 dnl *** done, have e got an implementation?
468 if test -z "$G_MODULE_IMPL"; then
469         G_MODULE_IMPL=0
470 fi
471 AC_SUBST(G_MODULE_IMPL)
472 AC_SUBST(G_MODULE_LIBS)
473 AC_SUBST(G_MODULE_LDFLAGS)
474 AC_SUBST(G_MODULE_HAVE_DLERROR)
475 AC_SUBST(G_MODULE_NEED_USCORE)
476
477
478 AC_OUTPUT([
479 Makefile
480 glib-config
481 gmodule/gmoduleconf.h
482 gmodule/Makefile
483 ],[chmod +x glib-config])