source: trunk/configure.ac @ 9522

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

(trunk) #2222: revert r8967, as foreshadowed in http://trac.transmissionbt.com/ticket/2222#comment:20

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