~registry/glib/glib-2-30

« back to all changes in this revision

Viewing changes to configure.in

  • Committer: Owen Taylor
  • Date: 1998-12-15 05:28:02 UTC
  • Revision ID: git-v1:931ea952650b013b834041b91b0c37a748ffd449
This commit merges the glib-threads branch into the main
branch. See the ChangeLog for details of the changes.

In brief overview:

 - The set of threading functions can be set
 - A default implementation is provided in -lgthread
 - All static data structures are locked using these
   functions if g_thread_init() is called.

Show diffs side-by-side

added added

removed removed

Lines of Context:
508
508
AC_SUBST(G_MODULE_NEED_USCORE)
509
509
AC_SUBST(GLIB_DEBUG_FLAGS)
510
510
 
 
511
 
 
512
dnl ***********************
 
513
dnl *** g_thread checks ***
 
514
dnl ***********************
 
515
 
 
516
AC_ARG_WITH(threads, [  --with-threads=[none/posix/solaris/nspr] specify a thread implementation to use.],,)
 
517
 
 
518
dnl error and warning message
 
519
dnl *************************
 
520
 
 
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."
 
523
 
 
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."
 
527
 
 
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."
 
532
 
 
533
LIBS_NOT_FOUND_1="I can't find the libraries for the thread implementation
 
534
                "
 
535
 
 
536
LIBS_NOT_FOUND_2=". Please choose another thread implementation or 
 
537
                provide informationon your thread implementation."
 
538
 
 
539
dnl determination of thread implementation
 
540
dnl ***************************************
 
541
 
 
542
if test x"$with_threads" = x; then
 
543
        case $host in
 
544
                *-*-solaris*)
 
545
                        AC_CHECK_LIB(thread,cond_init,with_threads=solaris)
 
546
                        ;;
 
547
        esac
 
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)
 
552
        fi
 
553
fi
 
554
 
 
555
AC_MSG_CHECKING(for thread implementation)
 
556
 
 
557
if test x"$with_threads" = x; then
 
558
        with_threads=none
 
559
        AC_MSG_WARN($THREAD_NO_IMPLEMENTATION)
 
560
fi
 
561
 
 
562
AC_MSG_RESULT($with_threads)
 
563
 
 
564
dnl determination of G_THREAD_LIBS
 
565
dnl ******************************
 
566
 
 
567
G_THREAD_LIBS=
 
568
 
 
569
case $with_threads in
 
570
        posix)
 
571
                G_THREAD_LIBS=error
 
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")                 
 
576
                ;;
 
577
        solaris)
 
578
                G_THREAD_LIBS=error
 
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 *],
 
584
                             [#include <thread.h>
 
585
                             begin DEFAULTMUTEX end],
 
586
                             [solaris_mutex_init_broken=yes],
 
587
                             [solaris_mutex_init_broken=no])
 
588
                AC_MSG_RESULT($solaris_mutex_init_broken)
 
589
                ;;
 
590
        nspr)
 
591
                AC_CHECK_LIB(nspr21,PRP_NewNakedCondVar,
 
592
                             G_THREAD_LIBS="-lnspr21")
 
593
                ;;
 
594
        none)
 
595
                ;;
 
596
        *)
 
597
                G_THREAD_LIBS=error
 
598
                ;;
 
599
esac
 
600
 
 
601
if test "x$G_THREAD_LIBS" = xerror; then
 
602
        AC_MSG_ERROR($LIBS_NOT_FOUND_1$with_threads$LIBS_NOT_FOUND_2)
 
603
fi
 
604
 
 
605
AC_MSG_CHECKING(necessary linker options)
 
606
AC_MSG_RESULT($G_THREAD_LIBS)
 
607
 
 
608
dnl determination of G_THREAD_CFLAGS
 
609
dnl ********************************
 
610
 
 
611
if test x"$with_threads" != xnone; then
 
612
        G_THREAD_CFLAGS="-D_REENTRANT" # good default
 
613
 
 
614
        case $host in
 
615
               -aix*)
 
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"
 
620
                        fi
 
621
                        ;;
 
622
        esac
 
623
 
 
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, , 
 
629
                G_THREAD_CFLAGS=
 
630
                AC_MSG_WARN($FLAG_DOES_NOT_WORK))
 
631
        CPPFLAGS=$old_CPPFLAGS
 
632
                
 
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"
 
638
                AC_TRY_COMPILE(,,
 
639
                        G_THREAD_CFLAGS="$G_THREAD_CFLAGS -fstack-check")
 
640
                CPPFLAGS=$old_CPPFLAGS
 
641
        else
 
642
                AC_MSG_WARN($THREAD_UNKNOWN_COMPILER)
 
643
        fi
 
644
 
 
645
        AC_MSG_CHECKING(necessary compiler options)
 
646
 
 
647
        AC_MSG_RESULT($G_THREAD_CFLAGS)
 
648
else
 
649
        G_THREAD_CFLAGS=
 
650
fi
 
651
 
 
652
AC_DEFINE_UNQUOTED(G_THREAD_SOURCE,"gthread-$with_threads.c")
 
653
AC_SUBST(G_THREAD_CFLAGS)
 
654
AC_SUBST(G_THREAD_LIBS)
 
655
 
 
656
dnl ******************************
 
657
dnl *** output the whole stuff ***
 
658
dnl ******************************
 
659
 
511
660
AC_OUTPUT_COMMANDS([
512
661
 
513
662
## Generate `glibconfig.h' in two cases
550
699
  if test x$glib_values_h = xyes; then
551
700
    echo '#include <values.h>' >> $outfile
552
701
  fi
 
702
  if test x$g_mutex_header_file != x; then
 
703
    echo '#include <'"$g_mutex_header_file"'>' >> $outfile
 
704
  fi
553
705
  if test x$glib_sys_poll_h = xyes; then
554
706
    echo '#include <sys/types.h>' >> $outfile
555
707
    echo '#include <sys/poll.h>' >> $outfile
628
780
#define G_BYTE_ORDER $g_byte_order
629
781
outfile_EOF
630
782
 
 
783
cat >>$outfile <<outfile_EOF                                               
 
784
 
 
785
/* definitions for the default mutex implementation */
 
786
outfile_EOF
 
787
 
 
788
  if test x$g_mutex_has_default = xyes; then
 
789
cat >>$outfile <<outfile_EOF                                               
 
790
 
 
791
typedef struct _GStaticMutex GStaticMutex;
 
792
struct _GStaticMutex 
 
793
{
 
794
  $g_mutex_default_type default_mutex;
 
795
  struct _GMutex* runtime_mutex;
 
796
};
 
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) )
 
801
outfile_EOF
 
802
  else
 
803
cat >>$outfile <<outfile_EOF                                               
 
804
 
 
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)
 
808
outfile_EOF
 
809
  fi
 
810
 
631
811
  g_bit_sizes="16 32"
632
812
  if test -n "$gint64"; then
633
813
    g_bit_sizes="$g_bit_sizes 64"
841
1021
  glib_wc="\$glib_wc
842
1022
#define G_HAVE_BROKEN_WCTYPE 1"
843
1023
fi
 
1024
 
 
1025
case $with_threads in
 
1026
        posix)
 
1027
                g_mutex_has_default=yes
 
1028
                g_mutex_default_type='pthread_mutex_t'
 
1029
                g_mutex_default_init='PTHREAD_MUTEX_INITIALIZER'
 
1030
                g_mutex_header_file='pthread.h'
 
1031
                ;;
 
1032
        solaris)
 
1033
                g_mutex_has_default=yes
 
1034
                g_mutex_default_type='mutex_t'
 
1035
                if test x$solaris_mutex_init_broken = xyes; then
 
1036
                  g_mutex_default_init="{ { { 0, 0, 0, 0 }, USYNC_THREAD }, { { { 0, 0, 0, 0, 0, 0, 0, 0 } } }, 0}"
 
1037
                else
 
1038
                  g_mutex_default_init="DEFAULTMUTEX"
 
1039
                fi
 
1040
                g_mutex_header_file='thread.h'
 
1041
                ;;
 
1042
        nspr)
 
1043
                g_mutex_has_default=no
 
1044
                ;;
 
1045
        *)              
 
1046
                g_mutex_has_default=no
 
1047
                ;;
 
1048
esac
844
1049
])
845
1050
 
846
1051
AC_OUTPUT([
848
1053
glib-config
849
1054
gmodule/gmoduleconf.h
850
1055
gmodule/Makefile
 
1056
gthread/Makefile
851
1057
docs/Makefile
852
1058
],[case "$CONFIG_FILES" in
853
1059
*glib-config*)chmod +x glib-config;;