source: trunk/configure.ac @ 13079

Last change on this file since 13079 was 13079, checked in by jordan, 5 years ago

#4622 'misleading error message in configure script' -- fixed.

File size: 16.9 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.42+])
7m4_define([peer_id_prefix],[-TR242Z-])
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])
324if test "x$with_gtk" = "x2" ; then
325    PKG_CHECK_EXISTS([gtk+-2.0 >= $GTK2_MINIMUM],[gtk_version="2" with_gtk="yes"],[gtk_version="none" with_gtk="no"])
326fi
327if test "x$with_gtk" = "x3" ; then
328    PKG_CHECK_EXISTS([gtk+-3.0 >= $GTK3_MINIMUM],[gtk_version="3" with_gtk="yes"],[gtk_version="none" with_gtk="no"])
329fi
330AC_ARG_ENABLE([nls],
331              [AS_HELP_STRING([--enable-nls],[enable native language support])],,
332              [enable_nls=yes])
333AM_CONDITIONAL([BUILD_GTK],[test "x$with_gtk" = "xyes"])
334use_libappindicator=no
335if test "x$with_gtk" = "xyes" ; then
336
337    if test "x$gtk_version" = "xnone" ; then
338        AC_MSG_ERROR("GTK+ not found!")
339    fi
340    if test "x$enable_nls" = "xno" ; then
341        AC_MSG_ERROR("The gtk client cannot be built without nls support.  Try adding either --enable-nls or --without-gtk" )
342    fi
343
344    if test "x$gtk_version" = "x3"; then
345
346        PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= $GTK3_MINIMUM
347                                  glib-2.0 >= $GLIB_MINIMUM
348                                  gio-2.0 >= $GIO_MINIMUM,
349                                  gmodule-2.0 >= $GLIB_MINIMUM
350                                  gthread-2.0 >= $GLIB_MINIMUM])
351        PKG_CHECK_MODULES([LIBAPPINDICATOR],
352                          [appindicator3-0.1 >= $LIBAPPINDICATOR_MINIMUM],
353                          [have_libappindicator=yes],
354                          [have_libappindicator=no])
355        AC_MSG_NOTICE([using GTK+ 3])
356    else
357
358        PKG_CHECK_MODULES([GTK], [gtk+-2.0 >= $GTK2_MINIMUM
359                                  glib-2.0 >= $GLIB_MINIMUM
360                                  gio-2.0 >= $GIO_MINIMUM,
361                                  gmodule-2.0 >= $GLIB_MINIMUM
362                                  gthread-2.0 >= $GLIB_MINIMUM])
363        PKG_CHECK_MODULES([LIBAPPINDICATOR],
364                          [appindicator-0.1 >= $LIBAPPINDICATOR_MINIMUM],
365                          [have_libappindicator=yes],
366                          [have_libappindicator=no])
367        AC_MSG_NOTICE([using GTK+ 2])
368
369    fi
370
371    if test "x$have_libappindicator" = "xyes"; then
372        use_libappindicator=yes
373        AC_DEFINE([HAVE_LIBAPPINDICATOR], 1)
374    else
375        LIBAPPINDICATOR_CFLAGS=
376        LIBAPPINDICATOR_LIBS=
377    fi
378fi
379
380dnl This section is only used for internationalization.
381dnl If you don't need translations and this section gives you trouble --
382dnl such as if you're building for a headless system --
383dnl it's okay to tear this section out and re-build the configure script.
384dnl
385dnl Note to packagers: the bump to intltool 0.40 was made to fix
386dnl a "make check" failure on some systems.  if upgrading to 0.40 is
387dnl a problem and the old version was working fine for you,
388dnl it should be safe to re-edit 0.40 back down to 0.23
389
390use_nls=no
391if test "x$enable_nls" = "xyes" ; then
392    use_nls=yes
393    IT_PROG_INTLTOOL([0.35.0],[no-xml])
394    AC_CHECK_HEADERS([libintl.h])
395    GETTEXT_PACKAGE=transmission-gtk
396    AC_SUBST(GETTEXT_PACKAGE)
397    AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[Gettext package])
398    AM_GLIB_GNU_GETTEXT
399    transmissionlocaledir='${prefix}/${DATADIRNAME}/locale'
400    AC_SUBST(transmissionlocaledir)
401fi
402AC_SUBST(INTLLIBS)
403
404
405dnl ----------------------------------------------------------------------------
406dnl
407dnl  platform-specific stuff.
408
409AC_CANONICAL_HOST
410have_darwin="no"
411have_msw="no"
412case $host_os in
413
414   *mingw32*)
415     have_msw="yes"
416     CXXFLAGS="$CXXFLAGS -mms-bitfields -mwin32 -mwindows"
417     CPPFLAGS="$CPPFLAGS -DWIN32 -D_WIN32 -DWIN32_LEAN_AND_MEAN"
418     LIBS="$LIBS -liphlpapi -lshell32 -lws2_32"
419     transmissionlocaledir="locale"
420     if test -z "$host_alias"; then
421       hostaliaswindres=
422     else
423       hostaliaswindres="$host_alias-windres";
424     fi
425     AC_CHECK_TOOL(WINDRES, windres)
426     ;;
427
428  *darwin*)
429    have_darwin="yes"
430    CFLAGS="-DMACOSX $CFLAGS"
431    ;;
432
433esac
434
435AC_ARG_ENABLE([lightweight],
436              AS_HELP_STRING([--enable-lightweight],[optimize libtransmission for low-resource systems: smaller cache size, prefer unencrypted peer connections, etc.]),
437              [enable_lightweight=${enableval}],
438              [enable_lightweight="no"])
439if test "x$enable_lightweight" = "xyes" ; then
440  AC_DEFINE([TR_LIGHTWEIGHT],[1],[optimize libtransmission for low-resource systems])
441fi
442
443AC_ARG_ENABLE([cli],
444              [AS_HELP_STRING([--enable-cli],[build command-line client])],
445              [build_cli=${enableval}],
446              [build_cli="yes"])
447AM_CONDITIONAL([BUILD_CLI],[test "x$build_cli" = "xyes"])
448
449AC_ARG_ENABLE([mac],
450              [AS_HELP_STRING([--enable-mac],[build Mac client])],
451              [build_mac=${enableval}],
452              [build_mac=${have_darwin}])
453AM_CONDITIONAL([BUILD_MAC],[test "x$build_mac" = "xyes"])
454
455AC_ARG_ENABLE([daemon],
456              [AS_HELP_STRING([--enable-daemon],[build daemon])],
457              [build_daemon=${enableval}],
458              [build_daemon="yes"])
459AM_CONDITIONAL([BUILD_DAEMON],[test "x$build_daemon" = "xyes"])
460
461
462if test "x$build_mac" = "xyes" ; then
463    # Make sure the proper Mac SDK is installed
464    if test ! -d /Developer/SDKs/MacOSX10.5.sdk; then
465      cat << EOF
466You need to install the Mac OS X 10.5 SDK in order to build Transmission
467with --enable-mac:
468  Get your Xcode CD or package
469  Restart the install
470  When it gets to "Installation Type", select "Customize"
471  Select "Mac OS X 10.5 SDK" under "Cross Development"
472  Finish the install.
473EOF
474      exit 1
475    fi
476fi
477if test "x$have_darwin" = "xyes"; then
478    AC_DEFINE([HAVE_DARWIN], 1)
479fi
480if test "x$have_msw" = "xyes"; then
481    AC_DEFINE([HAVE_MSW], 1)
482fi
483AM_CONDITIONAL(WIN32, test "x$have_msw" = "xyes")
484
485dnl ----------------------------------------------------------------------------
486dnl
487dnl  Generate the output
488
489AC_CONFIG_FILES([Makefile
490                 transmission-gtk.spec
491                 cli/Makefile
492                 daemon/Makefile
493                 extras/Makefile
494                 libtransmission/Makefile
495                 utils/Makefile
496                 third-party/Makefile
497                 third-party/dht/Makefile
498                 third-party/libutp/Makefile
499                 third-party/libnatpmp/Makefile
500                 third-party/miniupnp/Makefile
501                 macosx/Makefile
502                 gtk/Makefile
503                 gtk/icons/Makefile
504                 web/Makefile
505                 web/images/Makefile
506                 web/style/Makefile
507                 web/style/jqueryui/Makefile
508                 web/style/jqueryui/images/Makefile
509                 web/style/transmission/Makefile
510                 web/style/transmission/images/Makefile
511                 web/style/transmission/images/buttons/Makefile
512                 web/javascript/Makefile
513                 web/javascript/jquery/Makefile
514                 po/Makefile.in])
515
516AC_OUTPUT
517
518echo "
519
520Configuration:
521
522   Source code location:                              ${srcdir}
523   Compiler:                                          ${CXX}
524
525   Build libtransmission:                             yes
526      * optimized for low-resource systems:           ${enable_lightweight}
527      * µTP enabled:                                  ${build_utp}
528
529   Build Command-Line client:                         ${build_cli}
530
531   Build GTK+ client:                                 ${with_gtk} (GTK+ $gtk_version)
532      * libappindicator for an Ubuntu-style tray:     ${use_libappindicator}
533
534   Build Daemon:                                      ${build_daemon}
535
536   Build Mac client:                                  ${build_mac}
537
538"
Note: See TracBrowser for help on using the repository browser.