source: trunk/configure.ac @ 12064

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

(trunk) #4041 "FTBFS with enabled uTP on Debian" -- revised patch from taem which unbreaks autoconf build on darwin as reported by leena

File size: 16.8 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 ----------------------------------------------------------------------------
199dnl
200dnl  dht
201
202DHT_CFLAGS="-I\$(top_srcdir)/third-party/dht"
203DHT_LIBS="\$(top_builddir)/third-party/dht/libdht.a"
204AC_SUBST(DHT_CFLAGS)
205AC_SUBST(DHT_LIBS)
206
207
208dnl ----------------------------------------------------------------------------
209dnl
210dnl  utp
211
212AC_CHECK_LIB([rt],
213             [clock_gettime],
214             [libutp_extra_libs="-lrt"],
215             [libutp_extra_libs=""])
216
217AC_MSG_CHECKING([µTP])
218build_utp="no"
219if test "x$CXX" = "x" ; then
220    have_utp="no"
221else
222    have_utp="yes"
223fi
224AC_ARG_ENABLE([utp],
225              AS_HELP_STRING([--enable-utp],[build µTP support]),
226              [want_utp=${enableval}],
227              [want_utp=${have_utp}])
228if test "x$want_utp" = "xyes" ; then
229    if test "x$have_utp" = "xyes"; then
230        LIBUTP_CFLAGS="-I\$(top_srcdir)/third-party/"
231        LIBUTP_LIBS="\$(top_builddir)/third-party/libutp/libutp.a"
232        if test "x$libutp_extra_libs" != "x" ; then
233           LIBUTP_LIBS="$LIBUTP_LIBS $libutp_extra_libs"
234        fi
235        AC_DEFINE([WITH_UTP],[1])
236        build_utp="yes"
237    else
238      AC_MSG_ERROR("Unable to build uTP support -- C++ compiler not found")
239    fi
240fi
241AC_SUBST(LIBUTP_CFLAGS)
242AC_SUBST(LIBUTP_LIBS)
243AM_CONDITIONAL([BUILD_UTP],[test "x$build_utp" = "xyes"])
244AC_MSG_RESULT([$build_utp])
245
246
247dnl ----------------------------------------------------------------------------
248dnl
249dnl  detection for the GTK+ client
250
251PKG_CHECK_MODULES(GTK,
252                  [gtk+-2.0 >= $GTK_MINIMUM
253                   glib-2.0 >= $GLIB_MINIMUM
254                   gmodule-2.0 >= $GLIB_MINIMUM
255                   gthread-2.0 >= $GLIB_MINIMUM],
256                  [have_gtk=yes],
257                  [have_gtk=no])
258AC_ARG_ENABLE([gtk],
259              AS_HELP_STRING([--enable-gtk],[build gtk client]),
260              [want_gtk=${enableval}],
261              [want_gtk=${have_gtk}])
262build_gtk=no
263use_gio=no
264use_libappindicator=no
265use_libnotify=no
266use_dbus_glib=no
267use_canberra=no
268use_gconf2=no
269if test "x$want_gtk" = "xyes" ; then
270    if test "x$have_gtk" = "xyes"; then
271      build_gtk=yes
272    else
273      AC_MSG_ERROR("GTK+ not found!")
274    fi
275fi
276AM_CONDITIONAL([BUILD_GTK],[test "x$build_gtk" = "xyes"])
277
278if test "x$build_gtk" = "xyes"; then
279
280    PKG_CHECK_MODULES([GIO],
281                      [gio-2.0 >= $GIO_MINIMUM],
282                      [use_gio=yes],
283                      [use_gio=no])
284    if test "x$use_gio" = "xyes"; then
285        AC_DEFINE([HAVE_GIO], 1)
286    fi
287
288    PKG_CHECK_MODULES([LIBNOTIFY],
289                      [libnotify >= $LIBNOTIFY_MINIMUM],
290                      [have_libnotify=yes],
291                      [have_libnotify=no])
292    AC_ARG_ENABLE([libnotify],
293                  AS_HELP_STRING([--enable-libnotify],[enable notifications]),,
294                  [enable_libnotify=yes])
295    use_libnotify=no
296    if test "x$have_libnotify" = "xyes"; then
297        if test "x$enable_libnotify" = "xyes" ; then
298            use_libnotify=yes
299            AC_DEFINE([HAVE_LIBNOTIFY], 1)
300        else
301            LIBNOTIFY_CFLAGS=
302            LIBNOTIFY_LIBS=
303        fi
304    fi
305
306    PKG_CHECK_MODULES([LIBAPPINDICATOR],
307                      [appindicator-0.1 >= $LIBAPPINDICATOR_MINIMUM],
308                      [have_libappindicator=yes],
309                      [have_libappindicator=no])
310
311    AC_ARG_ENABLE([libappindicator],
312                  AS_HELP_STRING([--enable-libappindicator],[enable AppIndicator support]),,
313                  [enable_libappindicator=yes])
314    use_libappindicator=no
315    if test "x$have_libappindicator" = "xyes"; then
316        if test "x$enable_libappindicator" = "xyes" ; then
317            use_libappindicator=yes
318            AC_DEFINE([HAVE_LIBAPPINDICATOR], 1)
319        else
320            LIBAPPINDICATOR_CFLAGS=
321            LIBAPPINDICATOR_LIBS=
322        fi
323    fi
324
325    PKG_CHECK_MODULES([LIBCANBERRA],
326                      [libcanberra-gtk >= $CANBERRA_MINIMUM],
327                      [have_libcanberra=yes],
328                      [have_libcanberra=no])
329    AC_ARG_ENABLE([libcanberra],
330                  AS_HELP_STRING([--enable-libcanberra],[enable sounds]),,
331                  [enable_libcanberra=yes])
332    if test "x$have_libcanberra" = "xyes"; then
333        if test "x$enable_libcanberra" = "xyes" ; then
334            use_canberra=yes
335            AC_DEFINE([HAVE_LIBCANBERRA], 1)
336        else
337            LIBCANBERRA_CFLAGS=
338            LIBCANBERRA_LIBS=
339        fi
340    fi
341
342    PKG_CHECK_MODULES([GCONF2],
343                      [gconf-2.0 >= $GCONF2_MINIMUM],
344                      [have_gconf2=yes],
345                      [have_gconf2=no])
346    AC_ARG_ENABLE([gconf2],
347                  AS_HELP_STRING([--enable-gconf2],[enable GConf support]),,
348                  [enable_gconf2=yes])
349    if test "x$have_gconf2" = "xyes"; then
350        if test "x$enable_gconf2" = "xyes" ; then
351            use_gconf2=yes
352            AC_DEFINE([HAVE_GCONF2], 1)
353        else
354            GCONF2_CFLAGS=
355            GCONF2_LIBS=
356        fi
357    fi
358
359    PKG_CHECK_MODULES([DBUS_GLIB],
360                      [dbus-glib-1 >= $DBUS_GLIB_MINIMUM],
361                      [use_dbus_glib=yes],
362                      [use_dbus_glib=no])
363    if test "x$use_dbus_glib" = "xyes"; then
364        AC_DEFINE([HAVE_DBUS_GLIB], 1)
365    fi
366    if test "x$use_dbus_glib" = "xyes"; then
367        AC_PATH_PROG(DBUS_BINDING_TOOL, dbus-binding-tool, no)
368        if test "x$DBUS_BINDING_TOOL" = xno; then
369          AC_MSG_WARN([Cannot find dbus-binding-tool])
370          use_dbus_glib="no (dbus-binding-tool not found)"
371        fi
372    fi
373fi
374
375AC_ARG_ENABLE([nls],
376              AS_HELP_STRING([--enable-nls],[enable native language support]),,
377              [enable_nls=yes])
378
379if test "x$build_gtk" = "xyes" -a  "x$enable_nls" = "xno" ; then
380    AC_MSG_ERROR("The gtk client cannot be built without nls support.  Try adding either --enable-nls or --disable-gtk" )
381fi
382
383dnl This section is only used for internationalization.
384dnl If you don't need translations and this section gives you trouble --
385dnl such as if you're building for a headless system --
386dnl it's okay to tear this section out and re-build the configure script.
387dnl
388dnl Note to packagers: the bump to intltool 0.40 was made to fix
389dnl a "make check" failure on some systems.  if upgrading to 0.40 is
390dnl a problem and the old version was working fine for you,
391dnl it should be safe to re-edit 0.40 back down to 0.23
392
393use_nls=no
394if test "x$enable_nls" = "xyes" ; then
395    use_nls=yes
396    IT_PROG_INTLTOOL([0.35.0],[no-xml])
397    AC_CHECK_HEADERS([libintl.h])
398    GETTEXT_PACKAGE=transmission-gtk
399    AC_SUBST(GETTEXT_PACKAGE)
400    AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[Gettext package])
401    AM_GLIB_GNU_GETTEXT
402    transmissionlocaledir='${prefix}/${DATADIRNAME}/locale'
403    AC_SUBST(transmissionlocaledir)
404fi
405AC_SUBST(INTLLIBS)
406
407
408dnl ----------------------------------------------------------------------------
409dnl
410dnl  platform-specific stuff.
411
412AC_CANONICAL_HOST
413have_darwin="no"
414have_msw="no"
415case $host_os in
416
417   *mingw32*)
418     have_msw="yes"
419     CXXFLAGS="$CXXFLAGS -mms-bitfields -mwin32 -mwindows"
420     CPPFLAGS="$CPPFLAGS -DWIN32 -D_WIN32 -DWIN32_LEAN_AND_MEAN"
421     LIBS="$LIBS -liphlpapi -lshell32 -lws2_32"
422     transmissionlocaledir="locale"
423     if test -z "$host_alias"; then
424       hostaliaswindres=
425     else
426       hostaliaswindres="$host_alias-windres";
427     fi
428     AC_CHECK_TOOL(WINDRES, windres)
429     ;;
430
431  *darwin*)
432    have_darwin="yes"
433    CFLAGS="-DMACOSX $CFLAGS"
434    ;;
435
436esac
437
438AC_ARG_ENABLE([lightweight],
439              AS_HELP_STRING([--enable-lightweight],[optimize libtransmission for low-resource systems: smaller cache size, prefer unencrypted peer connections, etc.]),
440              [enable_lightweight=${enableval}],
441              [enable_lightweight="no"])
442if test "x$enable_lightweight" = "xyes" ; then
443  AC_DEFINE([TR_LIGHTWEIGHT],[1],[optimize libtransmission for low-resource systems])
444fi
445
446AC_ARG_ENABLE([cli],
447              [AS_HELP_STRING([--enable-cli],[build command-line client])],
448              [build_cli=${enableval}],
449              [build_cli="yes"])
450AM_CONDITIONAL([BUILD_CLI],[test "x$build_cli" = "xyes"])
451
452AC_ARG_ENABLE([mac],
453              [AS_HELP_STRING([--enable-mac],[build Mac client])],
454              [build_mac=${enableval}],
455              [build_mac=${have_darwin}])
456AM_CONDITIONAL([BUILD_MAC],[test "x$build_mac" = "xyes"])
457
458AC_ARG_ENABLE([daemon],
459              [AS_HELP_STRING([--enable-daemon],[build daemon])],
460              [build_daemon=${enableval}],
461              [build_daemon="yes"])
462AM_CONDITIONAL([BUILD_DAEMON],[test "x$build_daemon" = "xyes"])
463
464
465if test "x$build_mac" = "xyes" ; then
466    # Make sure the proper Mac SDK is installed
467    if test ! -d /Developer/SDKs/MacOSX10.5.sdk; then
468      cat << EOF
469You need to install the Mac OS X 10.5 SDK in order to build Transmission
470with --enable-mac:
471  Get your Xcode CD or package
472  Restart the install
473  When it gets to "Installation Type", select "Customize"
474  Select "Mac OS X 10.5 SDK" under "Cross Development"
475  Finish the install.
476EOF
477      exit 1
478    fi
479fi
480if test "x$have_darwin" = "xyes"; then
481    AC_DEFINE([HAVE_DARWIN], 1)
482fi
483if test "x$have_msw" = "xyes"; then
484    AC_DEFINE([HAVE_MSW], 1)
485fi
486AM_CONDITIONAL(WIN32, test "x$have_msw" = "xyes")
487
488dnl ----------------------------------------------------------------------------
489dnl
490dnl  Generate the output
491
492AC_CONFIG_FILES([Makefile
493                 transmission-gtk.spec
494                 cli/Makefile
495                 daemon/Makefile
496                 extras/Makefile
497                 libtransmission/Makefile
498                 utils/Makefile
499                 third-party/Makefile
500                 third-party/miniupnp/Makefile
501                 third-party/libnatpmp/Makefile
502                 third-party/libutp/Makefile
503                 third-party/dht/Makefile
504                 macosx/Makefile
505                 gtk/Makefile
506                 gtk/icons/Makefile
507                 web/Makefile
508                 web/images/Makefile
509                 web/images/buttons/Makefile
510                 web/images/graphics/Makefile
511                 web/images/progress/Makefile
512                 web/javascript/Makefile
513                 web/javascript/jquery/Makefile
514                 web/stylesheets/Makefile
515                 po/Makefile.in])
516
517AC_OUTPUT
518
519echo "
520
521Configuration:
522
523   Source code location:                              ${srcdir}
524   Compiler:                                          ${CXX}
525
526   Build libtransmission:                             yes
527
528      * optimized for low-resource systems:           ${enable_lightweight}
529      * µTP enabled:                                  ${build_utp}
530
531   Build Command-Line client:                         ${build_cli}
532
533   Build GTK+ client:                                 ${build_gtk}
534
535     Optional dependencies for GTK+ client:
536
537      * dbus support:                                 ${use_dbus_glib}
538      * gio for watchdir support:                     ${use_gio}
539      * libnotify for 'download completed' popups:    ${use_libnotify}
540      * libcanberra for 'download completed' sounds:  ${use_canberra}
541      * gconf2 to register as a magnet link handler:  ${use_gconf2}
542      * libappindicator for an Ubuntu-style tray:     ${use_libappindicator}
543
544   Build Daemon:                                      ${build_daemon}
545
546   Build Mac client:                                  ${build_mac}
547
548"
Note: See TracBrowser for help on using the repository browser.