Transmission 2.33
[tomato.git] / release / src / router / transmission / configure.ac
blob7dcbcf00006c531e0bfeb2d0b3fd69bbc3aa2716
1 dnl convention: -TR MAJOR MINOR MAINT STATUS - (each a single char)
2 dnl STATUS: "X" for prerelease beta builds,
3 dnl         "Z" for unsupported trunk builds,
4 dnl         "0" for stable, supported releases
5 dnl these should be the only two lines you need to change
6 m4_define([user_agent_prefix],[2.33])
7 m4_define([peer_id_prefix],[-TR2330-])
9 AC_INIT([transmission],
10         [user_agent_prefix],
11         [http://trac.transmissionbt.com/newticket])
12 AC_SUBST(USERAGENT_PREFIX,[user_agent_prefix])
13 AC_SUBST(PEERID_PREFIX,[peer_id_prefix])
15 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
17 AC_CONFIG_MACRO_DIR([m4])
19 dnl AM_CONFIG_HEADER(config.h)
20 AC_CONFIG_SRCDIR(libtransmission/transmission.h)
21 AM_INIT_AUTOMAKE([1.9 tar-pax])
22 AC_PROG_LIBTOOL
24 if test m4_substr(peer_id_prefix,6,1) = "0"; then
25   supported_build=yes
26   CPPFLAGS="$CPPFLAGS -DNDEBUG"
27 else
28   supported_build=no
29   if test "x$GCC" = "xyes" ; then
30     CFLAGS="$CFLAGS -g -O0"
31     CXXFLAGS="$CXXFLAGS -g -O0"
32   fi
34 AM_CONDITIONAL(TR_UNSTABLE, test "x$supported_build" = "xno")
38 ##   MANDATORY for everything
41 CURL_MINIMUM=7.15.4
42 AC_SUBST(CURL_MINIMUM)
43 LIBEVENT_MINIMUM=2.0.10
44 AC_SUBST(LIBEVENT_MINIUM)
45 OPENSSL_MINIMUM=0.9.4
46 AC_SUBST(OPENSSL_MINIMUM)
50 ##   MANDATORY for the GTK+ client
53 GLIB_MINIMUM=2.8.0
54 AC_SUBST(GLIB_MINIMUM)
55 GTK_MINIMUM=2.8.0
56 AC_SUBST(GTK_MINIMUM)
60 ##   OPTIONAL for the GTK+ client
63 # play the XDG "download done" sound...
64 CANBERRA_MINIMUM=0.10
65 AC_SUBST(CANBERRA_MINIMUM)
66 # inhibit hibernation when a torrent is active...
67 DBUS_GLIB_MINIMUM=0.70
68 AC_SUBST(DBUS_GLIB_MINIMUM)
69 # implement "watch" directories to use new .torrent files...
70 GIO_MINIMUM=2.15.5
71 AC_SUBST(GIO_MINIMUM)
72 # pop up a "download done" notice...
73 LIBNOTIFY_MINIMUM=0.4.3
74 AC_SUBST(LIBNOTIFY_MINIMUM)
75 # create the tray icon with AppIndicator
76 LIBAPPINDICATOR_MINIMUM=0.0.11
77   AC_SUBST(LIBAPPINDICATOR_MINIMUM)
80 AC_PROG_CC
81 AC_PROG_CXX
82 AC_C_INLINE
83 if test "x$GCC" = "xyes" ; then
85     CFLAGS="$CFLAGS -std=gnu99 -ggdb3 -Wall -W -Wpointer-arith -Wformat-security -Wcast-align -Wundef -Wcast-align -Wstrict-prototypes -Wmissing-declarations -Wmissing-format-attribute -Wredundant-decls -Wnested-externs -Wunused-parameter -Wwrite-strings -Winline -Wfloat-equal"
87     dnl figure out gcc version
88     AC_MSG_CHECKING([gcc version])
89     GCC_VERSION=`$CC -dumpversion`
90     GCC_MAJOR=`echo $GCC_VERSION | cut -d . -f1`
91     GCC_MINOR=`echo $GCC_VERSION | cut -d . -f2`
92     GCC_VERSION_NUM=`(expr $GCC_MAJOR "*" 100 + $GCC_MINOR) 2>/dev/null`
94     AC_MSG_RESULT($GCC_VERSION)
95     if test $GCC_VERSION_NUM -ge 304; then
96         dnl these were added in 3.4
97         CFLAGS="$CFLAGS -Wextra -Wdeclaration-after-statement -Winit-self"
98     fi
99     if test $GCC_VERSION_NUM -ge 403; then
100         dnl these were added in 4.3
101         CFLAGS="$CFLAGS -Wvariadic-macros"
102     fi
105 AC_HEADER_STDC
106 AC_HEADER_TIME
108 AC_CHECK_HEADERS([stdbool.h])
109 AC_CHECK_FUNCS([iconv_open pread pwrite lrintf strlcpy daemon dirname basename strcasecmp localtime_r fallocate64 posix_fallocate memmem strsep strtold syslog valloc getpagesize posix_memalign statvfs htonll ntohll])
110 AC_PROG_INSTALL
111 AC_PROG_MAKE_SET
112 ACX_PTHREAD
114 if test "x$ac_cv_func_strtold" != "xyes" ; then
115     CPPFLAGS="$CPPFLAGS -Dstrtold=strtod"
118 AC_SEARCH_LIBS(cos, [m])
119 AC_SEARCH_LIBS([socket], [socket net])
120 AC_SEARCH_LIBS([gethostbyname], [nsl bind])
121 PKG_CHECK_MODULES(OPENSSL, [openssl >= $OPENSSL_MINIMUM], , [CHECK_SSL()])
122 PKG_CHECK_MODULES(LIBCURL, [libcurl >= $CURL_MINIMUM])
123 PKG_CHECK_MODULES(LIBEVENT, [libevent >= $LIBEVENT_MINIMUM])
124 AC_PATH_ZLIB
126 AC_SYS_LARGEFILE
127 AC_CHECK_FUNCS([lseek64])
130 dnl ----------------------------------------------------------------------------
132 dnl posix_fadvise
134 dnl can posix_fadvise be used
135 AC_CHECK_DECLS(posix_fadvise, [], [], [
136 #define _XOPEN_SOURCE 600
137 #include <fcntl.h>])
138 AC_CHECK_FUNCS([posix_fadvise])
141 dnl ----------------------------------------------------------------------------
143 dnl file monitoring for the daemon
145 AC_CHECK_HEADER([sys/inotify.h], 
146                 [AC_CHECK_FUNC([inotify_init],[have_inotify="yes"],[have_inotify="no"])], 
147                 [have_inotify="no"]) 
148 AC_ARG_WITH([inotify], 
149             [AS_HELP_STRING([--with-inotify],[Enable inotify support (default=auto)])], 
150             [want_inotify=${withval}], 
151             [want_inotify=${have_inotify}]) 
152 if test "x$want_inotify" = "xyes" ; then 
153     if test "x$have_inotify" = "xyes"; then 
154       AC_DEFINE([WITH_INOTIFY],[1]) 
155     else 
156       AC_MSG_ERROR("inotify not found!") 
157     fi 
158 fi 
160 AC_CHECK_HEADER([sys/event.h], 
161                 [AC_CHECK_FUNC([kqueue],[have_kqueue="yes"],[have_kqueue="no"])], 
162                 [have_kqueue="no"]) 
163 AC_ARG_WITH([kqueue], 
164             [AS_HELP_STRING([--with-kqueue],[Enable kqueue support (default=auto)])], 
165             [want_kqueue=${withval}], 
166             [want_kqueue=${have_kqueue}]) 
167 if test "x$want_kqueue" = "xyes" ; then 
168     if test "x$have_kqueue" = "xyes"; then 
169       AC_DEFINE([WITH_KQUEUE],[1]) 
170     else 
171       AC_MSG_ERROR("kqueue not found!") 
172     fi 
173 fi 
175 AC_CHECK_HEADERS([sys/statvfs.h \
176                   xfs/xfs.h])
179 dnl ----------------------------------------------------------------------------
181 dnl va_copy
183 AC_MSG_CHECKING([how to copy va_list])
184 AC_TRY_LINK([#include <stdarg.h>], [va_list ap1, ap2; va_copy(ap1, ap2);],
185     AC_MSG_RESULT([va_copy]),
186         [ AH_TEMPLATE([va_copy], [define if va_copy is not available])
187         AC_TRY_LINK([#include <stdarg.h>], [va_list ap1, ap2; __va_copy(ap1, ap2);],
188         [ AC_DEFINE([va_copy], [__va_copy])
189         AC_MSG_RESULT([__va_copy])],
190         [ AC_DEFINE([va_copy(dest,src)], [memcpy(&dest,&src,sizeof(va_list))])
191         AC_MSG_RESULT([memcpy])]
192     )
196 dnl ----------------------------------------------------------------------------
198 dnl  dht
200 DHT_CFLAGS="-I\$(top_srcdir)/third-party/dht"
201 DHT_LIBS="\$(top_builddir)/third-party/dht/libdht.a"
202 AC_SUBST(DHT_CFLAGS)
203 AC_SUBST(DHT_LIBS)
206 dnl ----------------------------------------------------------------------------
208 dnl  utp
210 AC_CHECK_LIB([rt],
211              [clock_gettime],
212              [libutp_extra_libs="-lrt"],
213              [libutp_extra_libs=""])
215 AC_MSG_CHECKING([µTP])
216 build_utp="no"
217 if test "x$CXX" = "x" ; then
218     have_utp="no"
219 else
220     have_utp="yes"
222 AC_ARG_ENABLE([utp],
223               AS_HELP_STRING([--enable-utp],[build µTP support]),
224               [want_utp=${enableval}],
225               [want_utp=${have_utp}])
226 if test "x$want_utp" = "xyes" ; then
227     if test "x$have_utp" = "xyes"; then 
228         LIBUTP_CFLAGS="-I\$(top_srcdir)/third-party/"
229         LIBUTP_LIBS="\$(top_builddir)/third-party/libutp/libutp.a"
230         if test "x$libutp_extra_libs" != "x" ; then
231            LIBUTP_LIBS="$LIBUTP_LIBS $libutp_extra_libs"
232         fi
233         AC_DEFINE([WITH_UTP],[1])
234         build_utp="yes"
235     else 
236       AC_MSG_ERROR("Unable to build uTP support -- C++ compiler not found") 
237     fi 
238 fi 
239 AC_SUBST(LIBUTP_CFLAGS)
240 AC_SUBST(LIBUTP_LIBS)
241 AM_CONDITIONAL([BUILD_UTP],[test "x$build_utp" = "xyes"])
242 AC_MSG_RESULT([$build_utp])
245 dnl ----------------------------------------------------------------------------
247 dnl  detection for the GTK+ client
249 PKG_CHECK_MODULES(GTK,
250                   [gtk+-2.0 >= $GTK_MINIMUM
251                    glib-2.0 >= $GLIB_MINIMUM
252                    gmodule-2.0 >= $GLIB_MINIMUM
253                    gthread-2.0 >= $GLIB_MINIMUM],
254                   [have_gtk=yes],
255                   [have_gtk=no])
256 AC_ARG_ENABLE([gtk],
257               AS_HELP_STRING([--enable-gtk],[build gtk client]),
258               [want_gtk=${enableval}],
259               [want_gtk=${have_gtk}])
260 build_gtk=no
261 use_gio=no
262 use_libappindicator=no
263 use_libnotify=no
264 use_dbus_glib=no
265 use_canberra=no
266 if test "x$want_gtk" = "xyes" ; then
267     if test "x$have_gtk" = "xyes"; then
268       build_gtk=yes
269     else
270       AC_MSG_ERROR("GTK+ not found!")
271     fi
273 AM_CONDITIONAL([BUILD_GTK],[test "x$build_gtk" = "xyes"])
275 if test "x$build_gtk" = "xyes"; then
277     PKG_CHECK_MODULES([GIO],
278                       [gio-2.0 >= $GIO_MINIMUM],
279                       [use_gio=yes],
280                       [use_gio=no])
281     if test "x$use_gio" = "xyes"; then
282         AC_DEFINE([HAVE_GIO], 1)
283     fi
285     PKG_CHECK_MODULES([LIBNOTIFY],
286                       [libnotify >= $LIBNOTIFY_MINIMUM],
287                       [have_libnotify=yes],
288                       [have_libnotify=no])
289     AC_ARG_ENABLE([libnotify], 
290                   AS_HELP_STRING([--enable-libnotify],[enable notifications]),, 
291                   [enable_libnotify=yes]) 
292     use_libnotify=no
293     if test "x$have_libnotify" = "xyes"; then
294         if test "x$enable_libnotify" = "xyes" ; then
295             use_libnotify=yes
296             AC_DEFINE([HAVE_LIBNOTIFY], 1) 
297         else
298             LIBNOTIFY_CFLAGS=
299             LIBNOTIFY_LIBS=
300         fi
301     fi
303     PKG_CHECK_MODULES([LIBAPPINDICATOR],
304                       [appindicator-0.1 >= $LIBAPPINDICATOR_MINIMUM],
305                       [have_libappindicator=yes],
306                       [have_libappindicator=no])
308     AC_ARG_ENABLE([libappindicator], 
309                   AS_HELP_STRING([--enable-libappindicator],[enable AppIndicator support]),, 
310                   [enable_libappindicator=yes])
311     use_libappindicator=no
312     if test "x$have_libappindicator" = "xyes"; then
313         if test "x$enable_libappindicator" = "xyes" ; then
314             use_libappindicator=yes
315             AC_DEFINE([HAVE_LIBAPPINDICATOR], 1) 
316         else
317             LIBAPPINDICATOR_CFLAGS=
318             LIBAPPINDICATOR_LIBS=
319         fi
320     fi
322     PKG_CHECK_MODULES([LIBCANBERRA],
323                       [libcanberra-gtk >= $CANBERRA_MINIMUM],
324                       [have_libcanberra=yes],
325                       [have_libcanberra=no])
326     AC_ARG_ENABLE([libcanberra], 
327                   AS_HELP_STRING([--enable-libcanberra],[enable sounds]),, 
328                   [enable_libcanberra=yes]) 
329     if test "x$have_libcanberra" = "xyes"; then
330         if test "x$enable_libcanberra" = "xyes" ; then
331             use_canberra=yes
332             AC_DEFINE([HAVE_LIBCANBERRA], 1) 
333         else
334             LIBCANBERRA_CFLAGS=
335             LIBCANBERRA_LIBS=
336         fi
337     fi
339     PKG_CHECK_MODULES([DBUS_GLIB],
340                       [dbus-glib-1 >= $DBUS_GLIB_MINIMUM],
341                       [use_dbus_glib=yes],
342                       [use_dbus_glib=no])
343     if test "x$use_dbus_glib" = "xyes"; then
344         AC_DEFINE([HAVE_DBUS_GLIB], 1)
345     fi
346     if test "x$use_dbus_glib" = "xyes"; then
347         AC_PATH_PROG(DBUS_BINDING_TOOL, dbus-binding-tool, no)
348         if test "x$DBUS_BINDING_TOOL" = xno; then
349           AC_MSG_WARN([Cannot find dbus-binding-tool])
350           use_dbus_glib="no (dbus-binding-tool not found)"
351         fi
352     fi
355 AC_ARG_ENABLE([nls], 
356               AS_HELP_STRING([--enable-nls],[enable native language support]),,
357               [enable_nls=yes])
359 if test "x$build_gtk" = "xyes" -a  "x$enable_nls" = "xno" ; then
360     AC_MSG_ERROR("The gtk client cannot be built without nls support.  Try adding either --enable-nls or --disable-gtk" )
363 dnl This section is only used for internationalization.
364 dnl If you don't need translations and this section gives you trouble --
365 dnl such as if you're building for a headless system --
366 dnl it's okay to tear this section out and re-build the configure script.
368 dnl Note to packagers: the bump to intltool 0.40 was made to fix
369 dnl a "make check" failure on some systems.  if upgrading to 0.40 is
370 dnl a problem and the old version was working fine for you,
371 dnl it should be safe to re-edit 0.40 back down to 0.23
373 use_nls=no
374 if test "x$enable_nls" = "xyes" ; then
375     use_nls=yes
376     IT_PROG_INTLTOOL([0.35.0],[no-xml])
377     AC_CHECK_HEADERS([libintl.h])
378     GETTEXT_PACKAGE=transmission-gtk
379     AC_SUBST(GETTEXT_PACKAGE)
380     AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[Gettext package])
381     AM_GLIB_GNU_GETTEXT
382     transmissionlocaledir='${prefix}/${DATADIRNAME}/locale'
383     AC_SUBST(transmissionlocaledir)
385 AC_SUBST(INTLLIBS)
388 dnl ----------------------------------------------------------------------------
390 dnl  platform-specific stuff.
392 AC_CANONICAL_HOST
393 have_darwin="no"
394 have_msw="no"
395 case $host_os in
397    *mingw32*)
398      have_msw="yes"
399      CXXFLAGS="$CXXFLAGS -mms-bitfields -mwin32 -mwindows"
400      CPPFLAGS="$CPPFLAGS -DWIN32 -D_WIN32 -DWIN32_LEAN_AND_MEAN"
401      LIBS="$LIBS -liphlpapi -lshell32 -lws2_32"
402      transmissionlocaledir="locale"
403      if test -z "$host_alias"; then
404        hostaliaswindres=
405      else
406        hostaliaswindres="$host_alias-windres";
407      fi
408      AC_CHECK_TOOL(WINDRES, windres)
409      ;;
411   *darwin*)
412     have_darwin="yes"
413     CFLAGS="-DMACOSX $CFLAGS"
414     ;;
416 esac
418 AC_ARG_ENABLE([lightweight],
419               AS_HELP_STRING([--enable-lightweight],[optimize libtransmission for low-resource systems: smaller cache size, prefer unencrypted peer connections, etc.]),
420               [enable_lightweight=${enableval}],
421               [enable_lightweight="no"])
422 if test "x$enable_lightweight" = "xyes" ; then 
423   AC_DEFINE([TR_LIGHTWEIGHT],[1],[optimize libtransmission for low-resource systems])
424 fi 
426 AC_ARG_ENABLE([cli],
427               [AS_HELP_STRING([--enable-cli],[build command-line client])],
428               [build_cli=${enableval}],
429               [build_cli="yes"])
430 AM_CONDITIONAL([BUILD_CLI],[test "x$build_cli" = "xyes"])
432 AC_ARG_ENABLE([mac],
433               [AS_HELP_STRING([--enable-mac],[build Mac client])],
434               [build_mac=${enableval}],
435               [build_mac=${have_darwin}])
436 AM_CONDITIONAL([BUILD_MAC],[test "x$build_mac" = "xyes"])
438 AC_ARG_ENABLE([daemon],
439               [AS_HELP_STRING([--enable-daemon],[build daemon])],
440               [build_daemon=${enableval}],
441               [build_daemon="yes"])
442 AM_CONDITIONAL([BUILD_DAEMON],[test "x$build_daemon" = "xyes"])
445 if test "x$build_mac" = "xyes" ; then
446     # Make sure the proper Mac SDK is installed
447     if test ! -d /Developer/SDKs/MacOSX10.5.sdk; then
448       cat << EOF
449 You need to install the Mac OS X 10.5 SDK in order to build Transmission
450 with --enable-mac:
451   Get your Xcode CD or package
452   Restart the install
453   When it gets to "Installation Type", select "Customize"
454   Select "Mac OS X 10.5 SDK" under "Cross Development"
455   Finish the install.
457       exit 1
458     fi
460 if test "x$have_darwin" = "xyes"; then
461     AC_DEFINE([HAVE_DARWIN], 1)
463 if test "x$have_msw" = "xyes"; then
464     AC_DEFINE([HAVE_MSW], 1)
466 AM_CONDITIONAL(WIN32, test "x$have_msw" = "xyes")
468 dnl ----------------------------------------------------------------------------
470 dnl  Generate the output
472 AC_CONFIG_FILES([Makefile
473                  transmission-gtk.spec
474                  cli/Makefile
475                  daemon/Makefile
476                  extras/Makefile
477                  libtransmission/Makefile
478                  utils/Makefile
479                  third-party/Makefile
480                  third-party/miniupnp/Makefile
481                  third-party/libnatpmp/Makefile
482                  third-party/libutp/Makefile
483                  third-party/dht/Makefile
484                  macosx/Makefile
485                  gtk/Makefile
486                  gtk/icons/Makefile
487                  web/Makefile
488                  web/images/Makefile
489                  web/images/buttons/Makefile
490                  web/images/graphics/Makefile
491                  web/images/progress/Makefile
492                  web/javascript/Makefile
493                  web/javascript/jquery/Makefile
494                  web/stylesheets/Makefile
495                  po/Makefile.in])
497 AC_OUTPUT
499 echo "
501 Configuration:
503    Source code location:                              ${srcdir}
504    Compiler:                                          ${CXX}
506    Build libtransmission:                             yes
508       * optimized for low-resource systems:           ${enable_lightweight}
509       * µTP enabled:                                  ${build_utp}
511    Build Command-Line client:                         ${build_cli}
513    Build GTK+ client:                                 ${build_gtk}
515      Optional dependencies for GTK+ client:
517       * dbus support:                                 ${use_dbus_glib}
518       * gio for watchdir and mime-type support:       ${use_gio}
519       * libnotify for 'download completed' popups:    ${use_libnotify}
520       * libcanberra for 'download completed' sounds:  ${use_canberra}
521       * libappindicator for an Ubuntu-style tray:     ${use_libappindicator}
523    Build Daemon:                                      ${build_daemon}
525    Build Mac client:                                  ${build_mac}