* configure.ac (_PTHREADS): New template (used for NetBSD).
* configure.ac (THREADDLLIBS): New macro.
* tests/Makefile.am (test_atomic_LDADD, test_stack_LDADD,
test_atomic_pthreads_LDADD, test_malloc_LDADD): Use THREADDLLIBS
instead of "-lpthread".
* configure: Regenerate.
* Makefile.in: Ditto.
* doc/Makefile.in: Ditto.
* src/Makefile.in: Ditto.
* src/atomic_ops/Makefile.in: Ditto.
* src/atomic_ops/sysdeps/Makefile.in: Ditto.
* src/config.h.in: Ditto.
* tests/Makefile.in: Ditto.
+2011-06-01 Ivan Maidanski <ivmai@mail.ru>
+
+ * configure.ac (_PTHREADS): New template (used for NetBSD).
+ * configure.ac (THREADDLLIBS): New macro.
+ * tests/Makefile.am (test_atomic_LDADD, test_stack_LDADD,
+ test_atomic_pthreads_LDADD, test_malloc_LDADD): Use THREADDLLIBS
+ instead of "-lpthread".
+ * configure: Regenerate.
+ * Makefile.in: Ditto.
+ * doc/Makefile.in: Ditto.
+ * src/Makefile.in: Ditto.
+ * src/atomic_ops/Makefile.in: Ditto.
+ * src/atomic_ops/sysdeps/Makefile.in: Ditto.
+ * src/config.h.in: Ditto.
+ * tests/Makefile.in: Ditto.
+
2011-05-30 Ivan Maidanski <ivmai@mail.ru>
* configure.ac (PIC): Add workaround for GCC v3.4.6 which does not
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
+THREADDLLIBS = @THREADDLLIBS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
LIBOBJS
NEED_ASM_FALSE
NEED_ASM_TRUE
+THREADDLLIBS
PICFLAG
EGREP
GREP
+
+THREADDLLIBS=
+## Libraries needed to support threads.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_self in -lpthread" >&5
+$as_echo_n "checking for pthread_self in -lpthread... " >&6; }
+if ${ac_cv_lib_pthread_pthread_self+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpthread $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char pthread_self ();
+int
+main ()
+{
+return pthread_self ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_pthread_pthread_self=yes
+else
+ ac_cv_lib_pthread_pthread_self=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_self" >&5
+$as_echo "$ac_cv_lib_pthread_pthread_self" >&6; }
+if test "x$ac_cv_lib_pthread_pthread_self" = xyes; then :
+ THREADDLLIBS="-lpthread"
+fi
+
+
+$as_echo "#define _REENTRANT 1" >>confdefs.h
+
+case "$host" in
+ *-*-netbsd*)
+ $as_echo "#define _PTHREADS 1" >>confdefs.h
+
+ ;;
+ *-*-openbsd* | *-*-kfreebsd*-gnu | *-*-dgux*)
+ THREADDLLIBS=-pthread
+ ;;
+ *-*-cygwin* | *-*-darwin*)
+ THREADDLLIBS=
+ ;;
+esac
+
+
if test x$need_asm = xtrue; then
NEED_ASM_TRUE=
NEED_ASM_FALSE='#'
esac
fi
CFLAGS="$CFLAGS -DNDEBUG"
-
AC_SUBST(PICFLAG)
AC_SUBST(DEFS)
+AH_TEMPLATE([_PTHREADS], [Indicates the use of pthreads (NetBSD).])
+
+THREADDLLIBS=
+## Libraries needed to support threads.
+AC_CHECK_LIB(pthread, pthread_self, THREADDLLIBS="-lpthread",,)
+AC_DEFINE(_REENTRANT, 1, [Required define if using POSIX threads.])
+case "$host" in
+ *-*-netbsd*)
+ AC_DEFINE(_PTHREADS)
+ ;;
+ *-*-openbsd* | *-*-kfreebsd*-gnu | *-*-dgux*)
+ THREADDLLIBS=-pthread
+ ;;
+ *-*-cygwin* | *-*-darwin*)
+ THREADDLLIBS=
+ ;;
+esac
+AC_SUBST(THREADDLLIBS)
+
AM_CONDITIONAL(NEED_ASM, test x$need_asm = xtrue)
-AC_CONFIG_FILES([Makefile src/Makefile src/atomic_ops/Makefile src/atomic_ops/sysdeps/Makefile doc/Makefile tests/Makefile])
+AC_CONFIG_FILES([Makefile src/Makefile src/atomic_ops/Makefile \
+ src/atomic_ops/sysdeps/Makefile doc/Makefile tests/Makefile])
AC_CONFIG_COMMANDS([default],[[]],[[
PICFLAG="${PICFLAG}"
CC="${CC}"
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
+THREADDLLIBS = @THREADDLLIBS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
+THREADDLLIBS = @THREADDLLIBS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
+THREADDLLIBS = @THREADDLLIBS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
+THREADDLLIBS = @THREADDLLIBS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
/* Version number of package */
#undef VERSION
+
+/* Indicates the use of pthreads (NetBSD). */
+#undef _PTHREADS
+
+/* Required define if using POSIX threads. */
+#undef _REENTRANT
check_PROGRAMS=test_atomic test_atomic_pthreads test_stack test_malloc
test_atomic_SOURCES=test_atomic.c
-test_atomic_LDADD=-lpthread ../src/libatomic_ops.a
+test_atomic_LDADD=$(THREADDLLIBS) ../src/libatomic_ops.a
test_atomic_pthreads_SOURCES=test_atomic.c
test_atomic_pthreads_CPPFLAGS=-DAO_USE_PTHREAD_DEFS $(AM_CPPFLAGS)
-test_atomic_pthreads_LDADD=-lpthread ../src/libatomic_ops.a
+test_atomic_pthreads_LDADD=$(THREADDLLIBS) ../src/libatomic_ops.a
test_stack_SOURCES=test_stack.c
-test_stack_LDADD=-lpthread ../src/libatomic_ops_gpl.a ../src/libatomic_ops.a
+test_stack_LDADD=$(THREADDLLIBS) ../src/libatomic_ops_gpl.a \
+ ../src/libatomic_ops.a
test_malloc_SOURCES=test_malloc.c
-test_malloc_LDADD=-lpthread ../src/libatomic_ops_gpl.a ../src/libatomic_ops.a
+test_malloc_LDADD=$(THREADDLLIBS) ../src/libatomic_ops_gpl.a \
+ ../src/libatomic_ops.a
test_atomic_include.h: test_atomic.template
sed -e s/XX// $? > $@
CONFIG_CLEAN_VPATH_FILES =
am_test_atomic_OBJECTS = test_atomic.$(OBJEXT)
test_atomic_OBJECTS = $(am_test_atomic_OBJECTS)
-test_atomic_DEPENDENCIES = ../src/libatomic_ops.a
+am__DEPENDENCIES_1 =
+test_atomic_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+ ../src/libatomic_ops.a
am_test_atomic_pthreads_OBJECTS = \
test_atomic_pthreads-test_atomic.$(OBJEXT)
test_atomic_pthreads_OBJECTS = $(am_test_atomic_pthreads_OBJECTS)
-test_atomic_pthreads_DEPENDENCIES = ../src/libatomic_ops.a
+test_atomic_pthreads_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+ ../src/libatomic_ops.a
am_test_malloc_OBJECTS = test_malloc.$(OBJEXT)
test_malloc_OBJECTS = $(am_test_malloc_OBJECTS)
-test_malloc_DEPENDENCIES = ../src/libatomic_ops_gpl.a \
- ../src/libatomic_ops.a
+test_malloc_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+ ../src/libatomic_ops_gpl.a ../src/libatomic_ops.a
am_test_stack_OBJECTS = test_stack.$(OBJEXT)
test_stack_OBJECTS = $(am_test_stack_OBJECTS)
-test_stack_DEPENDENCIES = ../src/libatomic_ops_gpl.a \
- ../src/libatomic_ops.a
+test_stack_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+ ../src/libatomic_ops_gpl.a ../src/libatomic_ops.a
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
+THREADDLLIBS = @THREADDLLIBS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
CLEANFILES = list_atomic.i
AM_CPPFLAGS = -I$(srcdir)/../src
test_atomic_SOURCES = test_atomic.c
-test_atomic_LDADD = -lpthread ../src/libatomic_ops.a
+test_atomic_LDADD = $(THREADDLLIBS) ../src/libatomic_ops.a
test_atomic_pthreads_SOURCES = test_atomic.c
test_atomic_pthreads_CPPFLAGS = -DAO_USE_PTHREAD_DEFS $(AM_CPPFLAGS)
-test_atomic_pthreads_LDADD = -lpthread ../src/libatomic_ops.a
+test_atomic_pthreads_LDADD = $(THREADDLLIBS) ../src/libatomic_ops.a
test_stack_SOURCES = test_stack.c
-test_stack_LDADD = -lpthread ../src/libatomic_ops_gpl.a ../src/libatomic_ops.a
+test_stack_LDADD = $(THREADDLLIBS) ../src/libatomic_ops_gpl.a \
+ ../src/libatomic_ops.a
+
test_malloc_SOURCES = test_malloc.c
-test_malloc_LDADD = -lpthread ../src/libatomic_ops_gpl.a ../src/libatomic_ops.a
+test_malloc_LDADD = $(THREADDLLIBS) ../src/libatomic_ops_gpl.a \
+ ../src/libatomic_ops.a
+
all: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) all-am