source: trunk/configure.ac @ 9546

Last change on this file since 9546 was 9546, checked in by charles, 13 years ago

(trunk gtk) #2597: add an optional "download complete" sound to the gtk client

File size: 14.1 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.76+])
7m4_define([peer_id_prefix],[-TR176Z-])
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
40OPENSSL_MINIMUM=0.9.4
41CURL_MINIMUM=7.16.3
42GIO_MINIMUM=2.15.5
43GLIB_MINIMUM=2.6.0
44GTK_MINIMUM=2.6.0
45LIBNOTIFY_MINIMUM=0.4.3
46DBUS_GLIB_MINIMUM=0.70
47LIBEVENT_MINIMUM=1.4.5
48CANBERRA_MINIMUM=0.10
49AC_SUBST(OPENSSL_MINIMUM)
50AC_SUBST(CURL_MINIMUM)
51AC_SUBST(GIO_MINIMUM)
52AC_SUBST(GLIB_MINIMUM)
53AC_SUBST(GTK_MINIMUM)
54AC_SUBST(LIBNOTIFY_MINIMUM)
55AC_SUBST(DBUS_GLIB_MINIMUM)
56AC_SUBST(LIBEVENT_MINIUM)
57AC_SUBST(CANBERRA_MINIMUM)
58
59AC_PROG_CC
60AC_PROG_CXX
61AC_C_INLINE
62if test "x$GCC" = "xyes" ; then
63
64    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"
65
66    dnl figure out gcc version
67    AC_MSG_CHECKING([gcc version])
68    GCC_VERSION=`$CC -dumpversion`
69    GCC_MAJOR=`echo $GCC_VERSION | cut -d . -f1`
70    GCC_MINOR=`echo $GCC_VERSION | cut -d . -f2`
71    GCC_VERSION_NUM=`(expr $GCC_MAJOR "*" 100 + $GCC_MINOR) 2>/dev/null`
72
73    AC_MSG_RESULT($GCC_VERSION)
74    if test $GCC_VERSION_NUM -ge 304; then
75        dnl these were added in 3.4
76        CFLAGS="$CFLAGS -Wextra -Wdeclaration-after-statement -Winit-self"
77    fi
78fi
79
80AC_HEADER_STDC
81AC_HEADER_TIME
82
83AC_CHECK_FUNCS([pread pwrite lrintf strlcpy daemon dirname basename strcasecmp localtime_r posix_fallocate memmem strtold syslog])
84AC_PROG_INSTALL
85AC_PROG_MAKE_SET
86ACX_PTHREAD
87
88if test "x$ac_cv_func_strtold" != "xyes" ; then
89    CPPFLAGS="$CPPFLAGS -Dstrtold=strtod"
90fi
91
92AC_SEARCH_LIBS(cos, [m])
93AC_SEARCH_LIBS([socket], [socket net])
94AC_SEARCH_LIBS([gethostbyname], [nsl bind])
95PKG_CHECK_MODULES(OPENSSL, [openssl >= $OPENSSL_MINIMUM], , [CHECK_SSL()])
96PKG_CHECK_MODULES(LIBCURL, [libcurl >= $CURL_MINIMUM])
97AC_PATH_ZLIB
98
99AC_SYS_LARGEFILE
100AC_CHECK_FUNCS([lseek64])
101
102
103dnl ----------------------------------------------------------------------------
104dnl
105dnl posix_fadvise
106
107dnl can posix_fadvise be used
108AC_CHECK_DECLS(posix_fadvise, [], [], [
109#define _XOPEN_SOURCE 600
110#include <fcntl.h>])
111AC_CHECK_FUNCS([posix_fadvise])
112
113
114dnl ----------------------------------------------------------------------------
115dnl
116dnl file monitoring for the daemon
117
118AC_CHECK_HEADER([sys/inotify.h],
119                [AC_CHECK_FUNC([inotify_init],[have_inotify="yes"],[have_inotify="no"])],
120                [have_inotify="no"])
121AC_ARG_WITH([inotify],
122            [AS_HELP_STRING([--with-inotify],[Enable inotify support (default=auto)])],
123            [want_inotify=${enableval}],
124            [want_inotify=${have_inotify}])
125if test "x$want_inotify" = "xyes" ; then
126    if test "x$have_inotify" = "xyes"; then
127      AC_DEFINE([WITH_INOTIFY],[1])
128    else
129      AC_MSG_ERROR("inotify not found!")
130    fi
131fi
132 
133AC_CHECK_HEADER([sys/event.h],
134                [AC_CHECK_FUNC([kqueue],[have_kqueue="yes"],[have_kqueue="no"])],
135                [have_kqueue="no"])
136AC_ARG_WITH([kqueue],
137            [AS_HELP_STRING([--with-kqueue],[Enable kqueue support (default=auto)])],
138            [want_kqueue=${enableval}],
139            [want_kqueue=${have_kqueue}])
140if test "x$want_kqueue" = "xyes" ; then
141    if test "x$have_kqueue" = "xyes"; then
142      AC_DEFINE([WITH_KQUEUE],[1])
143    else
144      AC_MSG_ERROR("kqueue not found!")
145    fi
146fi
147
148AC_CHECK_HEADERS([xfs/xfs.h])
149
150
151dnl ----------------------------------------------------------------------------
152dnl
153dnl va_copy
154
155AC_MSG_CHECKING([how to copy va_list])
156AC_TRY_LINK([#include <stdarg.h>], [va_list ap1, ap2; va_copy(ap1, ap2);],
157    AC_MSG_RESULT([va_copy]),
158        [ AH_TEMPLATE([va_copy], [define if va_copy is not available])
159        AC_TRY_LINK([#include <stdarg.h>], [va_list ap1, ap2; __va_copy(ap1, ap2);],
160        [ AC_DEFINE([va_copy], [__va_copy])
161        AC_MSG_RESULT([__va_copy])],
162        [ AC_DEFINE([va_copy(dest,src)], [memcpy(&dest,&src,sizeof(va_list))])
163        AC_MSG_RESULT([memcpy])]
164    )
165])
166
167
168dnl libevent likes to link against librt if possible
169dnl for clock_gettime() and clock_settime()
170dnl TODO(libevent2): this can probably be removed after
171dnl we switch to libevent2, since it will have PKG_CONFIG
172AC_CHECK_LIB([rt],
173             [clock_gettime],
174             [libevent_extra_libs="-lrt"],
175             [libevent_extra_libs=""])
176
177dnl build our copy of libevent whether we use it or not,
178dnl because "make dist" needs its Makefiles to exist, and
179dnl AM_CONDITIONAL + AC_CONFIG_SUBDIRS don't seem to play nice
180AC_CONFIG_SUBDIRS([third-party/libevent])
181libevent_source=bundled
182AC_CHECK_LIB([event],[evutil_vsnprintf],
183             [libevent_found=yes],
184             [libevent_found=no],
185             [$libevent_extra_libs])
186AC_CHECK_HEADER([event-config.h],
187                [libevent_headers_found=yes],
188                [libevent_headers_found=no])
189libevent_source=bundled
190if test "x$libevent_found" = "xyes" ; then
191    if test "x$libevent_headers_found" = "xyes"; then
192      libevent_source=system
193    fi
194fi
195if test "x$libevent_source" = "xbundled"; then
196    AC_MSG_WARN([using our own libevent from third-party/libevent/])
197    AC_MSG_WARN([if you are cross-compiling this is probably NOT what you want.])
198    LIBEVENT_CFLAGS="-I\$(top_srcdir)/third-party/libevent -I\$(top_builddir)/third-party/libevent"
199    LIBEVENT_LIBS="\$(top_builddir)/third-party/libevent/libevent.la"
200else
201    LIBEVENT_CFLAGS=""
202    LIBEVENT_LIBS="-levent $libevent_extra_libs"
203fi
204AC_SUBST(LIBEVENT_CFLAGS)
205AC_SUBST(LIBEVENT_LIBS)
206
207
208dnl ----------------------------------------------------------------------------
209dnl
210dnl  dht
211
212
213DHT_CFLAGS="-I\$(top_srcdir)/third-party/dht"
214DHT_LIBS="\$(top_builddir)/third-party/dht/libdht.a"
215AC_SUBST(DHT_CFLAGS)
216AC_SUBST(DHT_LIBS)
217
218
219dnl ----------------------------------------------------------------------------
220dnl
221dnl  detection for the GTK+ client
222
223PKG_CHECK_MODULES(GTK,
224                  [gtk+-2.0 >= $GTK_MINIMUM
225                   glib-2.0 >= $GLIB_MINIMUM
226                   gmodule-2.0 >= $GLIB_MINIMUM
227                   gthread-2.0 >= $GLIB_MINIMUM],
228                  [have_gtk=yes],
229                  [have_gtk=no])
230AC_ARG_ENABLE([gtk],
231              AS_HELP_STRING([--enable-gtk],[build gtk client]),
232              [want_gtk=${enableval}],
233              [want_gtk=${have_gtk}])
234build_gtk=no
235use_gio=no
236use_libnotify=no
237use_dbus_glib=no
238if test "x$want_gtk" = "xyes" ; then
239    if test "x$have_gtk" = "xyes"; then
240      build_gtk=yes
241    else
242      AC_MSG_ERROR("GTK+ not found!")
243    fi
244fi
245AM_CONDITIONAL([BUILD_GTK],[test "x$build_gtk" = "xyes"])
246AC_SUBST(GTK_LIBS)
247AC_SUBST(GTK_CFLAGS)
248
249if test "x$build_gtk" = "xyes"; then
250
251    PKG_CHECK_MODULES([GIO],
252                      [gio-2.0 >= $GIO_MINIMUM],
253                      [use_gio=yes],
254                      [use_gio=no])
255    AC_SUBST(GIO_LIBS)
256    AC_SUBST(GIO_CFLAGS)
257    if test "x$use_gio" = "xyes"; then
258        AC_DEFINE([HAVE_GIO], 1)
259    fi
260
261    PKG_CHECK_MODULES([LIBNOTIFY],
262                      [libnotify >= $LIBNOTIFY_MINIMUM],
263                      [have_libnotify=yes],
264                      [have_libnotify=no])
265    AC_ARG_ENABLE([libnotify],
266                  AS_HELP_STRING([--enable-libnotify],[enable notifications]),,
267                  [enable_libnotify=yes])
268    use_libnotify=no
269    if test "x$enable_libnotify" = "xyes" ; then
270        if test "x$have_libnotify" = "xyes"; then
271            use_libnotify=yes
272            AC_SUBST(LIBNOTIFY_LIBS)
273            AC_SUBST(LIBNOTIFY_CFLAGS)
274            AC_DEFINE([HAVE_LIBNOTIFY], 1)
275        fi
276    fi
277
278    PKG_CHECK_MODULES([LIBCANBERRA],
279                      [libcanberra-gtk >= $CANBERRA_MINIMUM],
280                      [have_libcanberra=yes],
281                      [have_libcanberra=no])
282    AC_ARG_ENABLE([libcanberra],
283                  AS_HELP_STRING([--enable-libcanberra],[enable sounds]),,
284                  [enable_libcanberra=yes])
285    use_libcanberra=no
286    if test "x$enable_libcanberra" = "xyes" ; then
287        if test "x$have_libcanberra" = "xyes"; then
288            use_canberra=yes
289            AC_SUBST(LIBCANBERRA_LIBS)
290            AC_SUBST(LIBCANBERRA_CFLAGS)
291            AC_DEFINE([HAVE_LIBCANBERRA], 1)
292        fi
293    fi
294
295    PKG_CHECK_MODULES([DBUS_GLIB],
296                      [dbus-glib-1 >= $DBUS_GLIB_MINIMUM],
297                      [use_dbus_glib=yes],
298                      [use_dbus_glib=no])
299    AC_SUBST(DBUS_GLIB_LIBS)
300    AC_SUBST(DBUS_GLIB_CFLAGS)
301    if test "x$use_dbus_glib" = "xyes"; then
302        AC_DEFINE([HAVE_DBUS_GLIB], 1)
303    fi
304    if test "x$use_dbus_glib" = "xyes"; then
305        AC_PATH_PROG(DBUS_BINDING_TOOL, dbus-binding-tool, no)
306        if test "x$DBUS_BINDING_TOOL" = xno; then
307          AC_MSG_WARN([Cannot find dbus-binding-tool])
308          use_dbus_glib="no (dbus-binding-tool not found)"
309        fi
310    fi
311fi
312
313AC_ARG_ENABLE([nls],
314              AS_HELP_STRING([--enable-nls],[enable native language support]),,
315              [enable_nls=yes])
316
317if test "x$build_gtk" = "xyes" -a  "x$enable_nls" = "xno" ; then
318    AC_MSG_ERROR("The gtk client cannot be built without nls support.  Try adding either --enable-nls or --disable-gtk" )
319fi
320
321dnl This section is only used for internationalization.
322dnl If you don't need translations and this section gives you trouble --
323dnl such as if you're building for a headless system --
324dnl it's okay to tear this section out and re-build the configure script.
325dnl
326dnl Note to packagers: the bump to intltool 0.40 was made to fix
327dnl a "make check" failure on some systems.  if upgrading to 0.40 is
328dnl a problem and the old version was working fine for you,
329dnl it should be safe to re-edit 0.40 back down to 0.23
330
331use_nls=no
332if test "x$enable_nls" = "xyes" ; then
333    use_nls=yes
334    IT_PROG_INTLTOOL([0.40.0],[no-xml])
335    AC_CHECK_HEADERS([libintl.h])
336    GETTEXT_PACKAGE=transmission
337    AC_SUBST(GETTEXT_PACKAGE)
338    AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[Gettext package])
339    AM_GLIB_GNU_GETTEXT
340    transmissionlocaledir='${prefix}/${DATADIRNAME}/locale'
341    AC_SUBST(transmissionlocaledir)
342fi
343
344
345dnl ----------------------------------------------------------------------------
346dnl
347dnl  platform-specific stuff.
348
349AC_CANONICAL_HOST
350have_darwin="no"
351have_msw="no"
352case $host_os in
353
354   *mingw32*)
355     have_msw="yes"
356     CXXFLAGS="$CXXFLAGS -mms-bitfields -mwin32 -mwindows"
357     CPPFLAGS="$CPPFLAGS -DWIN32 -D_WIN32 -DWIN32_LEAN_AND_MEAN"
358     LIBS="$LIBS -lshell32 -lws2_32"
359     transmissionlocaledir="locale"
360     if test -z "$host_alias"; then
361       hostaliaswindres=
362     else
363       hostaliaswindres="$host_alias-windres";
364     fi
365     AC_CHECK_TOOL(WINDRES, windres)
366     ;;
367
368  *darwin*)
369    have_darwin="yes"
370    # Make sure the proper Mac SDK is installed
371    if test ! -d /Developer/SDKs/MacOSX10.5.sdk; then
372      cat << EOF
373You need to install the Mac OS X 10.5 SDK in order to build Transmission:
374  Get your Xcode CD or package
375  Restart the install
376  When it gets to "Installation Type", select "Customize"
377  Select "Mac OS X 10.5 SDK" under "Cross Development"
378  Finish the install.
379EOF
380      exit 1
381    fi
382    ;;
383
384esac
385
386AC_ARG_ENABLE([cli],
387              [AS_HELP_STRING([--enable-cli],[build command-line client])],
388              [build_cli=${enableval}],
389              [build_cli="yes"])
390AM_CONDITIONAL([BUILD_CLI],[test "x$build_cli" = "xyes"])
391
392AC_ARG_ENABLE([mac],
393              [AS_HELP_STRING([--enable-mac],[build Mac client])],
394              [build_mac=${enableval}],
395              [build_mac=${have_darwin}])
396AM_CONDITIONAL([BUILD_MAC],[test "x$build_mac" = "xyes"])
397
398AC_ARG_ENABLE([daemon],
399              [AS_HELP_STRING([--enable-daemon],[build daemon])],
400              [build_daemon=${enableval}],
401              [build_daemon="yes"])
402AM_CONDITIONAL([BUILD_DAEMON],[test "x$build_daemon" = "xyes"])
403
404
405if test "x$have_darwin" = "xyes"; then
406    AC_DEFINE([HAVE_DARWIN], 1)
407fi
408if test "x$have_msw" = "xyes"; then
409    AC_DEFINE([HAVE_MSW], 1)
410fi
411AM_CONDITIONAL(WIN32, test "x$have_msw" = "xyes")
412
413dnl ----------------------------------------------------------------------------
414dnl
415dnl  Generate the output
416
417AC_CONFIG_FILES([Makefile
418                 transmission.spec
419                 cli/Makefile
420                 daemon/Makefile
421                 doc/Makefile
422                 libtransmission/Makefile
423                 third-party/Makefile
424                 third-party/miniupnp/Makefile
425                 third-party/libnatpmp/Makefile
426                 third-party/dht/Makefile
427                 macosx/Makefile
428                 gtk/Makefile
429                 gtk/icons/Makefile
430                 po/Makefile.in])
431
432ac_configure_args="$ac_configure_args --enable-static --disable-shared -q"
433AC_OUTPUT
434
435echo "
436
437Configuration:
438
439        Source code location:          ${srcdir}
440        Compiler:                      ${CXX}
441        System or bundled libevent:    ${libevent_source}
442        DHT support:                   ${enable_dht}
443
444        Build Mac client:              ${build_mac}
445        Build GTK+ client:             ${build_gtk}
446          ... with canberra support:   ${use_canberra}
447          ... with gio support:        ${use_gio}
448          ... with dbus-glib support:  ${use_dbus_glib}
449          ... with libnotify support:  ${use_libnotify}
450        Build Command-Line client:     ${build_cli}
451        Build Daemon:                  ${build_daemon}
452
453"
Note: See TracBrowser for help on using the repository browser.