source: branches/1.7x/configure.ac @ 9355

Last change on this file since 9355 was 9355, checked in by charles, 13 years ago

(1.7x) backports for 1.76: #2447 (manpage errors)

File size: 13.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],[1.75])
7m4_define([peer_id_prefix],[-TR1750-])
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-ustar])
22AC_PROG_LIBTOOL
23
24if test m4_substr(peer_id_prefix,6,1) = "0"; then
25  supported_build=yes
26  if test "x$GCC" = "xyes" ; then
27    CFLAGS="$CFLAGS -g -O3 "
28    CXXFLAGS="$CXXFLAGS -g -O3 "
29  fi
30  CPPFLAGS="$CPPFLAGS -DNDEBUG"
31else
32  supported_build=no
33  if test "x$GCC" = "xyes" ; then
34    CFLAGS="$CFLAGS -g -O0"
35    CXXFLAGS="$CXXFLAGS -g -O0"
36  fi
37fi
38AM_CONDITIONAL(TR_UNSTABLE, test "x$supported_build" = "xno")
39
40OPENSSL_MINIMUM=0.9.4
41CURL_MINIMUM=7.16.3
42GIO_MINIMUM=2.15.5
43GLIB_MINIMUM=2.6.0
44GTK_MINIMUM=2.6.0
45LIBNOTIFY_MINIMUM=0.4.3
46DBUS_GLIB_MINIMUM=0.70
47LIBEVENT_MINIMUM=1.4.5
48AC_SUBST(OPENSSL_MINIMUM)
49AC_SUBST(CURL_MINIMUM)
50AC_SUBST(GIO_MINIMUM)
51AC_SUBST(GLIB_MINIMUM)
52AC_SUBST(GTK_MINIMUM)
53AC_SUBST(LIBNOTIFY_MINIMUM)
54AC_SUBST(DBUS_GLIB_MINIMUM)
55AC_SUBST(LIBEVENT_MINIUM)
56
57AC_PROG_CC
58AC_PROG_CXX
59AC_C_INLINE
60if test "x$GCC" = "xyes" ; then
61
62    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"
63
64    dnl figure out gcc version
65    AC_MSG_CHECKING([gcc version])
66    GCC_VERSION=`$CC -dumpversion`
67    GCC_MAJOR=`echo $GCC_VERSION | cut -d . -f1`
68    GCC_MINOR=`echo $GCC_VERSION | cut -d . -f2`
69    GCC_VERSION_NUM=`(expr $GCC_MAJOR "*" 100 + $GCC_MINOR) 2>/dev/null`
70
71    AC_MSG_RESULT($GCC_VERSION)
72    if test $GCC_VERSION_NUM -ge 304; then
73        dnl these were added in 3.4
74        CFLAGS="$CFLAGS -Wextra -Wdeclaration-after-statement -Winit-self"
75    fi
76fi
77
78AC_HEADER_STDC
79AC_HEADER_TIME
80
81AC_CHECK_FUNCS([lrintf strlcpy daemon dirname basename strcasecmp localtime_r posix_fallocate memmem strtold])
82AC_PROG_INSTALL
83AC_PROG_MAKE_SET
84ACX_PTHREAD
85
86if test "x$ac_cv_func_strtold" != "xyes" ; then
87    CPPFLAGS="$CPPFLAGS -Dstrtold=strtod"
88fi
89
90AC_SEARCH_LIBS(cos, [m])
91AC_SEARCH_LIBS([socket], [socket net])
92AC_SEARCH_LIBS([gethostbyname], [nsl bind])
93PKG_CHECK_MODULES(OPENSSL, [openssl >= $OPENSSL_MINIMUM], , [CHECK_SSL()])
94PKG_CHECK_MODULES(LIBCURL, [libcurl >= $CURL_MINIMUM])
95AC_PATH_ZLIB
96
97AC_SYS_LARGEFILE
98
99
100dnl ----------------------------------------------------------------------------
101dnl
102dnl posix_fadvise
103
104dnl can posix_fadvise be used
105AC_CHECK_DECLS(posix_fadvise, [], [], [
106#define _XOPEN_SOURCE 600
107#include <fcntl.h>])
108AC_CHECK_FUNCS([posix_fadvise])
109
110
111dnl ----------------------------------------------------------------------------
112dnl
113dnl file monitoring for the daemon
114
115AC_CHECK_HEADER([sys/inotify.h],
116                [AC_CHECK_FUNC([inotify_init],[have_inotify="yes"],[have_inotify="no"])],
117                [have_inotify="no"])
118AC_ARG_WITH([inotify],
119            [AS_HELP_STRING([--with-inotify],[Enable inotify support (default=auto)])],
120            [want_inotify=${enableval}],
121            [want_inotify=${have_inotify}])
122if test "x$want_inotify" = "xyes" ; then
123    if test "x$have_inotify" = "xyes"; then
124      AC_DEFINE([WITH_INOTIFY],[1])
125    else
126      AC_MSG_ERROR("inotify not found!")
127    fi
128fi
129 
130AC_CHECK_HEADER([sys/event.h],
131                [AC_CHECK_FUNC([kqueue],[have_kqueue="yes"],[have_kqueue="no"])],
132                [have_kqueue="no"])
133AC_ARG_WITH([kqueue],
134            [AS_HELP_STRING([--with-kqueue],[Enable kqueue support (default=auto)])],
135            [want_kqueue=${enableval}],
136            [want_kqueue=${have_kqueue}])
137if test "x$want_kqueue" = "xyes" ; then
138    if test "x$have_kqueue" = "xyes"; then
139      AC_DEFINE([WITH_KQUEUE],[1])
140    else
141      AC_MSG_ERROR("kqueue not found!")
142    fi
143fi
144
145AC_CHECK_HEADERS([xfs/xfs.h])
146
147
148dnl ----------------------------------------------------------------------------
149dnl
150dnl va_copy
151
152AC_MSG_CHECKING([how to copy va_list])
153AC_TRY_LINK([#include <stdarg.h>], [va_list ap1, ap2; va_copy(ap1, ap2);],
154    AC_MSG_RESULT([va_copy]),
155        [ AH_TEMPLATE([va_copy], [define if va_copy is not available])
156        AC_TRY_LINK([#include <stdarg.h>], [va_list ap1, ap2; __va_copy(ap1, ap2);],
157        [ AC_DEFINE([va_copy], [__va_copy])
158        AC_MSG_RESULT([__va_copy])],
159        [ AC_DEFINE([va_copy(dest,src)], [memcpy(&dest,&src,sizeof(va_list))])
160        AC_MSG_RESULT([memcpy])]
161    )
162])
163
164
165dnl libevent likes to link against librt if possible
166dnl for clock_gettime() and clock_settime()
167dnl TODO(libevent2): this can probably be removed after
168dnl we switch to libevent2, since it will have PKG_CONFIG
169AC_CHECK_LIB([rt],
170             [clock_gettime],
171             [libevent_extra_libs="-lrt"],
172             [libevent_extra_libs=""])
173
174dnl build our copy of libevent whether we use it or not,
175dnl because "make dist" needs its Makefiles to exist, and
176dnl AM_CONDITIONAL + AC_CONFIG_SUBDIRS don't seem to play nice
177AC_CONFIG_SUBDIRS([third-party/libevent])
178libevent_source=bundled
179AC_CHECK_LIB([event],[evutil_vsnprintf],
180             [libevent_found=yes],
181             [libevent_found=no],
182             [$libevent_extra_libs])
183AC_CHECK_HEADER([event-config.h],
184                [libevent_headers_found=yes],
185                [libevent_headers_found=no])
186libevent_source=bundled
187if test "x$libevent_found" = "xyes" ; then
188    if test "x$libevent_headers_found" = "xyes"; then
189      libevent_source=system
190    fi
191fi
192if test "x$libevent_source" = "xbundled"; then
193    AC_MSG_WARN([using our own libevent from third-party/libevent/])
194    AC_MSG_WARN([if you are cross-compiling this is probably NOT what you want.])
195    LIBEVENT_CFLAGS="-I\$(top_srcdir)/third-party/libevent -I\$(top_builddir)/third-party/libevent"
196    LIBEVENT_LIBS="\$(top_builddir)/third-party/libevent/libevent.la"
197else
198    LIBEVENT_CFLAGS=""
199    LIBEVENT_LIBS="-levent $libevent_extra_libs"
200fi
201AC_SUBST(LIBEVENT_CFLAGS)
202AC_SUBST(LIBEVENT_LIBS)
203
204
205dnl ----------------------------------------------------------------------------
206dnl
207dnl  dht
208
209
210AC_ARG_ENABLE([dht],
211              AS_HELP_STRING([--disable-dht],[omit DHT support]),
212              [enable_dht=${enableval}],
213              [enable_dht=yes])
214if test "x$enable_dht" = "xno" ; then
215    AC_DEFINE([WITHOUT_DHT], 1)
216    DHT_CFLAGS=""
217    DHT_LIBS=""
218else
219    DHT_CFLAGS="-I\$(top_srcdir)/third-party/dht"
220    DHT_LIBS="\$(top_builddir)/third-party/dht/libdht.a"
221fi
222AM_CONDITIONAL(DHT, test "x$enable_dht" = "xyes")
223AC_SUBST(DHT_CFLAGS)
224AC_SUBST(DHT_LIBS)
225
226
227dnl ----------------------------------------------------------------------------
228dnl
229dnl  detection for the GTK+ client
230
231PKG_CHECK_MODULES(GTK,
232                  [gtk+-2.0 >= $GTK_MINIMUM
233                   glib-2.0 >= $GLIB_MINIMUM
234                   gmodule-2.0 >= $GLIB_MINIMUM
235                   gthread-2.0 >= $GLIB_MINIMUM],
236                  [have_gtk=yes],
237                  [have_gtk=no])
238AC_ARG_ENABLE([gtk],
239              AS_HELP_STRING([--enable-gtk],[build gtk client]),
240              [want_gtk=${enableval}],
241              [want_gtk=${have_gtk}])
242build_gtk=no
243use_gio=no
244use_libnotify=no
245use_dbus_glib=no
246if test "x$want_gtk" = "xyes" ; then
247    if test "x$have_gtk" = "xyes"; then
248      build_gtk=yes
249    else
250      AC_MSG_ERROR("GTK+ not found!")
251    fi
252fi
253AM_CONDITIONAL([BUILD_GTK],[test "x$build_gtk" = "xyes"])
254AC_SUBST(GTK_LIBS)
255AC_SUBST(GTK_CFLAGS)
256
257if test "x$build_gtk" = "xyes"; then
258
259    PKG_CHECK_MODULES([GIO],
260                      [gio-2.0 >= $GIO_MINIMUM],
261                      [use_gio=yes],
262                      [use_gio=no])
263    AC_SUBST(GIO_LIBS)
264    AC_SUBST(GIO_CFLAGS)
265    if test "x$use_gio" = "xyes"; then
266        AC_DEFINE([HAVE_GIO], 1)
267    fi
268
269    PKG_CHECK_MODULES([LIBNOTIFY],
270                      [libnotify >= $LIBNOTIFY_MINIMUM],
271                      [have_libnotify=yes],
272                      [have_libnotify=no])
273    AC_ARG_ENABLE([libnotify],
274                  AS_HELP_STRING([--enable-libnotify],[enable notifications]),,
275                  [enable_libnotify=yes])
276    use_libnotify=no
277    if test "x$enable_libnotify" = "xyes" ; then
278        if test "x$have_libnotify" = "xyes"; then
279            use_libnotify=yes
280            AC_SUBST(LIBNOTIFY_LIBS)
281            AC_SUBST(LIBNOTIFY_CFLAGS)
282            AC_DEFINE([HAVE_LIBNOTIFY], 1)
283        fi
284    fi
285
286    PKG_CHECK_MODULES([DBUS_GLIB],
287                      [dbus-glib-1 >= $DBUS_GLIB_MINIMUM],
288                      [use_dbus_glib=yes],
289                      [use_dbus_glib=no])
290    AC_SUBST(DBUS_GLIB_LIBS)
291    AC_SUBST(DBUS_GLIB_CFLAGS)
292    if test "x$use_dbus_glib" = "xyes"; then
293        AC_DEFINE([HAVE_DBUS_GLIB], 1)
294    fi
295    if test "x$use_dbus_glib" = "xyes"; then
296        AC_PATH_PROG(DBUS_BINDING_TOOL, dbus-binding-tool, no)
297        if test "x$DBUS_BINDING_TOOL" = xno; then
298          AC_MSG_WARN([Cannot find dbus-binding-tool])
299          use_dbus_glib="no (dbus-binding-tool not found)"
300        fi
301    fi
302fi
303
304AC_ARG_ENABLE([nls],
305              AS_HELP_STRING([--enable-nls],[enable native language support]),,
306              [enable_nls=yes])
307
308if test "x$build_gtk" = "xyes" -a  "x$enable_nls" = "xno" ; then
309    AC_MSG_ERROR("The gtk client cannot be built without nls support.  Try adding either --enable-nls or --disable-gtk" )
310fi
311
312dnl This section is only used for internationalization.
313dnl If you don't need translations and this section gives you trouble --
314dnl such as if you're building for a headless system --
315dnl it's okay to tear this section out and re-build the configure script.
316dnl
317dnl Note to packagers: the bump to intltool 0.40 was made to fix
318dnl a "make check" failure on some systems.  if upgrading to 0.40 is
319dnl a problem and the old version was working fine for you,
320dnl it should be safe to re-edit 0.40 back down to 0.23
321
322use_nls=no
323if test "x$enable_nls" = "xyes" ; then
324    use_nls=yes
325    IT_PROG_INTLTOOL([0.40.0],[no-xml])
326    AC_CHECK_HEADERS([libintl.h])
327    GETTEXT_PACKAGE=transmission
328    AC_SUBST(GETTEXT_PACKAGE)
329    AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[Gettext package])
330    AM_GLIB_GNU_GETTEXT
331    transmissionlocaledir='${prefix}/${DATADIRNAME}/locale'
332    AC_SUBST(transmissionlocaledir)
333fi
334
335
336dnl ----------------------------------------------------------------------------
337dnl
338dnl  platform-specific stuff.
339
340AC_CANONICAL_HOST
341have_darwin="no"
342have_msw="no"
343case $host_os in
344
345   *mingw32*)
346     have_msw="yes"
347     CXXFLAGS="$CXXFLAGS -mms-bitfields -mwin32 -mwindows"
348     CPPFLAGS="$CPPFLAGS -DWIN32 -D_WIN32 -DWIN32_LEAN_AND_MEAN"
349     LIBS="$LIBS -lshell32 -lws2_32"
350     transmissionlocaledir="locale"
351     if test -z "$host_alias"; then
352       hostaliaswindres=
353     else
354       hostaliaswindres="$host_alias-windres";
355     fi
356     AC_CHECK_TOOL(WINDRES, windres)
357     ;;
358
359  *darwin*)
360    have_darwin="yes"
361    # Make sure the proper Mac SDK is installed
362    if test ! -d /Developer/SDKs/MacOSX10.5.sdk; then
363      cat << EOF
364You need to install the Mac OS X 10.5 SDK in order to build Transmission:
365  Get your Xcode CD or package
366  Restart the install
367  When it gets to "Installation Type", select "Customize"
368  Select "Mac OS X 10.5 SDK" under "Cross Development"
369  Finish the install.
370EOF
371      exit 1
372    fi
373    ;;
374
375esac
376
377AC_ARG_ENABLE([cli],
378              [AS_HELP_STRING([--enable-cli],[build command-line client])],
379              [build_cli=${enableval}],
380              [build_cli="yes"])
381AM_CONDITIONAL([BUILD_CLI],[test "x$build_cli" = "xyes"])
382
383AC_ARG_ENABLE([mac],
384              [AS_HELP_STRING([--enable-mac],[build Mac client])],
385              [build_mac=${enableval}],
386              [build_mac=${have_darwin}])
387AM_CONDITIONAL([BUILD_MAC],[test "x$build_mac" = "xyes"])
388
389AC_ARG_ENABLE([daemon],
390              [AS_HELP_STRING([--enable-daemon],[build daemon])],
391              [build_daemon=${enableval}],
392              [build_daemon="yes"])
393AM_CONDITIONAL([BUILD_DAEMON],[test "x$build_daemon" = "xyes"])
394
395
396if test "x$have_darwin" = "xyes"; then
397    AC_DEFINE([HAVE_DARWIN], 1)
398fi
399if test "x$have_msw" = "xyes"; then
400    AC_DEFINE([HAVE_MSW], 1)
401fi
402AM_CONDITIONAL(WIN32, test "x$have_msw" = "xyes")
403
404dnl ----------------------------------------------------------------------------
405dnl
406dnl  Generate the output
407
408AC_CONFIG_FILES([Makefile
409                 transmission.spec
410                 cli/Makefile
411                 daemon/Makefile
412                 doc/Makefile
413                 libtransmission/Makefile
414                 third-party/Makefile
415                 third-party/miniupnp/Makefile
416                 third-party/libnatpmp/Makefile
417                 third-party/dht/Makefile
418                 macosx/Makefile
419                 gtk/Makefile
420                 gtk/icons/Makefile
421                 po/Makefile.in])
422
423ac_configure_args="$ac_configure_args --enable-static --disable-shared -q"
424AC_OUTPUT
425
426echo "
427
428Configuration:
429
430        Source code location:          ${srcdir}
431        Compiler:                      ${CXX}
432        System or bundled libevent:    ${libevent_source}
433        DHT support:                   ${enable_dht}
434
435        Build Mac client:              ${build_mac}
436        Build GTK+ client:             ${build_gtk}
437          ... with gio support:        ${use_gio}
438          ... with dbus-glib support:  ${use_dbus_glib}
439          ... with libnotify support:  ${use_libnotify}
440        Build Command-Line client:     ${build_cli}
441        Build Daemon:                  ${build_daemon}
442
443"
Note: See TracBrowser for help on using the repository browser.