source: trunk/configure.ac @ 8887

Last change on this file since 8887 was 8887, checked in by charles, 11 years ago

(trunk) #2323: autoconf patch to buil transmission on cygwin (tbucked)

File size: 13.6 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
206
207AC_ARG_ENABLE([dht],
208              AS_HELP_STRING([--disable-dht],[omit DHT support]),
209              [enable_dht=${enableval}],
210              [enable_dht=yes])
211if test "x$enable_dht" = "xno" ; then
212    AC_DEFINE([WITHOUT_DHT], 1)
213    DHT_CFLAGS=""
214    DHT_LIBS=""
215else
216    DHT_CFLAGS="-I\$(top_srcdir)/third-party/dht"
217    DHT_LIBS="\$(top_builddir)/third-party/dht/libdht.a"
218fi
219AM_CONDITIONAL(DHT, test "x$enable_dht" = "xyes")
220AC_SUBST(DHT_CFLAGS)
221AC_SUBST(DHT_LIBS)
222
223
224dnl ----------------------------------------------------------------------------
225dnl
226dnl  detection for the GTK+ client
227
228PKG_CHECK_MODULES(GTK,
229                  [gtk+-2.0 >= $GTK_MINIMUM
230                   glib-2.0 >= $GLIB_MINIMUM
231                   gmodule-2.0 >= $GLIB_MINIMUM
232                   gthread-2.0 >= $GLIB_MINIMUM],
233                  [have_gtk=yes],
234                  [have_gtk=no])
235AC_ARG_ENABLE([gtk],
236              AS_HELP_STRING([--enable-gtk],[build gtk client]),
237              [want_gtk=${enableval}],
238              [want_gtk=${have_gtk}])
239build_gtk=no
240use_gio=no
241use_libnotify=no
242use_dbus_glib=no
243if test "x$want_gtk" = "xyes" ; then
244    if test "x$have_gtk" = "xyes"; then
245      build_gtk=yes
246    else
247      AC_MSG_ERROR("GTK+ not found!")
248    fi
249fi
250AM_CONDITIONAL([BUILD_GTK],[test "x$build_gtk" = "xyes"])
251AC_SUBST(GTK_LIBS)
252AC_SUBST(GTK_CFLAGS)
253
254if test "x$build_gtk" = "xyes"; then
255
256    PKG_CHECK_MODULES([GIO],
257                      [gio-2.0 >= $GIO_MINIMUM],
258                      [use_gio=yes],
259                      [use_gio=no])
260    AC_SUBST(GIO_LIBS)
261    AC_SUBST(GIO_CFLAGS)
262    if test "x$use_gio" = "xyes"; then
263        AC_DEFINE([HAVE_GIO], 1)
264    fi
265
266    PKG_CHECK_MODULES([LIBNOTIFY],
267                      [libnotify >= $LIBNOTIFY_MINIMUM],
268                      [have_libnotify=yes],
269                      [have_libnotify=no])
270    AC_ARG_ENABLE([libnotify],
271                  AS_HELP_STRING([--enable-libnotify],[enable notifications]),,
272                  [enable_libnotify=yes])
273    use_libnotify=no
274    if test "x$enable_libnotify" = "xyes" ; then
275        if test "x$have_libnotify" = "xyes"; then
276            use_libnotify=yes
277            AC_SUBST(LIBNOTIFY_LIBS)
278            AC_SUBST(LIBNOTIFY_CFLAGS)
279            AC_DEFINE([HAVE_LIBNOTIFY], 1)
280        fi
281    fi
282
283    PKG_CHECK_MODULES([DBUS_GLIB],
284                      [dbus-glib-1 >= $DBUS_GLIB_MINIMUM],
285                      [use_dbus_glib=yes],
286                      [use_dbus_glib=no])
287    AC_SUBST(DBUS_GLIB_LIBS)
288    AC_SUBST(DBUS_GLIB_CFLAGS)
289    if test "x$use_dbus_glib" = "xyes"; then
290        AC_DEFINE([HAVE_DBUS_GLIB], 1)
291    fi
292    if test "x$use_dbus_glib" = "xyes"; then
293        AC_PATH_PROG(DBUS_BINDING_TOOL, dbus-binding-tool, no)
294        if test "x$DBUS_BINDING_TOOL" = xno; then
295          AC_MSG_WARN([Cannot find dbus-binding-tool])
296          use_dbus_glib="no (dbus-binding-tool not found)"
297        fi
298    fi
299fi
300
301AC_ARG_ENABLE([nls],
302              AS_HELP_STRING([--enable-nls],[enable native language support]),,
303              [enable_nls=yes])
304
305if test "x$build_gtk" = "xyes" -a  "x$enable_nls" = "xno" ; then
306    AC_MSG_ERROR("The gtk client cannot be built without nls support.  Try adding either --enable-nls or --disable-gtk" )
307fi
308
309dnl This section is only used for internationalization.
310dnl If you don't need translations and this section gives you trouble --
311dnl such as if you're building for a headless system --
312dnl it's okay to tear this section out and re-build the configure script.
313dnl
314dnl Note to packagers: the bump to intltool 0.40 was made to fix
315dnl a "make check" failure on some systems.  if upgrading to 0.40 is
316dnl a problem and the old version was working fine for you,
317dnl it should be safe to re-edit 0.40 back down to 0.23
318
319use_nls=no
320if test "x$enable_nls" = "xyes" ; then
321    use_nls=yes
322    IT_PROG_INTLTOOL([0.40.0],[no-xml])
323    AC_CHECK_HEADERS([libintl.h])
324    GETTEXT_PACKAGE=transmission
325    AC_SUBST(GETTEXT_PACKAGE)
326    AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[Gettext package])
327    AM_GLIB_GNU_GETTEXT
328    transmissionlocaledir='${prefix}/${DATADIRNAME}/locale'
329    AC_SUBST(transmissionlocaledir)
330fi
331
332
333dnl ----------------------------------------------------------------------------
334dnl
335dnl  platform-specific stuff.
336
337AC_CANONICAL_HOST
338have_darwin="no"
339have_msw="no"
340case $host_os in
341
342   *mingw32*)
343     have_msw="yes"
344     CXXFLAGS="$CXXFLAGS -mms-bitfields -mwin32 -mwindows"
345     CPPFLAGS="$CPPFLAGS -DWIN32 -D_WIN32 -DWIN32_LEAN_AND_MEAN"
346     LIBS="$LIBS -lshell32 -lws2_32"
347     transmissionlocaledir="locale"
348     if test -z "$host_alias"; then
349       hostaliaswindres=
350     else
351       hostaliaswindres="$host_alias-windres";
352     fi
353     AC_CHECK_TOOL(WINDRES, windres)
354     ;;
355
356  *darwin*)
357    have_darwin="yes"
358    # Make sure the proper Mac SDK is installed
359    if test ! -d /Developer/SDKs/MacOSX10.5.sdk; then
360      cat << EOF
361You need to install the Mac OS X 10.5 SDK in order to build Transmission:
362  Get your Xcode CD or package
363  Restart the install
364  When it gets to "Installation Type", select "Customize"
365  Select "Mac OS X 10.5 SDK" under "Cross Development"
366  Finish the install.
367EOF
368      exit 1
369    fi
370    ;;
371
372esac
373
374AC_ARG_ENABLE([cli],
375              [AS_HELP_STRING([--enable-cli],[build command-line client])],
376              [build_cli=${enableval}],
377              [build_cli="yes"])
378AM_CONDITIONAL([BUILD_CLI],[test "x$build_cli" = "xyes"])
379
380AC_ARG_ENABLE([mac],
381              [AS_HELP_STRING([--enable-mac],[build Mac client])],
382              [build_mac=${enableval}],
383              [build_mac=${have_darwin}])
384AM_CONDITIONAL([BUILD_MAC],[test "x$build_mac" = "xyes"])
385
386AC_ARG_ENABLE([daemon],
387              [AS_HELP_STRING([--enable-daemon],[build daemon])],
388              [build_daemon=${enableval}],
389              [build_daemon="yes"])
390AM_CONDITIONAL([BUILD_DAEMON],[test "x$build_daemon" = "xyes"])
391
392
393if test "x$have_darwin" = "xyes"; then
394    AC_DEFINE([HAVE_DARWIN], 1)
395fi
396if test "x$have_msw" = "xyes"; then
397    AC_DEFINE([HAVE_MSW], 1)
398fi
399AM_CONDITIONAL(WIN32, test "x$have_msw" = "xyes")
400
401dnl ----------------------------------------------------------------------------
402dnl
403dnl  Generate the output
404
405AC_CONFIG_FILES([Makefile
406                 transmission.spec
407                 cli/Makefile
408                 daemon/Makefile
409                 doc/Makefile
410                 libtransmission/Makefile
411                 third-party/Makefile
412                 third-party/miniupnp/Makefile
413                 third-party/libnatpmp/Makefile
414                 third-party/dht/Makefile
415                 macosx/Makefile
416                 gtk/Makefile
417                 gtk/icons/Makefile
418                 po/Makefile.in])
419
420ac_configure_args="$ac_configure_args --enable-static --disable-shared -q"
421AC_OUTPUT
422
423echo "
424
425Configuration:
426
427        Source code location:          ${srcdir}
428        Compiler:                      ${CXX}
429        System or bundled libevent:    ${libevent_source}
430        DHT support:                   ${enable_dht}
431
432        Build Mac client:              ${build_mac}
433        Build GTK+ client:             ${build_gtk}
434          ... with gio support:        ${use_gio}
435          ... with dbus-glib support:  ${use_dbus_glib}
436          ... with libnotify support:  ${use_libnotify}
437        Build Command-Line client:     ${build_cli}
438        Build Daemon:                  ${build_daemon}
439
440"
Note: See TracBrowser for help on using the repository browser.