source: trunk/configure.ac @ 12972

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

use PKG_CHECK_EXISTS, rather than PKG_CHECK_MODULES, to test for GTK+ 2 and GTK+ 3.

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