source: trunk/configure.ac @ 8901

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

(trunk) fix r8893 oops: I accidentally committed a one-liner in configure.ac that I use to get T building on a machine that doesn't have intltool 0.40

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