source: trunk/configure.ac @ 8719

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

(trunk) autoconf/automake: move libdht.a into a DHT_LIBS variable

File size: 12.5 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.72])
7m4_define([peer_id_prefix],[-TR1720-])
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 "
26    CXXFLAGS="$CXXFLAGS -g -O3 "
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
48LIBNOTIFY_MINIMUM=0.4.3
49DBUS_GLIB_MINIMUM=0.70
50LIBEVENT_MINIMUM=1.4.5
51AC_SUBST(OPENSSL_MINIMUM)
52AC_SUBST(CURL_MINIMUM)
53AC_SUBST(GIO_MINIMUM)
54AC_SUBST(GLIB_MINIMUM)
55AC_SUBST(GTK_MINIMUM)
56AC_SUBST(LIBNOTIFY_MINIMUM)
57AC_SUBST(DBUS_GLIB_MINIMUM)
58AC_SUBST(LIBEVENT_MINIUM)
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_CHECK_FUNCS([lrintf strlcpy daemon dirname basename daemon strcasecmp localtime_r posix_fallocate memmem])
85AC_PROG_INSTALL
86AC_PROG_MAKE_SET
87ACX_PTHREAD
88
89AC_SEARCH_LIBS([socket], [socket net])
90AC_SEARCH_LIBS([gethostbyname], [nsl bind])
91PKG_CHECK_MODULES(OPENSSL, [openssl >= $OPENSSL_MINIMUM], , [CHECK_SSL()])
92PKG_CHECK_MODULES(LIBCURL, [libcurl >= $CURL_MINIMUM])
93AC_PATH_ZLIB
94
95AC_SYS_LARGEFILE
96
97
98dnl ----------------------------------------------------------------------------
99dnl
100dnl posix_fadvise
101
102dnl can posix_fadvise be used
103AC_CHECK_DECLS(posix_fadvise, [], [], [
104#define _XOPEN_SOURCE 600
105#include <fcntl.h>])
106AC_CHECK_FUNCS([posix_fadvise])
107
108
109dnl ----------------------------------------------------------------------------
110dnl
111dnl file monitoring for the daemon
112
113AC_CHECK_HEADER([sys/inotify.h],
114                [AC_CHECK_FUNC([inotify_init],[have_inotify="yes"],[have_inotify="no"])],
115                [have_inotify="no"])
116AC_ARG_WITH([inotify],
117            [AS_HELP_STRING([--with-inotify],[Enable inotify support (default=auto)])],
118            [want_inotify=${enableval}],
119            [want_inotify=${have_inotify}])
120if test "x$want_inotify" = "xyes" ; then
121    if test "x$have_inotify" = "xyes"; then
122      AC_DEFINE([WITH_INOTIFY],[1])
123    else
124      AC_MSG_ERROR("inotify not found!")
125    fi
126fi
127 
128AC_CHECK_HEADER([sys/event.h],
129                [AC_CHECK_FUNC([kqueue],[have_kqueue="yes"],[have_kqueue="no"])],
130                [have_kqueue="no"])
131AC_ARG_WITH([kqueue],
132            [AS_HELP_STRING([--with-kqueue],[Enable kqueue support (default=auto)])],
133            [want_kqueue=${enableval}],
134            [want_kqueue=${have_kqueue}])
135if test "x$want_kqueue" = "xyes" ; then
136    if test "x$have_kqueue" = "xyes"; then
137      AC_DEFINE([WITH_KQUEUE],[1])
138    else
139      AC_MSG_ERROR("kqueue not found!")
140    fi
141fi
142
143AC_CHECK_HEADERS([xfs/xfs.h])
144
145
146dnl ----------------------------------------------------------------------------
147dnl
148dnl va_copy
149
150AC_MSG_CHECKING([how to copy va_list])
151AC_TRY_LINK([#include <stdarg.h>], [va_list ap1, ap2; va_copy(ap1, ap2);],
152    AC_MSG_RESULT([va_copy]),
153        [ AH_TEMPLATE([va_copy], [define if va_copy is not available])
154        AC_TRY_LINK([#include <stdarg.h>], [va_list ap1, ap2; __va_copy(ap1, ap2);],
155        [ AC_DEFINE([va_copy], [__va_copy])
156        AC_MSG_RESULT([__va_copy])],
157        [ AC_DEFINE([va_copy(dest,src)], [memcpy(&dest,&src,sizeof(va_list))])
158        AC_MSG_RESULT([memcpy])]
159    )
160])
161
162
163dnl build our copy of libevent whether we use it or not,
164dnl because "make dist" needs its Makefiles to exist, and
165dnl AM_CONDITIONAL + AC_CONFIG_SUBDIRS don't seem to play nice
166AC_CONFIG_SUBDIRS([third-party/libevent])
167libevent_source=bundled
168AC_CHECK_LIB([event],[evutil_vsnprintf],
169             [libevent_found=yes],
170             [libevent_found=no],
171             [-levent])
172AC_CHECK_HEADER([event-config.h],
173                [libevent_headers_found=yes],
174                [libevent_headers_found=no])
175libevent_source=bundled
176if test "x$libevent_found" = "xyes" ; then
177    if test "x$libevent_headers_found" = "xyes"; then
178      libevent_source=system
179    fi
180fi
181if test "x$libevent_source" = "xbundled"; then
182    AC_MSG_WARN([using our own libevent from third-party/libevent/])
183    AC_MSG_WARN([if you are cross-compiling this is probably NOT what you want.])
184    LIBEVENT_CFLAGS="-I\$(top_srcdir)/third-party/libevent -I\$(top_builddir)/third-party/libevent"
185    LIBEVENT_LIBS="\$(top_builddir)/third-party/libevent/libevent.la"
186else
187    LIBEVENT_CFLAGS=""
188    LIBEVENT_LIBS="-levent -lrt"
189fi
190AC_SUBST(LIBEVENT_CFLAGS)
191AC_SUBST(LIBEVENT_LIBS)
192
193
194dnl ----------------------------------------------------------------------------
195dnl
196dnl  dht
197
198DHT_CFLAGS="-I\$(top_srcdir)/third-party/dht"
199DHT_LIBS="\$(top_builddir)/third-party/dht/libdht.a"
200AC_SUBST(DHT_CFLAGS)
201AC_SUBST(DHT_LIBS)
202
203
204dnl ----------------------------------------------------------------------------
205dnl
206dnl  detection for the GTK+ client
207
208PKG_CHECK_MODULES(GTK,
209                  [gtk+-2.0 >= $GTK_MINIMUM
210                   glib-2.0 >= $GLIB_MINIMUM
211                   gmodule-2.0 >= $GLIB_MINIMUM
212                   gthread-2.0 >= $GLIB_MINIMUM],
213                  [have_gtk=yes],
214                  [have_gtk=no])
215AC_ARG_ENABLE([gtk],
216              AS_HELP_STRING([--enable-gtk],[build gtk client]),
217              [want_gtk=${enableval}],
218              [want_gtk=${have_gtk}])
219build_gtk=no
220use_gio=no
221use_libnotify=no
222use_dbus_glib=no
223if test "x$want_gtk" = "xyes" ; then
224    if test "x$have_gtk" = "xyes"; then
225      build_gtk=yes
226    else
227      AC_MSG_ERROR("GTK+ not found!")
228    fi
229fi
230AM_CONDITIONAL([BUILD_GTK],[test "x$build_gtk" = "xyes"])
231AC_SUBST(GTK_LIBS)
232AC_SUBST(GTK_CFLAGS)
233
234if test "x$build_gtk" = "xyes"; then
235
236    PKG_CHECK_MODULES([GIO],
237                      [gio-2.0 >= $GIO_MINIMUM],
238                      [use_gio=yes],
239                      [use_gio=no])
240    AC_SUBST(GIO_LIBS)
241    AC_SUBST(GIO_CFLAGS)
242    if test "x$use_gio" = "xyes"; then
243        AC_DEFINE([HAVE_GIO], 1)
244    fi
245
246    PKG_CHECK_MODULES([LIBNOTIFY],
247                      [libnotify >= $LIBNOTIFY_MINIMUM],
248                      [have_libnotify=yes],
249                      [have_libnotify=no])
250    AC_ARG_ENABLE([libnotify],
251                  AS_HELP_STRING([--enable-libnotify],[enable notifications]),,
252                  [enable_libnotify=yes])
253    use_libnotify=no
254    if test "x$enable_libnotify" = "xyes" ; then
255        if test "x$have_libnotify" = "xyes"; then
256            use_libnotify=yes
257            AC_SUBST(LIBNOTIFY_LIBS)
258            AC_SUBST(LIBNOTIFY_CFLAGS)
259            AC_DEFINE([HAVE_LIBNOTIFY], 1)
260        fi
261    fi
262
263    PKG_CHECK_MODULES([DBUS_GLIB],
264                      [dbus-glib-1 >= $DBUS_GLIB_MINIMUM],
265                      [use_dbus_glib=yes],
266                      [use_dbus_glib=no])
267    AC_SUBST(DBUS_GLIB_LIBS)
268    AC_SUBST(DBUS_GLIB_CFLAGS)
269    if test "x$use_dbus_glib" = "xyes"; then
270        AC_DEFINE([HAVE_DBUS_GLIB], 1)
271    fi
272    if test "x$use_dbus_glib" = "xyes"; then
273        AC_PATH_PROG(DBUS_BINDING_TOOL, dbus-binding-tool, no)
274        if test "x$DBUS_BINDING_TOOL" = xno; then
275          AC_MSG_WARN([Cannot find dbus-binding-tool])
276          use_dbus_glib="no (dbus-binding-tool not found)"
277        fi
278    fi
279fi
280
281AC_ARG_ENABLE([nls],
282              AS_HELP_STRING([--enable-nls],[enable native language support]),,
283              [enable_nls=yes])
284
285if test "x$build_gtk" = "xyes" -a  "x$enable_nls" = "xno" ; then
286    AC_MSG_ERROR("The gtk client cannot be built without nls support.  Try adding either --enable-nls or --disable-gtk" )
287fi
288
289use_nls=no
290if test "x$enable_nls" = "xyes" ; then
291    use_nls=yes
292    IT_PROG_INTLTOOL([0.40.0],[no-xml])
293    AC_CHECK_HEADERS([libintl.h])
294    GETTEXT_PACKAGE=transmission
295    AC_SUBST(GETTEXT_PACKAGE)
296    AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[Gettext package])
297    AM_GLIB_GNU_GETTEXT
298    transmissionlocaledir='${prefix}/${DATADIRNAME}/locale'
299    AC_SUBST(transmissionlocaledir)
300fi
301
302
303dnl ----------------------------------------------------------------------------
304dnl
305dnl  platform-specific stuff.
306
307AC_CANONICAL_HOST
308have_darwin="no"
309have_msw="no"
310case $host_os in
311
312   *cygwin|*mingw32*)
313     have_msw="yes"
314     CXXFLAGS="$CXXFLAGS -mms-bitfields -mwin32 -mwindows"
315     CPPFLAGS="$CPPFLAGS -DWIN32 -D_WIN32 -DWIN32_LEAN_AND_MEAN"
316     LIBS="$LIBS -lshell32 -lws2_32"
317     transmissionlocaledir="locale"
318     if test -z "$host_alias"; then
319       hostaliaswindres=
320     else
321       hostaliaswindres="$host_alias-windres";
322     fi
323     AC_CHECK_TOOL(WINDRES, windres)
324     ;;
325
326  *darwin*)
327    have_darwin="yes"
328    # Make sure the Universal SDK is installed
329    if test ! -d /Developer/SDKs/MacOSX10.4u.sdk; then
330      cat << EOF
331You need to install the Universal SDK in order to build Transmission:
332  Get your Xcode CD or package
333  Restart the install
334  When it gets to "Installation Type", select "Customize"
335  Select "Mac OS X 10.4 (Universal) SDK" under "Cross Development"
336  Finish the install.
337EOF
338      exit 1
339    fi
340    ;;
341
342esac
343
344AC_ARG_ENABLE([cli],
345              [AS_HELP_STRING([--enable-cli],[build command-line client])],
346              [build_cli=${enableval}],
347              [build_cli="yes"])
348AM_CONDITIONAL([BUILD_CLI],[test "x$build_cli" = "xyes"])
349
350AC_ARG_ENABLE([mac],
351              [AS_HELP_STRING([--enable-mac],[build OS X client])],
352              [build_mac=${enableval}],
353              [build_mac=${have_darwin}])
354AM_CONDITIONAL([BUILD_MAC],[test "x$build_mac" = "xyes"])
355
356AC_ARG_ENABLE([daemon],
357              [AS_HELP_STRING([--enable-daemon],[build daemon])],
358              [build_daemon=${enableval}],
359              [build_daemon="yes"])
360AM_CONDITIONAL([BUILD_DAEMON],[test "x$build_daemon" = "xyes"])
361
362
363if test "x$have_darwin" = "xyes"; then
364    AC_DEFINE([HAVE_DARWIN], 1)
365fi
366if test "x$have_msw" = "xyes"; then
367    AC_DEFINE([HAVE_MSW], 1)
368fi
369AM_CONDITIONAL(WIN32, test "x$have_msw" = "xyes")
370
371dnl ----------------------------------------------------------------------------
372dnl
373dnl  Generate the output
374
375AC_CONFIG_FILES([Makefile
376                 transmission.spec
377                 cli/Makefile
378                 daemon/Makefile
379                 doc/Makefile
380                 libtransmission/Makefile
381                 third-party/Makefile
382                 third-party/miniupnp/Makefile
383                 third-party/libnatpmp/Makefile
384                 third-party/dht/Makefile
385                 macosx/Makefile
386                 gtk/Makefile
387                 gtk/icons/Makefile
388                 po/Makefile.in])
389
390ac_configure_args="$ac_configure_args --enable-static --disable-shared -q"
391AC_OUTPUT
392
393echo "
394
395Configuration:
396
397        Source code location:          ${srcdir}
398        Compiler:                      ${CXX}
399        System or bundled libevent:    ${libevent_source}
400
401        Build OS X client:             ${build_mac}
402        Build GTK+ client:             ${build_gtk}
403          ... with gio support:        ${use_gio}
404          ... with dbus-glib support:  ${use_dbus_glib}
405          ... with libnotify support:  ${use_libnotify}
406        Build Command-Line client:     ${build_cli}
407        Build Daemon:                  ${build_daemon}
408
409"
Note: See TracBrowser for help on using the repository browser.