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.50])
7 m4_define([peer_id_prefix],[-TR2500-])
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 AC_CHECK_PROG([HAVE_CXX],[$CXX],[yes],[no])
78 if test "x$GCC" = "xyes" ; then
80 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"
82 dnl figure out gcc version
83 AC_MSG_CHECKING([gcc version])
84 GCC_VERSION=`$CC -dumpversion`
85 GCC_MAJOR=`echo $GCC_VERSION | cut -d . -f1`
86 GCC_MINOR=`echo $GCC_VERSION | cut -d . -f2`
87 GCC_VERSION_NUM=`(expr $GCC_MAJOR "*" 100 + $GCC_MINOR) 2>/dev/null`
89 AC_MSG_RESULT($GCC_VERSION)
90 if test $GCC_VERSION_NUM -ge 304; then
91 dnl these were added in 3.4
92 CFLAGS="$CFLAGS -Wextra -Wdeclaration-after-statement -Winit-self"
94 if test $GCC_VERSION_NUM -ge 403; then
95 dnl these were added in 4.3
96 CFLAGS="$CFLAGS -Wvariadic-macros"
103 AC_CHECK_HEADERS([stdbool.h])
104 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])
109 if test "x$ac_cv_func_strtold" != "xyes" ; then
110 CPPFLAGS="$CPPFLAGS -Dstrtold=strtod"
113 AC_SEARCH_LIBS(cos, [m])
114 AC_SEARCH_LIBS([socket], [socket net])
115 AC_SEARCH_LIBS([gethostbyname], [nsl bind])
116 PKG_CHECK_MODULES(OPENSSL, [openssl >= $OPENSSL_MINIMUM], , [CHECK_SSL()])
117 PKG_CHECK_MODULES(LIBCURL, [libcurl >= $CURL_MINIMUM])
118 PKG_CHECK_MODULES(LIBEVENT, [libevent >= $LIBEVENT_MINIMUM])
122 AC_CHECK_FUNCS([lseek64])
125 dnl ----------------------------------------------------------------------------
129 dnl can posix_fadvise be used
130 AC_CHECK_DECLS(posix_fadvise, [], [], [
131 #define _XOPEN_SOURCE 600
133 AC_CHECK_FUNCS([posix_fadvise])
136 dnl ----------------------------------------------------------------------------
138 dnl file monitoring for the daemon
140 AC_CHECK_HEADER([sys/inotify.h],
141 [AC_CHECK_FUNC([inotify_init],[have_inotify="yes"],[have_inotify="no"])],
143 AC_ARG_WITH([inotify],
144 [AS_HELP_STRING([--with-inotify],[Enable inotify support (default=auto)])],
145 [want_inotify=${withval}],
146 [want_inotify=${have_inotify}])
147 if test "x$want_inotify" = "xyes" ; then
148 if test "x$have_inotify" = "xyes"; then
149 AC_DEFINE([WITH_INOTIFY],[1])
151 AC_MSG_ERROR("inotify not found!")
155 AC_CHECK_HEADER([sys/event.h],
156 [AC_CHECK_FUNC([kqueue],[have_kqueue="yes"],[have_kqueue="no"])],
158 AC_ARG_WITH([kqueue],
159 [AS_HELP_STRING([--with-kqueue],[Enable kqueue support (default=auto)])],
160 [want_kqueue=${withval}],
161 [want_kqueue=${have_kqueue}])
162 if test "x$want_kqueue" = "xyes" ; then
163 if test "x$have_kqueue" = "xyes"; then
164 AC_DEFINE([WITH_KQUEUE],[1])
166 AC_MSG_ERROR("kqueue not found!")
170 AC_CHECK_HEADERS([sys/statvfs.h \
174 dnl ----------------------------------------------------------------------------
178 AC_MSG_CHECKING([how to copy va_list])
179 AC_TRY_LINK([#include <stdarg.h>], [va_list ap1, ap2; va_copy(ap1, ap2);],
180 AC_MSG_RESULT([va_copy]),
181 [ AH_TEMPLATE([va_copy], [define if va_copy is not available])
182 AC_TRY_LINK([#include <stdarg.h>], [va_list ap1, ap2; __va_copy(ap1, ap2);],
183 [ AC_DEFINE([va_copy], [__va_copy])
184 AC_MSG_RESULT([__va_copy])],
185 [ AC_DEFINE([va_copy(dest,src)], [memcpy(&dest,&src,sizeof(va_list))])
186 AC_MSG_RESULT([memcpy])]
191 dnl ----------------------------------------------------------------------------
195 DHT_CFLAGS="-I\$(top_srcdir)/third-party/dht"
196 DHT_LIBS="\$(top_builddir)/third-party/dht/libdht.a"
201 dnl ----------------------------------------------------------------------------
207 [libutp_extra_libs="-lrt"],
208 [libutp_extra_libs=""])
210 AC_MSG_CHECKING([µTP])
212 if test "x$HAVE_CXX" = "xyes" ; then
218 AS_HELP_STRING([--enable-utp],[build µTP support]),
219 [want_utp=${enableval}],
220 [want_utp=${have_utp}])
221 if test "x$want_utp" = "xyes" ; then
222 if test "x$have_utp" = "xyes"; then
223 LIBUTP_CFLAGS="-I\$(top_srcdir)/third-party/"
224 LIBUTP_LIBS="\$(top_builddir)/third-party/libutp/libutp.a"
225 LIBUTP_LIBS_QT="\$\${TRANSMISSION_TOP}/third-party/libutp/libutp.a"
226 if test "x$libutp_extra_libs" != "x" ; then
227 LIBUTP_LIBS="$LIBUTP_LIBS $libutp_extra_libs"
228 LIBUTP_LIBS_QT="$LIBUTP_LIBS_QT $libutp_extra_libs"
230 AC_DEFINE([WITH_UTP],[1])
233 AC_MSG_ERROR("Unable to build uTP support -- C++ compiler not found")
236 AC_SUBST(LIBUTP_CFLAGS)
237 AC_SUBST(LIBUTP_LIBS)
238 AC_SUBST(LIBUTP_LIBS_QT)
239 AM_CONDITIONAL([BUILD_UTP],[test "x$build_utp" = "xyes"])
240 AC_MSG_RESULT([$build_utp])
244 dnl look for preinstalled miniupnpc...
247 AC_MSG_CHECKING([supported miniupnp library])
251 # See if the OS has its miniupnp 1.5 installed
254 #include <miniupnpc/miniupnpc.h>
255 #include <miniupnpc/upnpcommands.h>
257 struct UPNPDev * devlist;
258 struct UPNPUrls urls;
259 struct IGDdatas data;
264 upnpDiscover( 2000, NULL, NULL, 0 );
265 UPNP_GetValidIGD( devlist, &urls, &data, lanaddr, sizeof( lanaddr ) );
266 UPNP_GetSpecificPortMappingEntry( urls.controlURL, data.first.servicetype,
267 portStr, "TCP", intClient, intPort );
269 AC_DEFINE(HAVE_MINIUPNP_15, 1, [Define to 1 if you have miniupnpc version 1.5])
272 # See if the OS has its miniupnp 1.6 installed
276 #include <miniupnpc/miniupnpc.h>
277 #include <miniupnpc/upnpcommands.h>
279 struct UPNPDev * devlist;
280 struct UPNPUrls urls;
281 struct IGDdatas data;
286 upnpDiscover( 2000, NULL, NULL, 0, 0, &errno );
287 UPNP_GetValidIGD( devlist, &urls, &data, lanaddr, sizeof( lanaddr ) );
288 UPNP_GetSpecificPortMappingEntry( urls.controlURL, data.first.servicetype,
289 portStr, "TCP", intClient, intPort, NULL, NULL, NULL );
291 AC_DEFINE(HAVE_MINIUPNP_16, 1, [Define to 1 if you have miniupnpc version 1.6])
294 # ... and the results of our tests
296 AC_MSG_RESULT([$upnp_version])
297 AM_CONDITIONAL([BUILD_MINIUPNP],[test "x$upnp_version" = "xnone"])
298 if test "x$upnp_version" = "xnone" ; then
299 LIBUPNP_CFLAGS="-I\$(top_srcdir)/third-party/"
300 LIBUPNP_LIBS="\$(top_builddir)/third-party/miniupnp/libminiupnp.a"
301 LIBUPNP_LIBS_QT="\$\${TRANSMISSION_TOP}/third-party/miniupnp/libminiupnp.a"
302 dnl because this is the version that we bundle...
303 AC_DEFINE(HAVE_MINIUPNP_16, 1, [Define to 1 if you have miniupnpc version 1.6])
305 AC_DEFINE([SYSTEM_MINIUPNP])
307 LIBUPNP_LIBS="-lminiupnpc"
308 LIBUPNP_LIBS_QT="-lminiupnpc"
310 AC_SUBST(LIBUPNP_CFLAGS)
311 AC_SUBST(LIBUPNP_LIBS)
312 AC_SUBST(LIBUPNP_LIBS_QT)
317 dnl ----------------------------------------------------------------------------
319 dnl Allow usage of system natpmp library
321 LIBNATPMP_CFLAGS="-I\$(top_srcdir)/third-party/libnatpmp/"
322 LIBNATPMP_LIBS="\$(top_builddir)/third-party/libnatpmp/libnatpmp.a"
323 LIBNATPMP_LIBS_QT="\$\${TRANSMISSION_TOP}/third-party/libnatpmp/libnatpmp.a"
324 build_bundled_natpmp="yes"
325 AC_ARG_ENABLE([external-natpmp],
326 AS_HELP_STRING([--enable-external-natpmp],[Use system external-natpmp]),
327 [want_external_natpmp=${enableval}],
328 [want_external_natpmp=no])
329 if test "x$want_external_natpmp" != "xno" ; then
330 dnl Would be lovely if it had pkgconfig
332 LIBNATPMP_LIBS="-lnatpmp"
333 LIBNATPMP_LIBS_QT="-lnatpmp"
334 build_bundled_natpmp="no"
336 AM_CONDITIONAL([BUILD_NATPMP],[test "x$build_bundled_natpmp" = "xyes"])
337 AC_SUBST(LIBNATPMP_CFLAGS)
338 AC_SUBST(LIBNATPMP_LIBS)
339 AC_SUBST(LIBNATPMP_LIBS_QT)
342 dnl ----------------------------------------------------------------------------
344 dnl detection for the GTK+ client
348 with_gtk_default="no"
349 PKG_CHECK_EXISTS([gtk+-2.0 >= $GTK2_MINIMUM],[gtk_version="2" with_gtk_default="yes"])
350 PKG_CHECK_EXISTS([gtk+-3.0 >= $GTK3_MINIMUM],[gtk_version="3" with_gtk_default="yes"])
351 AC_ARG_WITH([gtk], AC_HELP_STRING([--with-gtk],[with Gtk]),
353 [with_gtk=$with_gtk_default])
354 if test "x$with_gtk" = "x2" ; then
355 PKG_CHECK_EXISTS([gtk+-2.0 >= $GTK2_MINIMUM],[gtk_version="2" with_gtk="yes"],[gtk_version="none" with_gtk="no"])
357 if test "x$with_gtk" = "x3" ; then
358 PKG_CHECK_EXISTS([gtk+-3.0 >= $GTK3_MINIMUM],[gtk_version="3" with_gtk="yes"],[gtk_version="none" with_gtk="no"])
361 [AS_HELP_STRING([--enable-nls],[enable native language support])],,
363 AM_CONDITIONAL([BUILD_GTK],[test "x$with_gtk" = "xyes"])
364 use_libappindicator=no
365 if test "x$with_gtk" = "xyes" ; then
367 if test "x$gtk_version" = "xnone" ; then
368 AC_MSG_ERROR("GTK+ not found!")
370 if test "x$enable_nls" = "xno" ; then
371 AC_MSG_ERROR("The gtk client cannot be built without nls support. Try adding either --enable-nls or --without-gtk" )
374 if test "x$gtk_version" = "x3"; then
376 PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= $GTK3_MINIMUM
377 glib-2.0 >= $GLIB_MINIMUM
378 gio-2.0 >= $GIO_MINIMUM,
379 gmodule-2.0 >= $GLIB_MINIMUM
380 gthread-2.0 >= $GLIB_MINIMUM])
381 PKG_CHECK_MODULES([LIBAPPINDICATOR],
382 [appindicator3-0.1 >= $LIBAPPINDICATOR_MINIMUM],
383 [have_libappindicator=yes],
384 [have_libappindicator=no])
385 AC_MSG_NOTICE([using GTK+ 3])
388 PKG_CHECK_MODULES([GTK], [gtk+-2.0 >= $GTK2_MINIMUM
389 glib-2.0 >= $GLIB_MINIMUM
390 gio-2.0 >= $GIO_MINIMUM,
391 gmodule-2.0 >= $GLIB_MINIMUM
392 gthread-2.0 >= $GLIB_MINIMUM])
393 PKG_CHECK_MODULES([LIBAPPINDICATOR],
394 [appindicator-0.1 >= $LIBAPPINDICATOR_MINIMUM],
395 [have_libappindicator=yes],
396 [have_libappindicator=no])
397 AC_MSG_NOTICE([using GTK+ 2])
401 if test "x$have_libappindicator" = "xyes"; then
402 use_libappindicator=yes
403 AC_DEFINE([HAVE_LIBAPPINDICATOR], 1)
405 LIBAPPINDICATOR_CFLAGS=
406 LIBAPPINDICATOR_LIBS=
410 dnl This section is only used for internationalization.
411 dnl If you don't need translations and this section gives you trouble --
412 dnl such as if you're building for a headless system --
413 dnl it's okay to tear this section out and re-build the configure script.
415 dnl Note to packagers: the bump to intltool 0.40 was made to fix
416 dnl a "make check" failure on some systems. if upgrading to 0.40 is
417 dnl a problem and the old version was working fine for you,
418 dnl it should be safe to re-edit 0.40 back down to 0.23
421 if test "x$enable_nls" = "xyes" ; then
423 m4_ifdef([IT_PROG_INTLTOOL],
424 [IT_PROG_INTLTOOL([0.35.0],[no-xml])],
425 [AC_MSG_ERROR("--enable-nls requires intltool to be installed.")])
426 AC_CHECK_HEADERS([libintl.h])
427 GETTEXT_PACKAGE=transmission-gtk
428 AC_SUBST(GETTEXT_PACKAGE)
429 AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[Gettext package])
431 transmissionlocaledir='${prefix}/${DATADIRNAME}/locale'
432 AC_SUBST(transmissionlocaledir)
437 dnl ----------------------------------------------------------------------------
439 dnl platform-specific stuff.
448 CXXFLAGS="$CXXFLAGS -mms-bitfields -mwin32 -mwindows"
449 CPPFLAGS="$CPPFLAGS -DWIN32 -D_WIN32 -DWIN32_LEAN_AND_MEAN"
450 LIBS="$LIBS -liphlpapi -lshell32 -lws2_32"
451 transmissionlocaledir="locale"
452 if test -z "$host_alias"; then
455 hostaliaswindres="$host_alias-windres";
457 AC_CHECK_TOOL(WINDRES, windres)
462 CFLAGS="-DMACOSX $CFLAGS"
467 AC_ARG_ENABLE([lightweight],
468 AS_HELP_STRING([--enable-lightweight],[optimize libtransmission for low-resource systems: smaller cache size, prefer unencrypted peer connections, etc.]),
469 [enable_lightweight=${enableval}],
470 [enable_lightweight="no"])
471 if test "x$enable_lightweight" = "xyes" ; then
472 AC_DEFINE([TR_LIGHTWEIGHT],[1],[optimize libtransmission for low-resource systems])
476 [AS_HELP_STRING([--enable-cli],[build command-line client])],
477 [build_cli=${enableval}],
479 AM_CONDITIONAL([BUILD_CLI],[test "x$build_cli" = "xyes"])
482 [AS_HELP_STRING([--enable-mac],[build Mac client])],
483 [build_mac=${enableval}],
484 [build_mac=${have_darwin}])
485 AM_CONDITIONAL([BUILD_MAC],[test "x$build_mac" = "xyes"])
487 AC_ARG_ENABLE([daemon],
488 [AS_HELP_STRING([--enable-daemon],[build daemon])],
489 [build_daemon=${enableval}],
490 [build_daemon="yes"])
491 AM_CONDITIONAL([BUILD_DAEMON],[test "x$build_daemon" = "xyes"])
494 if test "x$build_mac" = "xyes" ; then
495 # Make sure the proper Mac SDK is installed
496 if test ! -d /Developer/SDKs/MacOSX10.5.sdk; then
498 You need to install the Mac OS X 10.5 SDK in order to build Transmission
500 Get your Xcode CD or package
502 When it gets to "Installation Type", select "Customize"
503 Select "Mac OS X 10.5 SDK" under "Cross Development"
509 if test "x$have_darwin" = "xyes"; then
510 AC_DEFINE([HAVE_DARWIN], 1)
512 if test "x$have_msw" = "xyes"; then
513 AC_DEFINE([HAVE_MSW], 1)
515 AM_CONDITIONAL(WIN32, test "x$have_msw" = "xyes")
517 dnl ----------------------------------------------------------------------------
519 dnl Generate the output
521 AC_CONFIG_FILES([Makefile
522 transmission-gtk.spec
526 libtransmission/Makefile
529 third-party/dht/Makefile
530 third-party/libutp/Makefile
531 third-party/libnatpmp/Makefile
532 third-party/miniupnp/Makefile
540 web/style/jqueryui/Makefile
541 web/style/jqueryui/images/Makefile
542 web/style/transmission/Makefile
543 web/style/transmission/images/Makefile
544 web/style/transmission/images/buttons/Makefile
545 web/javascript/Makefile
546 web/javascript/jquery/Makefile
555 Source code location: ${srcdir}
558 Build libtransmission: yes
559 * optimized for low-resource systems: ${enable_lightweight}
560 * µTP enabled: ${build_utp}
562 Build Command-Line client: ${build_cli}
564 Build GTK+ client: ${with_gtk} (GTK+ $gtk_version)
565 * libappindicator for an Ubuntu-style tray: ${use_libappindicator}
567 Build Daemon: ${build_daemon}
569 Build Mac client: ${build_mac}