source: trunk/configure.ac @ 13408

Last change on this file since 13408 was 13408, checked in by livings124, 9 years ago

update to 2.61+

File size: 17.2 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.61+])
7m4_define([peer_id_prefix],[-TR261Z-])
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-pax])
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##
53
54GTK_MINIMUM=3.2.0
55AC_SUBST(GTK_MINIMUM)
56GLIB_MINIMUM=2.32.0
57AC_SUBST(GLIB_MINIMUM)
58GIO_MINIMUM=2.26.0
59AC_SUBST(GIO_MINIMUM)
60
61##
62##
63##   OPTIONAL for the GTK+ client
64##
65##
66
67# create the tray icon with AppIndicator
68LIBAPPINDICATOR_MINIMUM=0.4.90
69AC_SUBST(LIBAPPINDICATOR_MINIMUM)
70
71
72AC_PROG_CC
73AC_PROG_CXX
74if test "x$CXX" != "x"; then # CXX is set...
75  if test -f "$CXX"; then # maybe it's an absolute path passed in env variables...
76    AC_MSG_CHECKING([for $CXX])
77    HAVE_CXX="yes"
78    AC_MSG_RESULT([$HAVE_CXX])
79  else
80    AC_CHECK_PROG([HAVE_CXX],[$CXX],[yes],[no])
81  fi
82fi
83AC_C_INLINE
84if test "x$GCC" = "xyes" ; then
85
86    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"
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 -Wdeclaration-after-statement -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_HEADER_STDC
107AC_HEADER_TIME
108
109AC_CHECK_HEADERS([stdbool.h])
110AC_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 htonll ntohll mkdtemp])
111AC_PROG_INSTALL
112AC_PROG_MAKE_SET
113ACX_PTHREAD
114
115if test "x$ac_cv_func_strtold" != "xyes" ; then
116    CPPFLAGS="$CPPFLAGS -Dstrtold=strtod"
117fi
118
119AC_SEARCH_LIBS(cos, [m])
120AC_SEARCH_LIBS([socket], [socket net])
121AC_SEARCH_LIBS([gethostbyname], [nsl bind])
122PKG_CHECK_MODULES(OPENSSL, [openssl >= $OPENSSL_MINIMUM], , [CHECK_SSL()])
123PKG_CHECK_MODULES(LIBCURL, [libcurl >= $CURL_MINIMUM])
124PKG_CHECK_MODULES(LIBEVENT, [libevent >= $LIBEVENT_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([sys/statvfs.h \
177                  xfs/xfs.h])
178
179
180dnl ----------------------------------------------------------------------------
181dnl
182dnl va_copy
183
184AC_MSG_CHECKING([how to copy va_list])
185AC_TRY_LINK([#include <stdarg.h>], [va_list ap1, ap2; va_copy(ap1, ap2);],
186    AC_MSG_RESULT([va_copy]),
187        [ AH_TEMPLATE([va_copy], [define if va_copy is not available])
188        AC_TRY_LINK([#include <stdarg.h>], [va_list ap1, ap2; __va_copy(ap1, ap2);],
189        [ AC_DEFINE([va_copy], [__va_copy])
190        AC_MSG_RESULT([__va_copy])],
191        [ AC_DEFINE([va_copy(dest,src)], [memcpy(&dest,&src,sizeof(va_list))])
192        AC_MSG_RESULT([memcpy])]
193    )
194])
195
196
197dnl ----------------------------------------------------------------------------
198dnl
199dnl  dht
200
201DHT_CFLAGS="-I\$(top_srcdir)/third-party/dht"
202DHT_LIBS="\$(top_builddir)/third-party/dht/libdht.a"
203AC_SUBST(DHT_CFLAGS)
204AC_SUBST(DHT_LIBS)
205
206
207dnl ----------------------------------------------------------------------------
208dnl
209dnl  utp
210
211AC_CHECK_LIB([rt],
212             [clock_gettime],
213             [libutp_extra_libs="-lrt"],
214             [libutp_extra_libs=""])
215
216AC_MSG_CHECKING([µTP])
217build_utp="no"
218if test "x$HAVE_CXX" = "xyes" ; then
219    have_utp="yes"
220else
221    have_utp="no"
222fi
223AC_ARG_ENABLE([utp],
224              AS_HELP_STRING([--enable-utp],[build µTP support]),
225              [want_utp=${enableval}],
226              [want_utp=${have_utp}])
227if test "x$want_utp" = "xyes" ; then
228    if test "x$have_utp" = "xyes"; then
229        LIBUTP_CFLAGS="-I\$(top_srcdir)/third-party/"
230        LIBUTP_LIBS="\$(top_builddir)/third-party/libutp/libutp.a"
231        LIBUTP_LIBS_QT="\$\${TRANSMISSION_TOP}/third-party/libutp/libutp.a"
232        if test "x$libutp_extra_libs" != "x" ; then
233            LIBUTP_LIBS="$LIBUTP_LIBS $libutp_extra_libs"
234            LIBUTP_LIBS_QT="$LIBUTP_LIBS_QT $libutp_extra_libs"
235        fi
236        AC_DEFINE([WITH_UTP],[1])
237        build_utp="yes"
238    else
239      AC_MSG_ERROR("Unable to build uTP support -- C++ compiler not found")
240    fi
241fi
242AC_SUBST(LIBUTP_CFLAGS)
243AC_SUBST(LIBUTP_LIBS)
244AC_SUBST(LIBUTP_LIBS_QT)
245AM_CONDITIONAL([BUILD_UTP],[test "x$build_utp" = "xyes"])
246AC_MSG_RESULT([$build_utp])
247
248
249dnl
250dnl  look for preinstalled miniupnpc...
251dnl
252
253AC_MSG_CHECKING([supported miniupnp library])
254upnp_version="none"
255ac_save_LIBS="$LIBS"
256LIBS="-lminiupnpc"
257# See if the OS has its miniupnp 1.5 installed
258AC_TRY_LINK([
259    #include <stdlib.h>
260    #include <miniupnpc/miniupnpc.h>
261    #include <miniupnpc/upnpcommands.h>
262],[
263    struct UPNPDev * devlist;
264    struct UPNPUrls    urls;
265    struct IGDdatas    data;
266    char lanaddr[16];
267    char portStr[8];
268    char intPort[8];
269    char intClient[16];
270    upnpDiscover( 2000, NULL, NULL, 0 );
271    UPNP_GetValidIGD( devlist, &urls, &data, lanaddr, sizeof( lanaddr ) );
272    UPNP_GetSpecificPortMappingEntry( urls.controlURL, data.first.servicetype,
273                        portStr, "TCP", intClient, intPort );
274],[
275AC_DEFINE(HAVE_MINIUPNP_15, 1, [Define to 1 if you have miniupnpc version 1.5])
276upnp_version="1.5"])
277
278# See if the OS has its miniupnp 1.6 installed
279AC_TRY_LINK([
280    #include <stdlib.h>
281    #include <errno.h>
282    #include <miniupnpc/miniupnpc.h>
283    #include <miniupnpc/upnpcommands.h>
284],[
285    struct UPNPDev * devlist;
286    struct UPNPUrls    urls;
287    struct IGDdatas    data;
288    char lanaddr[16];
289    char portStr[8];
290    char intPort[8];
291    char intClient[16];
292    upnpDiscover( 2000, NULL, NULL, 0, 0, &errno );
293    UPNP_GetValidIGD( devlist, &urls, &data, lanaddr, sizeof( lanaddr ) );
294    UPNP_GetSpecificPortMappingEntry( urls.controlURL, data.first.servicetype,
295                        portStr, "TCP", intClient, intPort, NULL, NULL, NULL );
296],[
297AC_DEFINE(HAVE_MINIUPNP_16, 1, [Define to 1 if you have miniupnpc version 1.6])
298upnp_version="1.6"])
299
300# ... and the results of our tests
301LIBS="$ac_save_LIBS"
302AC_MSG_RESULT([$upnp_version])
303AM_CONDITIONAL([BUILD_MINIUPNP],[test "x$upnp_version" = "xnone"])
304if test "x$upnp_version" = "xnone" ; then
305    LIBUPNP_CFLAGS="-I\$(top_srcdir)/third-party/"
306    LIBUPNP_LIBS="\$(top_builddir)/third-party/miniupnp/libminiupnp.a"
307    LIBUPNP_LIBS_QT="\$\${TRANSMISSION_TOP}/third-party/miniupnp/libminiupnp.a"
308    dnl because this is the version that we bundle...
309    AC_DEFINE(HAVE_MINIUPNP_16, 1, [Define to 1 if you have miniupnpc version 1.6])
310else
311    AC_DEFINE([SYSTEM_MINIUPNP])
312    LIBUPNP_CFLAGS=""
313    LIBUPNP_LIBS="-lminiupnpc"
314    LIBUPNP_LIBS_QT="-lminiupnpc"
315fi
316AC_SUBST(LIBUPNP_CFLAGS)
317AC_SUBST(LIBUPNP_LIBS)
318AC_SUBST(LIBUPNP_LIBS_QT)
319
320
321 
322
323dnl ----------------------------------------------------------------------------
324dnl
325dnl  Allow usage of system natpmp library
326
327LIBNATPMP_CFLAGS="-I\$(top_srcdir)/third-party/libnatpmp/"
328LIBNATPMP_LIBS="\$(top_builddir)/third-party/libnatpmp/libnatpmp.a"
329LIBNATPMP_LIBS_QT="\$\${TRANSMISSION_TOP}/third-party/libnatpmp/libnatpmp.a"
330build_bundled_natpmp="yes"
331AC_ARG_ENABLE([external-natpmp],
332              AS_HELP_STRING([--enable-external-natpmp],[Use system external-natpmp]),
333              [want_external_natpmp=${enableval}],
334              [want_external_natpmp=no])
335if test "x$want_external_natpmp" != "xno" ; then
336        dnl Would be lovely if it had pkgconfig
337        LIBNATPMP_CFLAGS="" 
338        LIBNATPMP_LIBS="-lnatpmp"
339        LIBNATPMP_LIBS_QT="-lnatpmp"
340        build_bundled_natpmp="no"
341fi
342AM_CONDITIONAL([BUILD_NATPMP],[test "x$build_bundled_natpmp" = "xyes"])
343AC_SUBST(LIBNATPMP_CFLAGS)
344AC_SUBST(LIBNATPMP_LIBS)
345AC_SUBST(LIBNATPMP_LIBS_QT)
346
347
348dnl ----------------------------------------------------------------------------
349dnl
350dnl  detection for the GTK+ client
351
352AC_ARG_ENABLE([nls],
353              [AS_HELP_STRING([--enable-nls],[enable native language support])],,
354              [enable_nls=yes])
355PKG_CHECK_EXISTS([gtk+-3.0 >= $GTK_MINIMUM
356                  glib-2.0 >= $GLIB_MINIMUM
357                  gio-2.0 >= $GIO_MINIMUM,
358                  gmodule-2.0 >= $GLIB_MINIMUM
359                  gthread-2.0 >= $GLIB_MINIMUM],
360                 [have_gtk=yes],
361                 [have_gtk=no])
362AC_ARG_WITH([gtk], AC_HELP_STRING([--with-gtk],[with Gtk]),
363            [with_gtk=$withval],
364            [with_gtk=$have_gtk])
365AM_CONDITIONAL([BUILD_GTK],[test "x$with_gtk" = "xyes"])
366use_libappindicator=no
367if test "x$with_gtk" = "xyes" ; then
368
369    if test "x$enable_nls" = "xno" ; then
370        AC_MSG_ERROR("The gtk client cannot be built without nls support.  Try adding either --enable-nls or --without-gtk" )
371    fi
372
373    PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= $GTK_MINIMUM
374                              glib-2.0 >= $GLIB_MINIMUM
375                              gio-2.0 >= $GIO_MINIMUM,
376                              gmodule-2.0 >= $GLIB_MINIMUM
377                              gthread-2.0 >= $GLIB_MINIMUM])
378    PKG_CHECK_MODULES([LIBAPPINDICATOR],
379                      [appindicator3-0.1 >= $LIBAPPINDICATOR_MINIMUM],
380                      [have_libappindicator=yes],
381                      [have_libappindicator=no])
382    if test "x$have_libappindicator" = "xyes"; then
383        use_libappindicator=yes
384        AC_DEFINE([HAVE_LIBAPPINDICATOR], 1)
385    else
386        LIBAPPINDICATOR_CFLAGS=
387        LIBAPPINDICATOR_LIBS=
388    fi
389fi
390
391dnl This section is only used for internationalization.
392dnl If you don't need translations and this section gives you trouble --
393dnl such as if you're building for a headless system --
394dnl it's okay to tear this section out and re-build the configure script.
395dnl
396dnl Note to packagers: the bump to intltool 0.40 was made to fix
397dnl a "make check" failure on some systems.  if upgrading to 0.40 is
398dnl a problem and the old version was working fine for you,
399dnl it should be safe to re-edit 0.40 back down to 0.23
400
401use_nls=no
402if test "x$enable_nls" = "xyes" ; then
403    use_nls=yes
404    m4_ifdef([IT_PROG_INTLTOOL],
405             [IT_PROG_INTLTOOL([0.35.0],[no-xml])],
406             [AC_MSG_ERROR("--enable-nls requires intltool to be installed.")])
407    AC_CHECK_HEADERS([libintl.h])
408    GETTEXT_PACKAGE=transmission-gtk
409    AC_SUBST(GETTEXT_PACKAGE)
410    AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[Gettext package])
411    AM_GLIB_GNU_GETTEXT
412    transmissionlocaledir='${prefix}/${DATADIRNAME}/locale'
413    AC_SUBST(transmissionlocaledir)
414fi
415AC_SUBST(INTLLIBS)
416
417
418dnl ----------------------------------------------------------------------------
419dnl
420dnl  platform-specific stuff.
421
422AC_CANONICAL_HOST
423have_darwin="no"
424have_msw="no"
425case $host_os in
426
427   *mingw32*)
428     have_msw="yes"
429     CXXFLAGS="$CXXFLAGS -mms-bitfields -mwin32 -mwindows"
430     CPPFLAGS="$CPPFLAGS -DWIN32 -D_WIN32 -DWIN32_LEAN_AND_MEAN"
431     LIBS="$LIBS -liphlpapi -lshell32 -lws2_32"
432     transmissionlocaledir="locale"
433     if test -z "$host_alias"; then
434       hostaliaswindres=
435     else
436       hostaliaswindres="$host_alias-windres";
437     fi
438     AC_CHECK_TOOL(WINDRES, windres)
439     ;;
440
441  *darwin*)
442    have_darwin="yes"
443    CFLAGS="-DMACOSX $CFLAGS"
444    ;;
445
446esac
447
448AC_ARG_ENABLE([lightweight],
449              AS_HELP_STRING([--enable-lightweight],[optimize libtransmission for low-resource systems: smaller cache size, prefer unencrypted peer connections, etc.]),
450              [enable_lightweight=${enableval}],
451              [enable_lightweight="no"])
452if test "x$enable_lightweight" = "xyes" ; then
453  AC_DEFINE([TR_LIGHTWEIGHT],[1],[optimize libtransmission for low-resource systems])
454fi
455
456AC_ARG_ENABLE([cli],
457              [AS_HELP_STRING([--enable-cli],[build command-line client])],
458              [build_cli=${enableval}],
459              [build_cli="yes"])
460AM_CONDITIONAL([BUILD_CLI],[test "x$build_cli" = "xyes"])
461
462AC_ARG_ENABLE([mac],
463              [AS_HELP_STRING([--enable-mac],[build Mac client])],
464              [build_mac=${enableval}],
465              [build_mac=${have_darwin}])
466AM_CONDITIONAL([BUILD_MAC],[test "x$build_mac" = "xyes"])
467
468AC_ARG_ENABLE([daemon],
469              [AS_HELP_STRING([--enable-daemon],[build daemon])],
470              [build_daemon=${enableval}],
471              [build_daemon="yes"])
472AM_CONDITIONAL([BUILD_DAEMON],[test "x$build_daemon" = "xyes"])
473
474
475if test "x$build_mac" = "xyes" ; then
476    # Make sure the proper Mac SDK is installed
477    if test ! -d /Developer/SDKs/MacOSX10.5.sdk; then
478      cat << EOF
479You need to install the Mac OS X 10.5 SDK in order to build Transmission
480with --enable-mac:
481  Get your Xcode CD or package
482  Restart the install
483  When it gets to "Installation Type", select "Customize"
484  Select "Mac OS X 10.5 SDK" under "Cross Development"
485  Finish the install.
486EOF
487      exit 1
488    fi
489fi
490if test "x$have_darwin" = "xyes"; then
491    AC_DEFINE([HAVE_DARWIN], 1)
492fi
493if test "x$have_msw" = "xyes"; then
494    AC_DEFINE([HAVE_MSW], 1)
495fi
496AM_CONDITIONAL(WIN32, test "x$have_msw" = "xyes")
497
498dnl ----------------------------------------------------------------------------
499dnl
500dnl  Generate the output
501
502AC_CONFIG_FILES([Makefile
503                 transmission-gtk.spec
504                 cli/Makefile
505                 daemon/Makefile
506                 extras/Makefile
507                 libtransmission/Makefile
508                 utils/Makefile
509                 third-party/Makefile
510                 third-party/dht/Makefile
511                 third-party/libutp/Makefile
512                 third-party/libnatpmp/Makefile
513                 third-party/miniupnp/Makefile
514                 macosx/Makefile
515                 gtk/Makefile
516                 gtk/icons/Makefile
517                 qt/config.pri
518                 web/Makefile
519                 web/images/Makefile
520                 web/style/Makefile
521                 web/style/jqueryui/Makefile
522                 web/style/jqueryui/images/Makefile
523                 web/style/transmission/Makefile
524                 web/style/transmission/images/Makefile
525                 web/style/transmission/images/buttons/Makefile
526                 web/javascript/Makefile
527                 web/javascript/jquery/Makefile
528                 po/Makefile.in])
529
530AC_OUTPUT
531
532echo "
533
534Configuration:
535
536   Source code location:                              ${srcdir}
537   Compiler:                                          ${CXX}
538
539   Build libtransmission:                             yes
540      * optimized for low-resource systems:           ${enable_lightweight}
541      * µTP enabled:                                  ${build_utp}
542
543   Build Command-Line client:                         ${build_cli}
544
545   Build GTK+ client:                                 ${with_gtk}
546      * libappindicator for an Ubuntu-style tray:     ${use_libappindicator}
547
548   Build Daemon:                                      ${build_daemon}
549
550   Build Mac client:                                  ${build_mac}
551
552"
Note: See TracBrowser for help on using the repository browser.