configure.in 84.1 KB
Newer Older
1 2 3 4
# Process this file with autoconf to produce a configure script.
# require autoconf 2.54
AC_PREREQ(2.54)

5 6 7
dnl ***********************************
dnl *** include special GLib macros ***
dnl ***********************************
8

9
m4_define(glib_configure_in)
Owen Taylor's avatar
Owen Taylor committed
10

11
#
12 13
# The following version number definitions apply to GLib, GModule, GObject 
# and GThread as a whole, so if changes occoured in any of them, they are all
14 15
# treated with the same interface and binary age.
#
Owen Taylor's avatar
Owen Taylor committed
16
# Making releases:
17 18 19 20
#   glib_micro_version += 1;
#   glib_interface_age += 1;
#   glib_binary_age += 1;
# if any functions have been added, set glib_interface_age to 0.
Owen Taylor's avatar
Owen Taylor committed
21
# if backwards compatibility has been broken,
22
# set glib_binary_age _and_ glib_interface_age to 0.
Owen Taylor's avatar
Owen Taylor committed
23
#
24
m4_define([glib_major_version], [2])
25 26 27
m4_define([glib_minor_version], [15])
m4_define([glib_micro_version], [0])
m4_define([glib_interface_age], [0])
28 29 30
m4_define([glib_binary_age],
          [m4_eval(100 * glib_minor_version + glib_micro_version)])
m4_define([glib_version],
31
          [glib_major_version.glib_minor_version.glib_micro_version])
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67

# libtool version related macros
m4_define([glib_lt_release], [glib_major_version.glib_minor_version])
m4_define([glib_lt_current],
          [m4_eval(100 * glib_minor_version + glib_micro_version - glib_interface_age)])
m4_define([glib_lt_revision], [glib_interface_age])
m4_define([glib_lt_age], [m4_eval(glib_binary_age - glib_interface_age)])
m4_define([glib_lt_current_minus_age],
          [m4_eval(glib_lt_current - glib_lt_age)])

# if the minor version number is odd, then we want debugging.  Otherwise
# we only want minimal debugging support.
m4_define([glib_debug_default],
          [m4_if(m4_eval(glib_minor_version % 2), [1], [yes], [minimum])])dnl


AC_INIT(glib, [glib_version],
        [http://bugzilla.gnome.org/enter_bug.cgi?product=glib])

AC_CONFIG_SRCDIR([glib/glib.h])

# Save this value here, since automake will set cflags later
cflags_set=${CFLAGS+set}

AM_INIT_AUTOMAKE([no-define])

# Specify a configuration file
AM_CONFIG_HEADER([config.h])


GLIB_MAJOR_VERSION=glib_major_version
GLIB_MINOR_VERSION=glib_minor_version
GLIB_MICRO_VERSION=glib_micro_version
GLIB_INTERFACE_AGE=glib_interface_age
GLIB_BINARY_AGE=glib_binary_age
GLIB_VERSION=glib_version
68

69 70
AC_SUBST(GLIB_MAJOR_VERSION)
AC_SUBST(GLIB_MINOR_VERSION)
71
AC_SUBST(GLIB_MICRO_VERSION)
Owen Taylor's avatar
Owen Taylor committed
72
AC_SUBST(GLIB_VERSION)
73 74
AC_SUBST(GLIB_INTERFACE_AGE)
AC_SUBST(GLIB_BINARY_AGE)
Owen Taylor's avatar
Owen Taylor committed
75

76 77 78 79 80 81 82 83 84 85 86
AC_DEFINE(GLIB_MAJOR_VERSION, [glib_major_version],
	  [Define to the GLIB major version])
AC_DEFINE(GLIB_MINOR_VERSION, [glib_minor_version],
	  [Define to the GLIB minor version])
AC_DEFINE(GLIB_MICRO_VERSION, [glib_micro_version],
	  [Define to the GLIB micro version])
AC_DEFINE(GLIB_INTERFACE_AGE, [glib_interface_age],
	  [Define to the GLIB interface age])
AC_DEFINE(GLIB_BINARY_AGE, [glib_binary_age],
	  [Define to the GLIB binary age])

Owen Taylor's avatar
Owen Taylor committed
87
# libtool versioning
88 89 90 91 92
LT_RELEASE=glib_lt_release
LT_CURRENT=glib_lt_current
LT_REVISION=glib_lt_revision
LT_AGE=glib_lt_age
LT_CURRENT_MINUS_AGE=glib_lt_current_minus_age
Owen Taylor's avatar
Owen Taylor committed
93 94 95 96
AC_SUBST(LT_RELEASE)
AC_SUBST(LT_CURRENT)
AC_SUBST(LT_REVISION)
AC_SUBST(LT_AGE)
97
AC_SUBST(LT_CURRENT_MINUS_AGE)
Owen Taylor's avatar
Owen Taylor committed
98 99 100 101 102 103

dnl Initialize maintainer mode
AM_MAINTAINER_MODE

AC_CANONICAL_HOST

104
AC_MSG_CHECKING([for the BeOS])
105 106 107 108
case $host in
  *-*-beos*)
    glib_native_beos="yes"
    ;;
109
  *)
110 111 112
    glib_native_beos="no"
    ;;
esac
113
AC_MSG_RESULT([$glib_native_beos])
114

115
dnl
116

117 118 119
AC_MSG_CHECKING([for Win32])
case "$host" in
  *-*-mingw*)
120
    glib_native_win32=yes
121 122 123 124 125
    GLIB_DEF=glib.def
    GMODULE_DEF=gmodule.def
    GOBJECT_DEF=gobject.def
    GTHREAD_DEF=gthread.def
    TESTGMODULE_EXP=testgmodule.exp
Owen Taylor's avatar
Owen Taylor committed
126
    glib_pid_type='void *'
127 128
    ;;
  *)
129
    glib_native_win32=no
130 131 132 133 134
    GLIB_DEF=
    GMODULE_DEF=
    GOBJECT_DEF=
    GTHREAD_DEF=
    TESTGMODULE_EXP=
135
    glib_pid_type=int
136 137
    ;;
esac
138 139 140 141 142 143
case $host in
  *-*-linux*)
    glib_os_linux=yes
    ;;
esac

144
AC_MSG_RESULT([$glib_native_win32])
145 146 147 148 149 150 151 152 153 154

glib_have_carbon=no
AC_MSG_CHECKING([for Mac OS X Carbon support])
AC_TRY_CPP([
#include <Carbon/Carbon.h>
#include <CoreServices/CoreServices.h>
], glib_have_carbon=yes)

AC_MSG_RESULT([$glib_have_carbon])

155
AM_CONDITIONAL(OS_WIN32, [test "$glib_native_win32" = "yes"])
156
AM_CONDITIONAL(OS_UNIX, [test "$glib_native_win32" != "yes"])
157
AM_CONDITIONAL(OS_LINUX, [test "$glib_os_linux" = "yes"])
158
AM_CONDITIONAL(OS_CARBON, [test "$glib_have_carbon" = "yes"])
159 160 161 162 163 164
AC_SUBST(GLIB_DEF)
AC_SUBST(GMODULE_DEF)
AC_SUBST(GOBJECT_DEF)
AC_SUBST(GTHREAD_DEF)
AC_SUBST(TESTGMODULE_EXP)

165
if test "$glib_native_win32" = "yes"; then
166 167 168 169
  AC_CHECK_TOOL(WINDRES, windres, no)
  if test "$WINDRES" = no; then
    AC_MSG_ERROR([*** Could not find an implementation of windres in your PATH.])
  fi
170
  AC_CHECK_TOOL(NM, nm, no)
171
  if test "$NM" = no; then
172 173 174
    AC_MSG_ERROR([*** Could not find an implementation of nm in your PATH.])
  fi
  AC_CHECK_TOOL(RANLIB, ranlib, :)
175
  AC_CHECK_PROG(ms_librarian, [lib.exe], [yes], [no])
176
fi
177
AM_CONDITIONAL(MS_LIB_AVAILABLE, [test x$ms_librarian = xyes])
178

179 180 181
if test "$glib_native_win32" != yes; then
    # libtool option to control which symbols are exported
    # right now, symbols starting with _ are not exported
182
    LIBTOOL_EXPORT_OPTIONS='-export-symbols-regex "^g.*"'
183 184 185 186 187 188
else
    # We currently use .def files on Windows
    LIBTOOL_EXPORT_OPTIONS=
fi
AC_SUBST(LIBTOOL_EXPORT_OPTIONS)

189 190 191 192 193 194
if test "x$glib_have_carbon" = "xyes"; then
  AC_DEFINE(HAVE_CARBON, 1, [define to 1 if Carbon is available])
  LDFLAGS="$LDFLAGS -framework Carbon"
fi


195
dnl declare --enable-* args and collect ac_help strings
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
AC_ARG_ENABLE(debug,
              AC_HELP_STRING([--enable-debug=@<:@no/minimum/yes@:>@],
                             [turn on debugging @<:@default=glib_debug_default@:>@]),,
              enable_debug=glib_debug_default)

AC_ARG_ENABLE(gc_friendly,
              [AC_HELP_STRING([--enable-gc-friendly],
                              [turn on garbage collector friendliness [default=no]])],,
              [enable_gc_friendly=no])
AC_ARG_ENABLE(mem_pools,
              [AC_HELP_STRING([--disable-mem-pools],
			      [disable all glib memory pools])],,
	      [disable_mem_pools=no])
AC_ARG_ENABLE(threads,
              [AC_HELP_STRING([--enable-threads],
                              [turn on basic thread support [default=yes]
([=no] will override --with-threads)])],,
              [enable_threads=yes])
AC_ARG_ENABLE(rebuilds,
              [AC_HELP_STRING([--disable-rebuilds],
                              [disable all source autogeneration rules])],,
              [enable_rebuilds=yes])
218 219 220 221
AC_ARG_ENABLE(visibility,
              [AC_HELP_STRING([--disable-visibility],
                              [don't use ELF visibility attributes])],,
              [enable_visibility=yes])
222 223 224 225

if test "x$enable_threads" != "xyes"; then
  enable_threads=no
fi
Owen Taylor's avatar
Owen Taylor committed
226

227
AC_MSG_CHECKING([whether to enable garbage collector friendliness])
228
if test "x$enable_gc_friendly" = "xyes"; then
229
  AC_DEFINE(ENABLE_GC_FRIENDLY_DEFAULT, 1, [Whether to enable GC friendliness by default])
230
  AC_MSG_RESULT([yes])
231
else
232
  AC_MSG_RESULT([no])
233
fi
234

235
AC_MSG_CHECKING([whether to disable memory pools])
236
if test "x$disable_mem_pools" = "xno"; then
237
  AC_MSG_RESULT([no])
238
else
239
  AC_DEFINE(DISABLE_MEM_POOLS, [1], [Whether to disable memory pools])
240
  AC_SUBST(DISABLE_MEM_POOLS)
241
  AC_MSG_RESULT([yes])
242 243
fi

244 245 246 247 248 249 250 251 252 253 254
if test "$glib_native_win32" = "yes"; then
  if test x$enable_static = xyes -o x$enable_static = x; then
    AC_MSG_WARN([Disabling static library build, must build as DLL on Windows.])
    enable_static=no
  fi
  if test x$enable_shared = xno; then
    AC_MSG_WARN([Enabling shared library build, must build as DLL on Windows.])
  fi
  enable_shared=yes
fi

Owen Taylor's avatar
Owen Taylor committed
255
dnl Checks for programs.
256
AC_PROG_CC
257 258

dnl Check for a working C++ compiler, but do not bail out, if none is found.
259
AC_CHECK_PROGS(CXX, [$CCC c++ g++ gcc CC cxx cc++ cl], [gcc])
260 261 262
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_TRY_COMPILE(,[class a { int b; } c;], ,CXX=)
263
AM_CONDITIONAL(HAVE_CXX, [test "$CXX" != ""])
264
AC_LANG_RESTORE
Owen Taylor's avatar
Owen Taylor committed
265

266
AM_PROG_CC_STDC
Matthias Clasen's avatar
Matthias Clasen committed
267
AM_PROG_CC_C_O
268 269
AC_PROG_INSTALL

Owen Taylor's avatar
Owen Taylor committed
270 271
AC_SYS_LARGEFILE

272 273 274
#
# Find pkg-config
#
275
AC_PATH_PROG(PKG_CONFIG, [pkg-config], [no])
276
if test x$PKG_CONFIG = xno ; then
277
  AC_MSG_ERROR([*** pkg-config not found. See http://www.freedesktop.org/software/pkgconfig/])
278 279
fi

280
if $PKG_CONFIG --atleast-pkgconfig-version 0.16 ; then
281 282
  :
else
283
  AC_MSG_ERROR([*** pkg-config too old; version 0.16 or better required.])
284 285
fi

286 287 288 289 290 291 292 293 294 295
if test "x$enable_debug" = "xyes"; then
  if test x$cflags_set != xset ; then
      case " $CFLAGS " in
      *[[\ \	]]-g[[\ \	]]*) ;;
      *) CFLAGS="$CFLAGS -g" ;;
      esac
  fi
	
  GLIB_DEBUG_FLAGS="-DG_ENABLE_DEBUG"
else
296 297
  GLIB_DEBUG_FLAGS="-DG_DISABLE_CAST_CHECKS"

298
  if test "x$enable_debug" = "xno"; then
299
    GLIB_DEBUG_FLAGS="$GLIB_DEBUG_FLAGS -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS"
300 301 302
  fi
fi

303 304 305 306
if test "x$enable_visibility" = "xno"; then
  GLIB_DEBUG_FLAGS="$GLIB_DEBUG_FLAGS -DDISABLE_VISIBILITY"
fi

307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330
# Ensure MSVC-compatible struct packing convention is used when
# compiling for Win32 with gcc.
# What flag to depends on gcc version: gcc3 uses "-mms-bitfields", while
# gcc2 uses "-fnative-struct".
if test x"$glib_native_win32" = xyes; then
  if test x"$GCC" = xyes; then
    msnative_struct=''
    AC_MSG_CHECKING([how to get MSVC-compatible struct packing])
    if test -z "$ac_cv_prog_CC"; then
      our_gcc="$CC"
    else
      our_gcc="$ac_cv_prog_CC"
    fi
    case `$our_gcc --version | sed -e 's,\..*,.,' -e q` in
      2.)
	if $our_gcc -v --help 2>/dev/null | grep fnative-struct >/dev/null; then
	  msnative_struct='-fnative-struct'
	fi
	;;
      *)
	if $our_gcc -v --help 2>/dev/null | grep ms-bitfields >/dev/null; then
	  msnative_struct='-mms-bitfields'
	fi
	;;
331
    esac
332 333 334 335 336 337 338
    if test x"$msnative_struct" = x ; then
      AC_MSG_RESULT([no way])
      AC_MSG_WARN([produced libraries might be incompatible with MSVC-compiled code])
    else
      CFLAGS="$CFLAGS $msnative_struct"
      AC_MSG_RESULT([${msnative_struct}])
    fi
339 340 341
  fi
fi

342 343
AC_EXEEXT

344 345 346
# define a MAINT-like variable REBUILD which is set if Perl
# and awk are found, so autogenerated sources can be rebuilt
AC_PROG_AWK
347
AC_CHECK_PROGS(PERL, [perl5 perl])
348 349 350 351 352 353 354 355 356 357 358
# We would like indent, but don't require it.
AC_CHECK_PROG(INDENT, indent, indent)
REBUILD=\#
if test "x$enable_rebuilds" = "xyes" && \
     test -n "$PERL" && \
     $PERL -e 'exit !($] >= 5.002)' > /dev/null 2>&1 && \
     test -n "$AWK" ; then
  REBUILD=
fi
AC_SUBST(REBUILD)

359 360 361
# Need full path to Perl for glib-mkenums
#
if test "x$PERL" != x ; then
362
  AC_PATH_PROG(PERL_PATH, [$PERL])
363 364
fi
if test "x$PERL_PATH" = x ; then
365 366 367
  PERL_PATH="/usr/bin/env perl"
fi
AC_SUBST(PERL_PATH)
Owen Taylor's avatar
Owen Taylor committed
368

369 370 371 372 373 374
dnl ***********************
dnl *** Tests for iconv ***
dnl ***********************
dnl
dnl We do this before the gettext checks, to avoid distortion

375 376 377 378
AC_ARG_WITH(libiconv,
            [AC_HELP_STRING([--with-libiconv=@<:@no/gnu/native@:>@],
                            [use the libiconv library])],,
	    [with_libiconv=maybe])
379 380 381 382 383

found_iconv=no
case $with_libiconv in
  maybe)
    # Check in the C library first
384
    AC_CHECK_FUNC(iconv_open, [with_libiconv=no; found_iconv=yes])
385 386
    # Check if we have GNU libiconv
    if test $found_iconv = "no"; then
387
      AC_CHECK_LIB(iconv, libiconv_open, [with_libiconv=gnu; found_iconv=yes])
388 389 390
    fi
    # Check if we have a iconv in -liconv, possibly from vendor
    if test $found_iconv = "no"; then
391
      AC_CHECK_LIB(iconv, iconv_open, [with_libiconv=native; found_iconv=yes])
392 393 394
    fi
    ;;
  no)
395
    AC_CHECK_FUNC(iconv_open, [with_libiconv=no; found_iconv=yes])
396 397
    ;;
  gnu|yes)
398
    AC_CHECK_LIB(iconv, libiconv_open, [with_libiconv=gnu; found_iconv=yes])
399 400
    ;;
  native)
401
    AC_CHECK_LIB(iconv, iconv_open, [with_libiconv=native; found_iconv=yes])
402 403 404 405 406 407 408
    ;;
esac

if test "x$found_iconv" = "xno" ; then
   AC_MSG_ERROR([*** No iconv() implementation found in C library or libiconv])
fi

409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436
jm_GLIBC21
AC_ARG_ENABLE(iconv-cache, 
              [AC_HELP_STRING([--enable-iconv-cache=@<:@yes/no/auto@:>@],
                              [cache iconv descriptors [default=auto]])],,
              [enable_iconv_cache=auto])

AC_MSG_CHECKING([Whether to cache iconv descriptors])
case $enable_iconv_cache in
  auto)
    if test $ac_cv_gnu_library_2_1 = yes; then
      enable_iconv_cache=no
    else 
      enable_iconv_cache=yes
    fi
  ;;
  yes|no) 
  ;;
  *) AC_MSG_ERROR([Value given to --enable-iconv-cache must be one of yes, no or auto])
  ;;
esac

if test $enable_iconv_cache = yes; then
   AC_DEFINE(NEED_ICONV_CACHE,1,[Do we cache iconv descriptors])
fi

AC_MSG_RESULT($enable_iconv_cache)


Owen Taylor's avatar
Owen Taylor committed
437 438 439 440
dnl
dnl gettext support
dnl

441
ALL_LINGUAS="am ar as az be be@latin bg bn bn_IN bs ca cs cy da de dz el en_CA en_GB eo es et eu fa fi fr ga gl gu he hi hr hu hy id is it ja ka kn ko ku lt lv mg mk ml mn ms nb ne nl nn oc or pa pl pt pt_BR ro ru rw sk sl sq sr sr@Latn sr@ije sv ta te th tl tr tt uk vi wa xh yi zh_CN zh_HK zh_TW"
442
GLIB_GNU_GETTEXT
443

444
if test "$gt_cv_have_gettext" != "yes" ; then
445 446 447 448 449 450
  AC_MSG_ERROR([
*** You must have either have gettext support in your C library, or use the 
*** GNU gettext library. (http://www.gnu.org/software/gettext/gettext.html
])
fi

451
LIBS="$INTLLIBS $LIBS"
Owen Taylor's avatar
Owen Taylor committed
452 453 454

GETTEXT_PACKAGE=glib20
AC_SUBST(GETTEXT_PACKAGE)
455
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, ["$GETTEXT_PACKAGE"], 
456
  [Define the gettext package to be used])
Owen Taylor's avatar
Owen Taylor committed
457

458
GLIB_DEFINE_LOCALEDIR(GLIB_LOCALE_DIR)
Owen Taylor's avatar
Owen Taylor committed
459

460 461 462 463
dnl
dnl Now we are done with gettext checks, figure out ICONV_LIBS
dnl

464
if test x$with_libiconv != xno ; then
465 466 467 468 469 470 471 472 473
  case " $INTLLIBS " in
  *[[\ \	]]-liconv[[\ \	]]*) ;;
  *) ICONV_LIBS="-liconv" ;;
  esac
fi
AC_SUBST(ICONV_LIBS)

case $with_libiconv in
  gnu)
474
    AC_DEFINE(USE_LIBICONV_GNU, 1, [Using GNU libiconv])
475 476
    ;;
  native)
477
    AC_DEFINE(USE_LIBICONV_NATIVE, 1, [Using a native implementation of iconv in a separate library])
478 479 480
    ;;
esac

481
dnl Initialize libtool
482
AM_DISABLE_STATIC
483
AC_LIBTOOL_WIN32_DLL
484 485
AM_PROG_LIBTOOL

486 487
if test "x$GCC" = "xyes"; then
  case " $CFLAGS " in
488
  *[[\ \	]]-Wall[[\ \	]]*) ;;
489 490 491 492
  *) CFLAGS="$CFLAGS -Wall" ;;
  esac
fi

493
dnl
494
dnl DU4 native cc currently needs -std1 for ANSI mode (instead of K&R)
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515
dnl
if test $cross_compiling != yes ; then
    AC_MSG_CHECKING([for extra flags to get ANSI library prototypes])
    glib_save_LIBS=$LIBS
    LIBS="$LIBS -lm"
    AC_TRY_RUN([#include <math.h>
		 int main (void) { return (log(1) != log(1.)); }],
	 AC_MSG_RESULT(none needed),
	 glib_save_CFLAGS=$CFLAGS
	 CFLAGS="$CFLAGS -std1"
	 AC_TRY_RUN([#include <math.h>
		     int main (void) { return (log(1) != log(1.)); }],
	     AC_MSG_RESULT(-std1),
	     AC_MSG_RESULT()
	     CFLAGS=$glib_save_CFLAGS
	     AC_MSG_WARN(
		    [No ANSI prototypes found in library. (-std1 didn't work.)])
	 )
    )
    LIBS=$glib_save_LIBS
fi
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533

dnl NeXTStep cc seems to need this
AC_MSG_CHECKING([for extra flags for POSIX compliance])
AC_TRY_COMPILE([#include <dirent.h>], [DIR *dir;],
  AC_MSG_RESULT(none needed),
  glib_save_CFLAGS=$CFLAGS
  CFLAGS="$CFLAGS -posix"
  AC_TRY_COMPILE([#include <dirent.h>], [DIR *dir;],
    AC_MSG_RESULT(-posix),
    AC_MSG_RESULT()
    CFLAGS=$glib_save_CFLAGS
    AC_MSG_WARN([Could not determine POSIX flag. (-posix didn't work.)])))

# Checks for header files.
AC_HEADER_STDC

# Checks for library functions.
AC_FUNC_VPRINTF
534
AC_FUNC_MMAP
535
AC_FUNC_ALLOCA
536 537 538
AC_CHECK_FUNCS(posix_memalign)
AC_CHECK_FUNCS(memalign)
AC_CHECK_FUNCS(valloc)
539

540 541
AC_CHECK_FUNCS(atexit on_exit)

Emmanuele Bassi's avatar
Emmanuele Bassi committed
542 543
AC_CHECK_FUNCS(timegm)

544 545 546 547 548 549
AC_CHECK_SIZEOF(char)
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(void *)
AC_CHECK_SIZEOF(long long)
550
AC_CHECK_SIZEOF(__int64)
551

552
if test x$ac_cv_sizeof_long = x8 || test x$ac_cv_sizeof_long_long = x8 || test x$ac_cv_sizeof___int64 = x8 ; then
553 554 555 556 557 558 559 560
  :
else
  AC_MSG_ERROR([
*** GLib requires a 64 bit type. You might want to consider
*** using the GNU C compiler.
])
fi

561
if test x$glib_native_win32 != xyes && test x$ac_cv_sizeof_long_long = x8; then
562
	# long long is a 64 bit integer.
563
	AC_MSG_CHECKING(for format to printf and scanf a guint64)
564
	AC_CACHE_VAL(glib_cv_long_long_format,[
565
		for format in ll q I64; do
566
		  AC_TRY_RUN([#include <stdio.h>  
567 568 569 570
			int main()
			{
			  long long b, a = -0x3AFAFAFAFAFAFAFALL;
			  char buffer[1000];
571 572
			  sprintf (buffer, "%${format}u", a);
  			  sscanf (buffer, "%${format}u", &b);
573 574 575
			  exit (b!=a);
			}
			],
576 577 578
			[glib_cv_long_long_format=${format}
			break],
			[],[:])
579 580
		done])
	if test -n "$glib_cv_long_long_format"; then
581
	  AC_MSG_RESULT(%${glib_cv_long_long_format}u)
582
	  AC_DEFINE(HAVE_LONG_LONG_FORMAT,1,[define if system printf can print long long])
583 584 585
	  if test x"$glib_cv_long_long_format" = xI64; then
	    AC_DEFINE(HAVE_INT64_AND_I64,1,[define to support printing 64-bit integers with format I64])
	  fi
586 587 588
        else
	  AC_MSG_RESULT(none)
        fi
589 590
elif test x$ac_cv_sizeof___int64 = x8; then
	# __int64 is a 64 bit integer.
591
	AC_MSG_CHECKING(for format to printf and scanf a guint64)
592
	# We know this is MSVCRT.DLL, and what the formats are
593 594
	glib_cv_long_long_format=I64
	AC_MSG_RESULT(%${glib_cv_long_long_format}u)
595
        AC_DEFINE(HAVE_LONG_LONG_FORMAT,1,[define if system printf can print long long])
596
	AC_DEFINE(HAVE_INT64_AND_I64,1,[define to support printing 64-bit integers with format I64])
597 598 599 600 601 602
fi

dnl long doubles were not used, and a portability problem
dnl AC_C_LONG_DOUBLE
AC_C_CONST

603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622
dnl ok, here we try to check whether the systems prototypes for
dnl malloc and friends actually match the prototypes provided
dnl by gmem.h (keep in sync). i currently only know how to check
dnl this reliably with gcc (-Werror), improvements for other
dnl compilers are apprechiated.
SANE_MALLOC_PROTOS=no
AC_MSG_CHECKING([if malloc() and friends prototypes are gmem.h compatible])
glib_save_CFLAGS=$CFLAGS
if test "x$GCC" = "xyes"; then
  CFLAGS="$CFLAGS -Werror"
  AC_TRY_COMPILE([#include <stdlib.h>], [
    void* (*my_calloc_p)  (size_t, size_t) = calloc;
    void* (*my_malloc_p)  (size_t)         = malloc;
    void  (*my_free_p)    (void*)          = free;
    void* (*my_realloc_p) (void*, size_t)  = realloc;
    my_calloc_p = 0;
    my_malloc_p = 0;
    my_free_p = 0;
    my_realloc_p = 0;
  ],
623 624
    AC_DEFINE(SANE_MALLOC_PROTOS, 1, 
      [Define if you have correct malloc prototypes])
625 626 627 628 629
    SANE_MALLOC_PROTOS=yes)
fi
AC_MSG_RESULT($SANE_MALLOC_PROTOS)
CFLAGS=$glib_save_CFLAGS

630 631 632 633 634 635 636 637 638 639 640 641 642 643 644
dnl
dnl check in which direction the stack grows
dnl
AC_CACHE_CHECK([for growing stack pointer],glib_cv_stack_grows,[
        AC_TRY_RUN([
	volatile int *a = 0, *b = 0;
	void foo (void);
	int main () { volatile int y = 7; a = &y; foo (); return b > a; }
	void foo (void) { volatile int x = 5; b = &x; }
       	],
	glib_cv_stack_grows=no
        ,
	glib_cv_stack_grows=yes
        ,)
])
645

646 647 648
dnl AC_C_INLINE is useless to us since it bails out too early, we need to
dnl truely know which ones of `inline', `__inline' and `__inline__' are
dnl actually supported.
649
AC_CACHE_CHECK([for __inline],glib_cv_has__inline,[
650
        AC_COMPILE_IFELSE([
651 652 653 654 655 656 657 658 659
	__inline int foo () { return 0; }
	int main () { return foo (); }
       	],
	glib_cv_has__inline=yes
        ,
	glib_cv_has__inline=no
        ,)
])
case x$glib_cv_has__inline in
660
xyes) AC_DEFINE(G_HAVE___INLINE,1,[Have __inline keyword])
661
esac
662
AC_CACHE_CHECK([for __inline__],glib_cv_has__inline__,[
663
        AC_COMPILE_IFELSE([
664 665 666 667 668 669 670 671 672
	__inline__ int foo () { return 0; }
	int main () { return foo (); }
       	],
	glib_cv_has__inline__=yes
        ,
	glib_cv_has__inline__=no
        ,)
])
case x$glib_cv_has__inline__ in
673
xyes) AC_DEFINE(G_HAVE___INLINE__,1,[Have __inline__ keyword])
674
esac
675
AC_CACHE_CHECK([for inline], glib_cv_hasinline,[
676
        AC_COMPILE_IFELSE([
677
	#undef inline
678 679 680 681 682 683 684 685 686
	inline int foo () { return 0; }
	int main () { return foo (); }
       	],
	glib_cv_hasinline=yes
        ,
	glib_cv_hasinline=no
        ,)
])
case x$glib_cv_hasinline in
687
xyes) AC_DEFINE(G_HAVE_INLINE,1,[Have inline keyword])
688 689
esac

690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717
# if we can use inline functions in headers
AC_MSG_CHECKING(if inline functions in headers work)
AC_LINK_IFELSE([
#if defined (G_HAVE_INLINE) && defined (__GNUC__) && defined (__STRICT_ANSI__)
#  undef inline
#  define inline __inline__
#elif !defined (G_HAVE_INLINE)
#  undef inline
#  if defined (G_HAVE___INLINE__)
#    define inline __inline__
#  elif defined (G_HAVE___INLINE)
#    define inline __inline
#  endif
#endif

int glib_test_func2 (int);

static inline int
glib_test_func1 (void) {
  return glib_test_func2 (1);
}

int
main (void) {
  int i = 1;
}],[g_can_inline=yes],[g_can_inline=no])
AC_MSG_RESULT($g_can_inline)

718 719 720 721 722 723 724 725 726 727 728 729 730 731 732
dnl *** check for working do while(0) macros ***
AC_CACHE_CHECK([for working do while(0) macros], g_support_dowhile_macros, [
	AC_TRY_COMPILE([],[
	#define STMT_START do
	#define STMT_END while(0)
	#define STMT_TEST STMT_START { i = 0; } STMT_END
	int main(void) { int i = 1; STMT_TEST; return i; }],
	[g_support_dowhile_macros=yes],
	[g_support_dowhile_macros=no],
	[g_support_dowhile_macros=yes])
])
if test x$g_support_dowhile_macros = xyes; then
  AC_DEFINE(HAVE_DOWHILE_MACROS, 1, [define for working do while(0) macros])
fi

733
# check for flavours of varargs macros
734
AC_MSG_CHECKING(for ISO C99 varargs macros in C)
735 736 737 738
AC_TRY_COMPILE([],[
int a(int p1, int p2, int p3);
#define call_a(...) a(1,__VA_ARGS__)
call_a(2,3);
739 740 741 742
],g_have_iso_c_varargs=yes,g_have_iso_c_varargs=no)
AC_MSG_RESULT($g_have_iso_c_varargs)

AC_MSG_CHECKING(for ISO C99 varargs macros in C++)
743
if test "$CXX" = ""; then
744 745 746 747 748 749 750 751 752 753 754 755
dnl No C++ compiler
  g_have_iso_cxx_varargs=no
else
  AC_LANG_CPLUSPLUS
  AC_TRY_COMPILE([],[
int a(int p1, int p2, int p3);
#define call_a(...) a(1,__VA_ARGS__)
call_a(2,3);
],g_have_iso_cxx_varargs=yes,g_have_iso_cxx_varargs=no)
  AC_LANG_C
fi
AC_MSG_RESULT($g_have_iso_cxx_varargs)
756 757 758 759 760 761 762 763 764

AC_MSG_CHECKING(for GNUC varargs macros)
AC_TRY_COMPILE([],[
int a(int p1, int p2, int p3);
#define call_a(params...) a(1,params)
call_a(2,3);
],g_have_gnuc_varargs=yes,g_have_gnuc_varargs=no)
AC_MSG_RESULT($g_have_gnuc_varargs)

765 766 767 768 769
# check for GNUC visibility support
AC_MSG_CHECKING(for GNUC visibility attribute)
GLIB_CHECK_COMPILE_WARNINGS([
void
__attribute__ ((visibility ("hidden")))
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785
     f_hidden (void)
{
}
void
__attribute__ ((visibility ("internal")))
     f_internal (void)
{
}
void
__attribute__ ((visibility ("protected")))
     f_protected (void)
{
}
void
__attribute__ ((visibility ("default")))
     f_default (void)
786 787 788 789
{
}
int main (int argc, char **argv)
{
790 791 792 793
	f_hidden();
	f_internal();
	f_protected();
	f_default();
794 795 796 797
	return 0;
}
],g_have_gnuc_visibility=yes,g_have_gnuc_visibility=no)
AC_MSG_RESULT($g_have_gnuc_visibility)
798
AM_CONDITIONAL(HAVE_GNUC_VISIBILITY, [test x$g_have_gnuc_visibility = xyes])
799

800 801 802 803 804 805 806 807 808
AC_MSG_CHECKING([whether using Sun Studio C compiler])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if defined(__SUNPRO_C) || (__SUNPRO_C >= 0x550)
#else
# include "error: this is not Sun Studio."
#endif
]], [[]])], [ g_have_sunstudio_visibility=yes ], [ g_have_sunstudio_visibility=no ])
AC_MSG_RESULT($g_have_sunstudio_visibility)
AM_CONDITIONAL(HAVE_SUNSTUDIO_VISIBILITY, [test x$g_have_sunstudio_visibility = xyes])

809 810 811
# check for bytesex stuff
AC_C_BIGENDIAN

Tim Janik's avatar
Tim Janik committed
812
# check for header files
813
AC_CHECK_HEADERS([dirent.h float.h limits.h pwd.h sys/param.h sys/poll.h sys/resource.h])
814 815
AC_CHECK_HEADERS([sys/time.h sys/times.h sys/wait.h unistd.h values.h])
AC_CHECK_HEADERS([sys/select.h sys/types.h stdint.h sched.h malloc.h])
816

817 818 819 820 821 822
# Checks for libcharset
jm_LANGINFO_CODESET
jm_GLIBC21
AC_CHECK_HEADERS([stddef.h stdlib.h string.h])
AC_CHECK_FUNCS(setlocale)

823
# check additional type sizes
824
AC_CHECK_SIZEOF(size_t)
825

826 827 828
dnl Try to figure out whether gsize, gssize should be long or int
AC_MSG_CHECKING([for the appropriate definition for size_t])

829
case $ac_cv_sizeof_size_t in
830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846
  $ac_cv_sizeof_short) 
      glib_size_type=short
      ;;
  $ac_cv_sizeof_int) 
      glib_size_type=int
      ;;
  $ac_cv_sizeof_long) 
      glib_size_type=long
      ;;
  *)  AC_MSG_ERROR([No type matching size_t in size])
      ;;
esac

dnl If int/long are the same size, we see which one produces
dnl warnings when used in the location as size_t. (This matters
dnl on AIX with xlc)
dnl
847 848
if test $ac_cv_sizeof_size_t = $ac_cv_sizeof_int &&
   test $ac_cv_sizeof_size_t = $ac_cv_sizeof_long ; then
849
  GLIB_CHECK_COMPILE_WARNINGS([
850
#if defined(_AIX) && !defined(__GNUC__)
851 852
#pragma options langlvl=stdc89
#endif
853 854 855 856 857 858 859 860 861
#include <stddef.h> 
int main ()
{
  size_t s = 1;
  unsigned int *size_int = &s;
  return (int)*size_int;
}
    ],glib_size_type=int,
      [GLIB_CHECK_COMPILE_WARNINGS([
Matthias Clasen's avatar
Matthias Clasen committed
862
#if defined(_AIX) && !defined(__GNUC__)
863 864
#pragma options langlvl=stdc89
#endif
865 866 867 868 869 870 871 872 873 874 875 876
#include <stddef.h> 
int main ()
{
   size_t s = 1;
   unsigned long *size_long = &s;
   return (int)*size_long;
}
        ],glib_size_type=long)])
fi

AC_MSG_RESULT(unsigned $glib_size_type)

877
# Check for some functions
878
AC_CHECK_FUNCS(lstat strerror strsignal memmove vsnprintf stpcpy strcasecmp strncasecmp poll getcwd vasprintf setenv unsetenv getc_unlocked readlink symlink fdwalk)
879 880 881
# Check for high-resolution sleep functions
AC_CHECK_FUNCS(nanosleep nsleep)

882
AC_CHECK_HEADERS(crt_externs.h)
883
AC_CHECK_FUNCS(_NSGetEnviron)
884

885
AC_FUNC_VSNPRINTF_C99
886 887 888
AC_FUNC_PRINTF_UNIX98

#
889
# Check whether to use an included printf
890 891
#

892 893 894
AC_ARG_ENABLE(included-printf,
              [AC_HELP_STRING([--enable-included-printf],
                              [use included printf [default=auto]])],
895
              enable_included_printf="$enableval")
896

897 898 899
need_included_printf=no
if test "x$enable_included_printf" = "xyes" ; then
  need_included_printf=yes
900 901
fi
if test "$ac_cv_func_vsnprintf_c99" != "yes" ; then
902
  need_included_printf=yes
903 904
fi
if test "$ac_cv_func_printf_unix98" != "yes" ; then
905
  need_included_printf=yes
906
fi
907 908
if test "x$ac_cv_sizeof_long_long" = "x8" &&
   test -z "$glib_cv_long_long_format" ; then
909
  need_included_printf=yes
910 911
fi

912 913
if test "x$enable_included_printf" = "xno" && 
   test "x$need_included_printf" = "xyes" ; then
914
  AC_MSG_ERROR([
915
*** Your C library's printf doesn't appear to have the features that
916
*** GLib needs, but you specified --enable-included-printf=no.])
917 918
fi

919
enable_included_printf=$need_included_printf
920

921 922
AM_CONDITIONAL(HAVE_GOOD_PRINTF, test "$enable_included_printf" != "yes")
if test "$enable_included_printf" != "yes" ; then 
923
  AC_DEFINE(HAVE_GOOD_PRINTF,1,[define to use system printf])
924
else
925 926 927
  if test -z "$glib_cv_long_long_format" ; then
    glib_cv_long_long_format="ll"
  fi
928 929
  AC_DEFINE(HAVE_VASPRINTF,1)
fi
930 931 932 933 934 935 936 937 938 939

# Checks needed for gnulib vasnprintf
bh_C_SIGNED
jm_AC_TYPE_LONG_LONG
gt_TYPE_LONGDOUBLE
gt_TYPE_WCHAR_T
gt_TYPE_WINT_T
AC_TYPE_SIZE_T
AC_CHECK_TYPES(ptrdiff_t)
jm_AC_TYPE_INTMAX_T
Matthias Clasen's avatar
Matthias Clasen committed
940
AC_CHECK_FUNCS([snprintf wcslen])
941
AC_FUNC_SNPRINTF_C99
942

943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962
# Check if bcopy can be used for overlapping copies, if memmove isn't found.
# The check is borrowed from the PERL Configure script.
if test "$ac_cv_func_memmove" != "yes"; then
  AC_CACHE_CHECK(whether bcopy can handle overlapping copies,
    glib_cv_working_bcopy,[AC_TRY_RUN([
      int main() {
        char buf[128], abc[128], *b;
        int len, off, align;
        bcopy("abcdefghijklmnopqrstuvwxyz0123456789", abc, 36);
        for (align = 7; align >= 0; align--) {
          for (len = 36; len; len--) {
            b = buf+align; bcopy(abc, b, len);
            for (off = 1; off <= len; off++) {
              bcopy(b, b+off, len); bcopy(b+off, b, len);
                if (bcmp(b, abc, len)) return(1);
            }
          }
        }
        return(0);
      }],glib_cv_working_bcopy=yes,glib_cv_working_bcopy=no)])
963 964

  GLIB_ASSERT_SET(glib_cv_working_bcopy)
965
  if test "$glib_cv_working_bcopy" = "yes"; then
966
    AC_DEFINE(HAVE_WORKING_BCOPY,1,[Have a working bcopy])
967 968 969 970 971 972 973 974 975 976 977
  fi
fi

# Check for sys_errlist
AC_MSG_CHECKING(for sys_errlist)
AC_TRY_LINK(, [
extern char *sys_errlist[];
extern int sys_nerr;
sys_errlist[sys_nerr-1][0] = 0;
], glib_ok=yes, glib_ok=no)
AC_MSG_RESULT($glib_ok)
978
if test "$glib_ok" = "no"; then
979
    AC_DEFINE(NO_SYS_ERRLIST,1,[global 'sys_errlist' not found])
980 981 982 983 984 985
fi

# Check for sys_siglist
AC_MSG_CHECKING(for sys_siglist)
AC_TRY_LINK(, [
extern char *sys_siglist[];
986
exit (sys_siglist[0]);
987 988
], glib_ok=yes, glib_ok=no)
AC_MSG_RESULT($glib_ok)
989
if test "$glib_ok" = "no"; then
990
    AC_DEFINE(NO_SYS_SIGLIST,1,[global 'sys_siglist' not found])
991 992 993 994 995 996 997 998
fi

# Check for sys_siglist decl (see Tue Jan 19 00:44:24 1999 in changelog)
AC_MSG_CHECKING(for sys_siglist declaration)
AC_TRY_COMPILE([#include <signal.h>], [
strlen (sys_siglist[0]);
], glib_ok=yes, glib_ok=no)
AC_MSG_RESULT($glib_ok)
999
if test "$glib_ok" = "no"; then
1000
    AC_DEFINE(NO_SYS_SIGLIST_DECL,1,[global 'sys_siglist' not declared])
1001 1002 1003 1004 1005 1006
fi

# Check if <sys/select.h> needs to be included for fd_set
AC_MSG_CHECKING([for fd_set])
AC_TRY_COMPILE([#include <sys/types.h>],
        [fd_set readMask, writeMask;], gtk_ok=yes, gtk_ok=no)
1007
if test "$gtk_ok" = "yes"; then
1008 1009
    AC_MSG_RESULT([yes, found in sys/types.h])
else
1010
    AC_EGREP_HEADER(fd_set, sys/select.h, gtk_ok=yes)
1011
    if test "$gtk_ok" = "yes"; then
1012 1013
	# *** FIXME: give it a different name
        AC_DEFINE(HAVE_SYS_SELECT_H,1,[found fd_set in sys/select.h])
1014 1015
        AC_MSG_RESULT([yes, found in sys/select.h])
    else
1016
	AC_DEFINE(NO_FD_SET,1,[didn't find fd_set])
1017 1018 1019 1020 1021
	AC_MSG_RESULT(no)
    fi
fi

dnl *** check for sane realloc() ***
1022
AC_CACHE_CHECK([whether realloc (NULL,) will work],glib_cv_sane_realloc,[
1023
        AC_TRY_RUN([#include <stdlib.h>
1024 1025 1026
        int main() {
          return realloc (0, sizeof (int)) == 0;
        }],
1027 1028
        [glib_cv_sane_realloc=yes],
        [glib_cv_sane_realloc=no],
1029
	[glib_cv_sane_realloc=yes])
1030
])
1031
if test x$glib_cv_sane_realloc = xyes; then
1032
  AC_DEFINE(REALLOC_0_WORKS,1,[whether realloc (NULL,) works])
1033
fi
1034

1035
dnl Check for nl_langinfo and CODESET
1036 1037 1038 1039 1040 1041 1042 1043
AC_CACHE_CHECK([for nl_langinfo (CODESET)],glib_cv_langinfo_codeset,[
        AC_TRY_COMPILE([#include <langinfo.h>],
                [char *codeset = nl_langinfo (CODESET);],
                [glib_cv_langinfo_codeset=yes],
                [glib_cv_langinfo_codeset=no])])
if test x$glib_cv_langinfo_codeset = xyes; then
  AC_DEFINE(HAVE_CODESET,1,[Have nl_langinfo (CODESET)])
fi
1044

1045 1046 1047 1048 1049 1050 1051 1052 1053
dnl ****************************************
dnl *** posix_memalign                   ***
dnl ****************************************
AC_MSG_CHECKING(for a compliant posix_memalign() implementation)
AC_CACHE_VAL(glib_cv_compliant_posix_memalign,[
    glib_cv_compliant_posix_memalign=0
    if test "$ac_cv_func_posix_memalign" = "yes" ; then
	AC_TRY_RUN([
                #define _XOPEN_SOURCE 600
1054 1055
                #include <stdlib.h> /* posix_memalign() should be defined here */
                /* some systems break if #include <malloc.h> used */
1056 1057 1058 1059
		static void test_memalign (size_t boundary, size_t size) {
		    void *mem = 0;
		    if (posix_memalign (&mem, boundary, size) != 0 || !mem)
			exit (1);
1060 1061
                    else
                      free (mem);
1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087
		}
		int main() {
		    test_memalign (  128,   128 - 2 * sizeof (void*));
		    test_memalign (  256,   256 - 2 * sizeof (void*));
		    test_memalign (  512,   512 - 2 * sizeof (void*));
		    test_memalign ( 1024,  1024 - 2 * sizeof (void*));
		    test_memalign ( 2048,  2048 - 2 * sizeof (void*));
		    test_memalign ( 4096,  4096 - 2 * sizeof (void*));
		    test_memalign ( 8192,  8192 - 2 * sizeof (void*));
		    test_memalign (16384, 16384 - 2 * sizeof (void*));
		    test_memalign (32768, 32768 - 2 * sizeof (void*));
		    exit (0); /* success */
		}
		],
	    [glib_cv_compliant_posix_memalign=1], [], [:])
      :
    fi
    ])
if test "$glib_cv_compliant_posix_memalign" = "1"; then
    AC_MSG_RESULT(yes)
    AC_DEFINE(POSIX_MEMALIGN_WITH_COMPLIANT_ALLOCS, 1, [define if posix_memalign() can allocate any size])
else
    AC_MSG_RESULT(no)
fi


1088 1089 1090 1091
dnl ****************************************
dnl *** strlcpy/strlcat                  ***
dnl ****************************************
# Check for strlcpy
1092 1093
AC_CACHE_CHECK([for OpenBSD strlcpy/strlcat],glib_cv_have_strlcpy,[
AC_TRY_RUN([#include <stdlib.h>
1094 1095
#include <string.h>
int main() {
1096
  char p[10];
1097 1098
  (void) strlcpy (p, "hi", 10);
  if (strlcat (p, "bye", 0) != 3) 
1099
    return 1;
1100
  return 0;
1101 1102 1103 1104
}], glib_cv_have_strlcpy=yes, 
    glib_cv_have_strlcpy=no,
    glib_cv_have_strlcpy=no)])
if test "$glib_cv_have_strlcpy" = "yes"; then
1105
    AC_DEFINE(HAVE_STRLCPY,1,[Have functions strlcpy and strlcat])
1106
fi
1107
  
1108 1109 1110 1111 1112 1113

dnl **********************
dnl *** va_copy checks ***
dnl **********************
dnl we currently check for all three va_copy possibilities, so we get
dnl all results in config.log for bug reports.
1114
AC_CACHE_CHECK([for an implementation of va_copy()],glib_cv_va_copy,[
1115
	AC_LINK_IFELSE([#include <stdarg.h>
1116
#include <stdlib.h>
1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128
	void f (int i, ...) {
	va_list args1, args2;
	va_start (args1, i);
	va_copy (args2, args1);
	if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
	  exit (1);
	va_end (args1); va_end (args2);
	}
	int main() {
	  f (0, 42);
	  return 0;
	}],
1129
	[glib_cv_va_copy=yes],
1130
	[glib_cv_va_copy=no])
1131
])
1132
AC_CACHE_CHECK([for an implementation of __va_copy()],glib_cv___va_copy,[
1133
	AC_LINK_IFELSE([#include <stdarg.h>
1134
#include <stdlib.h>
1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146
	void f (int i, ...) {
	va_list args1, args2;
	va_start (args1, i);
	__va_copy (args2, args1);
	if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
	  exit (1);
	va_end (args1); va_end (args2);
	}
	int main() {
	  f (0, 42);
	  return 0;
	}],
1147
	[glib_cv___va_copy=yes],
1148
	[glib_cv___va_copy=no])
1149
])
1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162

if test "x$glib_cv_va_copy" = "xyes"; then
  g_va_copy_func=va_copy
else if test "x$glib_cv___va_copy" = "xyes"; then
  g_va_copy_func=__va_copy
fi
fi

if test -n "$g_va_copy_func"; then
  AC_DEFINE_UNQUOTED(G_VA_COPY,$g_va_copy_func,[A 'va_copy' style function])
fi

AC_CACHE_CHECK([whether va_lists can be copied by value],glib_cv_va_val_copy,[
1163
	AC_TRY_RUN([#include <stdarg.h>
1164
#include <stdlib.h> 
1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176
	void f (int i, ...) {
	va_list args1, args2;
	va_start (args1, i);
	args2 = args1;
	if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
	  exit (1);
	va_end (args1); va_end (args2);
	}
	int main() {
	  f (0, 42);
	  return 0;
	}],
1177 1178
	[glib_cv_va_val_copy=yes],
	[glib_cv_va_val_copy=no],
1179
	[glib_cv_va_val_copy=yes])
1180
])
1181

1182
if test "x$glib_cv_va_val_copy" = "xno"; then
1183
  AC_DEFINE(G_VA_COPY_AS_ARRAY,1, ['va_lists' cannot be copies as values])
1184 1185 1186 1187 1188 1189 1190 1191
fi

dnl ***********************
dnl *** g_module checks ***
dnl ***********************
G_MODULE_LIBS=
G_MODULE_LIBS_EXTRA=
G_MODULE_PLUGIN_LIBS=
1192 1193 1194 1195
if test x"$glib_native_win32" = xyes; then
  dnl No use for this on Win32
  G_MODULE_LDFLAGS=
else
1196
  export SED
1197 1198
  G_MODULE_LDFLAGS=`(./libtool --config; echo eval echo \\$export_dynamic_flag_spec) | sh`
fi
1199 1200
dnl G_MODULE_IMPL= don't reset, so cmd-line can override
G_MODULE_NEED_USCORE=0
Tim Janik's avatar
Tim Janik committed
1201
G_MODULE_BROKEN_RTLD_GLOBAL=0
1202
G_MODULE_HAVE_DLERROR=0
1203 1204 1205 1206 1207 1208
dnl *** force native WIN32 shared lib loader 
if test -z "$G_MODULE_IMPL"; then
  case "$host" in
  *-*-mingw*|*-*-cygwin*) G_MODULE_IMPL=G_MODULE_IMPL_WIN32 ;;
  esac
fi
1209 1210 1211 1212 1213 1214 1215
dnl *** force native AIX library loader
dnl *** dlopen() filepath must be of the form /path/libname.a(libname.so)
if test -z "$G_MODULE_IMPL"; then
  case "$host" in
  *-*-aix*) G_MODULE_IMPL=G_MODULE_IMPL_AR ;;
  esac
fi
1216 1217 1218
dnl *** dlopen() and dlsym() in system libraries
if test -z "$G_MODULE_IMPL"; then
	AC_CHECK_FUNC(dlopen,
1219 1220 1221
		      [AC_CHECK_FUNC(dlsym,
			             [G_MODULE_IMPL=G_MODULE_IMPL_DL],[])],
		      [])
1222 1223
fi
dnl *** load_image (BeOS)
Raja R Harinath's avatar
Raja R Harinath committed
1224
if test -z "$G_MODULE_IMPL" && test "x$glib_native_beos" = "xyes"; then
1225
  AC_CHECK_LIB(root, load_image,
1226
      [G_MODULE_LIBS="-lbe -lroot -lglib-2.0 "
1227 1228
      G_MODULE_LIBS_EXTRA="-L\$(top_builddir_full)/.libs"
      G_MODULE_PLUGIN_LIBS="-L\$(top_builddir_full)/gmodule/.libs -lgmodule"
1229 1230
      G_MODULE_IMPL=G_MODULE_IMPL_BEOS],
      [])
1231
fi   
Owen Taylor's avatar
Owen Taylor committed
1232 1233 1234 1235 1236 1237 1238
dnl *** NSLinkModule (dyld) in system libraries (Darwin)
if test -z "$G_MODULE_IMPL"; then
 	AC_CHECK_FUNC(NSLinkModule,
		      [G_MODULE_IMPL=G_MODULE_IMPL_DYLD
		       G_MODULE_NEED_USCORE=1],
		      [])
fi
1239
dnl *** dlopen() and dlsym() in libdl
1240 1241
if test -z "$G_MODULE_IMPL"; then
	AC_CHECK_LIB(dl, dlopen,
1242 1243 1244 1245
		     [AC_CHECK_LIB(dl, dlsym,
			           [G_MODULE_LIBS=-ldl
		                   G_MODULE_IMPL=G_MODULE_IMPL_DL],[])],
		     [])
1246 1247 1248 1249
fi
dnl *** shl_load() in libdld (HP-UX)
if test -z "$G_MODULE_IMPL"; then
	AC_CHECK_LIB(dld, shl_load,
1250 1251 1252
		[G_MODULE_LIBS=-ldld
		G_MODULE_IMPL=G_MODULE_IMPL_DLD],
		[])
1253 1254 1255 1256 1257
fi
dnl *** additional checks for G_MODULE_IMPL_DL
if test "$G_MODULE_IMPL" = "G_MODULE_IMPL_DL"; then
	LIBS_orig="$LIBS"
	LDFLAGS_orig="$LDFLAGS"
1258
	LIBS="$G_MODULE_LIBS $LIBS"
1259
	LDFLAGS="$LDFLAGS $G_MODULE_LDFLAGS"
1260
dnl *** check for OSF1/5.0 RTLD_GLOBAL brokenness
1261 1262 1263
	echo "void glib_plugin_test(void) { }" > plugin.c
	${SHELL} ./libtool --mode=compile ${CC} -shared \
		-export-dynamic -o plugin.o plugin.c 2>&1 >/dev/null
1264 1265 1266
	AC_CACHE_CHECK([for RTLD_GLOBAL brokenness],
		glib_cv_rtldglobal_broken,[
		AC_TRY_RUN([
1267 1268 1269 1270 1271 1272 1273
#include <dlfcn.h>
#ifndef RTLD_GLOBAL
#  define RTLD_GLOBAL 0
#endif
#ifndef RTLD_LAZY
#  define RTLD_LAZY 0
#endif
1274
int glib_plugin_test;
1275 1276
int main () {
    void *handle, *global, *local;
1277 1278
    global = &glib_plugin_test;
    handle = dlopen ("./.libs/plugin.o", RTLD_GLOBAL | RTLD_LAZY);
1279
    if (!handle) return 0;
1280
    local = dlsym (handle, "glib_plugin_test");
1281 1282
    return global == local;
}                       ],
1283 1284
			[glib_cv_rtldglobal_broken=no],
			[glib_cv_rtldglobal_broken=yes],
1285
			[glib_cv_rtldglobal_broken=no])
1286 1287
		rm -f plugin.c plugin.o plugin.lo .libs/plugin.o
		rmdir .libs 2>/dev/null
1288 1289 1290 1291 1292 1293
	])
	if test "x$glib_cv_rtldglobal_broken" = "xyes"; then
  		G_MODULE_BROKEN_RTLD_GLOBAL=1
	else
  		G_MODULE_BROKEN_RTLD_GLOBAL=0
	fi
1294
dnl *** check whether we need preceeding underscores
1295 1296
	AC_CACHE_CHECK([for preceeding underscore in symbols],
		glib_cv_uscore,[
1297
		AC_TRY_RUN([#include <dlfcn.h>
1298 1299 1300 1301 1302 1303 1304 1305 1306
                int glib_underscore_test (void) { return 42; }
		int main() {
		  void *f1 = (void*)0, *f2 = (void*)0, *handle;
		  handle = dlopen ((void*)0, 0);
		  if (handle) {
		    f1 = dlsym (handle, "glib_underscore_test");
		    f2 = dlsym (handle, "_glib_underscore_test");
		  } return (!f2 || f1);
		}],
1307 1308 1309
			[glib_cv_uscore=yes],
			[glib_cv_uscore=no],
			[])
1310
		rm -f plugin.c plugin.$ac_objext plugin.lo
1311
	])
1312
        GLIB_ASSERT_SET(glib_cv_uscore)
1313 1314 1315 1316 1317 1318 1319 1320 1321
	if test "x$glib_cv_uscore" = "xyes"; then
  		G_MODULE_NEED_USCORE=1
	else
  		G_MODULE_NEED_USCORE=0
	fi

	LDFLAGS="$LDFLAGS_orig"
dnl *** check for having dlerror()
	AC_CHECK_FUNC(dlerror,
1322 1323
		[G_MODULE_HAVE_DLERROR=1],
		[G_MODULE_HAVE_DLERROR=0])
1324 1325
	LIBS="$LIBS_orig"
fi
1326
dnl *** done, have we got an implementation?
1327 1328
if test -z "$G_MODULE_IMPL"; then
	G_MODULE_IMPL=0
1329 1330 1331
        G_MODULE_SUPPORTED=false
else
        G_MODULE_SUPPORTED=true
1332
fi
1333 1334

AC_MSG_CHECKING(for the suffix of shared libraries)
1335
export SED
1336 1337 1338 1339 1340
shrext_cmds=`./libtool --config | grep '^shrext_cmds='`
eval $shrext_cmds
module=yes eval std_shrext=$shrext_cmds
# chop the initial dot
glib_gmodule_suffix=`echo $std_shrext | sed 's/^\.//'`
1341
AC_MSG_RESULT(.$glib_gmodule_suffix)
1342 1343 1344 1345
# any reason it may fail?
if test "x$glib_gmodule_suffix" = x; then
	AC_MSG_ERROR(Cannot determine shared library suffix from libtool)
fi
1346
 
1347
AC_SUBST(G_MODULE_SUPPORTED)
1348 1349 1350 1351 1352 1353
AC_SUBST(G_MODULE_IMPL)
AC_SUBST(G_MODULE_LIBS)
AC_SUBST(G_MODULE_LIBS_EXTRA)
AC_SUBST(G_MODULE_PLUGIN_LIBS)
AC_SUBST(G_MODULE_LDFLAGS)
AC_SUBST(G_MODULE_HAVE_DLERROR)
1354
AC_SUBST(G_MODULE_BROKEN_RTLD_GLOBAL)
1355 1356 1357
AC_SUBST(G_MODULE_NEED_USCORE)
AC_SUBST(GLIB_DEBUG_FLAGS)

1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407
dnl **********************
dnl *** g_spawn checks ***
dnl **********************

AC_MSG_CHECKING(for gspawn implementation)
case "$host" in
  *-*-mingw*)
    GSPAWN=gspawn-win32.lo
    ;;
  *)
    GSPAWN=gspawn.lo
    ;;    
esac
AC_MSG_RESULT($GSPAWN)
AC_SUBST(GSPAWN)

dnl *************************
dnl *** GIOChannel checks ***
dnl *************************

AC_MSG_CHECKING(for GIOChannel implementation)
case "$host" in
  *-*-mingw*)
    GIO=giowin32.lo
    ;;
  *)
    GIO=giounix.lo
    ;;    
esac
AC_MSG_RESULT($GIO)
AC_SUBST(GIO)

dnl ****************************************
dnl *** platform dependent source checks ***
dnl ****************************************

AC_MSG_CHECKING(for platform-dependent source)
case "$host" in
  *-*-cygwin*|*-*-mingw*)
    PLATFORMDEP=gwin32.lo
    ;;
  *)
    PLATFORMDEP=
    ;;    
esac
AC_MSG_RESULT($PLATFORMDEP)
AC_SUBST(PLATFORMDEP)

AC_MSG_CHECKING([whether to compile timeloop])
case "$host" in
1408
  *-*-cygwin*|*-*-mingw*|*-*-minix)
1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429
    enable_timeloop=no
    ;;
  *)
    enable_timeloop=yes
    ;;    
esac
AC_MSG_RESULT($enable_timeloop)
AM_CONDITIONAL(ENABLE_TIMELOOP, test x$enable_timeloop = xyes)

AC_MSG_CHECKING([if building for some Win32 platform])
case "$host" in
  *-*-mingw*|*-*-cygwin*)
    platform_win32=yes
    ;;
  *)
    platform_win32=no
    ;;
esac
AC_MSG_RESULT($platform_win32)
AM_CONDITIONAL(PLATFORM_WIN32, test x$platform_win32 = xyes)

1430 1431 1432 1433
dnl ***********************
dnl *** g_thread checks ***
dnl ***********************

1434
AC_ARG_WITH(threads,
1435
           [AC_HELP_STRING([--with-threads=@<:@none/posix/dce/win32@:>@],
1436 1437
                           [specify a thread implementation to use])],
           [if test "x$with_threads" = x; then
1438
		want_threads=yes
1439
	    else
1440
		want_threads=$with_threads
1441 1442
	    fi],
	   [want_threads=yes])
1443 1444 1445 1446 1447 1448 1449 1450 1451 1452
if test "x$enable_threads" = "xno"; then
        want_threads=no
fi

dnl error and warning message
dnl *************************

THREAD_NO_IMPLEMENTATION="You do not have any known thread system on your
                computer. GLib will not have a default thread implementation."

1453
FLAG_DOES_NOT_WORK="I can't find the MACRO to enable thread safety on your
1454
                platform (normally it's "_REENTRANT"). I'll not use any flag on
1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472
                compilation now, but then your programs might not work.
                Please provide information on how it is done on your system."

LIBS_NOT_FOUND_1="I can't find the libraries for the thread implementation
		"

LIBS_NOT_FOUND_2=". Please choose another thread implementation or
		provide information on your thread implementation.
		You can also run 'configure --disable-threads' 
		to compile without thread support."

FUNC_NO_GETPWUID_R="the 'g_get_(user_name|real_name|home_dir|tmp_dir)'
		functions will not be MT-safe during their first call because
		there is no working 'getpwuid_r' on your system."

FUNC_NO_LOCALTIME_R="the 'g_date_set_time' function will not be MT-safe
		because there is no 'localtime_r' on your system."

1473 1474 1475 1476 1477 1478 1479 1480 1481 1482
POSIX_NO_YIELD="I can not find a yield functions for your platform. A rather
		crude surrogate will be used. If you happen to know a 
		yield function for your system, please inform the GLib 
		developers."

POSIX_NO_PRIORITIES="I can not find the minimal and maximal priorities for 
		threads on your system. Thus threads can only have the default 
		priority. If you happen to know these main/max
		priorities, please inform the GLib developers."

1483 1484 1485 1486 1487 1488
AIX_COMPILE_INFO="AIX's C compiler needs to be called by a different name, when
		linking threaded applications. As GLib cannot do that 
		automatically, you will get an linkg error everytime you are 
		not using the right compiler. In that case you have to relink 
		with the right compiler. Ususally just '_r' is appended 
		to the compiler name."
1489

1490 1491 1492
dnl determination of thread implementation
dnl ***************************************

1493 1494 1495 1496
# have_threads=no   means no thread support
# have_threads=none means no default thread implementation

have_threads=no
1497 1498
if test "x$want_threads" = xyes || test "x$want_threads" = xposix \
				|| test "x$want_threads" = xdce; then
1499
	# -D_POSIX4_DRAFT_SOURCE -D_POSIX4A_DRAFT10_SOURCE is for DG/UX
1500
	# -U_OSF_SOURCE is for Digital UNIX 4.0d
1501
	GTHREAD_COMPILE_IMPL_DEFINES="-D_POSIX4_DRAFT_SOURCE -D_POSIX4A_DRAFT10_SOURCE -U_OSF_SOURCE"
1502 1503
	glib_save_CPPFLAGS="$CPPFLAGS"
	CPPFLAGS="$CPPFLAGS $GTHREAD_COMPILE_IMPL_DEFINES"
1504
        if test "x$have_threads" = xno; then
1505
                AC_TRY_COMPILE([#include <pthread.h>],
1506
			[pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;],
1507 1508
			have_threads=posix)
        fi
1509
        if test "x$have_threads" = xno; then
1510
                AC_TRY_COMPILE([#include <pthread.h>],
1511 1512
			[pthread_mutex_t m; 
                         pthread_mutex_init (&m, pthread_mutexattr_default);],
1513
			have_threads=dce)
1514
        fi
1515 1516 1517 1518 1519 1520 1521
	# Tru64Unix requires -pthread to find pthread.h. See #103020
	CPPFLAGS="$CPPFLAGS -pthread"
	if test "x$have_threads" = xno; then
	AC_TRY_COMPILE([#include <pthread.h>],
		       [pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;],
		       have_threads=posix)
        fi
1522 1523
	CPPFLAGS="$glib_save_CPPFLAGS"
fi
1524 1525
if test "x$want_threads" = xyes || test "x$want_threads" = xwin32; then
       	case $host in
1526
               	*-*-mingw*)
1527 1528 1529 1530
		have_threads=win32
		;;
	esac
fi
1531 1532 1533
if test "x$want_threads" = xnone; then
	have_threads=none
fi
1534 1535 1536

AC_MSG_CHECKING(for thread implementation)

1537
if test "x$have_threads" = xno && test "x$want_threads" != xno; then
1538 1539 1540 1541 1542 1543 1544
	AC_MSG_RESULT(none available)
        AC_MSG_WARN($THREAD_NO_IMPLEMENTATION)
else
	AC_MSG_RESULT($have_threads)
fi


1545 1546
dnl determination of G_THREAD_CFLAGS
dnl ********************************
1547 1548 1549 1550 1551

G_THREAD_LIBS=
G_THREAD_LIBS_EXTRA=
G_THREAD_CFLAGS=

1552 1553 1554 1555 1556 1557
dnl
dnl Test program for basic POSIX threads functionality
dnl
m4_define([glib_thread_test],[
#include <pthread.h> 
int check_me = 0;
1558 1559
void* func(void* data) {check_me = 42; return &check_me;}
int main()
1560 1561
 { pthread_t t; 
   void *ret;
1562
   pthread_create (&t, $1, func, 0);
1563
   pthread_join (t, &ret);
1564
   return (check_me != 42 || ret != &check_me);
1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577
}])

dnl
dnl Test program for sched_get_priority_min()
dnl
m4_define([glib_sched_priority_test],[
#include <sched.h>
#include <errno.h>
int main() {
    errno = 0;
    return sched_get_priority_min(SCHED_OTHER)==-1
 	   && errno != 0;
}])
1578

1579
if test x"$have_threads" != xno; then
1580

1581 1582 1583 1584 1585
  if test x"$have_threads" = xposix; then
    # First we test for posix, whether -pthread or -pthreads do the trick as 
    # both CPPFLAG and LIBS. 
    # One of them does for most gcc versions and some other platforms/compilers
    # too and could be considered as the canonical way to go. 
1586
    case $host in
1587 1588
      *-*-cygwin*|*-*-darwin*)
         # skip cygwin and darwin -pthread or -pthreads test
1589
         ;;
1590 1591 1592 1593 1594 1595 1596
      *-solaris*)
        # These compiler/linker flags work with both Sun Studio and gcc
	# Sun Studio expands -mt to -D_REENTRANT and -lthread
	# gcc expands -pthreads to -D_REENTRANT -D_PTHREADS -lpthread
        G_THREAD_CFLAGS="-D_REENTRANT -D_PTHREADS"
        G_THREAD_LIBS="-lpthread -lthread"
        ;;
1597
      *)
1598
        for flag in pthread pthreads mt; do
1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610
          glib_save_CFLAGS="$CFLAGS"
          CFLAGS="$CFLAGS -$flag"
          AC_TRY_RUN(glib_thread_test(0),
                     glib_flag_works=yes,
                     glib_flag_works=no,
                     [AC_LINK_IFELSE(glib_thread_test(0),
                                     glib_flag_works=yes,
                                     glib_flag_works=no)])
          CFLAGS="$glib_save_CFLAGS"
          if test $glib_flag_works = yes ; then
             G_THREAD_CFLAGS=-$flag
	     G_THREAD_LIBS=-$flag
1611
	     break;
1612 1613 1614 1615
          fi
        done
         ;;
    esac 
1616 1617 1618 1619 1620
  fi

  if test x"$G_THREAD_CFLAGS" = x; then

    # The canonical -pthread[s] does not work. Try something different.
1621 1622 1623 1624

    case $host in
	*-aix*)
		if test x"$GCC" = xyes; then
1625 1626
			# GCC 3.0 and above needs -pthread. 
			# Should be coverd by the case above.
1627
			# GCC 2.x and below needs -mthreads
1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638
			G_THREAD_CFLAGS="-mthreads"		
			G_THREAD_LIBS=$G_THREAD_CFLAGS
		else 
			# We are probably using the aix compiler. Normaly a 
			# program would have to be compiled with the _r variant
			# of the corresponding compiler, but we as GLib cannot 
			# do that: but the good news is that for compiling the
			# only difference is the added -D_THREAD_SAFE compile 
			# option. This is according to the "C for AIX User's 
			# Guide".
			G_THREAD_CFLAGS="-D_THREAD_SAFE"
1639 1640
		fi
		;;
1641
	*-dg-dgux*)  # DG/UX
1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654
		G_THREAD_CFLAGS="-D_REENTRANT -D_POSIX4A_DRAFT10_SOURCE"
		;;
	*-osf*)
		# So we are using dce threads. posix threads are already 
		# catched above.
		G_THREAD_CFLAGS="-threads"
		G_THREAD_LIBS=$G_THREAD_CFLAGS
		;;
	*-sysv5uw7*) # UnixWare 7 
		# We are not using gcc with -pthread. Catched above.
		G_THREAD_CFLAGS="-Kthread"
		G_THREAD_LIBS=$G_THREAD_CFLAGS
		;;
1655 1656 1657 1658
	*-mingw*)
		# No flag needed when using MSVCRT.DLL
		G_THREAD_CFLAGS=""
		;;
1659 1660 1661
	*)
		G_THREAD_CFLAGS="-D_REENTRANT" # good default guess otherwise
		;;
1662
    esac
1663 1664
 
  fi
1665

1666
    # if we are not finding the localtime_r function, then we probably are
1667 1668 1669 1670 1671
    # not using the proper multithread flag

    glib_save_CPPFLAGS="$CPPFLAGS"
    CPPFLAGS="$CPPFLAGS $G_THREAD_CFLAGS"

1672
    # First we test, whether localtime_r is declared in time.h
1673
    # directly. Then we test whether a macro localtime_r exists, in
1674 1675 1676 1677 1678 1679 1680 1681
    # which case localtime_r in the test program is replaced and thus
    # if we still find localtime_r in the output, it is not defined as 
    # a macro.

    AC_EGREP_CPP([[^a-zA-Z1-9_]localtime_r[^a-zA-Z1-9_]], [#include <time.h>], ,
      [AC_EGREP_CPP([[^a-zA-Z1-9_]localtime_r[^a-zA-Z1-9_]], [#include <time.h> 
							   localtime_r(a,b)],
      		   AC_MSG_WARN($FLAG_DOES_NOT_WORK))])
1682 1683 1684 1685 1686

    CPPFLAGS="$glib_save_CPPFLAGS"

    AC_MSG_CHECKING(thread related cflags)
    AC_MSG_RESULT($G_THREAD_CFLAGS)
1687
    CPPFLAGS="$CPPFLAGS $G_THREAD_CFLAGS"