The examples/client_test program depends on Boost::Regex and

Boost::ProgramOptions. The configure script detects these and builds the
client_test if the necessary libs are found.
This commit is contained in:
peerkoel 2005-10-16 19:13:54 +00:00
parent f63702c964
commit d27ace98ba
4 changed files with 105 additions and 3 deletions

View File

@ -37,6 +37,25 @@ if test -z "$BOOST_THREAD_LIB"; then
AC_MSG_ERROR([unable to find Boost.Thread library, currently this is required.])
fi
AX_BOOST_REGEX
dnl check that Boost.Regex was found:
if test -z "$BOOST_REGEX_LIB"; then
AC_MSG_RESULT([unable to find Boost.Regex library, example test_client will not be build.])
BUILD_TESTCLIENT=no;
fi
AX_BOOST_PROGRAM_OPTIONS
dnl check that Boost.Program_options was found:
if test -z "$BOOST_PROGRAM_OPTIONS_LIB"; then
AC_MSG_RESULT([unable to find Boost.Program_options library, example test_client will not be build.])
BUILD_TESTCLIENT=no;
fi
if [[ "x$BUILD_TESTCLIENT" != "xno" ]]; then
CLIENT_TEST_BIN=client_test;
AC_SUBST(CLIENT_TEST_BIN)
fi
dnl try different ways of resolving gethostbyname
AC_CHECK_FUNC(gethostbyname, ,
AC_CHECK_LIB(resolv, gethostbyname, ,

View File

@ -1,8 +1,9 @@
bin_PROGRAMS = client_test dump_torrent make_torrent simple_client
bin_PROGRAMS = @CLIENT_TEST_BIN@ dump_torrent make_torrent simple_client
EXTRA_PROGRAMS = client_test
EXTRA_DIST = Jamfile
client_test_SOURCES = client_test.cpp
client_test_LDADD = $(top_builddir)/src/libtorrent.la
client_test_LDADD = $(top_builddir)/src/libtorrent.la -l@BOOST_REGEX_LIB@ -l@BOOST_PROGRAM_OPTIONS_LIB@
dump_torrent_SOURCES = dump_torrent.cpp
dump_torrent_LDADD = $(top_builddir)/src/libtorrent.la
@ -14,4 +15,4 @@ simple_client_SOURCES = simple_client.cpp
simple_client_LDADD = $(top_builddir)/src/libtorrent.la
AM_CXXFLAGS=-ftemplate-depth-50 -I$(top_srcdir)/include @DEBUGFLAGS@ @PTHREAD_CFLAGS@
AM_LDFLAGS= ${LDLAGS} -L./ -l@BOOST_DATE_TIME_LIB@ -l@BOOST_FILESYSTEM_LIB@ -l@BOOST_THREAD_LIB@ @PTHREAD_LIBS@
AM_LDFLAGS= ${LDLAGS} -L./ -l@BOOST_DATE_TIME_LIB@ -l@BOOST_FILESYSTEM_LIB@ -l@BOOST_THREAD_LIB@ @PTHREAD_LIBS@

View File

@ -0,0 +1,41 @@
dnl @synopsis AX_BOOST_PROGRAM_OPTIONS
dnl
dnl This macro checks to see if the Boost.ProgramOptions library is installed.
dnl It also attempts to guess the currect library name using several
dnl attempts. It tries to build the library name using a user supplied
dnl name or suffix and then just the raw library.
dnl
dnl If the library is found, HAVE_BOOST_PROGRAM_OPTIONS is defined and
dnl BOOST_THREAD_LIB is set to the name of the library.
dnl
dnl This macro calls AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB).
dnl
AC_DEFUN([AX_BOOST_PROGRAM_OPTIONS],
[AC_REQUIRE([AC_CXX_NAMESPACES])dnl
AC_CACHE_CHECK(whether the Boost::ProgramOptions library is available,
ax_cv_boost_program_options,
[AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[#include <boost/program_options.hpp>]],
[[boost::program_options::options_description desc("test"); return 0;]]),
ax_cv_boost_program_options=yes, ax_cv_boost_program_options=no)
AC_LANG_RESTORE
])
if test "$ax_cv_boost_program_options" = yes; then
AC_DEFINE(HAVE_BOOST_PROGRAM_OPTIONS,,[define if the Boost::ProgramOptions library is available])
dnl Now determine the appropriate file names
AC_ARG_WITH([boost-program_options],AS_HELP_STRING([--with-boost-program_options],
[specify the boost program_options library or suffix to use]),
[if test "x$with_boost_thread" != "xno"; then
ax_program_options_lib=$with_boost_program_options
ax_boost_program_options_lib=boost_program_options-$with_boost_program_options
fi])
for ax_lib in $ax_program_options_lib $ax_boost_program_options_lib boost_program_options; do
AC_CHECK_LIB($ax_lib, main, [BOOST_PROGRAM_OPTIONS_LIB=$ax_lib break])
done
AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB)
fi
])dnl

41
m4/ax_boost_regex.m4 Normal file
View File

@ -0,0 +1,41 @@
dnl @synopsis AX_BOOST_REGEX
dnl
dnl This macro checks to see if the Boost.Regex library is installed.
dnl It also attempts to guess the currect library name using several
dnl attempts. It tries to build the library name using a user supplied
dnl name or suffix and then just the raw library.
dnl
dnl If the library is found, HAVE_BOOST_REGEX is defined and
dnl BOOST_REGEX_LIB is set to the name of the library.
dnl
dnl This macro calls AC_SUBST(BOOST_REGEX_LIB).
dnl
dnl @version $Id$
dnl @author Michael Tindal <mtindal@paradoxpoint.com>
dnl
AC_DEFUN([AX_BOOST_REGEX],
[AC_REQUIRE([AC_CXX_NAMESPACES])dnl
AC_CACHE_CHECK(whether the Boost::Regex library is available,
ax_cv_boost_regex,
[AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[#include <boost/regex.hpp>]],
[[boost::regex r(); return 0;]]),
ax_cv_boost_regex=yes, ax_cv_boost_regex=no)
AC_LANG_RESTORE
])
if test "$ax_cv_boost_regex" = yes; then
AC_DEFINE(HAVE_BOOST_REGEX,,[define if the Boost::Regex library is available])
dnl Now determine the appropriate file names
AC_ARG_WITH([boost-regex],AS_HELP_STRING([--with-boost-regex],
[specify the boost regex library or suffix to use]),
[if test "x$with_boost_regex" != "xno"; then
ax_regex_lib=$with_boost_regex
ax_boost_regex_lib=boost_regex-$with_boost_regex
fi])
for ax_lib in $ax_regex_lib $ax_boost_regex_lib boost_regex; do
AC_CHECK_LIB($ax_lib, main, [BOOST_REGEX_LIB=$ax_lib break])
done
AC_SUBST(BOOST_REGEX_LIB)
fi
])dnl