PDOS

[uia] / trunk / uia / yam / acinclude.m4  

View of /trunk/uia/yam/acinclude.m4

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3604 - (download) (annotate)
Mon Dec 15 21:27:42 2008 UTC (11 months, 1 week ago) by jastr
File size: 5945 byte(s)
check for either of  -lboost_thread or -lboost_thread-mt, and add
a --with-boostthreadlib to allow for other boost variants

dnl Macro to provide an --enable-debug option to control "debug-mode" compile
dnl
AC_DEFUN([ACX_DEBUG], [
# If --enable-debug is specified, remove -O2 from CFLAGS/CXXFLAGS.
AC_ARG_ENABLE(debug, 
	AC_HELP_STRING([--enable-debug],
		[enable debugging mode (no optimization)]))
# XX for now, just default to debugging mode...
if test "$enable_debug" != "no"; then
	CFLAGS=`echo $CFLAGS | sed -e "s/-O2//"`
	CXXFLAGS=`echo $CXXFLAGS | sed -e "s/-O2//"`
fi
])dnl ACX_DEBUG

dnl Macro to provide an --enable-dmalloc option for debugging
AC_DEFUN([ACX_DMALLOC], [
AC_ARG_ENABLE(dmalloc,
	AC_HELP_STRING([--enable-dmalloc],
		[link against dmalloc]))
CXXLIBS=
echo "enable is $enable_dmalloc"
if test -n "$enable_dmalloc" -a "$enable_dmalloc" != "no" ; then
   	AC_DEFINE(DMALLOC)
	AC_DEFINE(DMALLOC_FUNC_CHECK)
	dnl AC_LANG_PUSH([C])
	dnl AC_CHECK_LIB([dmalloc],[dmalloc_malloc])
	dnl AC_LANG_POP dnl C
	AC_LANG_PUSH([C++])
	old_libs=$LIBS
	AC_SEARCH_LIBS([dmalloc_malloc], [dmallocxx dmalloccxx])
	CXXLIBS=$LIBS
	LIBS=$old_libs
	AC_LANG_POP dnl C++
fi
AC_SUBST(CXXLIBS)
])dnl ACX_DMALLOC

dnl Macro to check for OpenSSL crypto and ssl libraries
dnl
AC_DEFUN([ACX_OPENSSL], [
AC_LANG_PUSH([C])
# OpenSSL libraries
# XXX it would be better just not to build the OpenSSL-dependent stuff
# if the OpenSSL libraries aren't available.
AC_ARG_WITH(openssl, AC_HELP_STRING([--with-openssl=DIR],
		[OpenSSL install location]))
if test -n "$with_openssl"; then
	if test ! -f "$with_openssl/include/openssl/sha.h"; then
		AC_MSG_ERROR([Cannot find OpenSSL headers in '$with_openssl/include/openssl'])
	fi
	CPPFLAGS="-I$with_openssl/include $CPPFLAGS"
	LIBS="-L$with_openssl/lib $LIBS"
fi
AC_CHECK_LIB([crypto], [DSA_sign], ,
	AC_MSG_ERROR([Cannot find the OpenSSL crypto library (libcrypto).
	See http://openssl.org/ to obtain OpenSSL.])
)
AC_CHECK_LIB([ssl], [SSL_version], ,
	AC_MSG_ERROR([Cannot find the OpenSSL library (libssl).
	See http://openssl.org/ to obtain OpenSSL.])
)
AC_LANG_POP		dnl C
])dnl ACX_OPENSSL


dnl Macro to figure out how to get POSIX threads support
dnl
AC_DEFUN([ACX_PTHREADS], [
AC_LANG_PUSH([C])

# Find POSIX threads library (required by Boost's thread library).
# Inspired by and partly based on ACX_PTHREAD macro at
#	http://autoconf-archive.cryp.to/acx_pthread.html
# but simplified and less invasive to compilation environment:
# we don't require the use of a different compiler for pthreads use.
# This apparently eliminates the possibility of AIX support, but oh well.
#
# Libraries/flags to enable pthreads support:
#	none		Works without any flags
#	-pthread	Linux/gcc (kernel threads), BSD/gcc (userland threads)
#	-pthreads	Solaris/gcc
#	-mthreads	Mingw32/gcc, Lynx/gcc
#	pthread		Just add -lpthread to LIBS
pthreads_found=no
for flag in none -pthread -pthreads -mthreads pthread; do
	save_CFLAGS="$CFLAGS"
	save_CXXFLAGS="$CXXFLAGS"
	save_LIBS="$LIBS"
	case $flag in
	    none)
		AC_MSG_CHECKING([whether pthreads works without any flags])
		;;
	    -*)
		AC_MSG_CHECKING([whether pthreads works with $flag])
		CFLAGS="$flag $CFLAGS"
		CXXFLAGS="$flag $CXXFLAGS"
		;;
	    *)
		AC_MSG_CHECKING([for the pthreads library -l$flag])
		LIBS="-l$flag $LIBS"
	esac

	# Check for various functions.  We must include pthread.h,
	# since some functions may be macros.
	AC_TRY_LINK([#include <pthread.h>],
		[pthread_t th; pthread_join(th, 0);
		pthread_attr_init(0); pthread_cleanup_push(0, 0);
		pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
		[pthreads_found=yes])
	AC_MSG_RESULT($pthreads_found)
	if test "$pthreads_found" = "yes"; then
		break;
	else
		LIBS="$save_LIBS"
		CFLAGS="$save_CFLAGS"
		CXXFLAGS="$save_CXXFLAGS"
	fi
done
if test "$pthreads_found" != "yes"; then
	AC_MSG_ERROR([Can't find usable POSIX threads library (pthreads).])
fi

AC_LANG_POP		dnl C
])dnl ACX_PTHREADS


AC_DEFUN([ACX_BOOST], [
AC_LANG_PUSH([C++])
# Check for C++ Boost library required by the async networking code
AC_ARG_WITH(boost,
	AC_HELP_STRING([--with-boost=DIR],
		[Specify location of Boost C++ library]))
if test -n "$with_boost"; then
	INCDIRS="$INCDIRS $with_boost/include"
	CPPFLAGS="$CPPFLAGS -I$with_boost/include"
fi
AC_CHECK_HEADER([boost/bind.hpp], ,
	AC_MSG_ERROR([YAM requires the Boost C++ libraries.
	See http://boost.org/ to obtain them.])
)
AC_LANG_POP		dnl C++
])dnl ACX_BOOST


AC_DEFUN([ACX_BOOST_THREADS], [
AC_LANG_PUSH([C++])
if test -n "$with_boost" ; then
	LIBS="-L$with_boost/lib $LIBS"
fi
# the name of the boost library depends on how it was compiled...
AC_ARG_WITH(boostthreadlib,
	AC_HELP_STRING([--with-boostthreadlib=<name>],
                       [Name of the boost_thread lib to use. Default: libboost_thread or libboost_thread-mt]))
if test -n "$with_boostthreadlib"; then
   LIBS="-l$with_boostthreadlib $LIBS"
   AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <boost/thread.hpp>
                                   ],
			           [boost::thread::yield();])], ,
				   AC_MSG_ERROR([Cannot find the Boost thread library (-l$with_boostthreadlib).
				                 See http://boost.org/ to obtain the Boost C++ libraries.])
   )
else
   savelibs=$LIBS
   testlib="boost_thread-mt"
   LIBS="-l$testlib $LIBS"
   found=""
   AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <boost/thread.hpp>
                                    ],
			           [boost::thread::yield();])], 
				   found=yes, 
				   found=no)
   if test "$found" != "yes" ; then
      LIBS=$savelibs
      testlib="boost_thread"
      LIBS="-l$testlib $LIBS"
      found=""
      AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <boost/thread.hpp>
                                      ],
			              [boost::thread::yield();])], 
	             found=yes, 
		     found=no)
      if test "$found" != "yes" ; then
         AC_MSG_ERROR([Cannot find the Boost thread library in -lboost_thread or -lboost_thread-mt.
				   See http://boost.org/ to obtain the Boost C++ libraries.])
      fi
   fi
fi
AC_LANG_POP		dnl C++
])dnl ACX_BOOST



Maintained by PDOS
ViewVC Help
Powered by ViewVC 1.0.3