source: trunk/configure.ac @ 12957

Last change on this file since 12957 was 12957, checked in by jordan, 10 years ago

(trunk libT) #4323 "Allow usage of system miniupnpc" -- fixed.

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