1 dnl convention: -TR MAJOR MINOR MAINT STATUS - (each a single char)
2 dnl STATUS: "X" for prerelease beta builds,
3 dnl "Z" for unsupported trunk builds,
4 dnl "0" for stable, supported releases
5 dnl these should be the only two lines you need to change
6 m4_define([user_agent_prefix],[2.51])
7 m4_define([peer_id_prefix],[-TR2510-])
9 AC_INIT([transmission],
11 [http://trac.transmissionbt.com/newticket])
12 AC_SUBST(USERAGENT_PREFIX,[user_agent_prefix])
13 AC_SUBST(PEERID_PREFIX,[peer_id_prefix])
15 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
17 AC_CONFIG_MACRO_DIR([m4])
19 dnl AM_CONFIG_HEADER(config.h)
20 AC_CONFIG_SRCDIR(libtransmission/transmission.h)
21 AM_INIT_AUTOMAKE([1.9 tar-pax])
24 if test m4_substr(peer_id_prefix,6,1) = "0"; then
26 CPPFLAGS="$CPPFLAGS -DNDEBUG"
29 if test "x$GCC" = "xyes" ; then
30 CFLAGS="$CFLAGS -g -O0"
31 CXXFLAGS="$CXXFLAGS -g -O0"
34 AM_CONDITIONAL(TR_UNSTABLE, test "x$supported_build" = "xno")
38 ## MANDATORY for everything
42 AC_SUBST(CURL_MINIMUM)
43 LIBEVENT_MINIMUM=2.0.10
44 AC_SUBST(LIBEVENT_MINIUM)
46 AC_SUBST(OPENSSL_MINIMUM)
50 ## MANDATORY for the GTK+ client
55 AC_SUBST(GTK2_MINIMUM)
57 AC_SUBST(GTK3_MINIMUM)
59 AC_SUBST(GLIB_MINIMUM)
65 ## OPTIONAL for the GTK+ client
69 # create the tray icon with AppIndicator
70 LIBAPPINDICATOR_MINIMUM=0.0.11
71 AC_SUBST(LIBAPPINDICATOR_MINIMUM)
76 if test "x$CXX" != "x"; then # CXX is set...
77 if test -f "$CXX"; then # maybe it's an absolute path passed in env variables...
78 AC_MSG_CHECKING([for $CXX])
80 AC_MSG_RESULT([$HAVE_CXX])
82 AC_CHECK_PROG([HAVE_CXX],[$CXX],[yes],[no])
86 if test "x$GCC" = "xyes" ; then
88 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 -Winline -Wfloat-equal"
90 dnl figure out gcc version
91 AC_MSG_CHECKING([gcc version])
92 GCC_VERSION=`$CC -dumpversion`
93 GCC_MAJOR=`echo $GCC_VERSION | cut -d . -f1`
94 GCC_MINOR=`echo $GCC_VERSION | cut -d . -f2`
95 GCC_VERSION_NUM=`(expr $GCC_MAJOR "*" 100 + $GCC_MINOR) 2>/dev/null`
97 AC_MSG_RESULT($GCC_VERSION)
98 if test $GCC_VERSION_NUM -ge 304; then
99 dnl these were added in 3.4
100 CFLAGS="$CFLAGS -Wextra -Wdeclaration-after-statement -Winit-self"
102 if test $GCC_VERSION_NUM -ge 403; then
103 dnl these were added in 4.3
104 CFLAGS="$CFLAGS -Wvariadic-macros"
111 AC_CHECK_HEADERS([stdbool.h])
112 AC_CHECK_FUNCS([iconv_open pread pwrite lrintf strlcpy daemon dirname basename strcasecmp localtime_r fallocate64 posix_fallocate memmem strsep strtold syslog valloc getpagesize posix_memalign statvfs htonll ntohll mkdtemp])
117 if test "x$ac_cv_func_strtold" != "xyes" ; then
118 CPPFLAGS="$CPPFLAGS -Dstrtold=strtod"
121 AC_SEARCH_LIBS(cos, [m])
122 AC_SEARCH_LIBS([socket], [socket net])
123 AC_SEARCH_LIBS([gethostbyname], [nsl bind])
124 PKG_CHECK_MODULES(OPENSSL, [openssl >= $OPENSSL_MINIMUM], , [CHECK_SSL()])
125 PKG_CHECK_MODULES(LIBCURL, [libcurl >= $CURL_MINIMUM])
126 PKG_CHECK_MODULES(LIBEVENT, [libevent >= $LIBEVENT_MINIMUM])
130 AC_CHECK_FUNCS([lseek64])
133 dnl ----------------------------------------------------------------------------
137 dnl can posix_fadvise be used
138 AC_CHECK_DECLS(posix_fadvise, [], [], [
139 #define _XOPEN_SOURCE 600
141 AC_CHECK_FUNCS([posix_fadvise])
144 dnl ----------------------------------------------------------------------------
146 dnl file monitoring for the daemon
148 AC_CHECK_HEADER([sys/inotify.h],
149 [AC_CHECK_FUNC([inotify_init],[have_inotify="yes"],[have_inotify="no"])],
151 AC_ARG_WITH([inotify],
152 [AS_HELP_STRING([--with-inotify],[Enable inotify support (default=auto)])],
153 [want_inotify=${withval}],
154 [want_inotify=${have_inotify}])
155 if test "x$want_inotify" = "xyes" ; then
156 if test "x$have_inotify" = "xyes"; then
157 AC_DEFINE([WITH_INOTIFY],[1])
159 AC_MSG_ERROR("inotify not found!")
163 AC_CHECK_HEADER([sys/event.h],
164 [AC_CHECK_FUNC([kqueue],[have_kqueue="yes"],[have_kqueue="no"])],
166 AC_ARG_WITH([kqueue],
167 [AS_HELP_STRING([--with-kqueue],[Enable kqueue support (default=auto)])],
168 [want_kqueue=${withval}],
169 [want_kqueue=${have_kqueue}])
170 if test "x$want_kqueue" = "xyes" ; then
171 if test "x$have_kqueue" = "xyes"; then
172 AC_DEFINE([WITH_KQUEUE],[1])
174 AC_MSG_ERROR("kqueue not found!")
178 AC_CHECK_HEADERS([sys/statvfs.h \
182 dnl ----------------------------------------------------------------------------
186 AC_MSG_CHECKING([how to copy va_list])
187 AC_TRY_LINK([#include <stdarg.h>], [va_list ap1, ap2; va_copy(ap1, ap2);],
188 AC_MSG_RESULT([va_copy]),
189 [ AH_TEMPLATE([va_copy], [define if va_copy is not available])
190 AC_TRY_LINK([#include <stdarg.h>], [va_list ap1, ap2; __va_copy(ap1, ap2);],
191 [ AC_DEFINE([va_copy], [__va_copy])
192 AC_MSG_RESULT([__va_copy])],
193 [ AC_DEFINE([va_copy(dest,src)], [memcpy(&dest,&src,sizeof(va_list))])
194 AC_MSG_RESULT([memcpy])]
199 dnl ----------------------------------------------------------------------------
203 DHT_CFLAGS="-I\$(top_srcdir)/third-party/dht"
204 DHT_LIBS="\$(top_builddir)/third-party/dht/libdht.a"
209 dnl ----------------------------------------------------------------------------
215 [libutp_extra_libs="-lrt"],
216 [libutp_extra_libs=""])
218 AC_MSG_CHECKING([µTP])
220 if test "x$HAVE_CXX" = "xyes" ; then
226 AS_HELP_STRING([--enable-utp],[build µTP support]),
227 [want_utp=${enableval}],
228 [want_utp=${have_utp}])
229 if test "x$want_utp" = "xyes" ; then
230 if test "x$have_utp" = "xyes"; then
231 LIBUTP_CFLAGS="-I\$(top_srcdir)/third-party/"
232 LIBUTP_LIBS="\$(top_builddir)/third-party/libutp/libutp.a"
233 LIBUTP_LIBS_QT="\$\${TRANSMISSION_TOP}/third-party/libutp/libutp.a"
234 if test "x$libutp_extra_libs" != "x" ; then
235 LIBUTP_LIBS="$LIBUTP_LIBS $libutp_extra_libs"
236 LIBUTP_LIBS_QT="$LIBUTP_LIBS_QT $libutp_extra_libs"
238 AC_DEFINE([WITH_UTP],[1])
241 AC_MSG_ERROR("Unable to build uTP support -- C++ compiler not found")
244 AC_SUBST(LIBUTP_CFLAGS)
245 AC_SUBST(LIBUTP_LIBS)
246 AC_SUBST(LIBUTP_LIBS_QT)
247 AM_CONDITIONAL([BUILD_UTP],[test "x$build_utp" = "xyes"])
248 AC_MSG_RESULT([$build_utp])
252 dnl look for preinstalled miniupnpc...
255 AC_MSG_CHECKING([supported miniupnp library])
259 # See if the OS has its miniupnp 1.5 installed
262 #include <miniupnpc/miniupnpc.h>
263 #include <miniupnpc/upnpcommands.h>
265 struct UPNPDev * devlist;
266 struct UPNPUrls urls;
267 struct IGDdatas data;
272 upnpDiscover( 2000, NULL, NULL, 0 );
273 UPNP_GetValidIGD( devlist, &urls, &data, lanaddr, sizeof( lanaddr ) );
274 UPNP_GetSpecificPortMappingEntry( urls.controlURL, data.first.servicetype,
275 portStr, "TCP", intClient, intPort );
277 AC_DEFINE(HAVE_MINIUPNP_15, 1, [Define to 1 if you have miniupnpc version 1.5])
280 # See if the OS has its miniupnp 1.6 installed
284 #include <miniupnpc/miniupnpc.h>
285 #include <miniupnpc/upnpcommands.h>
287 struct UPNPDev * devlist;
288 struct UPNPUrls urls;
289 struct IGDdatas data;
294 upnpDiscover( 2000, NULL, NULL, 0, 0, &errno );
295 UPNP_GetValidIGD( devlist, &urls, &data, lanaddr, sizeof( lanaddr ) );
296 UPNP_GetSpecificPortMappingEntry( urls.controlURL, data.first.servicetype,
297 portStr, "TCP", intClient, intPort, NULL, NULL, NULL );
299 AC_DEFINE(HAVE_MINIUPNP_16, 1, [Define to 1 if you have miniupnpc version 1.6])
302 # ... and the results of our tests
304 AC_MSG_RESULT([$upnp_version])
305 AM_CONDITIONAL([BUILD_MINIUPNP],[test "x$upnp_version" = "xnone"])
306 if test "x$upnp_version" = "xnone" ; then
307 LIBUPNP_CFLAGS="-I\$(top_srcdir)/third-party/"
308 LIBUPNP_LIBS="\$(top_builddir)/third-party/miniupnp/libminiupnp.a"
309 LIBUPNP_LIBS_QT="\$\${TRANSMISSION_TOP}/third-party/miniupnp/libminiupnp.a"
310 dnl because this is the version that we bundle...
311 AC_DEFINE(HAVE_MINIUPNP_16, 1, [Define to 1 if you have miniupnpc version 1.6])
313 AC_DEFINE([SYSTEM_MINIUPNP])
315 LIBUPNP_LIBS="-lminiupnpc"
316 LIBUPNP_LIBS_QT="-lminiupnpc"
318 AC_SUBST(LIBUPNP_CFLAGS)
319 AC_SUBST(LIBUPNP_LIBS)
320 AC_SUBST(LIBUPNP_LIBS_QT)
325 dnl ----------------------------------------------------------------------------
327 dnl Allow usage of system natpmp library
329 LIBNATPMP_CFLAGS="-I\$(top_srcdir)/third-party/libnatpmp/"
330 LIBNATPMP_LIBS="\$(top_builddir)/third-party/libnatpmp/libnatpmp.a"
331 LIBNATPMP_LIBS_QT="\$\${TRANSMISSION_TOP}/third-party/libnatpmp/libnatpmp.a"
332 build_bundled_natpmp="yes"
333 AC_ARG_ENABLE([external-natpmp],
334 AS_HELP_STRING([--enable-external-natpmp],[Use system external-natpmp]),
335 [want_external_natpmp=${enableval}],
336 [want_external_natpmp=no])
337 if test "x$want_external_natpmp" != "xno" ; then
338 dnl Would be lovely if it had pkgconfig
340 LIBNATPMP_LIBS="-lnatpmp"
341 LIBNATPMP_LIBS_QT="-lnatpmp"
342 build_bundled_natpmp="no"
344 AM_CONDITIONAL([BUILD_NATPMP],[test "x$build_bundled_natpmp" = "xyes"])
345 AC_SUBST(LIBNATPMP_CFLAGS)
346 AC_SUBST(LIBNATPMP_LIBS)
347 AC_SUBST(LIBNATPMP_LIBS_QT)
350 dnl ----------------------------------------------------------------------------
352 dnl detection for the GTK+ client
356 with_gtk_default="no"
357 PKG_CHECK_EXISTS([gtk+-2.0 >= $GTK2_MINIMUM],[gtk_version="2" with_gtk_default="yes"])
358 PKG_CHECK_EXISTS([gtk+-3.0 >= $GTK3_MINIMUM],[gtk_version="3" with_gtk_default="yes"])
359 AC_ARG_WITH([gtk], AC_HELP_STRING([--with-gtk],[with Gtk]),
361 [with_gtk=$with_gtk_default])
362 if test "x$with_gtk" = "x2" ; then
363 PKG_CHECK_EXISTS([gtk+-2.0 >= $GTK2_MINIMUM],[gtk_version="2" with_gtk="yes"],[gtk_version="none" with_gtk="no"])
365 if test "x$with_gtk" = "x3" ; then
366 PKG_CHECK_EXISTS([gtk+-3.0 >= $GTK3_MINIMUM],[gtk_version="3" with_gtk="yes"],[gtk_version="none" with_gtk="no"])
369 [AS_HELP_STRING([--enable-nls],[enable native language support])],,
371 AM_CONDITIONAL([BUILD_GTK],[test "x$with_gtk" = "xyes"])
372 use_libappindicator=no
373 if test "x$with_gtk" = "xyes" ; then
375 if test "x$gtk_version" = "xnone" ; then
376 AC_MSG_ERROR("GTK+ not found!")
378 if test "x$enable_nls" = "xno" ; then
379 AC_MSG_ERROR("The gtk client cannot be built without nls support. Try adding either --enable-nls or --without-gtk" )
382 if test "x$gtk_version" = "x3"; then
384 PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= $GTK3_MINIMUM
385 glib-2.0 >= $GLIB_MINIMUM
386 gio-2.0 >= $GIO_MINIMUM,
387 gmodule-2.0 >= $GLIB_MINIMUM
388 gthread-2.0 >= $GLIB_MINIMUM])
389 PKG_CHECK_MODULES([LIBAPPINDICATOR],
390 [appindicator3-0.1 >= $LIBAPPINDICATOR_MINIMUM],
391 [have_libappindicator=yes],
392 [have_libappindicator=no])
393 AC_MSG_NOTICE([using GTK+ 3])
396 PKG_CHECK_MODULES([GTK], [gtk+-2.0 >= $GTK2_MINIMUM
397 glib-2.0 >= $GLIB_MINIMUM
398 gio-2.0 >= $GIO_MINIMUM,
399 gmodule-2.0 >= $GLIB_MINIMUM
400 gthread-2.0 >= $GLIB_MINIMUM])
401 PKG_CHECK_MODULES([LIBAPPINDICATOR],
402 [appindicator-0.1 >= $LIBAPPINDICATOR_MINIMUM],
403 [have_libappindicator=yes],
404 [have_libappindicator=no])
405 AC_MSG_NOTICE([using GTK+ 2])
409 if test "x$have_libappindicator" = "xyes"; then
410 use_libappindicator=yes
411 AC_DEFINE([HAVE_LIBAPPINDICATOR], 1)
413 LIBAPPINDICATOR_CFLAGS=
414 LIBAPPINDICATOR_LIBS=
418 dnl This section is only used for internationalization.
419 dnl If you don't need translations and this section gives you trouble --
420 dnl such as if you're building for a headless system --
421 dnl it's okay to tear this section out and re-build the configure script.
423 dnl Note to packagers: the bump to intltool 0.40 was made to fix
424 dnl a "make check" failure on some systems. if upgrading to 0.40 is
425 dnl a problem and the old version was working fine for you,
426 dnl it should be safe to re-edit 0.40 back down to 0.23
429 if test "x$enable_nls" = "xyes" ; then
431 m4_ifdef([IT_PROG_INTLTOOL],
432 [IT_PROG_INTLTOOL([0.35.0],[no-xml])],
433 [AC_MSG_ERROR("--enable-nls requires intltool to be installed.")])
434 AC_CHECK_HEADERS([libintl.h])
435 GETTEXT_PACKAGE=transmission-gtk
436 AC_SUBST(GETTEXT_PACKAGE)
437 AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[Gettext package])
439 transmissionlocaledir='${prefix}/${DATADIRNAME}/locale'
440 AC_SUBST(transmissionlocaledir)
445 dnl ----------------------------------------------------------------------------
447 dnl platform-specific stuff.
456 CXXFLAGS="$CXXFLAGS -mms-bitfields -mwin32 -mwindows"
457 CPPFLAGS="$CPPFLAGS -DWIN32 -D_WIN32 -DWIN32_LEAN_AND_MEAN"
458 LIBS="$LIBS -liphlpapi -lshell32 -lws2_32"
459 transmissionlocaledir="locale"
460 if test -z "$host_alias"; then
463 hostaliaswindres="$host_alias-windres";
465 AC_CHECK_TOOL(WINDRES, windres)
470 CFLAGS="-DMACOSX $CFLAGS"
475 AC_ARG_ENABLE([lightweight],
476 AS_HELP_STRING([--enable-lightweight],[optimize libtransmission for low-resource systems: smaller cache size, prefer unencrypted peer connections, etc.]),
477 [enable_lightweight=${enableval}],
478 [enable_lightweight="no"])
479 if test "x$enable_lightweight" = "xyes" ; then
480 AC_DEFINE([TR_LIGHTWEIGHT],[1],[optimize libtransmission for low-resource systems])
484 [AS_HELP_STRING([--enable-cli],[build command-line client])],
485 [build_cli=${enableval}],
487 AM_CONDITIONAL([BUILD_CLI],[test "x$build_cli" = "xyes"])
490 [AS_HELP_STRING([--enable-mac],[build Mac client])],
491 [build_mac=${enableval}],
492 [build_mac=${have_darwin}])
493 AM_CONDITIONAL([BUILD_MAC],[test "x$build_mac" = "xyes"])
495 AC_ARG_ENABLE([daemon],
496 [AS_HELP_STRING([--enable-daemon],[build daemon])],
497 [build_daemon=${enableval}],
498 [build_daemon="yes"])
499 AM_CONDITIONAL([BUILD_DAEMON],[test "x$build_daemon" = "xyes"])
502 if test "x$build_mac" = "xyes" ; then
503 # Make sure the proper Mac SDK is installed
504 if test ! -d /Developer/SDKs/MacOSX10.5.sdk; then
506 You need to install the Mac OS X 10.5 SDK in order to build Transmission
508 Get your Xcode CD or package
510 When it gets to "Installation Type", select "Customize"
511 Select "Mac OS X 10.5 SDK" under "Cross Development"
517 if test "x$have_darwin" = "xyes"; then
518 AC_DEFINE([HAVE_DARWIN], 1)
520 if test "x$have_msw" = "xyes"; then
521 AC_DEFINE([HAVE_MSW], 1)
523 AM_CONDITIONAL(WIN32, test "x$have_msw" = "xyes")
525 dnl ----------------------------------------------------------------------------
527 dnl Generate the output
529 AC_CONFIG_FILES([Makefile
530 transmission-gtk.spec
534 libtransmission/Makefile
537 third-party/dht/Makefile
538 third-party/libutp/Makefile
539 third-party/libnatpmp/Makefile
540 third-party/miniupnp/Makefile
548 web/style/jqueryui/Makefile
549 web/style/jqueryui/images/Makefile
550 web/style/transmission/Makefile
551 web/style/transmission/images/Makefile
552 web/style/transmission/images/buttons/Makefile
553 web/javascript/Makefile
554 web/javascript/jquery/Makefile
563 Source code location: ${srcdir}
566 Build libtransmission: yes
567 * optimized for low-resource systems: ${enable_lightweight}
568 * µTP enabled: ${build_utp}
570 Build Command-Line client: ${build_cli}
572 Build GTK+ client: ${with_gtk} (GTK+ $gtk_version)
573 * libappindicator for an Ubuntu-style tray: ${use_libappindicator}
575 Build Daemon: ${build_daemon}
577 Build Mac client: ${build_mac}