source: trunk/configure.ac @ 7979

Last change on this file since 7979 was 7979, checked in by charles, 12 years ago

(trunk daemon) #1882: take KyleK's suggestion of using inotify when possible. As he writes, "the opendir() approach will basically prevent my NAS drives to go to standby."

File size: 12.3 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.51+])
7m4_define([peer_id_prefix],[-TR151Z-])
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
15AC_CONFIG_MACRO_DIR([m4])
16
17dnl AM_CONFIG_HEADER(config.h)
18AC_CONFIG_SRCDIR(libtransmission/transmission.h)
19AM_INIT_AUTOMAKE([1.9 tar-ustar])
20AC_PROG_LIBTOOL
21
22if test m4_substr(peer_id_prefix,6,1) = "0"; then
23  supported_build=yes
24  if test "x$GCC" = "xyes" ; then
25    CFLAGS="$CFLAGS -g -O3 -funroll-loops "
26    CXXFLAGS="$CXXFLAGS -g -O3 -funroll-loops "
27  fi
28  AC_DEFINE(TR_STABLE_RELEASE, 1, [Define to 1 if this is a stable release of Transmission])
29else
30  supported_build=no
31  if test "x$GCC" = "xyes" ; then
32    CFLAGS="$CFLAGS -g -O0"
33    CXXFLAGS="$CXXFLAGS -g -O0"
34  fi
35  if test m4_substr(peer_id_prefix,6,1) = "X"; then
36    AC_DEFINE(TR_BETA_RELEASE, 1, [Define to 1 if this is a beta release of Transmission])
37  else
38    AC_DEFINE(TR_NIGHTLY_RELEASE, 1, [Define to 1 if this is a nightly release of Transmission])
39  fi
40fi
41AM_CONDITIONAL(TR_UNSTABLE, test "x$supported_build" = "xno")
42
43OPENSSL_MINIMUM=0.9.4
44CURL_MINIMUM=7.16.3
45GIO_MINIMUM=2.15.5
46GLIB_MINIMUM=2.6.0
47GTK_MINIMUM=2.6.0
48WX_MINIMUM=2.6.0
49LIBNOTIFY_MINIMUM=0.4.3
50DBUS_GLIB_MINIMUM=0.70
51AC_SUBST(OPENSSL_MINIMUM)
52AC_SUBST(CURL_MINIMUM)
53AC_SUBST(GIO_MINIMUM)
54AC_SUBST(GLIB_MINIMUM)
55AC_SUBST(GTK_MINIMUM)
56AC_SUBST(WX_MINIMUM)
57AC_SUBST(LIBNOTIFY_MINIMUM)
58AC_SUBST(DBUS_GLIB_MINIMUM)
59
60AC_PROG_CC
61AC_PROG_CXX
62AC_C_INLINE
63if test "x$GCC" = "xyes" ; then
64
65    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"
66
67    dnl figure out gcc version
68    AC_MSG_CHECKING([gcc version])
69    GCC_VERSION=`$CC -dumpversion`
70    GCC_MAJOR=`echo $GCC_VERSION | cut -d . -f1`
71    GCC_MINOR=`echo $GCC_VERSION | cut -d . -f2`
72    GCC_VERSION_NUM=`(expr $GCC_MAJOR "*" 100 + $GCC_MINOR) 2>/dev/null`
73
74    AC_MSG_RESULT($GCC_VERSION)
75    if test $GCC_VERSION_NUM -ge 304; then
76        dnl these were added in 3.4
77        CFLAGS="$CFLAGS -Wextra -Wdeclaration-after-statement -Winit-self"
78    fi
79fi
80
81AC_HEADER_STDC
82AC_HEADER_TIME
83
84AC_MSG_CHECKING([for fallocate])
85AC_TRY_LINK([#include <linux/falloc.h>],
86            [return fallocate(-1,0,0,0);],
87            [AC_DEFINE([HAVE_FALLOCATE],[1],[Defined if fallocate() exists])
88             AC_MSG_RESULT([yes])],
89            [AC_MSG_RESULT([no])])
90AC_CHECK_FUNCS([lrintf strlcpy daemon dirname basename daemon strcasecmp localtime_r posix_fallocate])
91AC_PROG_INSTALL
92AC_PROG_MAKE_SET
93ACX_PTHREAD
94
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
102
103
104dnl ----------------------------------------------------------------------------
105dnl
106dnl posix_fadvise
107
108dnl can posix_fadvise be used
109AC_CHECK_DECLS(posix_fadvise, [], [], [
110#define _XOPEN_SOURCE 600
111#include <fcntl.h>])
112AC_CHECK_FUNCS([posix_fadvise])
113
114
115dnl ----------------------------------------------------------------------------
116dnl
117dnl file monitoring for the daemon
118
119AC_CHECK_HEADER([sys/inotify.h],
120                [AC_CHECK_FUNC([inotify_init],[have_inotify="yes"],[have_inotify="no"])],
121                [have_inotify="no"])
122AC_ARG_WITH([inotify],
123            [AS_HELP_STRING([--with-inotify],[Enable inotify support (default=auto)])],
124            [want_inotify=${enableval}],
125            [want_inotify=${have_inotify}])
126if test "x$want_inotify" = "xyes" ; then
127    if test "x$have_inotify" = "xyes"; then
128      AC_DEFINE([WITH_INOTIFY],[1])
129    else
130      AC_MSG_ERROR("inotify not found!")
131    fi
132fi
133 
134AC_CHECK_HEADER([sys/event.h],
135                [AC_CHECK_FUNC([kqueue],[have_kqueue="yes"],[have_kqueue="no"])],
136                [have_kqueue="no"])
137AC_ARG_WITH([kqueue],
138            [AS_HELP_STRING([--with-kqueue],[Enable kqueue support (default=auto)])],
139            [want_kqueue=${enableval}],
140            [want_kqueue=${have_kqueue}])
141if test "x$want_kqueue" = "xyes" ; then
142    if test "x$have_kqueue" = "xyes"; then
143      AC_DEFINE([WITH_KQUEUE],[1])
144    else
145      AC_MSG_ERROR("kqueue not found!")
146    fi
147fi
148
149
150dnl ----------------------------------------------------------------------------
151dnl
152dnl va_copy
153
154AC_MSG_CHECKING([how to copy va_list])
155AC_TRY_LINK([#include <stdarg.h>], [va_list ap1, ap2; va_copy(ap1, ap2);],
156    AC_MSG_RESULT([va_copy]),
157        [ AH_TEMPLATE([va_copy], [define if va_copy is not available])
158        AC_TRY_LINK([#include <stdarg.h>], [va_list ap1, ap2; __va_copy(ap1, ap2);],
159        [ AC_DEFINE([va_copy], [__va_copy])
160        AC_MSG_RESULT([__va_copy])],
161        [ AC_DEFINE([va_copy(dest,src)], [memcpy(&dest,&src,sizeof(va_list))])
162        AC_MSG_RESULT([memcpy])]
163    )
164])
165
166dnl ----------------------------------------------------------------------------
167dnl
168dnl  libevent fun
169
170AC_CONFIG_SUBDIRS([third-party/libevent])
171AC_MSG_NOTICE([invoking libevent's configure script])
172LIBEVENT_CPPFLAGS="-I\$(top_srcdir)/third-party/libevent"
173AC_SUBST(LIBEVENT_CPPFLAGS)
174
175
176dnl ----------------------------------------------------------------------------
177dnl
178dnl  detection for the GTK+ client
179
180PKG_CHECK_MODULES(GTK,
181                  [gtk+-2.0 >= $GTK_MINIMUM
182                   glib-2.0 >= $GLIB_MINIMUM
183                   gmodule-2.0 >= $GLIB_MINIMUM
184                   gthread-2.0 >= $GLIB_MINIMUM],
185                  [have_gtk=yes],
186                  [have_gtk=no])
187AC_ARG_ENABLE([gtk],
188              AS_HELP_STRING([--enable-gtk],[build gtk client]),
189              [want_gtk=${enableval}],
190              [want_gtk=${have_gtk}])
191build_gtk=no
192use_gio=no
193use_libnotify=no
194use_dbus_glib=no
195if test "x$want_gtk" = "xyes" ; then
196    if test "x$have_gtk" = "xyes"; then
197      build_gtk=yes
198    else
199      AC_MSG_ERROR("GTK+ not found!")
200    fi
201fi
202AM_CONDITIONAL([BUILD_GTK],[test "x$build_gtk" = "xyes"])
203AC_SUBST(GTK_LIBS)
204AC_SUBST(GTK_CFLAGS)
205
206if test "x$build_gtk" = "xyes"; then
207
208    PKG_CHECK_MODULES([GIO],
209                      [gio-2.0 >= $GIO_MINIMUM],
210                      [use_gio=yes],
211                      [use_gio=no])
212    AC_SUBST(GIO_LIBS)
213    AC_SUBST(GIO_CFLAGS)
214    if test "x$use_gio" = "xyes"; then
215        AC_DEFINE([HAVE_GIO], 1)
216    fi
217
218    PKG_CHECK_MODULES([LIBNOTIFY],
219                      [libnotify >= $LIBNOTIFY_MINIMUM],
220                      [have_libnotify=yes],
221                      [have_libnotify=no])
222    AC_ARG_ENABLE([libnotify],
223                  AS_HELP_STRING([--enable-libnotify],[enable notifications]),,
224                  [enable_libnotify=yes])
225    use_libnotify=no
226    if test "x$enable_libnotify" = "xyes" ; then
227        if test "x$have_libnotify" = "xyes"; then
228            use_libnotify=yes
229            AC_SUBST(LIBNOTIFY_LIBS)
230            AC_SUBST(LIBNOTIFY_CFLAGS)
231            AC_DEFINE([HAVE_LIBNOTIFY], 1)
232        fi
233    fi
234
235    PKG_CHECK_MODULES([DBUS_GLIB],
236                      [dbus-glib-1 >= $DBUS_GLIB_MINIMUM],
237                      [use_dbus_glib=yes],
238                      [use_dbus_glib=no])
239    AC_SUBST(DBUS_GLIB_LIBS)
240    AC_SUBST(DBUS_GLIB_CFLAGS)
241    if test "x$use_dbus_glib" = "xyes"; then
242        AC_DEFINE([HAVE_DBUS_GLIB], 1)
243    fi
244    if test "x$use_dbus_glib" = "xyes"; then
245        AC_PATH_PROG(DBUS_BINDING_TOOL, dbus-binding-tool, no)
246        if test "x$DBUS_BINDING_TOOL" = xno; then
247          AC_MSG_WARN([Cannot find dbus-binding-tool])
248          use_dbus_glib="no (dbus-binding-tool not found)"
249        fi
250    fi
251fi
252
253AC_ARG_ENABLE([nls],
254              AS_HELP_STRING([--enable-nls],[enable native language support]),,
255              [enable_nls=yes])
256
257if test "x$build_gtk" = "xyes" -a  "x$enable_nls" = "xno" ; then
258    AC_MSG_ERROR("The gtk client cannot be built without nls support.  Try adding either --enable-nls or --disable-gtk" )
259fi
260
261use_nls=no
262if test "x$enable_nls" = "xyes" ; then
263    use_nls=yes
264    IT_PROG_INTLTOOL([0.23],[no-xml])
265    AC_CHECK_HEADERS([libintl.h])
266    GETTEXT_PACKAGE=transmission
267    AC_SUBST(GETTEXT_PACKAGE)
268    AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[Gettext package])
269    AM_GLIB_GNU_GETTEXT
270    transmissionlocaledir='${prefix}/${DATADIRNAME}/locale'
271    AC_SUBST(transmissionlocaledir)
272fi
273
274dnl ----------------------------------------------------------------------------
275dnl
276dnl  wxWidgets detection for the wxWidgets client
277
278build_wx=no
279AC_ARG_ENABLE([wx],
280              AS_HELP_STRING([--enable-wx],[build wxWidgets client]),
281              [want_wx=${enableval}],
282              [want_wx=no])
283if test "x$want_wx" != "xno"; then
284    AM_OPTIONS_WXCONFIG
285    AM_PATH_WXCONFIG($WX_MINIMUM,[have_wx=yes],[have_wx=no])
286    if test "x$have_wx" = "xyes"; then
287        build_wx=yes
288    elif test "x$want_wx" = "xyes"; then
289        AC_MSG_ERROR("wxWidgets not found!")
290    fi
291fi
292AM_CONDITIONAL([BUILD_WX],[test "x$build_wx" = "xyes"])
293
294
295
296dnl ----------------------------------------------------------------------------
297dnl
298dnl  platform-specific stuff.
299
300AC_CANONICAL_HOST
301have_darwin="no"
302have_msw="no"
303case $host_os in
304
305   *cygwin|*mingw32*)
306     have_msw="yes"
307     CXXFLAGS="$CXXFLAGS -mms-bitfields -mwin32 -mwindows"
308     CPPFLAGS="$CPPFLAGS -DWIN32 -D_WIN32 -DWIN32_LEAN_AND_MEAN"
309     LIBS="$LIBS -lshell32 -lws2_32"
310     transmissionlocaledir="locale"
311     if test -z "$host_alias"; then
312       hostaliaswindres=
313     else
314       hostaliaswindres="$host_alias-windres";
315     fi
316     AC_CHECK_TOOL(WINDRES, windres)
317     ;;
318
319  *darwin*)
320    have_darwin="yes"
321    # Make sure the Universal SDK is installed
322    if test ! -d /Developer/SDKs/MacOSX10.4u.sdk; then
323      cat << EOF
324You need to install the Universal SDK in order to build Transmission:
325  Get your Xcode CD or package
326  Restart the install
327  When it gets to "Installation Type", select "Customize"
328  Select "Mac OS X 10.4 (Universal) SDK" under "Cross Development"
329  Finish the install.
330EOF
331      exit 1
332    fi
333    ;;
334
335esac
336
337AC_ARG_ENABLE([cli],
338              [AS_HELP_STRING([--enable-cli],[build command-line client])],
339              [build_cli=${enableval}],
340              [build_cli="yes"])
341AM_CONDITIONAL([BUILD_CLI],[test "x$build_cli" = "xyes"])
342
343AC_ARG_ENABLE([mac],
344              [AS_HELP_STRING([--enable-mac],[build OS X client])],
345              [build_mac=${enableval}],
346              [build_mac=${have_darwin}])
347AM_CONDITIONAL([BUILD_MAC],[test "x$build_mac" = "xyes"])
348
349AC_ARG_ENABLE([daemon],
350              [AS_HELP_STRING([--enable-daemon],[build daemon])],
351              [build_daemon=${enableval}],
352              [build_daemon="yes"])
353AM_CONDITIONAL([BUILD_DAEMON],[test "x$build_daemon" = "xyes"])
354
355
356if test "x$have_darwin" = "xyes"; then
357    AC_DEFINE([HAVE_DARWIN], 1)
358fi
359if test "x$have_msw" = "xyes"; then
360    AC_DEFINE([HAVE_MSW], 1)
361fi
362AM_CONDITIONAL(WIN32, test "x$have_msw" = "xyes")
363
364dnl ----------------------------------------------------------------------------
365dnl
366dnl  Generate the output
367
368AC_CONFIG_FILES([Makefile
369                 transmission.spec
370                 cli/Makefile
371                 daemon/Makefile
372                 doc/Makefile
373                 libtransmission/Makefile
374                 third-party/Makefile
375                 third-party/miniupnp/Makefile
376                 third-party/libnatpmp/Makefile
377                 macosx/Makefile
378                 wx/Makefile
379                 wx/images/Makefile
380                 gtk/Makefile
381                 gtk/icons/Makefile
382                 po/Makefile.in])
383
384ac_configure_args="$ac_configure_args --enable-static --disable-shared -q"
385AC_OUTPUT
386
387echo "
388
389Configuration:
390
391        Source code location:       ${srcdir}
392        Compiler:                   ${CXX}
393        Build Command-Line client:  ${build_cli}
394        Build Daemon:               ${build_daemon}
395        Build GTK+ client:          ${build_gtk}
396          ... gio support:          ${use_gio}
397          ... dbus-glib support:    ${use_dbus_glib}
398          ... libnotify support:    ${use_libnotify}
399        Build OS X client:          ${build_mac}
400        Build wxWidgets client:     ${build_wx}
401
402"
Note: See TracBrowser for help on using the repository browser.