source: trunk/configure.ac @ 13516

Last change on this file since 13516 was 13516, checked in by jordan, 9 years ago

remove the va_copy tests in configure.ac, it's not used in the code anywhere

File size: 16.6 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.4.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  dht
183
184DHT_CFLAGS="-I\$(top_srcdir)/third-party/dht"
185DHT_LIBS="\$(top_builddir)/third-party/dht/libdht.a"
186AC_SUBST(DHT_CFLAGS)
187AC_SUBST(DHT_LIBS)
188
189
190dnl ----------------------------------------------------------------------------
191dnl
192dnl  utp
193
194AC_CHECK_LIB([rt],
195             [clock_gettime],
196             [libutp_extra_libs="-lrt"],
197             [libutp_extra_libs=""])
198
199AC_MSG_CHECKING([µTP])
200build_utp="no"
201if test "x$HAVE_CXX" = "xyes" ; then
202    have_utp="yes"
203else
204    have_utp="no"
205fi
206AC_ARG_ENABLE([utp],
207              AS_HELP_STRING([--enable-utp],[build µTP support]),
208              [want_utp=${enableval}],
209              [want_utp=${have_utp}])
210if test "x$want_utp" = "xyes" ; then
211    if test "x$have_utp" = "xyes"; then
212        LIBUTP_CFLAGS="-I\$(top_srcdir)/third-party/"
213        LIBUTP_LIBS="\$(top_builddir)/third-party/libutp/libutp.a"
214        LIBUTP_LIBS_QT="\$\${TRANSMISSION_TOP}/third-party/libutp/libutp.a"
215        if test "x$libutp_extra_libs" != "x" ; then
216            LIBUTP_LIBS="$LIBUTP_LIBS $libutp_extra_libs"
217            LIBUTP_LIBS_QT="$LIBUTP_LIBS_QT $libutp_extra_libs"
218        fi
219        AC_DEFINE([WITH_UTP],[1])
220        build_utp="yes"
221    else
222      AC_MSG_ERROR("Unable to build uTP support -- C++ compiler not found")
223    fi
224fi
225AC_SUBST(LIBUTP_CFLAGS)
226AC_SUBST(LIBUTP_LIBS)
227AC_SUBST(LIBUTP_LIBS_QT)
228AM_CONDITIONAL([BUILD_UTP],[test "x$build_utp" = "xyes"])
229AC_MSG_RESULT([$build_utp])
230
231
232dnl
233dnl  look for preinstalled miniupnpc...
234dnl
235
236AC_MSG_CHECKING([supported miniupnp library])
237upnp_version="none"
238ac_save_LIBS="$LIBS"
239LIBS="-lminiupnpc"
240# See if the OS has its miniupnp 1.5 installed
241AC_TRY_LINK([
242    #include <stdlib.h>
243    #include <miniupnpc/miniupnpc.h>
244    #include <miniupnpc/upnpcommands.h>
245],[
246    struct UPNPDev * devlist;
247    struct UPNPUrls    urls;
248    struct IGDdatas    data;
249    char lanaddr[16];
250    char portStr[8];
251    char intPort[8];
252    char intClient[16];
253    upnpDiscover( 2000, NULL, NULL, 0 );
254    UPNP_GetValidIGD( devlist, &urls, &data, lanaddr, sizeof( lanaddr ) );
255    UPNP_GetSpecificPortMappingEntry( urls.controlURL, data.first.servicetype,
256                        portStr, "TCP", intClient, intPort );
257],[
258AC_DEFINE(HAVE_MINIUPNP_15, 1, [Define to 1 if you have miniupnpc version 1.5])
259upnp_version="1.5"])
260
261# See if the OS has its miniupnp 1.6 installed
262AC_TRY_LINK([
263    #include <stdlib.h>
264    #include <errno.h>
265    #include <miniupnpc/miniupnpc.h>
266    #include <miniupnpc/upnpcommands.h>
267],[
268    struct UPNPDev * devlist;
269    struct UPNPUrls    urls;
270    struct IGDdatas    data;
271    char lanaddr[16];
272    char portStr[8];
273    char intPort[8];
274    char intClient[16];
275    upnpDiscover( 2000, NULL, NULL, 0, 0, &errno );
276    UPNP_GetValidIGD( devlist, &urls, &data, lanaddr, sizeof( lanaddr ) );
277    UPNP_GetSpecificPortMappingEntry( urls.controlURL, data.first.servicetype,
278                        portStr, "TCP", intClient, intPort, NULL, NULL, NULL );
279],[
280AC_DEFINE(HAVE_MINIUPNP_16, 1, [Define to 1 if you have miniupnpc version 1.6])
281upnp_version="1.6"])
282
283# ... and the results of our tests
284LIBS="$ac_save_LIBS"
285AC_MSG_RESULT([$upnp_version])
286AM_CONDITIONAL([BUILD_MINIUPNP],[test "x$upnp_version" = "xnone"])
287if test "x$upnp_version" = "xnone" ; then
288    LIBUPNP_CFLAGS="-I\$(top_srcdir)/third-party/"
289    LIBUPNP_LIBS="\$(top_builddir)/third-party/miniupnp/libminiupnp.a"
290    LIBUPNP_LIBS_QT="\$\${TRANSMISSION_TOP}/third-party/miniupnp/libminiupnp.a"
291    dnl because this is the version that we bundle...
292    AC_DEFINE(HAVE_MINIUPNP_16, 1, [Define to 1 if you have miniupnpc version 1.6])
293else
294    AC_DEFINE([SYSTEM_MINIUPNP])
295    LIBUPNP_CFLAGS=""
296    LIBUPNP_LIBS="-lminiupnpc"
297    LIBUPNP_LIBS_QT="-lminiupnpc"
298fi
299AC_SUBST(LIBUPNP_CFLAGS)
300AC_SUBST(LIBUPNP_LIBS)
301AC_SUBST(LIBUPNP_LIBS_QT)
302
303
304 
305
306dnl ----------------------------------------------------------------------------
307dnl
308dnl  Allow usage of system natpmp library
309
310LIBNATPMP_CFLAGS="-I\$(top_srcdir)/third-party/libnatpmp/"
311LIBNATPMP_LIBS="\$(top_builddir)/third-party/libnatpmp/libnatpmp.a"
312LIBNATPMP_LIBS_QT="\$\${TRANSMISSION_TOP}/third-party/libnatpmp/libnatpmp.a"
313build_bundled_natpmp="yes"
314AC_ARG_ENABLE([external-natpmp],
315              AS_HELP_STRING([--enable-external-natpmp],[Use system external-natpmp]),
316              [want_external_natpmp=${enableval}],
317              [want_external_natpmp=no])
318if test "x$want_external_natpmp" != "xno" ; then
319        dnl Would be lovely if it had pkgconfig
320        LIBNATPMP_CFLAGS="" 
321        LIBNATPMP_LIBS="-lnatpmp"
322        LIBNATPMP_LIBS_QT="-lnatpmp"
323        build_bundled_natpmp="no"
324fi
325AM_CONDITIONAL([BUILD_NATPMP],[test "x$build_bundled_natpmp" = "xyes"])
326AC_SUBST(LIBNATPMP_CFLAGS)
327AC_SUBST(LIBNATPMP_LIBS)
328AC_SUBST(LIBNATPMP_LIBS_QT)
329
330
331dnl ----------------------------------------------------------------------------
332dnl
333dnl  detection for the GTK+ client
334
335AC_ARG_ENABLE([nls],
336              [AS_HELP_STRING([--enable-nls],[enable native language support])],,
337              [enable_nls=yes])
338PKG_CHECK_EXISTS([gtk+-3.0 >= $GTK_MINIMUM
339                  glib-2.0 >= $GLIB_MINIMUM
340                  gio-2.0 >= $GIO_MINIMUM,
341                  gmodule-2.0 >= $GLIB_MINIMUM
342                  gthread-2.0 >= $GLIB_MINIMUM],
343                 [have_gtk=yes],
344                 [have_gtk=no])
345AC_ARG_WITH([gtk], AC_HELP_STRING([--with-gtk],[with Gtk]),
346            [with_gtk=$withval],
347            [with_gtk=$have_gtk])
348AM_CONDITIONAL([BUILD_GTK],[test "x$with_gtk" = "xyes"])
349use_libappindicator=no
350if test "x$with_gtk" = "xyes" ; then
351
352    if test "x$enable_nls" = "xno" ; then
353        AC_MSG_ERROR("The gtk client cannot be built without nls support.  Try adding either --enable-nls or --without-gtk" )
354    fi
355
356    PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= $GTK_MINIMUM
357                              glib-2.0 >= $GLIB_MINIMUM
358                              gio-2.0 >= $GIO_MINIMUM,
359                              gmodule-2.0 >= $GLIB_MINIMUM
360                              gthread-2.0 >= $GLIB_MINIMUM])
361    PKG_CHECK_MODULES([LIBAPPINDICATOR],
362                      [appindicator3-0.1 >= $LIBAPPINDICATOR_MINIMUM],
363                      [have_libappindicator=yes],
364                      [have_libappindicator=no])
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    m4_ifdef([IT_PROG_INTLTOOL],
388             [IT_PROG_INTLTOOL([0.35.0],[no-xml])],
389             [AC_MSG_ERROR("--enable-nls requires intltool to be installed.")])
390    AC_CHECK_HEADERS([libintl.h])
391    GETTEXT_PACKAGE=transmission-gtk
392    AC_SUBST(GETTEXT_PACKAGE)
393    AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[Gettext package])
394    AM_GLIB_GNU_GETTEXT
395    transmissionlocaledir='${prefix}/${DATADIRNAME}/locale'
396    AC_SUBST(transmissionlocaledir)
397fi
398AC_SUBST(INTLLIBS)
399
400
401dnl ----------------------------------------------------------------------------
402dnl
403dnl  platform-specific stuff.
404
405AC_CANONICAL_HOST
406have_darwin="no"
407have_msw="no"
408case $host_os in
409
410   *mingw32*)
411     have_msw="yes"
412     CXXFLAGS="$CXXFLAGS -mms-bitfields -mwin32 -mwindows"
413     CPPFLAGS="$CPPFLAGS -DWIN32 -D_WIN32 -DWIN32_LEAN_AND_MEAN"
414     LIBS="$LIBS -liphlpapi -lshell32 -lws2_32"
415     transmissionlocaledir="locale"
416     if test -z "$host_alias"; then
417       hostaliaswindres=
418     else
419       hostaliaswindres="$host_alias-windres";
420     fi
421     AC_CHECK_TOOL(WINDRES, windres)
422     ;;
423
424  *darwin*)
425    have_darwin="yes"
426    CFLAGS="-DMACOSX $CFLAGS"
427    ;;
428
429esac
430
431AC_ARG_ENABLE([lightweight],
432              AS_HELP_STRING([--enable-lightweight],[optimize libtransmission for low-resource systems: smaller cache size, prefer unencrypted peer connections, etc.]),
433              [enable_lightweight=${enableval}],
434              [enable_lightweight="no"])
435if test "x$enable_lightweight" = "xyes" ; then
436  AC_DEFINE([TR_LIGHTWEIGHT],[1],[optimize libtransmission for low-resource systems])
437fi
438
439AC_ARG_ENABLE([cli],
440              [AS_HELP_STRING([--enable-cli],[build command-line client])],
441              [build_cli=${enableval}],
442              [build_cli="yes"])
443AM_CONDITIONAL([BUILD_CLI],[test "x$build_cli" = "xyes"])
444
445AC_ARG_ENABLE([mac],
446              [AS_HELP_STRING([--enable-mac],[build Mac client])],
447              [build_mac=${enableval}],
448              [build_mac=${have_darwin}])
449AM_CONDITIONAL([BUILD_MAC],[test "x$build_mac" = "xyes"])
450
451AC_ARG_ENABLE([daemon],
452              [AS_HELP_STRING([--enable-daemon],[build daemon])],
453              [build_daemon=${enableval}],
454              [build_daemon="yes"])
455AM_CONDITIONAL([BUILD_DAEMON],[test "x$build_daemon" = "xyes"])
456
457
458if test "x$build_mac" = "xyes" ; then
459    # Make sure the proper Mac SDK is installed
460    if test ! -d /Developer/SDKs/MacOSX10.5.sdk; then
461      cat << EOF
462You need to install the Mac OS X 10.5 SDK in order to build Transmission
463with --enable-mac:
464  Get your Xcode CD or package
465  Restart the install
466  When it gets to "Installation Type", select "Customize"
467  Select "Mac OS X 10.5 SDK" under "Cross Development"
468  Finish the install.
469EOF
470      exit 1
471    fi
472fi
473if test "x$have_darwin" = "xyes"; then
474    AC_DEFINE([HAVE_DARWIN], 1)
475fi
476if test "x$have_msw" = "xyes"; then
477    AC_DEFINE([HAVE_MSW], 1)
478fi
479AM_CONDITIONAL(WIN32, test "x$have_msw" = "xyes")
480
481dnl ----------------------------------------------------------------------------
482dnl
483dnl  Generate the output
484
485AC_CONFIG_FILES([Makefile
486                 transmission-gtk.spec
487                 cli/Makefile
488                 daemon/Makefile
489                 extras/Makefile
490                 libtransmission/Makefile
491                 utils/Makefile
492                 third-party/Makefile
493                 third-party/dht/Makefile
494                 third-party/libutp/Makefile
495                 third-party/libnatpmp/Makefile
496                 third-party/miniupnp/Makefile
497                 macosx/Makefile
498                 gtk/Makefile
499                 gtk/icons/Makefile
500                 qt/config.pri
501                 web/Makefile
502                 web/images/Makefile
503                 web/style/Makefile
504                 web/style/jqueryui/Makefile
505                 web/style/jqueryui/images/Makefile
506                 web/style/transmission/Makefile
507                 web/style/transmission/images/Makefile
508                 web/style/transmission/images/buttons/Makefile
509                 web/javascript/Makefile
510                 web/javascript/jquery/Makefile
511                 po/Makefile.in])
512
513AC_OUTPUT
514
515echo "
516
517Configuration:
518
519   Source code location:                              ${srcdir}
520   Compiler:                                          ${CXX}
521
522   Build libtransmission:                             yes
523      * optimized for low-resource systems:           ${enable_lightweight}
524      * µTP enabled:                                  ${build_utp}
525
526   Build Command-Line client:                         ${build_cli}
527
528   Build GTK+ client:                                 ${with_gtk}
529      * libappindicator for an Ubuntu-style tray:     ${use_libappindicator}
530
531   Build Daemon:                                      ${build_daemon}
532
533   Build Mac client:                                  ${build_mac}
534
535"
Note: See TracBrowser for help on using the repository browser.