source: trunk/configure.ac @ 10675

Last change on this file since 10675 was 10675, checked in by charles, 12 years ago

(trunk) #3222 "don't bundle libevent" -- autoconf-based builds no longer use our copy of libevent, and it's not included in the tarball anymore.

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