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],[3.00])
7m4_define([peer_id_prefix],[-TR3000-])
8
9AC_INIT([transmission],[user_agent_prefix],[https://github.com/transmission/transmission])
10AC_SUBST(USERAGENT_PREFIX,[user_agent_prefix])
11AC_SUBST(PEERID_PREFIX,[peer_id_prefix])
12
13m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
14
15AC_CONFIG_MACRO_DIR([m4])
16
17dnl AM_CONFIG_HEADER(config.h)
18AC_CONFIG_SRCDIR(libtransmission/transmission.h)
19AM_INIT_AUTOMAKE([1.9 tar-pax no-dist-gzip dist-xz foreign])
20LT_INIT
21LT_LIB_M
22
23if test m4_substr(peer_id_prefix,6,1) = "0"; then
24  supported_build=yes
25  CPPFLAGS="$CPPFLAGS -DNDEBUG"
26else
27  supported_build=no
28  if test "x$GCC" = "xyes" ; then
29    CFLAGS="$CFLAGS -g -O0"
30    CXXFLAGS="$CXXFLAGS -g -O0"
31  fi
32fi
33AM_CONDITIONAL(TR_UNSTABLE, test "x$supported_build" = "xno")
34AM_CONDITIONAL(HAVE_REVISION_FILE, test -f REVISION)
35
36##
37##
38##   MANDATORY for everything
39##
40##
41
42CURL_MINIMUM=7.15.4
43AC_SUBST(CURL_MINIMUM)
44LIBEVENT_MINIMUM=2.0.10
45AC_SUBST(LIBEVENT_MINIMUM)
46ZLIB_MINIMUM=1.2.3
47AC_SUBST(ZLIB_MINIMUM)
48
49# crypto backends
50OPENSSL_MINIMUM=0.9.7
51AC_SUBST(OPENSSL_MINIMUM)
52CYASSL_MINIMUM=3.0
53AC_SUBST(CYASSL_MINIMUM)
54POLARSSL_MINIMUM=0x01020000 # 1.2
55AC_SUBST(POLARSSL_MINIMUM)
56
57##
58##
59##   MANDATORY for the GTK+ client
60##
61##
62
63GTK_MINIMUM=3.4.0
64AC_SUBST(GTK_MINIMUM)
65GLIB_MINIMUM=2.32.0
66AC_SUBST(GLIB_MINIMUM)
67GIO_MINIMUM=2.26.0
68AC_SUBST(GIO_MINIMUM)
69
70##
71##
72##   OPTIONAL for the GTK+ client
73##
74##
75
76# create the tray icon with AppIndicator
77LIBAPPINDICATOR_MINIMUM=0.4.90
78AC_SUBST(LIBAPPINDICATOR_MINIMUM)
79
80
81AC_PROG_CC
82AC_PROG_CXX
83AC_C_INLINE
84if test "x$GCC" = "xyes" ; then
85
86    CFLAGS="$CFLAGS -std=gnu99 -ggdb3 -Wall -W -Wpointer-arith -Wformat-security -Wundef -Wcast-align -Wstrict-prototypes -Wmissing-declarations -Wmissing-format-attribute -Wredundant-decls -Wnested-externs -Wunused-parameter -Wwrite-strings -Winline -Wfloat-equal"
87
88    dnl figure out gcc version
89    AC_MSG_CHECKING([gcc version])
90    GCC_VERSION=`$CC -dumpversion`
91    GCC_MAJOR=`echo $GCC_VERSION | cut -d . -f1`
92    GCC_MINOR=`echo $GCC_VERSION | cut -d . -f2`
93    GCC_VERSION_NUM=`(expr $GCC_MAJOR "*" 100 + $GCC_MINOR) 2>/dev/null`
94
95    AC_MSG_RESULT($GCC_VERSION)
96    if test $GCC_VERSION_NUM -ge 304; then
97        dnl these were added in 3.4
98        CFLAGS="$CFLAGS -Wextra -Winit-self"
99    fi
100    if test $GCC_VERSION_NUM -ge 403; then
101        dnl these were added in 4.3
102        CFLAGS="$CFLAGS -Wvariadic-macros"
103    fi
104fi
105
106AC_PROG_LN_S
107AC_PROG_MKDIR_P
108
109AC_HEADER_STDC
110AC_HEADER_TIME
111
112AC_CHECK_HEADERS([xlocale.h])
113AC_CHECK_FUNCS([iconv pread pwrite lrintf strlcpy daemon dirname basename canonicalize_file_name strcasecmp localtime_r fallocate64 posix_fallocate memmem strsep strtold syslog valloc getpagesize posix_memalign statvfs htonll ntohll mkdtemp uselocale _configthreadlocale strcasestr])
114AC_PROG_INSTALL
115AC_PROG_MAKE_SET
116ACX_PTHREAD
117
118if test "x$ac_cv_func_strtold" != "xyes" ; then
119    CPPFLAGS="$CPPFLAGS -Dstrtold=strtod"
120fi
121
122AC_SEARCH_LIBS(cos, [m])
123AC_SEARCH_LIBS([socket], [socket net])
124AC_SEARCH_LIBS([gethostbyname], [nsl bind])
125AC_SEARCH_LIBS([quotacursor_skipidtype], [quota])
126PKG_CHECK_MODULES(LIBCURL, [libcurl >= $CURL_MINIMUM])
127PKG_CHECK_MODULES(LIBEVENT, [libevent >= $LIBEVENT_MINIMUM])
128PKG_CHECK_MODULES(ZLIB, [zlib >= $ZLIB_MINIMUM])
129
130
131AC_ARG_WITH([crypto], AS_HELP_STRING([--with-crypto=PKG],
132            [Use specified crypto library: auto (default), openssl, cyassl, polarssl]),
133            [want_crypto=$withval], [want_crypto=auto])
134
135AS_IF([test "x$want_crypto" = "xauto" -o "x$want_crypto" = "xopenssl"], [
136    PKG_CHECK_MODULES(OPENSSL, [openssl >= $OPENSSL_MINIMUM],
137        [want_crypto="openssl"; CRYPTO_PKG="openssl"; CRYPTO_CFLAGS="$OPENSSL_CFLAGS"; CRYPTO_LIBS="$OPENSSL_LIBS"],
138        [AS_IF([test "x$want_crypto" = "xopenssl"],
139            [AC_MSG_ERROR([OpenSSL support requested, but library not found.])]
140        )]
141    )
142])
143AS_IF([test "x$want_crypto" = "xauto" -o "x$want_crypto" = "xcyassl"], [
144    PKG_CHECK_MODULES(WOLFSSL, [wolfssl >= $CYASSL_MINIMUM],
145        [want_crypto="cyassl"; CRYPTO_PKG="cyassl"; CRYPTO_CFLAGS="$WOLFSSL_CFLAGS"; CRYPTO_LIBS="$WOLFSSL_LIBS"; CYASSL_IS_WOLFSSL=yes],
146        [PKG_CHECK_MODULES(CYASSL, [cyassl >= $CYASSL_MINIMUM],
147            [want_crypto="cyassl"; CRYPTO_PKG="cyassl"; CRYPTO_CFLAGS="$CYASSL_CFLAGS"; CRYPTO_LIBS="$CYASSL_LIBS"],
148            [AS_IF([test "x$want_crypto" = "xcyassl"],
149                [AC_MSG_ERROR([CyaSSL support requested, but library not found.])]
150            )]
151        )]
152    )
153])
154AS_IF([test "x$want_crypto" = "xauto" -o "x$want_crypto" = "xpolarssl"], [
155    PKG_CHECK_MODULES(MBEDTLS, [mbedtls >= $POLARSSL_MINIMUM],
156        [want_crypto="polarssl"; CRYPTO_PKG="polarssl"; CRYPTO_CFLAGS="$MBEDTLS_CFLAGS"; CRYPTO_LIBS="$MBEDTLS_LIBS"; POLARSSL_IS_MBEDTLS=yes],
157        [AC_CHECK_HEADER([polarssl/version.h],
158            [AC_EGREP_CPP([version_ok], [#include <polarssl/version.h>
159                                         #if defined (POLARSSL_VERSION_NUMBER) && POLARSSL_VERSION_NUMBER >= $POLARSSL_MINIMUM
160                                         version_ok
161                                         #endif],
162                [AC_CHECK_LIB([polarssl], [dhm_calc_secret],
163                    [want_crypto="polarssl"; CRYPTO_PKG="polarssl"; CRYPTO_CFLAGS=""; CRYPTO_LIBS="-lpolarssl"],
164                    [AS_IF([test "x$want_crypto" = "xpolarssl"],
165                        [AC_MSG_ERROR([PolarSSL support requested, but library not found.])]
166                    )]
167                )],
168                [AS_IF([test "x$want_crypto" = "xpolarssl"],
169                    [AC_MSG_ERROR([PolarSSL support requested, but version not suitable.])]
170                )]
171            )],
172            [AS_IF([test "x$want_crypto" = "xpolarssl"],
173                [AC_MSG_ERROR([PolarSSL support requested, but headers not found.])]
174            )]
175        )]
176    )
177])
178# we should have found the library by now
179AS_IF([test "x$CRYPTO_PKG" = "x"], [
180    AS_IF([test "x$want_crypto" = "xauto"],
181        [AC_MSG_ERROR([Unable to find any supported crypto library.])],
182        [AC_MSG_ERROR([Requested crypto library "$want_crypto" is not supported.])],
183    )
184])
185
186AM_CONDITIONAL([CRYPTO_USE_OPENSSL],[test "x$CRYPTO_PKG" = "xopenssl"])
187AM_CONDITIONAL([CRYPTO_USE_CYASSL],[test "x$CRYPTO_PKG" = "xcyassl"])
188AM_CONDITIONAL([CYASSL_IS_WOLFSSL],[test "x$CYASSL_IS_WOLFSSL" = "xyes"])
189AM_CONDITIONAL([CRYPTO_USE_POLARSSL],[test "x$CRYPTO_PKG" = "xpolarssl"])
190AM_CONDITIONAL([POLARSSL_IS_MBEDTLS],[test "x$POLARSSL_IS_MBEDTLS" = "xyes"])
191AC_SUBST(CRYPTO_PKG)
192AC_SUBST(CRYPTO_CFLAGS)
193AC_SUBST(CRYPTO_LIBS)
194
195
196AC_SYS_LARGEFILE
197
198AC_FUNC_GETMNTENT
199
200dnl ----------------------------------------------------------------------------
201dnl
202dnl posix_fadvise
203
204dnl can posix_fadvise be used
205AC_CHECK_DECLS(posix_fadvise, [], [], [
206#define _XOPEN_SOURCE 600
207#include <fcntl.h>])
208AC_CHECK_FUNCS([posix_fadvise])
209
210
211dnl ----------------------------------------------------------------------------
212dnl
213dnl file monitoring for the daemon
214
215AC_ARG_WITH([inotify],
216            [AS_HELP_STRING([--with-inotify], [Enable inotify support (default=auto)])],
217            [WANT_INOTIFY=${withval}],
218            [WANT_INOTIFY=auto])
219HAVE_INOTIFY=0
220AS_IF([test "x$WANT_INOTIFY" != "xno"],
221      [AC_CHECK_HEADER([sys/inotify.h],
222                       [AC_CHECK_FUNC([inotify_init],
223                                      [HAVE_INOTIFY=1])],
224                       [AS_IF([test "x$WANT_INOTIFY" = "xyes"],
225                              [AC_MSG_ERROR("inotify not found!")])])])
226AM_CONDITIONAL([USE_INOTIFY], [test "x$WANT_INOTIFY" != "xno" -a $HAVE_INOTIFY -eq 1])
227
228AC_ARG_WITH([kqueue],
229            [AS_HELP_STRING([--with-kqueue],[Enable kqueue support (default=auto)])],
230            [WANT_KQUEUE=${withval}],
231            [WANT_KQUEUE=auto])
232HAVE_KQUEUE=0
233AS_IF([test "x$WANT_KQUEUE" != "xno"],
234      [AC_CHECK_HEADER([sys/event.h],
235                       [AC_CHECK_FUNC([kqueue],
236                                      [HAVE_KQUEUE=1])],
237                       [AS_IF([test "x$WANT_KQUEUE" = "xyes"],
238                              [AC_MSG_ERROR("kqueue not found!")])])])
239AM_CONDITIONAL([USE_KQUEUE], [test "x$WANT_KQUEUE" != "xno" -a $HAVE_KQUEUE -eq 1])
240
241
242AC_CHECK_HEADERS([sys/statvfs.h \
243                  xfs/xfs.h])
244
245
246dnl ----------------------------------------------------------------------------
247dnl
248dnl file monitoring for the daemon
249
250# Check whether to enable systemd startup notification.
251# This requires libsystemd.
252AC_ARG_WITH([systemd], AS_HELP_STRING([--with-systemd],
253            [Add support for systemd startup notification (default is autodetected)]),
254            [USE_SYSTEMD=$withval], [USE_SYSTEMD=auto])
255AS_IF([test "x$USE_SYSTEMD" != "xno"], [
256    PKG_CHECK_MODULES([SYSTEMD], [libsystemd],
257        [AC_DEFINE(USE_SYSTEMD,1,[Use systemd startup notification])],
258        [AS_IF([test "x$USE_SYSTEMD" = "xyes"],
259            [AC_MSG_ERROR([systemd startup notification support requested, but libsystemd not found.])]
260        )]
261    )
262])
263
264
265dnl ----------------------------------------------------------------------------
266dnl
267dnl  dht
268
269DHT_CFLAGS="-I\$(top_builddir)/third-party/dht/include"
270DHT_LIBS="\$(top_builddir)/third-party/dht/libdht.a"
271DHT_LIBS_QT="\$\${TRANSMISSION_TOP}/third-party/dht/libdht.a"
272build_bundled_dht="yes"
273AC_ARG_ENABLE([external-dht],
274              AS_HELP_STRING([--enable-external-dht],[Use system external-dht]),
275              [want_external_dht=${enableval}],
276              [want_external_dht=no])
277if test "x$want_external_dht" != "xno" ; then
278       dnl Would be lovely if it had pkgconfig
279       DHT_CFLAGS=""
280       DHT_LIBS="-ldht"
281       DHT_LIBS_QT="-ldht"
282       build_bundled_dht="no"
283fi
284
285AM_CONDITIONAL([BUILD_DHT],[test "x$build_bundled_dht" = "xyes"])
286AC_SUBST(DHT_CFLAGS)
287AC_SUBST(DHT_LIBS)
288AC_SUBST(DHT_LIBS_QT)
289
290
291dnl ----------------------------------------------------------------------------
292dnl
293dnl  libb64
294
295LIBB64_CFLAGS="-I\$(top_srcdir)/third-party/libb64/include"
296LIBB64_LIBS="\$(top_builddir)/third-party/libb64/libb64.a"
297LIBB64_LIBS_QT="\$\${TRANSMISSION_TOP}/third-party/libb64/libb64.a"
298build_bundled_b64="yes"
299AC_ARG_ENABLE([external-b64],
300              AS_HELP_STRING([--enable-external-b64],[Use system libb64]),
301              [want_external_b64=${enableval}],
302              [want_external_b64=no])
303if test "x$want_external_b64" != "xno" ; then
304    LIBB64_CFLAGS="-DUSE_SYSTEM_B64"
305    LIBB64_LIBS="-lb64"
306    LIBB64_LIBS_QT="-lb64"
307    build_bundled_b64="no"
308fi
309
310AM_CONDITIONAL([BUILD_B64],[test "x$build_bundled_b64" = "xyes"])
311AC_SUBST(LIBB64_CFLAGS)
312AC_SUBST(LIBB64_LIBS)
313AC_SUBST(LIBB64_LIBS_QT)
314
315
316dnl ----------------------------------------------------------------------------
317dnl
318dnl  utp
319
320AC_CHECK_LIB([rt],
321             [clock_gettime],
322             [libutp_extra_libs="-lrt"],
323             [libutp_extra_libs=""])
324
325AC_MSG_CHECKING([µTP])
326build_utp="no"
327
328ac_save_LIBS="$LIBS"
329LIBS="-lutp"
330AC_LINK_IFELSE(
331  [AC_LANG_PROGRAM([#include <libutp/utp.h>],
332                   [struct UTPFunctionTable func;])],
333  [have_utp="yes"],
334  [have_utp="no"]
335)
336LIBS="$ac_save_LIBS"
337
338if test "x$have_utp" = "xyes" -o "x$CXX" != "x"; then
339    want_utp_default="yes"
340else
341    want_utp_default="no"
342fi
343
344AC_ARG_ENABLE([utp],
345              AS_HELP_STRING([--enable-utp],[build µTP support]),
346              [want_utp=${enableval}],
347              [want_utp=${want_utp_default}])
348if test "x$want_utp" = "xyes"; then
349    if test "x$have_utp" = "xyes"; then
350        dnl Would be lovely if it had pkgconfig
351        LIBUTP_CFLAGS=""
352        LIBUTP_LIBS="-lutp $libutp_extra_libs"
353        LIBUTP_LIBS_QT="-lutp $libutp_extra_libs"
354        AC_DEFINE([WITH_UTP],[1])
355        build_utp="system"
356    elif test "x$CXX" != "x"; then
357        LIBUTP_CFLAGS="-I\$(top_builddir)/third-party/libutp/include"
358        LIBUTP_LIBS="\$(top_builddir)/third-party/libutp/libutp.a"
359        LIBUTP_LIBS_QT="\$\${TRANSMISSION_TOP}/third-party/libutp/libutp.a"
360        if test "x$libutp_extra_libs" != "x" ; then
361            LIBUTP_LIBS="$LIBUTP_LIBS $libutp_extra_libs"
362            LIBUTP_LIBS_QT="$LIBUTP_LIBS_QT $libutp_extra_libs"
363        fi
364        AC_DEFINE([WITH_UTP],[1])
365        build_utp="yes"
366    else
367      AC_MSG_ERROR("Unable to build uTP support -- C++ compiler not found")
368    fi
369fi
370AC_SUBST(LIBUTP_CFLAGS)
371AC_SUBST(LIBUTP_LIBS)
372AC_SUBST(LIBUTP_LIBS_QT)
373AM_CONDITIONAL([BUILD_UTP],[test "x$build_utp" = "xyes"])
374AC_MSG_RESULT([$build_utp])
375
376
377dnl
378dnl  look for preinstalled miniupnpc...
379dnl
380
381ac_save_LIBS="$LIBS"
382LIBS="-lminiupnpc"
383AC_MSG_CHECKING([system miniupnpc library])
384
385dnl See if ANY version of miniupnpc is installed
386AC_LINK_IFELSE(
387  [AC_LANG_PROGRAM([#include <miniupnpc/miniupnpc.h>],
388                   [struct UPNPDev dev;])],
389  [upnp_version="unknown"],
390  [upnp_version="none"]
391)
392
393dnl Let's hope it's 1.7 or higher, since it provides
394dnl MINIUPNPC_API_VERSION and we won't have to figure
395dnl it out on our own
396if test "x$upnp_version" = "xunknown" ; then
397  AC_COMPILE_IFELSE(
398    [AC_LANG_PROGRAM(
399      [#include <stdlib.h>
400       #include <miniupnpc/miniupnpc.h>],
401      [#ifndef MINIUPNPC_API_VERSION
402       #error MINIUPNPC_API_VERSION undefined
403       #endif]
404    )],
405    [upnp_version=">= 1.7"]
406  )
407fi
408
409dnl Or maybe it's miniupnp 1.6
410if test "x$upnp_version" = "xunknown" ; then
411  AC_LINK_IFELSE([AC_LANG_PROGRAM([[
412    #include <stdlib.h>
413    #include <errno.h>
414    #include <miniupnpc/miniupnpc.h>
415    #include <miniupnpc/upnpcommands.h>
416  ]], [[
417    struct UPNPDev * devlist;
418    struct UPNPUrls urls;
419    struct IGDdatas data;
420    char lanaddr[16];
421    char portStr[8];
422    char intPort[8];
423    char intClient[16];
424    upnpDiscover( 2000, NULL, NULL, 0, 0, &errno );
425    UPNP_GetValidIGD( devlist, &urls, &data, lanaddr, sizeof( lanaddr ) );
426    UPNP_GetSpecificPortMappingEntry( urls.controlURL, data.first.servicetype,
427                        portStr, "TCP", intClient, intPort, NULL, NULL, NULL );
428  ]])],[
429  AC_DEFINE(MINIUPNPC_API_VERSION, 8, [miniupnpc 1.6 has API version 8])
430  upnp_version="1.6"])
431fi
432
433dnl Or maybe it's miniupnp 1.5
434if test "x$upnp_version" = "xunknown" ; then
435  AC_LINK_IFELSE([AC_LANG_PROGRAM([[
436    #include <stdlib.h>
437    #include <miniupnpc/miniupnpc.h>
438    #include <miniupnpc/upnpcommands.h>
439  ]], [[
440    struct UPNPDev * devlist;
441    struct UPNPUrls urls;
442    struct IGDdatas data;
443    char lanaddr[16];
444    char portStr[8];
445    char intPort[8];
446    char intClient[16];
447    upnpDiscover( 2000, NULL, NULL, 0 );
448    UPNP_GetValidIGD( devlist, &urls, &data, lanaddr, sizeof( lanaddr ) );
449    UPNP_GetSpecificPortMappingEntry( urls.controlURL, data.first.servicetype,
450                        portStr, "TCP", intClient, intPort );
451  ]])],[
452  AC_DEFINE(MINIUPNPC_API_VERSION, 5, [miniupnpc 1.5 has API version 5])
453  upnp_version="1.5"])
454fi
455
456# ... and the results of our tests
457LIBS="$ac_save_LIBS"
458AC_MSG_RESULT([$upnp_version])
459AM_CONDITIONAL([BUILD_MINIUPNP],[test "x$upnp_version" = "xnone"])
460if test "x$upnp_version" = "xnone" ; then
461    LIBUPNP_CFLAGS="-I\$(top_builddir)/third-party/miniupnpc/include"
462    LIBUPNP_LIBS="\$(top_builddir)/third-party/miniupnpc/libminiupnp.a"
463    LIBUPNP_LIBS_QT="\$\${TRANSMISSION_TOP}/third-party/miniupnpc/libminiupnp.a"
464else
465    AC_DEFINE([SYSTEM_MINIUPNP])
466    LIBUPNP_CFLAGS=""
467    LIBUPNP_LIBS="-lminiupnpc"
468    LIBUPNP_LIBS_QT="-lminiupnpc"
469fi
470AC_SUBST(LIBUPNP_CFLAGS)
471AC_SUBST(LIBUPNP_LIBS)
472AC_SUBST(LIBUPNP_LIBS_QT)
473
474
475
476
477dnl ----------------------------------------------------------------------------
478dnl
479dnl  Allow usage of system natpmp library
480
481LIBNATPMP_CFLAGS="-I\$(top_srcdir)/third-party/libnatpmp/"
482LIBNATPMP_LIBS="\$(top_builddir)/third-party/libnatpmp/libnatpmp.a"
483LIBNATPMP_LIBS_QT="\$\${TRANSMISSION_TOP}/third-party/libnatpmp/libnatpmp.a"
484build_bundled_natpmp="yes"
485AC_ARG_ENABLE([external-natpmp],
486              AS_HELP_STRING([--enable-external-natpmp],[Use system external-natpmp]),
487              [want_external_natpmp=${enableval}],
488              [want_external_natpmp=no])
489if test "x$want_external_natpmp" != "xno" ; then
490	dnl Would be lovely if it had pkgconfig
491	LIBNATPMP_CFLAGS=""
492	LIBNATPMP_LIBS="-lnatpmp"
493	LIBNATPMP_LIBS_QT="-lnatpmp"
494	build_bundled_natpmp="no"
495fi
496AM_CONDITIONAL([BUILD_NATPMP],[test "x$build_bundled_natpmp" = "xyes"])
497AC_SUBST(LIBNATPMP_CFLAGS)
498AC_SUBST(LIBNATPMP_LIBS)
499AC_SUBST(LIBNATPMP_LIBS_QT)
500
501
502dnl ----------------------------------------------------------------------------
503dnl
504dnl  detection for the GTK+ client
505
506AC_ARG_ENABLE([nls],
507              [AS_HELP_STRING([--enable-nls],[enable native language support])],,
508              [enable_nls=yes])
509PKG_CHECK_EXISTS([gtk+-3.0 >= $GTK_MINIMUM
510                  glib-2.0 >= $GLIB_MINIMUM
511                  gio-2.0 >= $GIO_MINIMUM,
512                  gmodule-2.0 >= $GLIB_MINIMUM
513                  gthread-2.0 >= $GLIB_MINIMUM],
514                 [have_gtk=yes],
515                 [have_gtk=no])
516AC_ARG_WITH([gtk], AS_HELP_STRING([--with-gtk],[with Gtk]),
517            [with_gtk=$withval],
518            [with_gtk=$have_gtk])
519AM_CONDITIONAL([BUILD_GTK],[test "x$with_gtk" = "xyes"])
520use_libappindicator=no
521if test "x$with_gtk" = "xyes" ; then
522
523    if test "x$enable_nls" = "xno" ; then
524        AC_MSG_ERROR("The gtk client cannot be built without nls support.  Try adding either --enable-nls or --without-gtk" )
525    fi
526
527    PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= $GTK_MINIMUM
528                              glib-2.0 >= $GLIB_MINIMUM
529                              gio-2.0 >= $GIO_MINIMUM,
530                              gmodule-2.0 >= $GLIB_MINIMUM
531                              gthread-2.0 >= $GLIB_MINIMUM])
532    PKG_CHECK_MODULES([LIBAPPINDICATOR],
533                      [appindicator3-0.1 >= $LIBAPPINDICATOR_MINIMUM],
534                      [have_libappindicator=yes],
535                      [have_libappindicator=no])
536    if test "x$have_libappindicator" = "xyes"; then
537        use_libappindicator=yes
538        AC_DEFINE([HAVE_LIBAPPINDICATOR], 1)
539    else
540        LIBAPPINDICATOR_CFLAGS=
541        LIBAPPINDICATOR_LIBS=
542    fi
543fi
544
545dnl This section is only used for internationalization.
546dnl If you don't need translations and this section gives you trouble --
547dnl such as if you're building for a headless system --
548dnl it's okay to tear this section out and re-build the configure script.
549dnl
550dnl Note to packagers: the bump to intltool 0.40 was made to fix
551dnl a "make check" failure on some systems.  if upgrading to 0.40 is
552dnl a problem and the old version was working fine for you,
553dnl it should be safe to re-edit 0.40 back down to 0.23
554
555use_nls=no
556if test "x$enable_nls" = "xyes" ; then
557    use_nls=yes
558    m4_ifdef([IT_PROG_INTLTOOL],
559             [IT_PROG_INTLTOOL([0.35.0],[no-xml])],
560             [AC_MSG_ERROR("--enable-nls requires intltool to be installed.")])
561    AC_CHECK_HEADERS([libintl.h])
562    GETTEXT_PACKAGE=transmission-gtk
563    AC_SUBST(GETTEXT_PACKAGE)
564    AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[Gettext package])
565    AM_GLIB_GNU_GETTEXT
566    transmissionlocaledir='${prefix}/${DATADIRNAME}/locale'
567    AC_SUBST(transmissionlocaledir)
568fi
569AC_SUBST(INTLLIBS)
570
571
572dnl ----------------------------------------------------------------------------
573dnl
574dnl  platform-specific stuff.
575
576AC_CANONICAL_HOST
577have_darwin="no"
578have_msw="no"
579case $host_os in
580
581   *mingw32*)
582     have_msw="yes"
583     CXXFLAGS="$CXXFLAGS -mms-bitfields -mwin32 -mwindows"
584     CPPFLAGS="$CPPFLAGS -DWINVER=0x0600 -D_WIN32_WINNT=0x0600 -DWIN32_LEAN_AND_MEAN"
585     # CPPFLAGS="$CPPFLAGS -D__USE_MINGW_ANSI_STDIO=1 -D__STDC_FORMAT_MACROS=1"
586     LIBS="$LIBS -liphlpapi -lshell32 -lws2_32"
587     transmissionlocaledir="locale"
588     if test -z "$host_alias"; then
589       hostaliaswindres=
590     else
591       hostaliaswindres="$host_alias-windres";
592     fi
593     AC_CHECK_TOOL(WINDRES, windres)
594     ;;
595
596  *darwin*)
597    have_darwin="yes"
598    ;;
599
600esac
601
602AC_ARG_ENABLE([lightweight],
603              AS_HELP_STRING([--enable-lightweight],[optimize libtransmission for low-resource systems: smaller cache size, prefer unencrypted peer connections, etc.]),
604              [enable_lightweight=${enableval}],
605              [enable_lightweight="no"])
606if test "x$enable_lightweight" = "xyes" ; then
607  AC_DEFINE([TR_LIGHTWEIGHT],[1],[optimize libtransmission for low-resource systems])
608fi
609
610AC_ARG_ENABLE([cli],
611              [AS_HELP_STRING([--enable-cli],[build command-line client])],
612              [build_cli=${enableval}],
613              [build_cli="no"])
614AM_CONDITIONAL([BUILD_CLI],[test "x$build_cli" = "xyes"])
615
616AC_ARG_ENABLE([mac],
617              [AS_HELP_STRING([--enable-mac],[build Mac client])],
618              [build_mac=${enableval}],
619              [build_mac=${have_darwin}])
620AM_CONDITIONAL([BUILD_MAC],[test "x$build_mac" = "xyes"])
621
622AC_ARG_ENABLE([daemon],
623              [AS_HELP_STRING([--enable-daemon],[build daemon])],
624              [build_daemon=${enableval}],
625              [build_daemon="yes"])
626AM_CONDITIONAL([BUILD_DAEMON],[test "x$build_daemon" = "xyes"])
627
628
629if test "x$build_mac" = "xyes" ; then
630   AC_DEFINE([BUILD_MAC_CLIENT], 1)
631    # Make sure the proper Mac SDK is installed
632    if test ! -d /Developer/SDKs/MacOSX10.5.sdk; then
633      cat << EOF
634You need to install the Mac OS X 10.5 SDK in order to build Transmission
635with --enable-mac:
636  Get your Xcode CD or package
637  Restart the install
638  When it gets to "Installation Type", select "Customize"
639  Select "Mac OS X 10.5 SDK" under "Cross Development"
640  Finish the install.
641EOF
642      exit 1
643    fi
644fi
645AM_CONDITIONAL(WIN32, test "x$have_msw" = "xyes")
646
647dnl ----------------------------------------------------------------------------
648dnl
649dnl  Generate the output
650
651AC_CONFIG_FILES([Makefile
652                 transmission-gtk.spec
653                 cli/Makefile
654                 daemon/Makefile
655                 extras/Makefile
656                 libtransmission/Makefile
657                 utils/Makefile
658                 third-party/Makefile
659                 third-party/dht/Makefile
660                 third-party/libb64/Makefile
661                 third-party/libutp/Makefile
662                 third-party/libnatpmp/Makefile
663                 third-party/miniupnpc/Makefile
664                 macosx/Makefile
665                 gtk/Makefile
666                 gtk/icons/Makefile
667                 qt/config.pri
668                 web/Makefile
669                 web/images/Makefile
670                 web/style/Makefile
671                 web/style/jqueryui/Makefile
672                 web/style/jqueryui/images/Makefile
673                 web/style/transmission/Makefile
674                 web/style/transmission/images/Makefile
675                 web/style/transmission/images/buttons/Makefile
676                 web/javascript/Makefile
677                 web/javascript/jquery/Makefile
678                 po/Makefile.in])
679
680AC_OUTPUT
681
682echo "
683
684Configuration:
685
686   Source code location:                              ${srcdir}
687   Compiler:                                          ${CXX}
688
689   Build libtransmission:                             yes
690      * optimized for low-resource systems:           ${enable_lightweight}
691      * µTP enabled:                                  ${build_utp}
692      * crypto library:                               ${CRYPTO_PKG}
693
694   Build Command-Line client:                         ${build_cli}
695
696   Build GTK+ client:                                 ${with_gtk}
697      * libappindicator for an Ubuntu-style tray:     ${use_libappindicator}
698
699   Build Daemon:                                      ${build_daemon}
700
701   Build Mac client:                                  ${build_mac}
702
703"
704