source: trunk/configure.ac @ 12040

Last change on this file since 12040 was 12040, checked in by jordan, 11 years ago

(trunk) #2338 "Add uTP support" -- have the autoconf system default to build uTP support iff a C++ compiler can be found by AC_PROG_CXX

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