Add checks for -lpthread, stolen from Gtk+ configure.in.

Define G_THREAD_SAFE in glibconfig.h if thread support is present.
This commit is contained in:
Jeff Garzik 1998-11-11 22:39:32 +00:00
parent 11376df686
commit c4261064d6
2 changed files with 27 additions and 2 deletions

View File

@ -62,6 +62,7 @@ AC_ARG_ENABLE(mem_profile, [ --enable-mem-profile=[no/yes] turn on malloc profi
AC_ARG_ENABLE(ansi, [ --enable-ansi turn on strict ansi [default=no]],
, enable_ansi=no)
AC_ARG_WITH(threads, [ --with-threads=[posix] support threading [default=no]])
AC_MSG_CHECKING(whether to enable memory checking)
if test "x$enable_mem_check" = "xyes"; then
@ -92,6 +93,19 @@ fi
AC_DEFINE_UNQUOTED(G_COMPILED_WITH_DEBUGGING, "${enable_debug}")
glib_use_threads=no
if test "x$with_threads" = "xposix" || test "x$with_threads" = "xyes"; then
AC_CHECK_LIB(pthread, pthread_attr_init,
glib_use_threads=yes
CFLAGS="$CFLAGS -D_REENTRANT",
# AIX has libpthreads, cause they're special. Special friends (TM)
AC_CHECK_LIB(pthreads, pthread_attr_init,
glib_use_threads=yes
CFLAGS="$CFLAGS -D_REENTRANT -D_THREAD_SAFE"))
fi
AC_MSG_CHECKING(whether to enable POSIX thread support)
AC_MSG_RESULT($glib_use_threads)
# Checks for programs.
AC_PROG_CC
AM_PROG_CC_STDC
@ -610,6 +624,7 @@ outfile_EOF
$glib_atexit
$glib_memmove
$glib_defines
$glib_threads
$glib_vacopy
@ -828,6 +843,14 @@ if test x$glib_working_wctype = xno; then
glib_wc="\$glib_wc
#define G_HAVE_BROKEN_WCTYPE 1"
fi
if test x$glib_use_threads = xyes; then
glib_threads='
#define G_THREAD_SAFE 1'
else
glib_threads='
#undef G_THREAD_SAFE'
fi
])
AC_OUTPUT([

View File

@ -29,12 +29,14 @@ extern "C" {
#define G_MODULE_IMPL_DL 1
#define G_MODULE_IMPL_DLD 2
#define G_MODULE_IMPL_WIN32 3
#define G_MODULE_IMPL_OS2 4
#define G_MODULE_IMPL_BEOS 5
#define G_MODULE_IMPL G_MODULE_IMPL_WIN32
#undef G_MODULE_HAVE_DLERROR
#ifdef __LCC__
#define G_MODULE_NEED_USCORE
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */