source: trunk/configure.ac @ 9795

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

(trunk) use AC_ARG_VAR for some autoconf variables s.t. their values will persist between reconfs

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