508
508
AC_SUBST(G_MODULE_NEED_USCORE)
509
509
AC_SUBST(GLIB_DEBUG_FLAGS)
512
dnl ***********************
513
dnl *** g_thread checks ***
514
dnl ***********************
516
AC_ARG_WITH(threads, [ --with-threads=[none/posix/solaris/nspr] specify a thread implementation to use.],,)
518
dnl error and warning message
519
dnl *************************
521
THREAD_NO_IMPLEMENTATION="You do not have any known thread system on your
522
computer. glib will not be thread safe on your computer."
524
THREAD_UNKNOWN_COMPILER="Your compiler is not known, so I cannot
525
determine the necessary compiler options to compile programs
526
which are using threads. Please provide such information."
528
FLAG_DOES_NOT_WORK="I can't find the MACRO, that enables thread safety on your
529
platform (normaly it's "_REENTRANT"). I'll not use any flag on
530
compilation now, but then your programs might not work.
531
Please provide information on how it is done on your system."
533
LIBS_NOT_FOUND_1="I can't find the libraries for the thread implementation
536
LIBS_NOT_FOUND_2=". Please choose another thread implementation or
537
provide informationon your thread implementation."
539
dnl determination of thread implementation
540
dnl ***************************************
542
if test x"$with_threads" = x; then
545
AC_CHECK_LIB(thread,cond_init,with_threads=solaris)
548
if test x"$with_threads" = x; then
549
AC_CHECK_LIB(pthread,pthread_cond_init,with_threads=posix)
550
AC_CHECK_LIB(pthreads,pthread_attr_init,with_threads=posix)
551
AC_CHECK_LIB(nspr21,PRP_NewNakedCondVar,with_threads=nspr)
555
AC_MSG_CHECKING(for thread implementation)
557
if test x"$with_threads" = x; then
559
AC_MSG_WARN($THREAD_NO_IMPLEMENTATION)
562
AC_MSG_RESULT($with_threads)
564
dnl determination of G_THREAD_LIBS
565
dnl ******************************
569
case $with_threads in
572
AC_CHECK_LIB(pthreads,pthread_cond_init,
573
G_THREAD_LIBS="-lpthreads")
574
AC_CHECK_LIB(pthread,pthread_cond_init,
575
G_THREAD_LIBS="-lpthread")
579
AC_CHECK_LIB(thread,cond_init,G_THREAD_LIBS="-lthread")
580
# solaris has a broken initializer for mutexes, if we find it,
581
# we will replace it.
582
AC_MSG_CHECKING(for broken solaris mutex initialization)
583
AC_EGREP_CPP([ *begin *{ *0 *, *0 *, *0 *, *0 *, *0 *, *0 *, *0 *, *0 *, *0 *, *0 *, *0 *, *0 *, *0 *, *0 *} *end *],
585
begin DEFAULTMUTEX end],
586
[solaris_mutex_init_broken=yes],
587
[solaris_mutex_init_broken=no])
588
AC_MSG_RESULT($solaris_mutex_init_broken)
591
AC_CHECK_LIB(nspr21,PRP_NewNakedCondVar,
592
G_THREAD_LIBS="-lnspr21")
601
if test "x$G_THREAD_LIBS" = xerror; then
602
AC_MSG_ERROR($LIBS_NOT_FOUND_1$with_threads$LIBS_NOT_FOUND_2)
605
AC_MSG_CHECKING(necessary linker options)
606
AC_MSG_RESULT($G_THREAD_LIBS)
608
dnl determination of G_THREAD_CFLAGS
609
dnl ********************************
611
if test x"$with_threads" != xnone; then
612
G_THREAD_CFLAGS="-D_REENTRANT" # good default
616
# FIXME: can somebody confirm this -D_THREAD_SAFE ???
617
G_THREAD_CFLAGS="$G_THREAD_CFLAGS -D_THREAD_SAFE"
618
if test x"$GCC" = xyes; then
619
G_THREAD_CFLAGS="$G_THREAD_CFLAGS -mthreads"
624
# if we are not finding the ctime_r function, then we probably are
625
# not using the proper multithread flag
626
old_CPPFLAGS=$CPPFLAGS
627
CPPFLAGS="$CPPFLAGS $G_THREAD_CFLAGS"
628
AC_EGREP_HEADER([[^a-zA-Z_]ctime_r[^a-zA-Z_]], time.h, ,
630
AC_MSG_WARN($FLAG_DOES_NOT_WORK))
631
CPPFLAGS=$old_CPPFLAGS
633
if test x"$GCC" = xyes; then
634
# older gcc's do not know the -fstack-check option and will
635
# stop compiling, so just check this here
636
old_CPPFLAGS="$CPPFLAGS"
637
CPPFLAGS="$CPPFLAGS -fstack-check"
639
G_THREAD_CFLAGS="$G_THREAD_CFLAGS -fstack-check")
640
CPPFLAGS=$old_CPPFLAGS
642
AC_MSG_WARN($THREAD_UNKNOWN_COMPILER)
645
AC_MSG_CHECKING(necessary compiler options)
647
AC_MSG_RESULT($G_THREAD_CFLAGS)
652
AC_DEFINE_UNQUOTED(G_THREAD_SOURCE,"gthread-$with_threads.c")
653
AC_SUBST(G_THREAD_CFLAGS)
654
AC_SUBST(G_THREAD_LIBS)
656
dnl ******************************
657
dnl *** output the whole stuff ***
658
dnl ******************************
511
660
AC_OUTPUT_COMMANDS([
513
662
## Generate `glibconfig.h' in two cases
628
780
#define G_BYTE_ORDER $g_byte_order
783
cat >>$outfile <<outfile_EOF
785
/* definitions for the default mutex implementation */
788
if test x$g_mutex_has_default = xyes; then
789
cat >>$outfile <<outfile_EOF
791
typedef struct _GStaticMutex GStaticMutex;
794
$g_mutex_default_type default_mutex;
795
struct _GMutex* runtime_mutex;
797
#define G_STATIC_MUTEX_INIT { $g_mutex_default_init, NULL }
798
#define g_static_mutex_get_mutex(mutex) \
799
( g_thread_use_default_impl ? (GMutex*)&mutex.default_mutex : \
800
g_static_mutex_get_mutex_impl(&mutex.runtime_mutex) )
803
cat >>$outfile <<outfile_EOF
805
typedef struct _GMutex* GStaticMutex;
806
#define G_STATIC_MUTEX_INIT NULL
807
#define g_static_mutex_get_mutex(mutex) g_static_mutex_get_mutex_impl(&mutex)
631
811
g_bit_sizes="16 32"
632
812
if test -n "$gint64"; then
633
813
g_bit_sizes="$g_bit_sizes 64"