removed connecting_to_tracker state
[libtorrent.git] / configure.in
blob3cde7df3f49e30eff943317089b4f3e1adbfecfb
1 AC_PREREQ(2.59)
3 AC_INIT(src/torrent.cpp)
4 AM_INIT_AUTOMAKE(libtorrent-rasterbar, 0.14)
6 dnl interface version info
7 VERSION_INFO_CURRENT=0
8 VERSION_INFO_REVISION=0
9 VERSION_INFO_AGE=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)
18 AC_PROG_CC
20 if test -z "$(which $CC)"; then
21     AC_MSG_ERROR([Unable to find a working C compiler, giving up.])
24 AC_PROG_CPP
25 AC_PROG_CXX
27 if test -z "$(which $CXX)"; then
28     AC_MSG_ERROR([Unable to find a working C++ compiler, giving up.])
31 AC_CACHE_SAVE
32 AC_PROG_INSTALL
33 AC_PROG_MAKE_SET
34 AC_PROG_LIBTOOL
35 # AC_PROG_RANLIB is obsolete by AC_PROC_LIBTOOL
37 AC_SYS_LARGEFILE
39 dnl Check for pthreads.
40 ACX_PTHREAD
41 dnl Apply pthread config.
42 CC=$PTHREAD_CC
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],[
50    AX_BOOST_SYSTEM
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.])
54    fi
56    AX_BOOST_ASIO
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.])
60    fi
61 ],[
62    AX_BOOST_BASE([1.34],[
64    dnl the user can choose which Asio library to use
65    AC_ARG_WITH([asio],
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.]),
68         [[asio=$withval]],
69         [[asio=shipped]]
70    )
72    dnl Check the value for the --with-asio switch
73    AC_MSG_CHECKING([which Asio implementation to use])
74    case "$asio" in
75         "shipped")
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.])
82                 )
83                 ;;
84         "system")
85                 AC_MSG_RESULT(system)
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.])
91                 )
92                 ;;
93         *)
94                 AC_MSG_RESULT(detect)
95                 ASIO_HPP=$asio/../asio.hpp
96                 ASIO_DIR=$asio
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.])
100                 )
101                 ;;
102     esac
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])
110 AX_BOOST_IOSTREAMS
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.])
116 AX_BOOST_DATE_TIME
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.])
122 AX_BOOST_FILESYSTEM
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.])
128 AX_BOOST_THREAD
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.])
134 AX_BOOST_REGEX
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.])
138    BUILD_TESTCLIENT=no;
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.])
145    BUILD_TESTCLIENT=no;
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
168 AC_ARG_WITH(
169         [logging],
170         AS_HELP_STRING([--with-logging=none|default|verbose],[Specify how much logging to use. Default is none.]),
171         [[logging=$withval]],
172         [[logging=none]]
175 COMPILETIME_OPTIONS=""
176 dnl Check the value for the --with-logging switch
177 AC_MSG_CHECKING([what form of logging to use])
178 case "$logging" in
179         "none")
180                 AC_MSG_RESULT(none)
181                 ;;
182         "default")
183                 AC_MSG_RESULT(default)
184                 AC_DEFINE(TORRENT_LOGGING,,[define to use some logging])
185                 COMPILETIME_OPTIONS+="-DTORRENT_LOGGING "
186                 ;;
187         "verbose")
188                 AC_MSG_RESULT(verbose)
189                 AC_DEFINE(TORRENT_VERBOSE_LOGGING,,[define to use verbose logging])
190                 COMPILETIME_OPTIONS+="-DTORRENT_VERBOSE_LOGGING "
191                 ;;
192         *)
193                 AC_MSG_RESULT()
194                 AC_MSG_ERROR([Unknown logging option "$logging". Use either "none", "default" or "verbose".])
195                 ;;
196 esac
198 dnl find out what kind of dht-support to use
199 AC_ARG_WITH(
200         [dht],
201         AS_HELP_STRING([--with-dht=on|off|logging],[Specify how to use DHT support. Option logging will add extra logging. Default is on.]),
202         [[dht=$withval]],
203         [[dht=on]]
205 dnl Check the value for the --with-dht switch
206 AC_MSG_CHECKING([how to use DHT])
207 case "$dht" in
208         "on")
209                 AC_MSG_RESULT(on)
210                 ;;
211         "off")
212                 AC_MSG_RESULT(off)
213                 AC_DEFINE(TORRENT_DISABLE_DHT,,[define not to use DHT support])
214                 COMPILETIME_OPTIONS+="-DTORRENT_DISABLE_DHT "
215                 ;;
216         "logging")
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 "
220                 ;;
221         *)
222                 AC_MSG_RESULT()
223                 AC_MSG_ERROR([Unknown dht option "$dht". Use either "on", "off" or "logging".])
224                 ;;
225 esac
226 AM_CONDITIONAL(USE_DHT, test "x$dht" != "xoff")
228 dnl encryption support.
229 AC_ARG_WITH(
230        [encryption],
231        AS_HELP_STRING([--with-encryption=on|off],[Specify how to use encryption support. Default is on.]),
232        [[encryption=$withval]],
233        [[encryption=on]]
236 dnl Check the value for the --with-encryption switch
237 AC_MSG_CHECKING([how to use encryption])
238 case "$encryption" in
239        "on")
240                AC_MSG_RESULT(on)
241                CHECK_SSL()
242                AC_DEFINE(TORRENT_USE_OPENSSL,,[define to use openssl with libtorrent-rasterbar])
243                COMPILETIME_OPTIONS+="-DTORRENT_USE_OPENSSL "
245                ;;
246        "off")
247                AC_MSG_RESULT(off)
248                AC_DEFINE(TORRENT_DISABLE_ENCRYPTION,,[define not to use encryption support])
249                COMPILETIME_OPTIONS+="-DTORRENT_DISABLE_ENCRYPTION "
250                ;;
251        *)
252                AC_MSG_RESULT()
253                AC_MSG_ERROR([Unknown encryption option "$encryption". Use either "on" or "off".])
254                ;;
255 esac
256 AM_CONDITIONAL(USE_ENCRYPTION, test "x$encryption" != "xoff")
258 dnl the user can choose which zlib to use
259 AC_ARG_WITH(
260         [zlib],
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.]),
262         [[zlib=$withval]],
263         [[zlib=detect]]
265 dnl Check the value for the --with-zlib switch
266 AC_MSG_CHECKING([which zlib implementation to use])
267 case "$zlib" in
268         "detect")
269                 AC_MSG_RESULT([autodetect])
270                 AC_CHECK_LIB(z, main,
271                         [zlib="system"],
272                         [zlib="shipped"]
273                 )
274                 ;;
275         "shipped")
276                 AC_MSG_RESULT(shipped)
277                 ;;
278         "system")
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.])
282                 )
283                 ;;
284         "no")
285                 AC_MSG_RESULT()
286                 AC_MSG_ERROR([libtorrent-rasterbar depends on zlib, you must specify either "system" or "shipped".])
287                 ;;
288         *)
289                 AC_MSG_RESULT()
290                 AC_MSG_ERROR([Unknown zlib option "$zlib". Use either "system" or "shipped".])
291                 ;;
292 esac
293 if [[ "$zlib" = "shipped" ]]; then
294         ZLIB="\$(top_builddir)/zlib/libzlib.la"
295         ZLIBDIR="zlib"
296         ZLIBINCL="-I\$(top_srcdir)/zlib"
297         AC_CONFIG_FILES(zlib/Makefile)
298 elif [[ "$zlib" = "system" ]]; then
299         ZLIB="-lz"
300         ZLIBDIR=""
301         ZLIBINCL=""
304 dnl make ZLIB and ZLIBDIR visible to Makefiles
305 AC_SUBST([ZLIB])
306 AC_SUBST([ZLIBDIR])
307 AC_SUBST([ZLIBINCL])
309 dnl Check whether the examples should be build
310 AC_ARG_ENABLE(
311         [examples],
312         AS_HELP_STRING([--enable-examples],[Build the examples. Default is not to build them.]),
313         [[examples=$enableval]],
314         [[examples=no]]
316 dnl Check the value of the --with-examples switch
317 AC_MSG_CHECKING([if the examples should be build])
318 case "$examples" in
319         "yes")
320                 AC_MSG_RESULT(yes)
321                 EXAMPLESDIR="examples"
322                 ;;
323         "no")
324                 AC_MSG_RESULT(no)
325                 EXAMPLESDIR=""
326                 ;;
327         "")
328                 AC_MSG_RESULT(yes (default))
329                 EXAMPLESDIR="examples"
330                 ;;
331         *)
332                 AC_MSG_RESULT()
333                 AC_MSG_ERROR([Unknown --enable-examples option "$examples". Use either "yes" or "no".])
334                 ;;
335 esac
336 dnl make $examples visible to Makefiles
337 AC_SUBST([EXAMPLESDIR])
339 dnl Check whether the tests should be build
340 AC_ARG_ENABLE(
341         [tests],
342         AS_HELP_STRING([--enable-tests],[Build test files. Default is not to build them.]),
343         [[tests=$enableval]],
344         [[tests=no]]
346 dnl Check the value of the --with-tests switch
347 AC_MSG_CHECKING([if test files should be build])
348 case "$tests" in
349         "yes")
350                 AC_MSG_RESULT(yes)
351                 TESTSDIR="test"
352                 ;;
353         "no")
354                 AC_MSG_RESULT(no)
355                 TESTSDIR=""
356                 ;;
357         "")
358                 AC_MSG_RESULT(yes (default))
359                 TESTSDIR="test"
360                 ;;
361         *)
362                 AC_MSG_RESULT()
363                 AC_MSG_ERROR([Unknown --enable-tests option "$examples". Use either "yes" or "no".])
364                 ;;
365 esac
366 dnl make $examples visible to Makefiles
367 AC_SUBST([TESTSDIR])
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?
376 AC_ARG_ENABLE(
377         [debug],
378         AS_HELP_STRING([--enable-debug],[Set compiler flags for debug symbols, default is no debugging.]),
379         [case "$enableval" in
380                 no)
381                         AC_DEFINE(NDEBUG,,[Define to disable debugging])
382                         DEBUGFLAGS=""
383                         COMPILETIME_OPTIONS+="-DNDEBUG "
384                         ;;
385                 yes)
386                         DEBUGFLAGS="-g"
387                         COMPILETIME_OPTIONS+="-DLT_DEBUG "
388                         ;;
389                 *)
390                         DEBUGFLAGS="$enableval"
391                         ;;
392         esac],
393         [DEBUGFLAGS=""
394         AC_DEFINE(NDEBUG,,[Define to disable debugging])]
396 AC_SUBST(DEBUGFLAGS)
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)
408 AC_OUTPUT