+dnl $OpenLDAP$
+dnl
dnl Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
dnl COPYING RESTRICTIONS APPLY, See COPYRIGHT file
dnl
dnl OpenLDAP Autoconf Macros
dnl
dnl --------------------------------------------------------------------
+AC_DEFUN([OL_RCS_ID], "[$]$1[$]")dnl
+dnl --------------------------------------------------------------------
dnl Restricted form of AC_ARG_ENABLE that limits user options
dnl
dnl $1 = option name
])dnl
dnl
dnl --------------------------------------------------------------------
-AC_DEFUN([OL_PTHREAD_TRY_LINK], [# Pthread try link: $1 ($2)
- if test "$ol_link_threads" = no ; then
- # try $1
- AC_CACHE_CHECK([for pthread link with $1], [$2], [
- # save the flags
- ol_LIBS="$LIBS"
- LIBS="$1 $LIBS"
-
- AC_TRY_LINK([
+AC_DEFUN([OL_PTHREAD_TEST_INCLUDES],
+[/* pthread test headers */
#include <pthread.h>
#ifndef NULL
#define NULL (void*)0
#endif
-],[
+
+static void *task(p)
+ void *p;
+{
+ return (void *) (p == NULL);
+}
+])
+AC_DEFUN([OL_PTHREAD_TEST_FUNCTION],[
+ /* pthread test function */
pthread_t t;
+ int status;
+
+ /* make sure pthread_create() isn't just a stub */
+#if HAVE_PTHREADS_D4
+ status = pthread_create(&t, pthread_attr_default, task, NULL);
+#else
+ status = pthread_create(&t, NULL, task, NULL);
+#endif
+
+ if( status ) exit( status );
+ /* make sure pthread_detach() isn't just a stub */
#if HAVE_PTHREADS_D4
- pthread_create(&t, pthread_attr_default, NULL, NULL);
- pthread_detach( &t );
+ status = pthread_detach( &t );
#else
- pthread_create(&t, NULL, NULL, NULL);
- pthread_detach( t );
+ status = pthread_detach( t );
#endif
+
#ifdef HAVE_LINUX_THREADS
pthread_kill_other_threads_np();
#endif
-], [$2=yes], [$2=no])
+
+ exit( status );
+])
+
+AC_DEFUN([OL_PTHREAD_TEST_PROGRAM],
+[OL_PTHREAD_TEST_INCLUDES
+
+int main(argc, argv)
+ int argc;
+ char **argv;
+{
+OL_PTHREAD_TEST_FUNCTION
+}
+])
+dnl --------------------------------------------------------------------
+AC_DEFUN([OL_PTHREAD_TRY], [# Pthread try link: $1 ($2)
+if test "$ol_link_threads" = no ; then
+ # try $1
+ AC_CACHE_CHECK([for pthread link with $1], [$2], [
+ # save the flags
+ ol_LIBS="$LIBS"
+ LIBS="$1 $LIBS"
+
+ AC_TRY_RUN(OL_PTHREAD_TEST_PROGRAM,
+ [$2=yes], [$2=no],
+ [AC_TRY_LINK(OL_PTHREAD_TEST_INCLUDES,OL_PTHREAD_TEST_FUNCTION,
+ [$2=yes], [$2=no])])
# restore the LIBS
LIBS="$ol_LIBS"
- ])
+ ])
- if test $$2 = yes ; then
- ol_link_pthreads="$1"
- ol_link_threads=posix
- fi
+ if test $$2 = yes ; then
+ ol_link_pthreads="$1"
+ ol_link_threads=posix
fi
+fi
])
dnl
dnl ====================================================================
+dnl Check GNU Pth pthread Header
+dnl
+dnl defines ol_cv_header linux_threads to 'yes' or 'no'
+dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
+dnl doesn't exists. Existance of pthread.h should separately
+dnl checked.
+dnl
+AC_DEFUN([OL_HEADER_GNU_PTH_PTHREAD_H], [
+ AC_CACHE_CHECK([for GNU Pth pthread.h],
+ [ol_cv_header_gnu_pth_pthread_h],
+ [AC_EGREP_CPP(__gnu_pth__,
+ [#include <pthread.h>
+#ifdef _POSIX_THREAD_IS_GNU_PTH
+ __gnu_pth__
+#endif
+],
+ [ol_cv_header_gnu_pth_pthread_h=yes],
+ [ol_cv_header_gnu_pth_pthread_h=no])
+ ])
+])dnl
+dnl ====================================================================
dnl Check LinuxThreads Header
dnl
dnl defines ol_cv_header linux_threads to 'yes' or 'no'
])dnl
dnl
dnl ====================================================================
+dnl Define inet_aton is available
+AC_DEFUN(OL_FUNC_INET_ATON,
+ [AC_CACHE_CHECK([for inet_aton()], ol_cv_func_inet_aton,
+ [AC_TRY_LINK([
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+# ifdef HAVE_SYS_SELECT_H
+# include <sys/select.h>
+# endif
+# include <netinet/in.h>
+# ifdef HAVE_ARPA_INET_H
+# include <arpa/inet.h>
+# endif
+#endif
+], [struct in_addr in;
+int rc = inet_aton( "255.255.255.255", &in );],
+ ol_cv_func_inet_aton=yes, ol_cv_func_inet_aton=no)])
+ if test $ol_cv_func_inet_aton != no; then
+ AC_DEFINE(HAVE_INET_ATON, 1,
+ [define to you inet_aton(3) is available])
+ fi
+ ])dnl
+dnl
+dnl ====================================================================
dnl check no of arguments for ctime_r
AC_DEFUN(OL_FUNC_CTIME_R_NARGS,
[AC_CACHE_CHECK(number of arguments of ctime_r, ol_cv_func_ctime_r_nargs,