source: trunk/configure.ac @ 7896

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

(trunk) local CFLAGS and CXXFLAGS environment variables are clobbered

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