PDOS

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

View of /trunk/uia/uianet/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: 10457 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=
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
AC_ARG_WITH(opensslengine, AC_HELP_STRING([--with-opensslengine=<name>],
                                          [OpenSSL Engine to enable]))
if test -n "$with_opensslengine" ; then
   OPENSSL_ENGINE_ENABLE="1"
   OPENSSL_ENGINE_NAME=$with_opensslengine
else
   OPENSSL_ENGINE_ENABLE=0
   OPENSSL_ENGINE_NAME="none"
fi
AC_SUBST(OPENSSL_ENGINE_ENABLE)
AC_SUBST(OPENSSL_ENGINE_NAME)
])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

AC_DEFUN([ACX_YAM], [
AC_LANG_PUSH([C++])
# Check for C++ Yam library required by the async networking code
AC_ARG_WITH(yam,
	AC_HELP_STRING([--with-yam=DIR],
		[Specify location of Yam C++ library]))
if test -n "$with_yam"; then
	INCDIRS="$INCDIRS $with_yam/include"
	CPPFLAGS="$CPPFLAGS -I$with_yam/include"
fi
dnl AC_CHECK_HEADER([yam/mainloop.hpp], ,
dnl 	AC_MSG_ERROR([UIA requires the Yam C++ libraries])
dnl )
AC_LANG_POP		dnl C++
])dnl ACX_BOOST



AC_DEFUN([ACX_LIBYAM], [
AC_LANG_PUSH([C++])
if test -n "$with_yam" ; then
	LIBS="-L$with_yam/lib -lyam_sunrpc -lyam $LIBS"
	YAM="$with_yam"
	AC_SUBST(YAM)
fi
LIBS="$LIBS"
dnl AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <yam/mainloop_impl.hpp>
dnl 		 		 #include <yam/sunrpc_channel_tcp.hpp>],
dnl 				[yam::mainloop *a = new yam::mainloop_impl();])], ,
dnl 	AC_MSG_ERROR([Cannot find the yam library (-lyam)])
dnl )
AC_LANG_POP		dnl C++
])dnl ACX_LIBYAM

AC_DEFUN([ACX_BONJOUR], [
AC_ARG_WITH(avahi,
	AC_HELP_STRING([--with-avahi],
		       [use avahi to publish and subscribe to broadcasts]), , with_avahi=no)
AC_ARG_WITH(bonjour,
	AC_HELP_STRING([--with-bonjour],
		       [use the bonjour API for broadcasts]), , with_bonjour=no)
if test "$with_avahi" != "no" ; then
   if test "$with_bonjour" != "no" ; then
      AC_MSG_ERROR([Specify at most one of avahi and bonjour])
   fi
fi

BONJOUR_FLAVOR=""

if test "$with_bonjour" = "no" ; then
   AC_PATH_PROGS([AVAHI_PUBLISH], [avahi-publish], [])
   if test -n "$AVAHI_PUBLISH" ; then
     BONJOUR_FLAVOR="avahi"
   else
     if test "$with_avahi" != "no" ; then
       AC_MSG_ERROR([cannot find avahi-publish, which is required for
                     device introductions])
     fi
   fi
fi

if test -z "$BONJOUR_FLAVOR" ; then
   AC_MSG_CHECKING([for DNSServiceRegister])
   AC_LANG_PUSH([C])
   # Apple Bonjour API, using Apple's code.
   AC_SEARCH_LIBS([DNSServiceRegister], [dns_sd], ,
      AC_MSG_ERROR([UIA requires the Bonjour API for device introduction.
   		    See http://developer.apple.com/networking/bonjour/ to obtain it]))
   AC_LANG_POP dnl C
   BONJOUR_FLAVOR="bonjour"
fi
#if using bonjour, check for bonjour.h
if test $BONJOUR_FLAVOR = "bonjour" ; then
   AC_CHECK_HEADER([dns_sd.h],
                   [AC_DEFINE([HAVE_DNS_SD_H], [1],)],
                   [AC_MSG_ERROR([cannot find dns_sd.h])])
fi
AC_SUBST(BONJOUR_FLAVOR)
])dnl ACX_BONJOUR


AC_DEFUN([ACX_QT4], [
AC_LANG_PUSH([C++])
# Qt 4 toolkit, for the UIA control GUI
AC_ARG_WITH(qt, AC_HELP_STRING([--with-qt=DIR],
		[Qt toolkit version 4 for UIA control GUI]))
if test "$with_qt" = "no"; then
	QMAKE=""
elif test -n "$with_qt"; then
	QMAKE="$with_qt/bin/qmake"
	if ! test -x $QMAKE; then
		AC_MSG_WARN([$QMAKE not found.])
		QMAKE=""
	fi
else
	AC_CHECK_PROGS(QMAKE,[qmake-qt4 qmake4 qmake])
fi
if test -n "$QMAKE"; then
	AC_MSG_CHECKING([Qt toolkit version])
	if test -n "$QMAKE" && ! ($QMAKE -v | grep -q "Qt version 4"); then
		AC_MSG_RESULT([wrong version.])
		QMAKE=""
	else
		AC_MSG_RESULT([correct (version 4).])
	fi
fi
if test "$with_qt" != "no"; then
	if test -n "$QMAKE"; then
		AC_CONFIG_FILES([ctl/ctl.pri])
	else
		AC_MSG_WARN([Qt 4 not found; control GUI will not be built.])
		AC_MSG_WARN([See http://www.trolltech.com/ to obtain Qt 4.])
	fi
fi
AC_LANG_POP		dnl C++
])dnl ACX_QT4


AC_DEFUN([ACX_PYTHON], [
AC_ARG_WITH(python,
	AC_HELP_STRING([--with-python=PROG],
		[Specify the python binary to use]), [],
	[with_python=""])
if test "$with_python" = "yes" ; then
   AC_MSG_ERROR([You need to specify a program for --with-python.])
elif test "$with_python" = "no" ; then
     with_python=""
fi
if test "x$with_python" = x ; then
  with_python="python2.5 python2.4 python"
fi 
AC_PATH_PROGS([PYTHON], [$with_python],
  [AC_MSG_ERROR([UIA requires Python, ideally version 2.4. or newer])])
])dnl ACX_PYTHON


AC_DEFUN([ACX_TWISTED], [
AC_MSG_CHECKING([for Twisted framework for Python])
if ! ($PYTHON -c "from twisted.internet import reactor" 2>/dev/null); then
	AC_MSG_RESULT([no])
	AC_MSG_ERROR([UIA requires the Twisted networking framework for Python.
		See http://twistedmatrix.com/trac/ to obtain Twisted.])
fi
AC_MSG_RESULT([yes])
])dnl ACX_TWISTED




Maintained by PDOS
ViewVC Help
Powered by ViewVC 1.0.3