source: trunk/configure.ac @ 8549

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

(trunk) #2125: Get svn revision number with autoconf rather than make

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