source: trunk/configure.ac @ 14310

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

Use built-in APPLE macro instead of SYS_DARWIN and MACOSX

File size: 17.7 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.83+])
7m4_define([peer_id_prefix],[-TR283Z-])
8
9AC_INIT([transmission],[user_agent_prefix],[http://trac.transmissionbt.com/newticket])
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])
20LT_INIT
21
22if test m4_substr(peer_id_prefix,6,1) = "0"; then
23  supported_build=yes
24  CPPFLAGS="$CPPFLAGS -DNDEBUG"
25else
26  supported_build=no
27  if test "x$GCC" = "xyes" ; then
28    CFLAGS="$CFLAGS -g -O0"
29    CXXFLAGS="$CXXFLAGS -g -O0"
30  fi
31fi
32AM_CONDITIONAL(TR_UNSTABLE, test "x$supported_build" = "xno")
33
34##
35##
36##   MANDATORY for everything
37##
38##
39CURL_MINIMUM=7.15.4
40AC_SUBST(CURL_MINIMUM)
41LIBEVENT_MINIMUM=2.0.10
42AC_SUBST(LIBEVENT_MINIMUM)
43OPENSSL_MINIMUM=0.9.4
44AC_SUBST(OPENSSL_MINIMUM)
45
46##
47##
48##   MANDATORY for the GTK+ client
49##
50##
51
52GTK_MINIMUM=3.4.0
53AC_SUBST(GTK_MINIMUM)
54GLIB_MINIMUM=2.32.0
55AC_SUBST(GLIB_MINIMUM)
56GIO_MINIMUM=2.26.0
57AC_SUBST(GIO_MINIMUM)
58
59##
60##
61##   OPTIONAL for the GTK+ client
62##
63##
64
65# create the tray icon with AppIndicator
66LIBAPPINDICATOR_MINIMUM=0.4.90
67AC_SUBST(LIBAPPINDICATOR_MINIMUM)
68
69
70AC_PROG_CC
71AC_PROG_CXX
72AC_C_INLINE
73if test "x$GCC" = "xyes" ; then
74
75    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"
76
77    dnl figure out gcc version
78    AC_MSG_CHECKING([gcc version])
79    GCC_VERSION=`$CC -dumpversion`
80    GCC_MAJOR=`echo $GCC_VERSION | cut -d . -f1`
81    GCC_MINOR=`echo $GCC_VERSION | cut -d . -f2`
82    GCC_VERSION_NUM=`(expr $GCC_MAJOR "*" 100 + $GCC_MINOR) 2>/dev/null`
83
84    AC_MSG_RESULT($GCC_VERSION)
85    if test $GCC_VERSION_NUM -ge 304; then
86        dnl these were added in 3.4
87        CFLAGS="$CFLAGS -Wextra -Wdeclaration-after-statement -Winit-self"
88    fi
89    if test $GCC_VERSION_NUM -ge 403; then
90        dnl these were added in 4.3
91        CFLAGS="$CFLAGS -Wvariadic-macros"
92    fi
93fi
94
95AC_HEADER_STDC
96AC_HEADER_TIME
97
98AC_CHECK_HEADERS([stdbool.h])
99AC_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])
100AC_PROG_INSTALL
101AC_PROG_MAKE_SET
102ACX_PTHREAD
103
104if test "x$ac_cv_func_strtold" != "xyes" ; then
105    CPPFLAGS="$CPPFLAGS -Dstrtold=strtod"
106fi
107
108AC_SEARCH_LIBS(cos, [m])
109AC_SEARCH_LIBS([socket], [socket net])
110AC_SEARCH_LIBS([gethostbyname], [nsl bind])
111AC_SEARCH_LIBS([quotacursor_skipidtype], [quota])
112PKG_CHECK_MODULES(OPENSSL, [openssl >= $OPENSSL_MINIMUM], , [CHECK_SSL()])
113PKG_CHECK_MODULES(LIBCURL, [libcurl >= $CURL_MINIMUM])
114PKG_CHECK_MODULES(LIBEVENT, [libevent >= $LIBEVENT_MINIMUM])
115AC_PATH_ZLIB
116
117AC_SYS_LARGEFILE
118AC_CHECK_FUNCS([lseek64])
119
120AC_FUNC_GETMNTENT
121
122dnl ----------------------------------------------------------------------------
123dnl
124dnl posix_fadvise
125
126dnl can posix_fadvise be used
127AC_CHECK_DECLS(posix_fadvise, [], [], [
128#define _XOPEN_SOURCE 600
129#include <fcntl.h>])
130AC_CHECK_FUNCS([posix_fadvise])
131
132
133dnl ----------------------------------------------------------------------------
134dnl
135dnl file monitoring for the daemon
136
137AC_CHECK_HEADER([sys/inotify.h],
138                [AC_CHECK_FUNC([inotify_init],[have_inotify="yes"],[have_inotify="no"])],
139                [have_inotify="no"])
140AC_ARG_WITH([inotify],
141            [AS_HELP_STRING([--with-inotify],[Enable inotify support (default=auto)])],
142            [want_inotify=${withval}],
143            [want_inotify=${have_inotify}])
144if test "x$want_inotify" = "xyes" ; then
145    if test "x$have_inotify" = "xyes"; then
146      AC_DEFINE([WITH_INOTIFY],[1])
147    else
148      AC_MSG_ERROR("inotify not found!")
149    fi
150fi
151
152AC_CHECK_HEADER([sys/event.h],
153                [AC_CHECK_FUNC([kqueue],[have_kqueue="yes"],[have_kqueue="no"])],
154                [have_kqueue="no"])
155AC_ARG_WITH([kqueue],
156            [AS_HELP_STRING([--with-kqueue],[Enable kqueue support (default=auto)])],
157            [want_kqueue=${withval}],
158            [want_kqueue=${have_kqueue}])
159if test "x$want_kqueue" = "xyes" ; then
160    if test "x$have_kqueue" = "xyes"; then
161      AC_DEFINE([WITH_KQUEUE],[1])
162    else
163      AC_MSG_ERROR("kqueue not found!")
164    fi
165fi
166
167AC_CHECK_HEADERS([sys/statvfs.h \
168                  xfs/xfs.h])
169
170
171dnl ----------------------------------------------------------------------------
172dnl
173dnl file monitoring for the daemon
174
175# Check whether to enable systemd startup notification.
176# This requires libsystemd-daemon.
177AC_ARG_WITH([systemd-daemon], AS_HELP_STRING([--with-systemd-daemon],
178            [Add support for systemd startup notification (default is autodetected)]),
179            [USE_SYSTEMD_DAEMON=$withval], [USE_SYSTEMD_DAEMON=auto])
180AS_IF([test "x$USE_SYSTEMD_DAEMON" != "xno"], [
181    PKG_CHECK_MODULES([SYSTEMD_DAEMON], [libsystemd-daemon],
182        [AC_DEFINE(USE_SYSTEMD_DAEMON,1,[Use systemd startup notification])],
183        [AS_IF([test "x$USE_SYSTEMD_DAEMON" = "xyes"],
184            [AC_MSG_ERROR([systemd startup notification support requested, but libsystemd-daemon not found.])]
185        )]
186    )
187])
188
189
190dnl ----------------------------------------------------------------------------
191dnl
192dnl  dht
193
194DHT_CFLAGS="-I\$(top_srcdir)/third-party/dht"
195DHT_LIBS="\$(top_builddir)/third-party/dht/libdht.a"
196AC_SUBST(DHT_CFLAGS)
197AC_SUBST(DHT_LIBS)
198
199
200dnl ----------------------------------------------------------------------------
201dnl
202dnl  utp
203
204AC_CHECK_LIB([rt],
205             [clock_gettime],
206             [libutp_extra_libs="-lrt"],
207             [libutp_extra_libs=""])
208
209AC_MSG_CHECKING([µTP])
210build_utp="no"
211if test "x$CXX" != "x" ; then
212    have_utp="yes"
213else
214    have_utp="no"
215fi
216AC_ARG_ENABLE([utp],
217              AS_HELP_STRING([--enable-utp],[build µTP support]),
218              [want_utp=${enableval}],
219              [want_utp=${have_utp}])
220if test "x$want_utp" = "xyes" ; then
221    if test "x$have_utp" = "xyes"; then
222        LIBUTP_CFLAGS="-I\$(top_srcdir)/third-party/"
223        LIBUTP_LIBS="\$(top_builddir)/third-party/libutp/libutp.a"
224        LIBUTP_LIBS_QT="\$\${TRANSMISSION_TOP}/third-party/libutp/libutp.a"
225        if test "x$libutp_extra_libs" != "x" ; then
226            LIBUTP_LIBS="$LIBUTP_LIBS $libutp_extra_libs"
227            LIBUTP_LIBS_QT="$LIBUTP_LIBS_QT $libutp_extra_libs"
228        fi
229        AC_DEFINE([WITH_UTP],[1])
230        build_utp="yes"
231    else
232      AC_MSG_ERROR("Unable to build uTP support -- C++ compiler not found")
233    fi
234fi
235AC_SUBST(LIBUTP_CFLAGS)
236AC_SUBST(LIBUTP_LIBS)
237AC_SUBST(LIBUTP_LIBS_QT)
238AM_CONDITIONAL([BUILD_UTP],[test "x$build_utp" = "xyes"])
239AC_MSG_RESULT([$build_utp])
240
241
242dnl
243dnl  look for preinstalled miniupnpc...
244dnl
245
246ac_save_LIBS="$LIBS"
247LIBS="-lminiupnpc"
248AC_MSG_CHECKING([system miniupnpc library])
249
250dnl See if ANY version of miniupnpc is installed
251AC_LINK_IFELSE(
252  [AC_LANG_PROGRAM([#include <miniupnpc/miniupnpc.h>],
253                   [struct UPNPDev dev;])],
254  [upnp_version="unknown"],
255  [upnp_version="none"]
256)
257
258dnl Let's hope it's 1.7 or higher, since it provides
259dnl MINIUPNPC_API_VERSION and we won't have to figure
260dnl it out on our own
261if test "x$upnp_version" = "xunknown" ; then
262  AC_RUN_IFELSE(
263    [AC_LANG_PROGRAM(
264      [#include <stdlib.h>
265       #include <miniupnpc/miniupnpc.h>],
266      [#ifdef MINIUPNPC_API_VERSION
267       return EXIT_SUCCESS;
268       #else
269       return EXIT_FAILURE;
270       #endif]
271    )],
272    [upnp_version=">= 1.7"]
273  )
274fi
275
276dnl Or maybe it's miniupnp 1.6
277if test "x$upnp_version" = "xunknown" ; then
278  AC_LINK_IFELSE([AC_LANG_PROGRAM([[
279    #include <stdlib.h>
280    #include <errno.h>
281    #include <miniupnpc/miniupnpc.h>
282    #include <miniupnpc/upnpcommands.h>
283  ]], [[
284    struct UPNPDev * devlist;
285    struct UPNPUrls urls;
286    struct IGDdatas data;
287    char lanaddr[16];
288    char portStr[8];
289    char intPort[8];
290    char intClient[16];
291    upnpDiscover( 2000, NULL, NULL, 0, 0, &errno );
292    UPNP_GetValidIGD( devlist, &urls, &data, lanaddr, sizeof( lanaddr ) );
293    UPNP_GetSpecificPortMappingEntry( urls.controlURL, data.first.servicetype,
294                        portStr, "TCP", intClient, intPort, NULL, NULL, NULL );
295  ]])],[
296  AC_DEFINE(MINIUPNPC_API_VERSION, 8, [miniupnpc 1.6 has API version 8])
297  upnp_version="1.6"])
298fi
299
300dnl Or maybe it's miniupnp 1.5
301if test "x$upnp_version" = "xunknown" ; then
302  AC_LINK_IFELSE([AC_LANG_PROGRAM([[
303    #include <stdlib.h>
304    #include <miniupnpc/miniupnpc.h>
305    #include <miniupnpc/upnpcommands.h>
306  ]], [[
307    struct UPNPDev * devlist;
308    struct UPNPUrls urls;
309    struct IGDdatas data;
310    char lanaddr[16];
311    char portStr[8];
312    char intPort[8];
313    char intClient[16];
314    upnpDiscover( 2000, NULL, NULL, 0 );
315    UPNP_GetValidIGD( devlist, &urls, &data, lanaddr, sizeof( lanaddr ) );
316    UPNP_GetSpecificPortMappingEntry( urls.controlURL, data.first.servicetype,
317                        portStr, "TCP", intClient, intPort );
318  ]])],[
319  AC_DEFINE(MINIUPNPC_API_VERSION, 5, [miniupnpc 1.5 has API version 5])
320  upnp_version="1.5"])
321fi
322
323# ... and the results of our tests
324LIBS="$ac_save_LIBS"
325AC_MSG_RESULT([$upnp_version])
326AM_CONDITIONAL([BUILD_MINIUPNP],[test "x$upnp_version" = "xnone"])
327if test "x$upnp_version" = "xnone" ; then
328    LIBUPNP_CFLAGS="-I\$(top_srcdir)/third-party/"
329    LIBUPNP_LIBS="\$(top_builddir)/third-party/miniupnp/libminiupnp.a"
330    LIBUPNP_LIBS_QT="\$\${TRANSMISSION_TOP}/third-party/miniupnp/libminiupnp.a"
331else
332    AC_DEFINE([SYSTEM_MINIUPNP])
333    LIBUPNP_CFLAGS=""
334    LIBUPNP_LIBS="-lminiupnpc"
335    LIBUPNP_LIBS_QT="-lminiupnpc"
336fi
337AC_SUBST(LIBUPNP_CFLAGS)
338AC_SUBST(LIBUPNP_LIBS)
339AC_SUBST(LIBUPNP_LIBS_QT)
340
341
342 
343
344dnl ----------------------------------------------------------------------------
345dnl
346dnl  Allow usage of system natpmp library
347
348LIBNATPMP_CFLAGS="-I\$(top_srcdir)/third-party/libnatpmp/"
349LIBNATPMP_LIBS="\$(top_builddir)/third-party/libnatpmp/libnatpmp.a"
350LIBNATPMP_LIBS_QT="\$\${TRANSMISSION_TOP}/third-party/libnatpmp/libnatpmp.a"
351build_bundled_natpmp="yes"
352AC_ARG_ENABLE([external-natpmp],
353              AS_HELP_STRING([--enable-external-natpmp],[Use system external-natpmp]),
354              [want_external_natpmp=${enableval}],
355              [want_external_natpmp=no])
356if test "x$want_external_natpmp" != "xno" ; then
357        dnl Would be lovely if it had pkgconfig
358        LIBNATPMP_CFLAGS="" 
359        LIBNATPMP_LIBS="-lnatpmp"
360        LIBNATPMP_LIBS_QT="-lnatpmp"
361        build_bundled_natpmp="no"
362fi
363AM_CONDITIONAL([BUILD_NATPMP],[test "x$build_bundled_natpmp" = "xyes"])
364AC_SUBST(LIBNATPMP_CFLAGS)
365AC_SUBST(LIBNATPMP_LIBS)
366AC_SUBST(LIBNATPMP_LIBS_QT)
367
368
369dnl ----------------------------------------------------------------------------
370dnl
371dnl  detection for the GTK+ client
372
373AC_ARG_ENABLE([nls],
374              [AS_HELP_STRING([--enable-nls],[enable native language support])],,
375              [enable_nls=yes])
376PKG_CHECK_EXISTS([gtk+-3.0 >= $GTK_MINIMUM
377                  glib-2.0 >= $GLIB_MINIMUM
378                  gio-2.0 >= $GIO_MINIMUM,
379                  gmodule-2.0 >= $GLIB_MINIMUM
380                  gthread-2.0 >= $GLIB_MINIMUM],
381                 [have_gtk=yes],
382                 [have_gtk=no])
383AC_ARG_WITH([gtk], AS_HELP_STRING([--with-gtk],[with Gtk]),
384            [with_gtk=$withval],
385            [with_gtk=$have_gtk])
386AM_CONDITIONAL([BUILD_GTK],[test "x$with_gtk" = "xyes"])
387use_libappindicator=no
388if test "x$with_gtk" = "xyes" ; then
389
390    if test "x$enable_nls" = "xno" ; then
391        AC_MSG_ERROR("The gtk client cannot be built without nls support.  Try adding either --enable-nls or --without-gtk" )
392    fi
393
394    PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= $GTK_MINIMUM
395                              glib-2.0 >= $GLIB_MINIMUM
396                              gio-2.0 >= $GIO_MINIMUM,
397                              gmodule-2.0 >= $GLIB_MINIMUM
398                              gthread-2.0 >= $GLIB_MINIMUM])
399    PKG_CHECK_MODULES([LIBAPPINDICATOR],
400                      [appindicator3-0.1 >= $LIBAPPINDICATOR_MINIMUM],
401                      [have_libappindicator=yes],
402                      [have_libappindicator=no])
403    if test "x$have_libappindicator" = "xyes"; then
404        use_libappindicator=yes
405        AC_DEFINE([HAVE_LIBAPPINDICATOR], 1)
406    else
407        LIBAPPINDICATOR_CFLAGS=
408        LIBAPPINDICATOR_LIBS=
409    fi
410fi
411
412dnl This section is only used for internationalization.
413dnl If you don't need translations and this section gives you trouble --
414dnl such as if you're building for a headless system --
415dnl it's okay to tear this section out and re-build the configure script.
416dnl
417dnl Note to packagers: the bump to intltool 0.40 was made to fix
418dnl a "make check" failure on some systems.  if upgrading to 0.40 is
419dnl a problem and the old version was working fine for you,
420dnl it should be safe to re-edit 0.40 back down to 0.23
421
422use_nls=no
423if test "x$enable_nls" = "xyes" ; then
424    use_nls=yes
425    m4_ifdef([IT_PROG_INTLTOOL],
426             [IT_PROG_INTLTOOL([0.35.0],[no-xml])],
427             [AC_MSG_ERROR("--enable-nls requires intltool to be installed.")])
428    AC_CHECK_HEADERS([libintl.h])
429    GETTEXT_PACKAGE=transmission-gtk
430    AC_SUBST(GETTEXT_PACKAGE)
431    AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[Gettext package])
432    AM_GLIB_GNU_GETTEXT
433    transmissionlocaledir='${prefix}/${DATADIRNAME}/locale'
434    AC_SUBST(transmissionlocaledir)
435fi
436AC_SUBST(INTLLIBS)
437
438
439dnl ----------------------------------------------------------------------------
440dnl
441dnl  platform-specific stuff.
442
443AC_CANONICAL_HOST
444have_darwin="no"
445have_msw="no"
446case $host_os in
447
448   *mingw32*)
449     have_msw="yes"
450     CXXFLAGS="$CXXFLAGS -mms-bitfields -mwin32 -mwindows"
451     CPPFLAGS="$CPPFLAGS -DWIN32 -D_WIN32 -DWIN32_LEAN_AND_MEAN"
452     LIBS="$LIBS -liphlpapi -lshell32 -lws2_32"
453     transmissionlocaledir="locale"
454     if test -z "$host_alias"; then
455       hostaliaswindres=
456     else
457       hostaliaswindres="$host_alias-windres";
458     fi
459     AC_CHECK_TOOL(WINDRES, windres)
460     ;;
461
462  *darwin*)
463    have_darwin="yes"
464    ;;
465
466esac
467
468AC_ARG_ENABLE([lightweight],
469              AS_HELP_STRING([--enable-lightweight],[optimize libtransmission for low-resource systems: smaller cache size, prefer unencrypted peer connections, etc.]),
470              [enable_lightweight=${enableval}],
471              [enable_lightweight="no"])
472if test "x$enable_lightweight" = "xyes" ; then
473  AC_DEFINE([TR_LIGHTWEIGHT],[1],[optimize libtransmission for low-resource systems])
474fi
475
476AC_ARG_ENABLE([cli],
477              [AS_HELP_STRING([--enable-cli],[build command-line client])],
478              [build_cli=${enableval}],
479              [build_cli="yes"])
480AM_CONDITIONAL([BUILD_CLI],[test "x$build_cli" = "xyes"])
481
482AC_ARG_ENABLE([mac],
483              [AS_HELP_STRING([--enable-mac],[build Mac client])],
484              [build_mac=${enableval}],
485              [build_mac=${have_darwin}])
486AM_CONDITIONAL([BUILD_MAC],[test "x$build_mac" = "xyes"])
487
488AC_ARG_ENABLE([daemon],
489              [AS_HELP_STRING([--enable-daemon],[build daemon])],
490              [build_daemon=${enableval}],
491              [build_daemon="yes"])
492AM_CONDITIONAL([BUILD_DAEMON],[test "x$build_daemon" = "xyes"])
493
494
495if test "x$build_mac" = "xyes" ; then
496   AC_DEFINE([BUILD_MAC_CLIENT], 1)
497    # Make sure the proper Mac SDK is installed
498    if test ! -d /Developer/SDKs/MacOSX10.5.sdk; then
499      cat << EOF
500You need to install the Mac OS X 10.5 SDK in order to build Transmission
501with --enable-mac:
502  Get your Xcode CD or package
503  Restart the install
504  When it gets to "Installation Type", select "Customize"
505  Select "Mac OS X 10.5 SDK" under "Cross Development"
506  Finish the install.
507EOF
508      exit 1
509    fi
510fi
511if test "x$have_msw" = "xyes"; then
512    AC_DEFINE([HAVE_MSW], 1)
513fi
514AM_CONDITIONAL(WIN32, test "x$have_msw" = "xyes")
515
516dnl ----------------------------------------------------------------------------
517dnl
518dnl  Generate the output
519
520AC_CONFIG_FILES([Makefile
521                 transmission-gtk.spec
522                 cli/Makefile
523                 daemon/Makefile
524                 extras/Makefile
525                 libtransmission/Makefile
526                 utils/Makefile
527                 third-party/Makefile
528                 third-party/dht/Makefile
529                 third-party/libutp/Makefile
530                 third-party/libnatpmp/Makefile
531                 third-party/miniupnp/Makefile
532                 macosx/Makefile
533                 gtk/Makefile
534                 gtk/icons/Makefile
535                 qt/config.pri
536                 web/Makefile
537                 web/images/Makefile
538                 web/style/Makefile
539                 web/style/jqueryui/Makefile
540                 web/style/jqueryui/images/Makefile
541                 web/style/transmission/Makefile
542                 web/style/transmission/images/Makefile
543                 web/style/transmission/images/buttons/Makefile
544                 web/javascript/Makefile
545                 web/javascript/jquery/Makefile
546                 po/Makefile.in])
547
548AC_OUTPUT
549
550echo "
551
552Configuration:
553
554   Source code location:                              ${srcdir}
555   Compiler:                                          ${CXX}
556
557   Build libtransmission:                             yes
558      * optimized for low-resource systems:           ${enable_lightweight}
559      * µTP enabled:                                  ${build_utp}
560
561   Build Command-Line client:                         ${build_cli}
562
563   Build GTK+ client:                                 ${with_gtk}
564      * libappindicator for an Ubuntu-style tray:     ${use_libappindicator}
565
566   Build Daemon:                                      ${build_daemon}
567
568   Build Mac client:                                  ${build_mac}
569
570"
Note: See TracBrowser for help on using the repository browser.