source: branches/2.4x/configure.ac @ 13006

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

(2.4x) backport autoconf support for GTK+ 2 and GTK+ 3 from r12964 and r12972

File size: 14.1 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],[-TR2410-])
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
242dnl  detection for the GTK+ client
243
244
245gtk_version="none"
246with_gtk_default="no"
247PKG_CHECK_EXISTS([gtk+-2.0 >= $GTK2_MINIMUM],[gtk_version="2" with_gtk_default="yes"])
248PKG_CHECK_EXISTS([gtk+-3.0 >= $GTK3_MINIMUM],[gtk_version="3" with_gtk_default="yes"])
249AC_ARG_WITH([gtk], AC_HELP_STRING([--with-gtk],[with Gtk]),
250            [with_gtk=$withval],
251            [with_gtk=$with_gtk_default])
252AC_ARG_ENABLE([nls],
253              [AS_HELP_STRING([--enable-nls],[enable native language support])],,
254              [enable_nls=yes])
255AM_CONDITIONAL([BUILD_GTK],[test "x$with_gtk" = "xyes"])
256use_libappindicator=no
257if test "x$with_gtk" = "xyes" ; then
258
259    if test "x$gtk_version" = "xnone" ; then
260        AC_MSG_ERROR("GTK+ not found!")
261    fi
262    if test "x$enable_nls" = "xno" ; then
263        AC_MSG_ERROR("The gtk client cannot be built without nls support.  Try adding either --enable-nls or --disable-gtk" )
264    fi
265
266    if test "x$gtk_version" = "x3"; then
267
268        PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= $GTK3_MINIMUM
269                                  glib-2.0 >= $GLIB_MINIMUM
270                                  gio-2.0 >= $GIO_MINIMUM,
271                                  gmodule-2.0 >= $GLIB_MINIMUM
272                                  gthread-2.0 >= $GLIB_MINIMUM])
273        PKG_CHECK_MODULES([LIBAPPINDICATOR],
274                          [appindicator3-0.1 >= $LIBAPPINDICATOR_MINIMUM],
275                          [have_libappindicator=yes],
276                          [have_libappindicator=no])
277        AC_MSG_NOTICE([using GTK+ 3])
278    else
279
280        PKG_CHECK_MODULES([GTK], [gtk+-2.0 >= $GTK2_MINIMUM
281                                  glib-2.0 >= $GLIB_MINIMUM
282                                  gio-2.0 >= $GIO_MINIMUM,
283                                  gmodule-2.0 >= $GLIB_MINIMUM
284                                  gthread-2.0 >= $GLIB_MINIMUM])
285        PKG_CHECK_MODULES([LIBAPPINDICATOR],
286                          [appindicator-0.1 >= $LIBAPPINDICATOR_MINIMUM],
287                          [have_libappindicator=yes],
288                          [have_libappindicator=no])
289        AC_MSG_NOTICE([using GTK+ 2])
290
291    fi
292
293    if test "x$have_libappindicator" = "xyes"; then
294        use_libappindicator=yes
295        AC_DEFINE([HAVE_LIBAPPINDICATOR], 1)
296    else
297        LIBAPPINDICATOR_CFLAGS=
298        LIBAPPINDICATOR_LIBS=
299    fi
300fi
301
302dnl This section is only used for internationalization.
303dnl If you don't need translations and this section gives you trouble --
304dnl such as if you're building for a headless system --
305dnl it's okay to tear this section out and re-build the configure script.
306dnl
307dnl Note to packagers: the bump to intltool 0.40 was made to fix
308dnl a "make check" failure on some systems.  if upgrading to 0.40 is
309dnl a problem and the old version was working fine for you,
310dnl it should be safe to re-edit 0.40 back down to 0.23
311
312use_nls=no
313if test "x$enable_nls" = "xyes" ; then
314    use_nls=yes
315    IT_PROG_INTLTOOL([0.35.0],[no-xml])
316    AC_CHECK_HEADERS([libintl.h])
317    GETTEXT_PACKAGE=transmission-gtk
318    AC_SUBST(GETTEXT_PACKAGE)
319    AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[Gettext package])
320    AM_GLIB_GNU_GETTEXT
321    transmissionlocaledir='${prefix}/${DATADIRNAME}/locale'
322    AC_SUBST(transmissionlocaledir)
323fi
324AC_SUBST(INTLLIBS)
325
326
327dnl ----------------------------------------------------------------------------
328dnl
329dnl  platform-specific stuff.
330
331AC_CANONICAL_HOST
332have_darwin="no"
333have_msw="no"
334case $host_os in
335
336   *mingw32*)
337     have_msw="yes"
338     CXXFLAGS="$CXXFLAGS -mms-bitfields -mwin32 -mwindows"
339     CPPFLAGS="$CPPFLAGS -DWIN32 -D_WIN32 -DWIN32_LEAN_AND_MEAN"
340     LIBS="$LIBS -liphlpapi -lshell32 -lws2_32"
341     transmissionlocaledir="locale"
342     if test -z "$host_alias"; then
343       hostaliaswindres=
344     else
345       hostaliaswindres="$host_alias-windres";
346     fi
347     AC_CHECK_TOOL(WINDRES, windres)
348     ;;
349
350  *darwin*)
351    have_darwin="yes"
352    CFLAGS="-DMACOSX $CFLAGS"
353    ;;
354
355esac
356
357AC_ARG_ENABLE([lightweight],
358              AS_HELP_STRING([--enable-lightweight],[optimize libtransmission for low-resource systems: smaller cache size, prefer unencrypted peer connections, etc.]),
359              [enable_lightweight=${enableval}],
360              [enable_lightweight="no"])
361if test "x$enable_lightweight" = "xyes" ; then
362  AC_DEFINE([TR_LIGHTWEIGHT],[1],[optimize libtransmission for low-resource systems])
363fi
364
365AC_ARG_ENABLE([cli],
366              [AS_HELP_STRING([--enable-cli],[build command-line client])],
367              [build_cli=${enableval}],
368              [build_cli="yes"])
369AM_CONDITIONAL([BUILD_CLI],[test "x$build_cli" = "xyes"])
370
371AC_ARG_ENABLE([mac],
372              [AS_HELP_STRING([--enable-mac],[build Mac client])],
373              [build_mac=${enableval}],
374              [build_mac=${have_darwin}])
375AM_CONDITIONAL([BUILD_MAC],[test "x$build_mac" = "xyes"])
376
377AC_ARG_ENABLE([daemon],
378              [AS_HELP_STRING([--enable-daemon],[build daemon])],
379              [build_daemon=${enableval}],
380              [build_daemon="yes"])
381AM_CONDITIONAL([BUILD_DAEMON],[test "x$build_daemon" = "xyes"])
382
383
384if test "x$build_mac" = "xyes" ; then
385    # Make sure the proper Mac SDK is installed
386    if test ! -d /Developer/SDKs/MacOSX10.5.sdk; then
387      cat << EOF
388You need to install the Mac OS X 10.5 SDK in order to build Transmission
389with --enable-mac:
390  Get your Xcode CD or package
391  Restart the install
392  When it gets to "Installation Type", select "Customize"
393  Select "Mac OS X 10.5 SDK" under "Cross Development"
394  Finish the install.
395EOF
396      exit 1
397    fi
398fi
399if test "x$have_darwin" = "xyes"; then
400    AC_DEFINE([HAVE_DARWIN], 1)
401fi
402if test "x$have_msw" = "xyes"; then
403    AC_DEFINE([HAVE_MSW], 1)
404fi
405AM_CONDITIONAL(WIN32, test "x$have_msw" = "xyes")
406
407dnl ----------------------------------------------------------------------------
408dnl
409dnl  Generate the output
410
411AC_CONFIG_FILES([Makefile
412                 transmission-gtk.spec
413                 cli/Makefile
414                 daemon/Makefile
415                 extras/Makefile
416                 libtransmission/Makefile
417                 utils/Makefile
418                 third-party/Makefile
419                 third-party/miniupnp/Makefile
420                 third-party/libnatpmp/Makefile
421                 third-party/libutp/Makefile
422                 third-party/dht/Makefile
423                 macosx/Makefile
424                 gtk/Makefile
425                 gtk/icons/Makefile
426                 web/Makefile
427                 web/images/Makefile
428                 web/images/buttons/Makefile
429                 web/images/graphics/Makefile
430                 web/images/progress/Makefile
431                 web/javascript/Makefile
432                 web/javascript/jquery/Makefile
433                 web/stylesheets/Makefile
434                 po/Makefile.in])
435
436AC_OUTPUT
437
438echo "
439
440Configuration:
441
442   Source code location:                              ${srcdir}
443   Compiler:                                          ${CXX}
444
445   Build libtransmission:                             yes
446      * optimized for low-resource systems:           ${enable_lightweight}
447      * µTP enabled:                                  ${build_utp}
448
449   Build Command-Line client:                         ${build_cli}
450
451   Build GTK+ client:                                 ${with_gtk}
452      * libappindicator for an Ubuntu-style tray:     ${use_libappindicator}
453
454   Build Daemon:                                      ${build_daemon}
455
456   Build Mac client:                                  ${build_mac}
457
458"
Note: See TracBrowser for help on using the repository browser.