configure.in 102 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
#
Matthias Clasen's avatar
Matthias Clasen committed
12 13 14
# The following version number definitions apply to GLib, GModule, GObject,
# GThread and GIO as a whole, so if changes occurred in any of them, they are
# all treated with the same interface and binary age.
15
#
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])
Allison Karlitskaya's avatar
Allison Karlitskaya committed
25
m4_define([glib_minor_version], [25])
Matthias Clasen's avatar
Matthias Clasen committed
26
m4_define([glib_micro_version], [4])
Matthias Clasen's avatar
Matthias Clasen committed
27
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

# 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])

61 62 63 64
# Support silent build rules, requires at least automake-1.11. Enable
# by either passing --enable-silent-rules to configure or passing V=0
# to make
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([no])])
65 66 67 68 69 70 71

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
72

73 74
AC_SUBST(GLIB_MAJOR_VERSION)
AC_SUBST(GLIB_MINOR_VERSION)
75
AC_SUBST(GLIB_MICRO_VERSION)
Owen Taylor's avatar
Owen Taylor committed
76
AC_SUBST(GLIB_VERSION)
77 78
AC_SUBST(GLIB_INTERFACE_AGE)
AC_SUBST(GLIB_BINARY_AGE)
Owen Taylor's avatar
Owen Taylor committed
79

80 81 82 83 84 85 86 87 88 89 90
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
91
# libtool versioning
92 93 94 95 96
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
97 98 99 100
AC_SUBST(LT_RELEASE)
AC_SUBST(LT_CURRENT)
AC_SUBST(LT_REVISION)
AC_SUBST(LT_AGE)
101
AC_SUBST(LT_CURRENT_MINUS_AGE)
Owen Taylor's avatar
Owen Taylor committed
102 103 104 105 106 107

dnl Initialize maintainer mode
AM_MAINTAINER_MODE

AC_CANONICAL_HOST

108
AC_MSG_CHECKING([for the BeOS])
109 110 111 112
case $host in
  *-*-beos*)
    glib_native_beos="yes"
    ;;
113
  *)
114 115 116
    glib_native_beos="no"
    ;;
esac
117
AC_MSG_RESULT([$glib_native_beos])
118

119
dnl
120

121
AC_MSG_CHECKING([for Win32])
122
LIB_EXE_MACHINE_FLAG=X86
123 124
case "$host" in
  *-*-mingw*)
125
    glib_native_win32=yes
Owen Taylor's avatar
Owen Taylor committed
126
    glib_pid_type='void *'
127
    glib_cv_stack_grows=no
128 129 130 131 132 133 134 135 136
    # Unfortunately the mingw implementations of C99-style snprintf and vsnprintf
    # don't seem to be quite good enough, at least not in mingw-runtime-3.14.
    # (Sorry, I don't know exactly what is the problem, but it is related to
    # floating point formatting and decimal point vs. comma.)
    # The simple tests in AC_FUNC_VSNPRINTF_C99 and AC_FUNC_SNPRINTF_C99 aren't
    # rigorous enough to notice, though.
    # So preset the autoconf cache variables.
    ac_cv_func_vsnprintf_c99=no
    ac_cv_func_snprintf_c99=no
137 138 139 140 141
    case "$host" in
    x86_64-*-*)
      LIB_EXE_MACHINE_FLAG=X64
      ;;
    esac
142 143
    ;;
  *)
144
    glib_native_win32=no
145
    glib_pid_type=int
146 147
    ;;
esac
148 149 150 151 152 153
case $host in
  *-*-linux*)
    glib_os_linux=yes
    ;;
esac

154
AC_MSG_RESULT([$glib_native_win32])
155

156 157
AC_SUBST(LIB_EXE_MACHINE_FLAG)

158 159 160 161 162 163 164 165 166
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])

167
AM_CONDITIONAL(OS_WIN32, [test "$glib_native_win32" = "yes"])
168
AM_CONDITIONAL(OS_WIN32_X64, [test "$LIB_EXE_MACHINE_FLAG" = "X64"])
169
AM_CONDITIONAL(OS_UNIX, [test "$glib_native_win32" != "yes"])
170
AM_CONDITIONAL(OS_LINUX, [test "$glib_os_linux" = "yes"])
171
AM_CONDITIONAL(OS_CARBON, [test "$glib_have_carbon" = "yes"])
172

173
if test "$glib_native_win32" = "yes"; then
174 175 176 177
  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
178
  AC_CHECK_TOOL(NM, nm, no)
179
  if test "$NM" = no; then
180 181 182
    AC_MSG_ERROR([*** Could not find an implementation of nm in your PATH.])
  fi
  AC_CHECK_TOOL(RANLIB, ranlib, :)
183
  AC_CHECK_PROG(ms_librarian, [lib.exe], [yes], [no])
184
fi
185
AM_CONDITIONAL(MS_LIB_AVAILABLE, [test x$ms_librarian = xyes])
186

187 188 189
if test "$glib_native_win32" != yes; then
    # libtool option to control which symbols are exported
    # right now, symbols starting with _ are not exported
190
    LIBTOOL_EXPORT_OPTIONS='-export-symbols-regex "^g.*"'
191 192 193 194 195 196
else
    # We currently use .def files on Windows
    LIBTOOL_EXPORT_OPTIONS=
fi
AC_SUBST(LIBTOOL_EXPORT_OPTIONS)

197 198 199 200 201 202
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


203
dnl declare --enable-* args and collect ac_help strings
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
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])
226 227 228 229
AC_ARG_ENABLE(visibility,
              [AC_HELP_STRING([--disable-visibility],
                              [don't use ELF visibility attributes])],,
              [enable_visibility=yes])
230 231 232 233

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

235
AC_MSG_CHECKING([whether to enable garbage collector friendliness])
236
if test "x$enable_gc_friendly" = "xyes"; then
237
  AC_DEFINE(ENABLE_GC_FRIENDLY_DEFAULT, 1, [Whether to enable GC friendliness by default])
238
  AC_MSG_RESULT([yes])
239
else
240
  AC_MSG_RESULT([no])
241
fi
242

243
AC_MSG_CHECKING([whether to disable memory pools])
244
if test "x$disable_mem_pools" = "xno"; then
245
  AC_MSG_RESULT([no])
246
else
247
  AC_DEFINE(DISABLE_MEM_POOLS, [1], [Whether to disable memory pools])
248
  AC_SUBST(DISABLE_MEM_POOLS)
249
  AC_MSG_RESULT([yes])
250 251
fi

252 253 254 255 256 257 258
dnl location to install runtime libraries, e.g. ../../lib to install
dnl to /lib if libdir is /usr/lib
AC_ARG_WITH(runtime-libdir,
           [AC_HELP_STRING([--with-runtime-libdir=RELPATH],
                           [Install runtime libraries relative to libdir])],
           [],
	   [with_runtime_libdir=""])
Matthias Clasen's avatar
Matthias Clasen committed
259 260
GLIB_RUNTIME_LIBDIR="$with_runtime_libdir"
ABS_GLIB_RUNTIME_LIBDIR="`readlink -f $libdir/$with_runtime_libdir`"
261
AC_SUBST(GLIB_RUNTIME_LIBDIR)
Matthias Clasen's avatar
Matthias Clasen committed
262
AC_SUBST(ABS_GLIB_RUNTIME_LIBDIR)
263 264
AM_CONDITIONAL(HAVE_GLIB_RUNTIME_LIBDIR, [test "x$with_runtime_libdir" != "x"])

Owen Taylor's avatar
Owen Taylor committed
265
dnl Checks for programs.
266
AC_PROG_CC
267
AC_PROG_CPP
268 269

dnl Check for a working C++ compiler, but do not bail out, if none is found.
270
AC_CHECK_TOOLS(CXX, [$CCC c++ g++ gcc CC cxx cc++ cl], [gcc])
271 272 273
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_TRY_COMPILE(,[class a { int b; } c;], ,CXX=)
274
AM_CONDITIONAL(HAVE_CXX, [test "$CXX" != ""])
275
AC_LANG_RESTORE
Owen Taylor's avatar
Owen Taylor committed
276

277
AM_PROG_CC_STDC
Matthias Clasen's avatar
Matthias Clasen committed
278
AM_PROG_CC_C_O
279 280
AC_PROG_INSTALL

Owen Taylor's avatar
Owen Taylor committed
281 282
AC_SYS_LARGEFILE

283 284 285
#
# Find pkg-config
#
286
AC_PATH_PROG(PKG_CONFIG, [pkg-config], [no])
287
if test x$PKG_CONFIG = xno ; then
288
  AC_MSG_ERROR([*** pkg-config not found. See http://www.freedesktop.org/software/pkgconfig/])
289 290
fi

291
if $PKG_CONFIG --atleast-pkgconfig-version 0.16 ; then
292 293
  :
else
294
  AC_MSG_ERROR([*** pkg-config too old; version 0.16 or better required.])
295 296
fi

297 298 299 300 301 302 303 304 305 306
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
307 308
  GLIB_DEBUG_FLAGS="-DG_DISABLE_CAST_CHECKS"

309
  if test "x$enable_debug" = "xno"; then
310
    GLIB_DEBUG_FLAGS="$GLIB_DEBUG_FLAGS -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS"
311 312 313
  fi
fi

314 315 316 317
if test "x$enable_visibility" = "xno"; then
  GLIB_DEBUG_FLAGS="$GLIB_DEBUG_FLAGS -DDISABLE_VISIBILITY"
fi

318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
# 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
	;;
342
    esac
343 344 345 346 347 348 349
    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
350 351
  fi
fi
352 353
GLIB_EXTRA_CFLAGS="${msnative_struct}"
AC_SUBST(GLIB_EXTRA_CFLAGS)
354

355 356
AC_EXEEXT

357 358 359
# define a MAINT-like variable REBUILD which is set if Perl
# and awk are found, so autogenerated sources can be rebuilt
AC_PROG_AWK
360
AC_CHECK_PROGS(PERL, [perl5 perl])
361 362 363 364 365 366 367 368 369 370 371
# 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)

372 373 374
# Need full path to Perl for glib-mkenums
#
if test "x$PERL" != x ; then
375
  AC_PATH_PROG(PERL_PATH, [$PERL])
376 377
fi
if test "x$PERL_PATH" = x ; then
378 379 380
  PERL_PATH="/usr/bin/env perl"
fi
AC_SUBST(PERL_PATH)
Owen Taylor's avatar
Owen Taylor committed
381

382 383 384 385
# Need suitable python path for greport
AM_PATH_PYTHON(2.4,,PYTHON="/usr/bin/env python2.4")


386 387 388 389 390 391
dnl ***********************
dnl *** Tests for iconv ***
dnl ***********************
dnl
dnl We do this before the gettext checks, to avoid distortion

392
dnl On Windows we use a native implementation
393

394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419
if test x"$glib_native_win32" = xyes; then
  with_libiconv=native
else
  AC_ARG_WITH(libiconv,
	      [AC_HELP_STRING([--with-libiconv=@<:@no/gnu/native@:>@],
			      [use the libiconv library])],,
	      [with_libiconv=maybe])

  found_iconv=no
  case $with_libiconv in
    maybe)
      # Check in the C library first
      AC_CHECK_FUNC(iconv_open, [with_libiconv=no; found_iconv=yes])
      # Check if we have GNU libiconv
      if test $found_iconv = "no"; then
	AC_CHECK_LIB(iconv, libiconv_open, [with_libiconv=gnu; found_iconv=yes])
      fi
      # Check if we have a iconv in -liconv, possibly from vendor
      if test $found_iconv = "no"; then
	AC_CHECK_LIB(iconv, iconv_open, [with_libiconv=native; found_iconv=yes])
      fi
      ;;
    no)
      AC_CHECK_FUNC(iconv_open, [with_libiconv=no; found_iconv=yes])
      ;;
    gnu|yes)
420
      AC_CHECK_LIB(iconv, libiconv_open, [with_libiconv=gnu; found_iconv=yes])
421 422
      ;;
    native)
423
      AC_CHECK_LIB(iconv, iconv_open, [with_libiconv=native; found_iconv=yes])
424 425
      ;;
  esac
426

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

432
gl_GLIBC21
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
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)


460 461 462 463 464 465 466 467 468 469 470
dnl
dnl zlib support
dnl
found_zlib=no
AC_CHECK_LIB(z, inflate, [AC_CHECK_HEADER(zlib.h, found_zlib=yes)])

if test "x$found_zlib" = "xno" ; then
   AC_MSG_ERROR([*** Working zlib library and headers not found ***])
fi
ZLIB_LIBS='-lz'
AC_SUBST(ZLIB_LIBS)
Owen Taylor's avatar
Owen Taylor committed
471 472 473 474
dnl
dnl gettext support
dnl

Matthias Clasen's avatar
Matthias Clasen committed
475
ALL_LINGUAS="`grep -v '^#' "$srcdir/po/LINGUAS" | tr '\n' ' '`"
Matthias Clasen's avatar
Matthias Clasen committed
476
AC_SUBST([CONFIG_STATUS_DEPENDENCIES],['$(top_srcdir)/po/LINGUAS'])
477
GLIB_GNU_GETTEXT
478

479
if test "$gt_cv_have_gettext" != "yes" ; then
480 481 482 483 484 485
  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

Owen Taylor's avatar
Owen Taylor committed
486
LIBS="$INTLLIBS $LIBS"
Owen Taylor's avatar
Owen Taylor committed
487 488 489

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

493
GLIB_DEFINE_LOCALEDIR(GLIB_LOCALE_DIR)
Owen Taylor's avatar
Owen Taylor committed
494

495 496 497 498
dnl
dnl Now we are done with gettext checks, figure out ICONV_LIBS
dnl

499 500 501 502 503 504 505
if test x"$glib_native_win32" != xyes; then
  if test x$with_libiconv != xno ; then
    case " $INTLLIBS " in
    *[[\ \	]]-liconv[[\ \	]]*) ;;
    *) ICONV_LIBS="-liconv" ;;
    esac
  fi
506 507 508 509 510
fi
AC_SUBST(ICONV_LIBS)

case $with_libiconv in
  gnu)
511
    AC_DEFINE(USE_LIBICONV_GNU, 1, [Using GNU libiconv])
512 513
    ;;
  native)
514
    AC_DEFINE(USE_LIBICONV_NATIVE, 1, [Using a native implementation of iconv in a separate library])
515 516 517
    ;;
esac

518
dnl Initialize libtool
519
AM_DISABLE_STATIC
520
AC_LIBTOOL_WIN32_DLL
521
AM_PROG_LIBTOOL
522 523 524
dnl when using libtool 2.x create libtool early, because it's used in configure
m4_ifdef([LT_OUTPUT], [LT_OUTPUT])

525

526 527
if test "x$GCC" = "xyes"; then
  case " $CFLAGS " in
528
  *[[\ \	]]-Wall[[\ \	]]*) ;;
529 530 531 532
  *) CFLAGS="$CFLAGS -Wall" ;;
  esac
fi

533 534
CPPFLAGS="$CPPFLAGS -DG_DISABLE_SINGLE_INCLUDES"

535 536 537 538 539 540
if test "$glib_native_win32" = "yes"; then
  if test x$enable_static = xyes -a x$enable_shared = xyes; then
    AC_MSG_ERROR([Can not build both shared and static at the same time on Windows.])
  fi
  if test x$enable_static = xyes; then
    glib_win32_static_compilation=yes
541 542
    GLIB_WIN32_STATIC_COMPILATION_DEFINE="#define GLIB_STATIC_COMPILATION 1
#define GOBJECT_STATIC_COMPILATION 1"
543
    AC_SUBST(GLIB_WIN32_STATIC_COMPILATION_DEFINE)
544 545
  fi
fi
546
AM_CONDITIONAL(OS_WIN32_AND_DLL_COMPILATION, [test x$glib_native_win32 = xyes -a x$glib_win32_static_compilation != xyes])
547

548
dnl
549
dnl DU4 native cc currently needs -std1 for ANSI mode (instead of K&R)
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570
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
571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588

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
589
AC_FUNC_ALLOCA
Matthias Clasen's avatar
Matthias Clasen committed
590 591
AC_CHECK_FUNCS(mmap posix_memalign memalign valloc fsync pipe2)
AC_CHECK_FUNCS(atexit on_exit timegm gmtime_r)
Emmanuele Bassi's avatar
Emmanuele Bassi committed
592

593 594 595 596 597 598
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)
599
AC_CHECK_SIZEOF(__int64)
600

601
if test x$ac_cv_sizeof_long = x8 || test x$ac_cv_sizeof_long_long = x8 || test x$ac_cv_sizeof___int64 = x8 ; then
602 603 604 605 606 607 608 609
  :
else
  AC_MSG_ERROR([
*** GLib requires a 64 bit type. You might want to consider
*** using the GNU C compiler.
])
fi

610
if test x$glib_native_win32 != xyes && test x$ac_cv_sizeof_long_long = x8; then
611
	# long long is a 64 bit integer.
612
	AC_MSG_CHECKING(for format to printf and scanf a guint64)
613
	AC_CACHE_VAL(glib_cv_long_long_format,[
614
		for format in ll q I64; do
615
		  AC_TRY_RUN([#include <stdio.h>  
616 617 618 619
			int main()
			{
			  long long b, a = -0x3AFAFAFAFAFAFAFALL;
			  char buffer[1000];
620 621
			  sprintf (buffer, "%${format}u", a);
  			  sscanf (buffer, "%${format}u", &b);
622 623 624
			  exit (b!=a);
			}
			],
625 626 627
			[glib_cv_long_long_format=${format}
			break],
			[],[:])
628 629
		done])
	if test -n "$glib_cv_long_long_format"; then
630
	  AC_MSG_RESULT(%${glib_cv_long_long_format}u)
631
	  AC_DEFINE(HAVE_LONG_LONG_FORMAT,1,[define if system printf can print long long])
632 633 634
	  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
635 636 637
        else
	  AC_MSG_RESULT(none)
        fi
638 639
elif test x$ac_cv_sizeof___int64 = x8; then
	# __int64 is a 64 bit integer.
640
	AC_MSG_CHECKING(for format to printf and scanf a guint64)
641
	# We know this is MSVCRT.DLL, and what the formats are
642 643
	glib_cv_long_long_format=I64
	AC_MSG_RESULT(%${glib_cv_long_long_format}u)
644
        AC_DEFINE(HAVE_LONG_LONG_FORMAT,1,[define if system printf can print long long])
645
	AC_DEFINE(HAVE_INT64_AND_I64,1,[define to support printing 64-bit integers with format I64])
646 647 648 649 650 651
fi

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

652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671
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;
  ],
672 673
    AC_DEFINE(SANE_MALLOC_PROTOS, 1, 
      [Define if you have correct malloc prototypes])
674 675 676 677 678
    SANE_MALLOC_PROTOS=yes)
fi
AC_MSG_RESULT($SANE_MALLOC_PROTOS)
CFLAGS=$glib_save_CFLAGS

679 680 681 682 683 684 685 686 687 688 689 690 691 692 693
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
        ,)
])
694

695 696 697
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.
698
AC_CACHE_CHECK([for __inline],glib_cv_has__inline,[
699
        AC_COMPILE_IFELSE([
700 701 702 703 704 705 706 707 708
	__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
709
xyes) AC_DEFINE(G_HAVE___INLINE,1,[Have __inline keyword])
710
esac
711
AC_CACHE_CHECK([for __inline__],glib_cv_has__inline__,[
712
        AC_COMPILE_IFELSE([
713 714 715 716 717 718 719 720 721
	__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
722
xyes) AC_DEFINE(G_HAVE___INLINE__,1,[Have __inline__ keyword])
723
esac
724
AC_CACHE_CHECK([for inline], glib_cv_hasinline,[
725
        AC_COMPILE_IFELSE([
726
	#undef inline
727 728 729 730 731 732 733 734 735
	inline int foo () { return 0; }
	int main () { return foo (); }
       	],
	glib_cv_hasinline=yes
        ,
	glib_cv_hasinline=no
        ,)
])
case x$glib_cv_hasinline in
736
xyes) AC_DEFINE(G_HAVE_INLINE,1,[Have inline keyword])
737 738
esac

739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766
# 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)

767
dnl *** check for working do while(0) macros ***
768
AC_CACHE_CHECK([for working do while(0) macros], g_cv_support_dowhile_macros, [
769 770 771 772 773
	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; }],
774 775 776
	[g_cv_support_dowhile_macros=yes],
	[g_cv_support_dowhile_macros=no],
	[g_cv_support_dowhile_macros=yes])
777
])
778
if test x$g_cv_support_dowhile_macros = xyes; then
779 780 781
  AC_DEFINE(HAVE_DOWHILE_MACROS, 1, [define for working do while(0) macros])
fi

782
# check for flavours of varargs macros
783
AC_MSG_CHECKING(for ISO C99 varargs macros in C)
784 785 786 787
AC_TRY_COMPILE([],[
int a(int p1, int p2, int p3);
#define call_a(...) a(1,__VA_ARGS__)
call_a(2,3);
788 789 790 791
],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++)
792
if test "$CXX" = ""; then
793 794 795 796 797 798 799 800 801 802 803 804
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)
805 806 807 808 809 810 811 812 813

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)

814 815 816 817 818
# check for GNUC visibility support
AC_MSG_CHECKING(for GNUC visibility attribute)
GLIB_CHECK_COMPILE_WARNINGS([
void
__attribute__ ((visibility ("hidden")))
819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834
     f_hidden (void)
{
}
void
__attribute__ ((visibility ("internal")))
     f_internal (void)
{
}
void
__attribute__ ((visibility ("protected")))
     f_protected (void)
{
}
void
__attribute__ ((visibility ("default")))
     f_default (void)
835 836 837 838
{
}
int main (int argc, char **argv)
{
839 840 841 842
	f_hidden();
	f_internal();
	f_protected();
	f_default();
843 844 845 846
	return 0;
}
],g_have_gnuc_visibility=yes,g_have_gnuc_visibility=no)
AC_MSG_RESULT($g_have_gnuc_visibility)
847
AM_CONDITIONAL(HAVE_GNUC_VISIBILITY, [test x$g_have_gnuc_visibility = xyes])
848

849 850 851 852 853 854 855 856 857
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])

858 859
# check for bytesex stuff
AC_C_BIGENDIAN
Matthias Clasen's avatar
Matthias Clasen committed
860 861 862 863 864 865 866 867 868 869 870 871 872 873
if test x$ac_cv_c_bigendian = xuniversal ; then
AC_TRY_COMPILE([#include <endian.h>], [#if __BYTE_ORDER == __BIG_ENDIAN
#else
#error Not a big endian. 
#endif],
    ac_cv_c_bigendian=yes
    ,AC_TRY_COMPILE([#include <endian.h>], [#if __BYTE_ORDER == __LITTLE_ENDIAN
#else
#error Not a little endian. 
#endif],
    ac_cv_c_bigendian=no
    ,AC_MSG_WARN([Could not determine endianness.])))
fi

874

Tim Janik's avatar
Tim Janik committed
875
# check for header files
876
AC_CHECK_HEADERS([dirent.h float.h limits.h pwd.h grp.h sys/param.h sys/poll.h sys/resource.h])
877
AC_CHECK_HEADERS([sys/time.h sys/times.h sys/wait.h unistd.h values.h])
Matthias Clasen's avatar
Matthias Clasen committed
878
AC_CHECK_HEADERS([sys/select.h sys/types.h stdint.h inttypes.h sched.h malloc.h])
879 880
AC_CHECK_HEADERS([sys/vfs.h sys/mount.h sys/vmount.h sys/statfs.h sys/statvfs.h])
AC_CHECK_HEADERS([mntent.h sys/mnttab.h sys/vfstab.h sys/mntctl.h sys/sysctl.h fstab.h])
Matthias Clasen's avatar
Matthias Clasen committed
881
AC_CHECK_HEADERS([sys/uio.h])
882 883 884

# check for structure fields
AC_CHECK_MEMBERS([struct stat.st_mtimensec, struct stat.st_mtim.tv_nsec, struct stat.st_atimensec, struct stat.st_atim.tv_nsec, struct stat.st_ctimensec, struct stat.st_ctim.tv_nsec])
885
AC_CHECK_MEMBERS([struct stat.st_blksize, struct stat.st_blocks, struct statfs.f_fstypename, struct statfs.f_bavail],,, [#include <sys/types.h>
Matthias Clasen's avatar
Matthias Clasen committed
886 887
#include <sys/stat.h>
#include <unistd.h>
888
#ifdef HAVE_SYS_STATFS_H
889
#include <sys/statfs.h>
890
#endif
891
#ifdef HAVE_SYS_PARAM_H
892 893
#include <sys/param.h>
#endif
894
#ifdef HAVE_SYS_MOUNT_H
895 896
#include <sys/mount.h>
#endif])
897 898
# struct statvfs.f_basetype is available on Solaris but not for Linux. 
AC_CHECK_MEMBERS([struct statvfs.f_basetype],,, [#include <sys/statvfs.h>])
899

900
# Checks for libcharset
901 902
AM_LANGINFO_CODESET
gl_GLIBC21
903 904 905
AC_CHECK_HEADERS([stddef.h stdlib.h string.h])
AC_CHECK_FUNCS(setlocale)

906
# check additional type sizes
907
AC_CHECK_SIZEOF(size_t)
908

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

912
case $ac_cv_sizeof_size_t in
913 914 915 916 917 918 919 920 921
  $ac_cv_sizeof_short) 
      glib_size_type=short
      ;;
  $ac_cv_sizeof_int) 
      glib_size_type=int
      ;;
  $ac_cv_sizeof_long) 
      glib_size_type=long
      ;;
922 923 924 925 926 927
  $ac_cv_sizeof_long_long)
      glib_size_type='long long'
      ;;
  $ac_cv_sizeof__int64)
      glib_size_type='__int64'
      ;;
928 929 930 931 932 933 934 935
  *)  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
936 937
if test $ac_cv_sizeof_size_t = $ac_cv_sizeof_int &&
   test $ac_cv_sizeof_size_t = $ac_cv_sizeof_long ; then
938
  GLIB_CHECK_COMPILE_WARNINGS([
939
#if defined(_AIX) && !defined(__GNUC__)
940 941
#pragma options langlvl=stdc89
#endif
942 943 944 945 946 947 948 949 950
#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
951
#if defined(_AIX) && !defined(__GNUC__)
952 953
#pragma options langlvl=stdc89
#endif
954 955 956 957 958 959 960 961 962 963 964 965
#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)

966
# Check for some functions
967
AC_CHECK_FUNCS(lstat strerror strsignal memmove vsnprintf stpcpy strcasecmp strncasecmp poll getcwd vasprintf setenv unsetenv getc_unlocked readlink symlink fdwalk)
968
AC_CHECK_FUNCS(chown lchmod lchown fchmod fchown link statvfs statfs utimes getgrgid getpwuid)
Matthias Clasen's avatar
Matthias Clasen committed
969
AC_CHECK_FUNCS(getmntent_r setmntent endmntent hasmntopt getmntinfo)
970 971
# Check for high-resolution sleep functions
AC_CHECK_FUNCS(nanosleep nsleep)
972
AC_CHECK_FUNCS(splice)
973

974
AC_CHECK_HEADERS(crt_externs.h)
975
AC_CHECK_FUNCS(_NSGetEnviron)
976

977
AC_FUNC_VSNPRINTF_C99
978 979
AC_FUNC_PRINTF_UNIX98

980 981 982 983 984 985 986
# Internet address families
if test $glib_native_win32 = yes; then
  glib_inet_includes=["
#include <winsock2.h>
  "]
else
  glib_inet_includes=["
987
#include <sys/types.h>
988 989 990 991 992 993 994 995 996 997 998 999 1000
#include <sys/socket.h>
  "]
fi

glib_failed=false
GLIB_CHECK_VALUE(AF_INET, $glib_inet_includes, glib_failed=true)
GLIB_CHECK_VALUE(AF_INET6, $glib_inet_includes, glib_failed=true)
# winsock defines this even though it doesn't support it
GLIB_CHECK_VALUE(AF_UNIX, $glib_inet_includes, glib_failed=true)
if $glib_failed ; then
  AC_MSG_ERROR([Could not determine values for AF_INET* constants])
fi

1001 1002 1003 1004 1005 1006 1007 1008
glib_failed=false
GLIB_CHECK_VALUE(MSG_PEEK, $glib_inet_includes, glib_failed=true)
GLIB_CHECK_VALUE(MSG_OOB, $glib_inet_includes, glib_failed=true)
GLIB_CHECK_VALUE(MSG_DONTROUTE, $glib_inet_includes, glib_failed=true)
if $glib_failed ; then
  AC_MSG_ERROR([Could not determine values for MSG_* constants])
fi

1009
AC_CHECK_FUNCS(getprotobyname_r endservent)
1010
AC_CHECK_HEADERS([netdb.h wspiapi.h])
1011

1012 1013 1014 1015
# For gio/libasyncns
if test $glib_native_win32 = no; then
  AC_CHECK_FUNCS(strndup setresuid setreuid)
  AC_CHECK_HEADERS(sys/prctl.h arpa/nameser_compat.h)
1016 1017 1018

  # We can't just use AC_CHECK_FUNC/AC_CHECK_LIB here. Bug 586150
  AC_MSG_CHECKING([for res_query])
1019 1020 1021 1022
  AC_TRY_LINK([#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>],
1023 1024 1025 1026
              [res_query("test", 0, 0, (void *)0, 0);],
              [AC_MSG_RESULT([yes])],
              [save_libs="$LIBS"
               LIBS="-lresolv $LIBS"
1027 1028 1029 1030
               AC_TRY_LINK([#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>],
1031 1032 1033 1034 1035 1036 1037 1038 1039 1040
                           [res_query("test", 0, 0, (void *)0, 0);],
                           [AC_MSG_RESULT([in -lresolv])
                            LIBASYNCNS_LIBADD="-lresolv"],
                           [LIBS="-lbind $save_libs"
                            AC_TRY_LINK([#include <resolv.h>],
                                        [res_query("test", 0, 0, (void *)0, 0);],
                                        [AC_MSG_RESULT([in -lbind])
                                         LIBASYNCNS_LIBADD="-lbind"],
                                        [AC_MSG_ERROR(not found)])])
               LIBS="$save_libs"])
1041 1042 1043
  AC_SUBST(LIBASYNCNS_LIBADD)
fi

1044 1045 1046 1047 1048 1049 1050 1051
case $host in
  *-*-solaris* )
     AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, Needed to get declarations for msg_control and msg_controllen on Solaris)
     AC_DEFINE(_XOPEN_SOURCE,          2, Needed to get declarations for msg_control and msg_controllen on Solaris)
     AC_DEFINE(__EXTENSIONS__,         1, Needed to get declarations for msg_control and msg_controllen on Solaris)
     ;;
esac

1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 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 1088 1089 1090 1091 1092
dnl
dnl if statfs() takes 2 arguments (Posix) or 4 (Solaris)
dnl
if test "$ac_cv_func_statfs" = yes ; then
  AC_MSG_CHECKING([number of arguments to statfs()])
  AC_TRY_COMPILE([#include <unistd.h>
  #ifdef HAVE_SYS_PARAM_H
  #include <sys/param.h>
  #endif
  #ifdef HAVE_SYS_VFS_H
  #include <sys/vfs.h>
  #endif
  #ifdef HAVE_SYS_MOUNT_H
  #include <sys/mount.h>
  #endif
  #ifdef HAVE_SYS_STATFS_H
  #include <sys/statfs.h>
  #endif], [struct statfs st;
  statfs(NULL, &st);],[
    AC_MSG_RESULT([2])
    AC_DEFINE(STATFS_ARGS, 2, [Number of arguments to statfs()])],[
    AC_TRY_COMPILE([#include <unistd.h>
  #ifdef HAVE_SYS_PARAM_H
  #include <sys/param.h>
  #endif
  #ifdef HAVE_SYS_VFS_H
  #include <sys/vfs.h>
  #endif
  #ifdef HAVE_SYS_MOUNT_H
  #include <sys/mount.h>
  #endif
  #ifdef HAVE_SYS_STATFS_H
  #include <sys/statfs.h>
  #endif], [struct statfs st;
  statfs(NULL, &st, sizeof (st), 0);],[
      AC_MSG_RESULT([4])
      AC_DEFINE(STATFS_ARGS, 4, [Number of arguments to statfs()])],[
      AC_MSG_RESULT(unknown)
      AC_MSG_ERROR([unable to determine number of arguments to statfs()])])])
fi

1093
#
1094
# Check whether to use an included printf
1095 1096
#

1097 1098 1099
AC_ARG_ENABLE(included-printf,
              [AC_HELP_STRING([--enable-included-printf],
                              [use included printf [default=auto]])],
1100
              enable_included_printf="$enableval")
1101

1102 1103 1104
need_included_printf=no
if test "x$enable_included_printf" = "xyes" ; then
  need_included_printf=yes
1105 1106
fi
if test "$ac_cv_func_vsnprintf_c99" != "yes" ; then
1107
  need_included_printf=yes
1108 1109
fi
if test "$ac_cv_func_printf_unix98" != "yes" ; then
1110
  need_included_printf=yes
1111
fi
1112 1113
if test "x$ac_cv_sizeof_long_long" = "x8" &&
   test -z "$glib_cv_long_long_format" ; then
1114
  need_included_printf=yes
1115 1116
fi

1117 1118
if test "x$enable_included_printf" = "xno" && 
   test "x$need_included_printf" = "xyes" ; then
1119
  AC_MSG_ERROR([
1120
*** Your C library's printf doesn't appear to have the features that
1121
*** GLib needs, but you specified --enable-included-printf=no.])
1122 1123
fi

1124
enable_included_printf=$need_included_printf
1125

1126 1127
AM_CONDITIONAL(HAVE_GOOD_PRINTF, test "$enable_included_printf" != "yes")
if test "$enable_included_printf" != "yes" ; then 
1128
  AC_DEFINE(HAVE_GOOD_PRINTF,1,[define to use system printf])
1129
else
1130 1131 1132
  if test -z "$glib_cv_long_long_format" ; then
    glib_cv_long_long_format="ll"
  fi
1133 1134
  AC_DEFINE(HAVE_VASPRINTF,1)
fi
1135 1136 1137 1138 1139 1140 1141 1142 1143 1144

# 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
1145
AC_CHECK_FUNCS([snprintf wcslen])
1146
AC_FUNC_SNPRINTF_C99
1147

1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167
# 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)])
1168 1169

  GLIB_ASSERT_SET(glib_cv_working_bcopy)
1170
  if test "$glib_cv_working_bcopy" = "yes"; then
1171
    AC_DEFINE(HAVE_WORKING_BCOPY,1,[Have a working bcopy])
1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182
  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)
1183
if test "$glib_ok" = "no"; then
1184
    AC_DEFINE(NO_SYS_ERRLIST,1,[global 'sys_errlist' not found])
1185 1186 1187 1188 1189 1190
fi

# Check for sys_siglist
AC_MSG_CHECKING(for sys_siglist)
AC_TRY_LINK(, [
extern char *sys_siglist[];
1191
exit (sys_siglist[0]);
1192 1193
], glib_ok=yes, glib_ok=no)
AC_MSG_RESULT($glib_ok)
1194
if test "$glib_ok" = "no"; then
1195
    AC_DEFINE(NO_SYS_SIGLIST,1,[global 'sys_siglist' not found])
1196 1197 1198 1199 1200 1201 1202 1203
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)
1204
if test "$glib_ok" = "no"; then
1205
    AC_DEFINE(NO_SYS_SIGLIST_DECL,1,[global 'sys_siglist' not declared])
1206 1207 1208 1209 1210 1211
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)
1212
if test "$gtk_ok" = "yes"; then
1213 1214
    AC_MSG_RESULT([yes, found in sys/types.h])
else
1215
    AC_EGREP_HEADER(fd_set, sys/select.h, gtk_ok=yes)
1216
    if test "$gtk_ok" = "yes"; then
1217 1218
	# *** FIXME: give it a different name
        AC_DEFINE(HAVE_SYS_SELECT_H,1,[found fd_set in sys/select.h])
1219 1220
        AC_MSG_RESULT([yes, found in sys/select.h])
    else
1221
	AC_DEFINE(NO_FD_SET,1,[didn't find fd_set])
1222 1223 1224 1225 1226
	AC_MSG_RESULT(no)
    fi
fi

dnl *** check for sane realloc() ***
1227
AC_CACHE_CHECK([whether realloc (NULL,) will work],glib_cv_sane_realloc,[
1228
        AC_TRY_RUN([#include <stdlib.h>
1229 1230 1231
        int main() {
          return realloc (0, sizeof (int)) == 0;
        }],
1232 1233
        [glib_cv_sane_realloc=yes],
        [glib_cv_sane_realloc=no],
1234
	[glib_cv_sane_realloc=yes])
1235
])
1236
if test x$glib_cv_sane_realloc = xyes; then
1237
  AC_DEFINE(REALLOC_0_WORKS,1,[whether realloc (NULL,) works])
1238
fi
1239

1240
dnl Check for nl_langinfo and CODESET
1241 1242 1243 1244 1245 1246 1247 1248
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
1249

1250 1251 1252 1253 1254 1255 1256 1257 1258
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
1259 1260
                #include <stdlib.h> /* posix_memalign() should be defined here */
                /* some systems break if #include <malloc.h> used */
1261 1262 1263 1264
		static void test_memalign (size_t boundary, size_t size) {
		    void *mem = 0;
		    if (posix_memalign (&mem, boundary, size) != 0 || !mem)
			exit (1);
1265 1266
                    else
                      free (mem);
1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292
		}
		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


1293 1294 1295 1296
dnl ****************************************
dnl *** strlcpy/strlcat                  ***
dnl ****************************************
# Check for strlcpy
1297 1298
AC_CACHE_CHECK([for OpenBSD strlcpy/strlcat],glib_cv_have_strlcpy,[
AC_TRY_RUN([#include <stdlib.h>
1299 1300
#include <string.h>
int main() {
1301
  char p[10];
1302 1303
  (void) strlcpy (p, "hi", 10);
  if (strlcat (p, "bye", 0) != 3) 
1304
    return 1;
1305
  return 0;
1306 1307 1308 1309
}], glib_cv_have_strlcpy=yes, 
    glib_cv_have_strlcpy=no,
    glib_cv_have_strlcpy=no)])
if test "$glib_cv_have_strlcpy" = "yes"; then
1310
    AC_DEFINE(HAVE_STRLCPY,1,[Have functions strlcpy and strlcat])
1311
fi
1312
  
1313 1314 1315 1316 1317 1318

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.
1319
AC_CACHE_CHECK([for an implementation of va_copy()],glib_cv_va_copy,[
1320
	AC_LINK_IFELSE([#include <stdarg.h>
1321
#include <stdlib.h>
1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333
	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;
	}],
1334
	[glib_cv_va_copy=yes],
1335
	[glib_cv_va_copy=no])
1336
])
1337
AC_CACHE_CHECK([for an implementation of __va_copy()],glib_cv___va_copy,[
1338
	AC_LINK_IFELSE([#include <stdarg.h>
1339
#include <stdlib.h>
1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351
	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;
	}],
1352
	[glib_cv___va_copy=yes],
1353
	[glib_cv___va_copy=no])
1354
])
1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367

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,[
1368
	AC_TRY_RUN([#include <stdarg.h>
1369
#include <stdlib.h> 
1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381
	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;
	}],
1382 1383
	[glib_cv_va_val_copy=yes],
	[glib_cv_va_val_copy=no],
1384
	[glib_cv_va_val_copy=yes])
1385
])
1386

1387
if test "x$glib_cv_va_val_copy" = "xno"; then
1388
  AC_DEFINE(G_VA_COPY_AS_ARRAY,1, ['va_lists' cannot be copies as values])
1389 1390 1391 1392 1393 1394 1395 1396
fi

dnl ***********************
dnl *** g_module checks ***
dnl ***********************
G_MODULE_LIBS=
G_MODULE_LIBS_EXTRA=
G_MODULE_PLUGIN_LIBS=
1397 1398 1399 1400
if test x"$glib_native_win32" = xyes; then
  dnl No use for this on Win32
  G_MODULE_LDFLAGS=
else
1401
  export SED
1402 1403
  G_MODULE_LDFLAGS=`(./libtool --config; echo eval echo \\$export_dynamic_flag_spec) | sh`
fi
1404 1405
dnl G_MODULE_IMPL= don't reset, so cmd-line can override
G_MODULE_NEED_USCORE=0
Tim Janik's avatar
Tim Janik committed
1406
G_MODULE_BROKEN_RTLD_GLOBAL=0
1407
G_MODULE_HAVE_DLERROR=0
1408 1409 1410 1411 1412 1413
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
1414 1415 1416 1417 1418 1419 1420
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
1421 1422 1423
dnl *** dlopen() and dlsym() in system libraries
if test -z "$G_MODULE_IMPL"; then
	AC_CHECK_FUNC(dlopen,
1424 1425 1426
		      [AC_CHECK_FUNC(dlsym,
			             [G_MODULE_IMPL=G_MODULE_IMPL_DL],[])],
		      [])
1427 1428
fi
dnl *** load_image (BeOS)
Raja R Harinath's avatar
Raja R Harinath committed
1429
if test -z "$G_MODULE_IMPL" && test "x$glib_native_beos" = "xyes"; then
1430
  AC_CHECK_LIB(root, load_image,
1431
      [G_MODULE_LIBS="-lbe -lroot -lglib-2.0 "
1432 1433
      G_MODULE_LIBS_EXTRA="-L\$(top_builddir_full)/.libs"
      G_MODULE_PLUGIN_LIBS="-L\$(top_builddir_full)/gmodule/.libs -lgmodule"
1434 1435
      G_MODULE_IMPL=G_MODULE_IMPL_BEOS],
      [])
1436
fi   
Owen Taylor's avatar
Owen Taylor committed
1437 1438 1439