3 AC_INIT(src/torrent.cpp)
4 AM_INIT_AUTOMAKE(libtorrent-rasterbar, 0.14)
6 dnl interface version info
8 VERSION_INFO_REVISION=0
11 INTERFACE_VERSION_INFO=$VERSION_INFO_CURRENT:$VERSION_INFO_REVISION:$VERSION_INFO_AGE
13 AC_SUBST(INTERFACE_VERSION_INFO)
15 # Nowhere in the source is config.h included, so make defines command line arguments
16 # AM_CONFIG_HEADER(config.h)
20 if test -z "$(which $CC)"; then
21 AC_MSG_ERROR([Unable to find a working C compiler, giving up.])
27 if test -z "$(which $CXX)"; then
28 AC_MSG_ERROR([Unable to find a working C++ compiler, giving up.])
35 # AC_PROG_RANLIB is obsolete by AC_PROC_LIBTOOL
39 dnl Check for pthreads.
41 dnl Apply pthread config.
43 CPPFLAGS="$CPPFLAGS $PTHREAD_CFLAGS"
44 LIBS="$LIBS $PTHREAD_LIBS"
46 AM_CONDITIONAL([ENABLE_SHIPPED_ASIO], false)
48 dnl Check for boost libraries.
49 AX_BOOST_BASE([1.35],[
51 dnl check that Boost.System was found:
52 if test -z "$BOOST_SYSTEM_LIB"; then
53 AC_MSG_ERROR([unable to find Boost.System library, currently this is required.])
57 dnl check that Boost.Asio was found:
58 if test -z "$BOOST_ASIO_LIB"; then
59 AC_MSG_ERROR([Unable to find Boost.Asio library, currently this is required.])
62 AX_BOOST_BASE([1.34],[
64 dnl the user can choose which Asio library to use
66 AS_HELP_STRING([--with-asio=shipped|system|your_path],
67 [Specify the Asio library to use, shipped or system. Default is to use shipped library. You can also specify a path for your system.]),
72 dnl Check the value for the --with-asio switch
73 AC_MSG_CHECKING([which Asio implementation to use])
76 AC_MSG_RESULT(shipped)
77 ASIO_HPP=include/libtorrent/asio.hpp
78 ASIO_DIR=include/libtorrent/asio
79 AC_CHECK_FILES($ASIO_HPP $ASIO_DIR/ssl/stream.hpp $ASIO_DIR/ip/tcp.hpp,
80 enable_shipped_asio=yes,
81 AC_MSG_ERROR([libtorrent-rasterbar depends on Asio library but it was not found.])
86 ASIO_HPP=/usr/include/asio.hpp
87 ASIO_DIR=/usr/include/asio
88 AC_CHECK_FILES($ASIO_HPP $ASIO_DIR/ssl/stream.hpp $ASIO_DIR/ip/tcp.hpp,
89 enable_shipped_asio=no,
90 AC_MSG_ERROR([libtorrent-rasterbar depends on Asio library but it was not found on your system.])
95 ASIO_HPP=$asio/../asio.hpp
97 AC_CHECK_FILES($ASIO_HPP $ASIO_DIR/ssl/stream.hpp $ASIO_DIR/ip/tcp.hpp,
98 enable_shipped_asio=no,
99 AC_MSG_ERROR([libtorrent-rasterbar depends on Asio library but it was not found in the path you specified.])
103 AM_CONDITIONAL([ENABLE_SHIPPED_ASIO], [test x$enable_shipped_asio = "xyes"])
107 AC_MSG_NOTICE([BOOST_CPPFLAGS=$BOOST_CPPFLAGS])
108 AC_MSG_NOTICE([BOOST_LDFLAGS=$BOOST_LDFLAGS])
111 dnl check that Boost.IOStreams was found:
112 if test -z "$BOOST_IOSTREAMS_LIB"; then
113 AC_MSG_ERROR([unable to find Boost.IOStreams library, currently this is required.])
117 dnl check that Boost.DateTime was found:
118 if test -z "$BOOST_DATE_TIME_LIB"; then
119 AC_MSG_ERROR([Unable to find Boost.DateTime library, currently this is required.])
123 dnl check that Boost.Filesystem was found:
124 if test -z "$BOOST_FILESYSTEM_LIB"; then
125 AC_MSG_ERROR([Unable to find Boost.Filesystem library, currently this is required.])
129 dnl check that Boost.Thread was found:
130 if test -z "$BOOST_THREAD_LIB"; then
131 AC_MSG_ERROR([Unable to find Boost.Thread library, currently this is required.])
135 dnl check that Boost.Regex was found:
136 if test -z "$BOOST_REGEX_LIB"; then
137 AC_MSG_RESULT([Unable to find Boost.Regex library, example test_client will not be build.])
141 AX_BOOST_PROGRAM_OPTIONS
142 dnl check that Boost.Program_options was found:
143 if test -z "$BOOST_PROGRAM_OPTIONS_LIB"; then
144 AC_MSG_RESULT([Unable to find Boost.Program_options library, example test_client will not be build.])
148 dnl Apply boost config.
149 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
150 LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
152 if [[ "x$BUILD_TESTCLIENT" != "xno" ]]; then
153 CLIENT_TEST_BIN=client_test;
154 AC_SUBST(CLIENT_TEST_BIN)
157 dnl try different ways of resolving gethostbyname
158 AC_CHECK_FUNC(gethostbyname, ,
159 AC_CHECK_LIB(resolv, gethostbyname, ,
160 AC_CHECK_LIB(nsl, gethostbyname, ,
161 AC_CHECK_LIB(ws2_32, main,
162 AC_CHECK_LIB(wsock32, main, [LIBS="$LIBS -lws2_32 -lwsock32";] ,
163 AC_MSG_ERROR([wsock32 not found. Stopped.])) ,
164 AC_MSG_ERROR([gethostbyname not found. Stopped.]))))
167 dnl find out what kind of logging to use
170 AS_HELP_STRING([--with-logging=none|default|verbose],[Specify how much logging to use. Default is none.]),
171 [[logging=$withval]],
175 COMPILETIME_OPTIONS=""
176 dnl Check the value for the --with-logging switch
177 AC_MSG_CHECKING([what form of logging to use])
183 AC_MSG_RESULT(default)
184 AC_DEFINE(TORRENT_LOGGING,,[define to use some logging])
185 COMPILETIME_OPTIONS+="-DTORRENT_LOGGING "
188 AC_MSG_RESULT(verbose)
189 AC_DEFINE(TORRENT_VERBOSE_LOGGING,,[define to use verbose logging])
190 COMPILETIME_OPTIONS+="-DTORRENT_VERBOSE_LOGGING "
194 AC_MSG_ERROR([Unknown logging option "$logging". Use either "none", "default" or "verbose".])
198 dnl find out what kind of dht-support to use
201 AS_HELP_STRING([--with-dht=on|off|logging],[Specify how to use DHT support. Option logging will add extra logging. Default is on.]),
205 dnl Check the value for the --with-dht switch
206 AC_MSG_CHECKING([how to use DHT])
213 AC_DEFINE(TORRENT_DISABLE_DHT,,[define not to use DHT support])
214 COMPILETIME_OPTIONS+="-DTORRENT_DISABLE_DHT "
217 AC_MSG_RESULT(logging)
218 AC_DEFINE(TORRENT_DHT_VERBOSE_LOGGING,,[define to use DHT support with extra logging])
219 COMPILETIME_OPTIONS+="-DTORRENT_DHT_VERBOSE_LOGGING "
223 AC_MSG_ERROR([Unknown dht option "$dht". Use either "on", "off" or "logging".])
226 AM_CONDITIONAL(USE_DHT, test "x$dht" != "xoff")
228 dnl encryption support.
231 AS_HELP_STRING([--with-encryption=on|off],[Specify how to use encryption support. Default is on.]),
232 [[encryption=$withval]],
236 dnl Check the value for the --with-encryption switch
237 AC_MSG_CHECKING([how to use encryption])
238 case "$encryption" in
242 AC_DEFINE(TORRENT_USE_OPENSSL,,[define to use openssl with libtorrent-rasterbar])
243 COMPILETIME_OPTIONS+="-DTORRENT_USE_OPENSSL "
248 AC_DEFINE(TORRENT_DISABLE_ENCRYPTION,,[define not to use encryption support])
249 COMPILETIME_OPTIONS+="-DTORRENT_DISABLE_ENCRYPTION "
253 AC_MSG_ERROR([Unknown encryption option "$encryption". Use either "on" or "off".])
256 AM_CONDITIONAL(USE_ENCRYPTION, test "x$encryption" != "xoff")
258 dnl the user can choose which zlib to use
261 AS_HELP_STRING([--with-zlib=shipped|system],[Specify the zlib to use, shipped or system. Default is to autodetect system and fallback to shipped.]),
265 dnl Check the value for the --with-zlib switch
266 AC_MSG_CHECKING([which zlib implementation to use])
269 AC_MSG_RESULT([autodetect])
270 AC_CHECK_LIB(z, main,
276 AC_MSG_RESULT(shipped)
279 AC_MSG_RESULT(system)
280 AC_CHECK_LIB(z, main, ,
281 AC_MSG_ERROR([libtorrent-rasterbar depends on zlib but zlib was not found on your system.])
286 AC_MSG_ERROR([libtorrent-rasterbar depends on zlib, you must specify either "system" or "shipped".])
290 AC_MSG_ERROR([Unknown zlib option "$zlib". Use either "system" or "shipped".])
293 if [[ "$zlib" = "shipped" ]]; then
294 ZLIB="\$(top_builddir)/zlib/libzlib.la"
296 ZLIBINCL="-I\$(top_srcdir)/zlib"
297 AC_CONFIG_FILES(zlib/Makefile)
298 elif [[ "$zlib" = "system" ]]; then
304 dnl make ZLIB and ZLIBDIR visible to Makefiles
309 dnl Check whether the examples should be build
312 AS_HELP_STRING([--enable-examples],[Build the examples. Default is not to build them.]),
313 [[examples=$enableval]],
316 dnl Check the value of the --with-examples switch
317 AC_MSG_CHECKING([if the examples should be build])
321 EXAMPLESDIR="examples"
328 AC_MSG_RESULT(yes (default))
329 EXAMPLESDIR="examples"
333 AC_MSG_ERROR([Unknown --enable-examples option "$examples". Use either "yes" or "no".])
336 dnl make $examples visible to Makefiles
337 AC_SUBST([EXAMPLESDIR])
339 dnl Check whether the tests should be build
342 AS_HELP_STRING([--enable-tests],[Build test files. Default is not to build them.]),
343 [[tests=$enableval]],
346 dnl Check the value of the --with-tests switch
347 AC_MSG_CHECKING([if test files should be build])
358 AC_MSG_RESULT(yes (default))
363 AC_MSG_ERROR([Unknown --enable-tests option "$examples". Use either "yes" or "no".])
366 dnl make $examples visible to Makefiles
369 dnl Set some defines if we are building a shared library
370 if [[ "x$enable_shared" == "xyes" ]]; then
371 AC_DEFINE(TORRENT_BUILDING_SHARED,,[Make sure the functions and classes are exported.])
372 AC_DEFINE(TORRENT_LINKING_SHARED,,[Make sure the functions and classes are exported.])
375 dnl want some debugging symbols with that?
378 AS_HELP_STRING([--enable-debug],[Set compiler flags for debug symbols, default is no debugging.]),
379 [case "$enableval" in
381 AC_DEFINE(NDEBUG,,[Define to disable debugging])
383 COMPILETIME_OPTIONS+="-DNDEBUG "
387 COMPILETIME_OPTIONS+="-DLT_DEBUG "
390 DEBUGFLAGS="$enableval"
394 AC_DEFINE(NDEBUG,,[Define to disable debugging])]
398 dnl Compile time options.
399 AC_SUBST(COMPILETIME_OPTIONS)
401 AC_CONFIG_FILES(Makefile src/Makefile include/Makefile libtorrent-rasterbar.pc)
402 if [[ "x$examples" == "xyes" ]]; then
403 AC_CONFIG_FILES(examples/Makefile)
405 if [[ "x$tests" == "xyes" ]]; then
406 AC_CONFIG_FILES(test/Makefile)