allow coexistance of N build and AC build.
[tomato.git] / release / src / router / transmission / configure.ac
blob8b6b403e41e2641d0008812dfafecfcd9a289223
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.81])
7 m4_define([peer_id_prefix],[-TR2810-])
9 AC_INIT([transmission],[user_agent_prefix],[http://trac.transmissionbt.com/newticket])
10 AC_SUBST(USERAGENT_PREFIX,[user_agent_prefix])
11 AC_SUBST(PEERID_PREFIX,[peer_id_prefix])
13 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
15 AC_CONFIG_MACRO_DIR([m4])
17 dnl AM_CONFIG_HEADER(config.h)
18 AC_CONFIG_SRCDIR(libtransmission/transmission.h)
19 AM_INIT_AUTOMAKE([1.9 tar-pax no-dist-gzip dist-xz])
20 LT_INIT
22 if test m4_substr(peer_id_prefix,6,1) = "0"; then
23   supported_build=yes
24   CPPFLAGS="$CPPFLAGS -DNDEBUG"
25 else
26   supported_build=no
27   if test "x$GCC" = "xyes" ; then
28     CFLAGS="$CFLAGS -g -O0"
29     CXXFLAGS="$CXXFLAGS -g -O0"
30   fi
32 AM_CONDITIONAL(TR_UNSTABLE, test "x$supported_build" = "xno")
36 ##   MANDATORY for everything
39 CURL_MINIMUM=7.15.4
40 AC_SUBST(CURL_MINIMUM)
41 LIBEVENT_MINIMUM=2.0.10
42 AC_SUBST(LIBEVENT_MINIMUM)
43 OPENSSL_MINIMUM=0.9.4
44 AC_SUBST(OPENSSL_MINIMUM)
48 ##   MANDATORY for the GTK+ client
52 GTK_MINIMUM=3.4.0
53 AC_SUBST(GTK_MINIMUM)
54 GLIB_MINIMUM=2.32.0
55 AC_SUBST(GLIB_MINIMUM)
56 GIO_MINIMUM=2.26.0
57 AC_SUBST(GIO_MINIMUM)
61 ##   OPTIONAL for the GTK+ client
65 # create the tray icon with AppIndicator
66 LIBAPPINDICATOR_MINIMUM=0.4.90
67 AC_SUBST(LIBAPPINDICATOR_MINIMUM)
70 AC_PROG_CC
71 AC_PROG_CXX
72 if test "x$CXX" != "x"; then # CXX is set...
73   if test -f "$CXX"; then # maybe it's an absolute path passed in env variables...
74     AC_MSG_CHECKING([for $CXX])
75     HAVE_CXX="yes"
76     AC_MSG_RESULT([$HAVE_CXX])
77   else
78     AC_CHECK_PROG([HAVE_CXX],[$CXX],[yes],[no])
79   fi
81 AC_C_INLINE
82 if test "x$GCC" = "xyes" ; then
84     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"
86     dnl figure out gcc version
87     AC_MSG_CHECKING([gcc version])
88     GCC_VERSION=`$CC -dumpversion`
89     GCC_MAJOR=`echo $GCC_VERSION | cut -d . -f1`
90     GCC_MINOR=`echo $GCC_VERSION | cut -d . -f2`
91     GCC_VERSION_NUM=`(expr $GCC_MAJOR "*" 100 + $GCC_MINOR) 2>/dev/null`
93     AC_MSG_RESULT($GCC_VERSION)
94     if test $GCC_VERSION_NUM -ge 304; then
95         dnl these were added in 3.4
96         CFLAGS="$CFLAGS -Wextra -Wdeclaration-after-statement -Winit-self"
97     fi
98     if test $GCC_VERSION_NUM -ge 403; then
99         dnl these were added in 4.3
100         CFLAGS="$CFLAGS -Wvariadic-macros"
101     fi
104 AC_HEADER_STDC
105 AC_HEADER_TIME
107 AC_CHECK_HEADERS([stdbool.h])
108 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 AC_PROG_INSTALL
110 AC_PROG_MAKE_SET
111 ACX_PTHREAD
113 if test "x$ac_cv_func_strtold" != "xyes" ; then
114     CPPFLAGS="$CPPFLAGS -Dstrtold=strtod"
117 AC_SEARCH_LIBS(cos, [m])
118 AC_SEARCH_LIBS([socket], [socket net])
119 AC_SEARCH_LIBS([gethostbyname], [nsl bind])
120 PKG_CHECK_MODULES(OPENSSL, [openssl >= $OPENSSL_MINIMUM], , [CHECK_SSL()])
121 PKG_CHECK_MODULES(LIBCURL, [libcurl >= $CURL_MINIMUM])
122 PKG_CHECK_MODULES(LIBEVENT, [libevent >= $LIBEVENT_MINIMUM])
123 AC_PATH_ZLIB
125 AC_SYS_LARGEFILE
126 AC_CHECK_FUNCS([lseek64])
128 AC_FUNC_GETMNTENT
130 dnl ----------------------------------------------------------------------------
132 dnl posix_fadvise
134 dnl can posix_fadvise be used
135 AC_CHECK_DECLS(posix_fadvise, [], [], [
136 #define _XOPEN_SOURCE 600
137 #include <fcntl.h>])
138 AC_CHECK_FUNCS([posix_fadvise])
141 dnl ----------------------------------------------------------------------------
143 dnl file monitoring for the daemon
145 AC_CHECK_HEADER([sys/inotify.h],
146                 [AC_CHECK_FUNC([inotify_init],[have_inotify="yes"],[have_inotify="no"])],
147                 [have_inotify="no"])
148 AC_ARG_WITH([inotify],
149             [AS_HELP_STRING([--with-inotify],[Enable inotify support (default=auto)])],
150             [want_inotify=${withval}],
151             [want_inotify=${have_inotify}])
152 if test "x$want_inotify" = "xyes" ; then
153     if test "x$have_inotify" = "xyes"; then
154       AC_DEFINE([WITH_INOTIFY],[1])
155     else
156       AC_MSG_ERROR("inotify not found!")
157     fi
160 AC_CHECK_HEADER([sys/event.h],
161                 [AC_CHECK_FUNC([kqueue],[have_kqueue="yes"],[have_kqueue="no"])],
162                 [have_kqueue="no"])
163 AC_ARG_WITH([kqueue],
164             [AS_HELP_STRING([--with-kqueue],[Enable kqueue support (default=auto)])],
165             [want_kqueue=${withval}],
166             [want_kqueue=${have_kqueue}])
167 if test "x$want_kqueue" = "xyes" ; then
168     if test "x$have_kqueue" = "xyes"; then
169       AC_DEFINE([WITH_KQUEUE],[1])
170     else
171       AC_MSG_ERROR("kqueue not found!")
172     fi
175 AC_CHECK_HEADERS([sys/statvfs.h \
176                   xfs/xfs.h])
179 dnl ----------------------------------------------------------------------------
181 dnl file monitoring for the daemon
183 # Check whether to enable systemd startup notification.
184 # This requires libsystemd-daemon.
185 AC_ARG_WITH([systemd-daemon], AS_HELP_STRING([--with-systemd-daemon],
186             [Add support for systemd startup notification (default is autodetected)])
187             [USE_SYSTEMD_DAEMON=$withval], [USE_SYSTEMD_DAEMON=auto])
188 AS_IF([test "x$USE_SYSTEMD_DAEMON" != "xno"], [
189     PKG_CHECK_MODULES([SYSTEMD_DAEMON], [libsystemd-daemon],
190         [AC_DEFINE(USE_SYSTEMD_DAEMON,1,[Use systemd startup notification])],
191         [AS_IF([test "x$USE_SYSTEMD_DAEMON" = "xyes"],
192             [AC_MSG_ERROR([systemd startup notification support requested, but libsystemd-daemon not found.])]
193         )]
194     )
198 dnl ----------------------------------------------------------------------------
200 dnl  dht
202 DHT_CFLAGS="-I\$(top_srcdir)/third-party/dht"
203 DHT_LIBS="\$(top_builddir)/third-party/dht/libdht.a"
204 AC_SUBST(DHT_CFLAGS)
205 AC_SUBST(DHT_LIBS)
208 dnl ----------------------------------------------------------------------------
210 dnl  utp
212 AC_CHECK_LIB([rt],
213              [clock_gettime],
214              [libutp_extra_libs="-lrt"],
215              [libutp_extra_libs=""])
217 AC_MSG_CHECKING([µTP])
218 build_utp="no"
219 if test "x$HAVE_CXX" = "xyes" ; then
220     have_utp="yes"
221 else
222     have_utp="no"
224 AC_ARG_ENABLE([utp],
225               AS_HELP_STRING([--enable-utp],[build µTP support]),
226               [want_utp=${enableval}],
227               [want_utp=${have_utp}])
228 if test "x$want_utp" = "xyes" ; then
229     if test "x$have_utp" = "xyes"; then
230         LIBUTP_CFLAGS="-I\$(top_srcdir)/third-party/"
231         LIBUTP_LIBS="\$(top_builddir)/third-party/libutp/libutp.a"
232         LIBUTP_LIBS_QT="\$\${TRANSMISSION_TOP}/third-party/libutp/libutp.a"
233         if test "x$libutp_extra_libs" != "x" ; then
234             LIBUTP_LIBS="$LIBUTP_LIBS $libutp_extra_libs"
235             LIBUTP_LIBS_QT="$LIBUTP_LIBS_QT $libutp_extra_libs"
236         fi
237         AC_DEFINE([WITH_UTP],[1])
238         build_utp="yes"
239     else
240       AC_MSG_ERROR("Unable to build uTP support -- C++ compiler not found")
241     fi
243 AC_SUBST(LIBUTP_CFLAGS)
244 AC_SUBST(LIBUTP_LIBS)
245 AC_SUBST(LIBUTP_LIBS_QT)
246 AM_CONDITIONAL([BUILD_UTP],[test "x$build_utp" = "xyes"])
247 AC_MSG_RESULT([$build_utp])
251 dnl  look for preinstalled miniupnpc...
254 AC_MSG_CHECKING([supported miniupnp library])
255 upnp_version="none"
256 ac_save_LIBS="$LIBS"
257 LIBS="-lminiupnpc"
258 # See if the OS has its miniupnp 1.5 installed
259 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
260     #include <stdlib.h>
261     #include <miniupnpc/miniupnpc.h>
262     #include <miniupnpc/upnpcommands.h>
263 ]], [[
264     struct UPNPDev * devlist;
265     struct UPNPUrls    urls;
266     struct IGDdatas    data;
267     char lanaddr[16];
268     char portStr[8];
269     char intPort[8];
270     char intClient[16];
271     upnpDiscover( 2000, NULL, NULL, 0 );
272     UPNP_GetValidIGD( devlist, &urls, &data, lanaddr, sizeof( lanaddr ) ); 
273     UPNP_GetSpecificPortMappingEntry( urls.controlURL, data.first.servicetype,
274                         portStr, "TCP", intClient, intPort );
275 ]])],[
276 AC_DEFINE(HAVE_MINIUPNP_15, 1, [Define to 1 if you have miniupnpc version 1.5])
277 upnp_version="1.5"],[])
279 # See if the OS has its miniupnp 1.6 installed
280 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
281     #include <stdlib.h>
282     #include <errno.h>
283     #include <miniupnpc/miniupnpc.h>
284     #include <miniupnpc/upnpcommands.h>
285 ]], [[
286     struct UPNPDev * devlist;
287     struct UPNPUrls    urls;
288     struct IGDdatas    data;
289     char lanaddr[16];
290     char portStr[8];
291     char intPort[8];
292     char intClient[16];
293     upnpDiscover( 2000, NULL, NULL, 0, 0, &errno );
294     UPNP_GetValidIGD( devlist, &urls, &data, lanaddr, sizeof( lanaddr ) ); 
295     UPNP_GetSpecificPortMappingEntry( urls.controlURL, data.first.servicetype,
296                         portStr, "TCP", intClient, intPort, NULL, NULL, NULL );
297 ]])],[
298 AC_DEFINE(HAVE_MINIUPNP_16, 1, [Define to 1 if you have miniupnpc version 1.6])
299 upnp_version="1.6"],[])
301 # ... and the results of our tests
302 LIBS="$ac_save_LIBS"
303 AC_MSG_RESULT([$upnp_version])
304 AM_CONDITIONAL([BUILD_MINIUPNP],[test "x$upnp_version" = "xnone"])
305 if test "x$upnp_version" = "xnone" ; then
306     LIBUPNP_CFLAGS="-I\$(top_srcdir)/third-party/"
307     LIBUPNP_LIBS="\$(top_builddir)/third-party/miniupnp/libminiupnp.a"
308     LIBUPNP_LIBS_QT="\$\${TRANSMISSION_TOP}/third-party/miniupnp/libminiupnp.a"
309     dnl because this is the version that we bundle...
310     AC_DEFINE(HAVE_MINIUPNP_16, 1, [Define to 1 if you have miniupnpc version 1.6])
311 else
312     AC_DEFINE([SYSTEM_MINIUPNP])
313     LIBUPNP_CFLAGS="" 
314     LIBUPNP_LIBS="-lminiupnpc"
315     LIBUPNP_LIBS_QT="-lminiupnpc"
317 AC_SUBST(LIBUPNP_CFLAGS)
318 AC_SUBST(LIBUPNP_LIBS)
319 AC_SUBST(LIBUPNP_LIBS_QT)
324 dnl ----------------------------------------------------------------------------
326 dnl  Allow usage of system natpmp library 
328 LIBNATPMP_CFLAGS="-I\$(top_srcdir)/third-party/libnatpmp/" 
329 LIBNATPMP_LIBS="\$(top_builddir)/third-party/libnatpmp/libnatpmp.a" 
330 LIBNATPMP_LIBS_QT="\$\${TRANSMISSION_TOP}/third-party/libnatpmp/libnatpmp.a" 
331 build_bundled_natpmp="yes" 
332 AC_ARG_ENABLE([external-natpmp], 
333               AS_HELP_STRING([--enable-external-natpmp],[Use system external-natpmp]), 
334               [want_external_natpmp=${enableval}], 
335               [want_external_natpmp=no]) 
336 if test "x$want_external_natpmp" != "xno" ; then 
337         dnl Would be lovely if it had pkgconfig 
338         LIBNATPMP_CFLAGS=""  
339         LIBNATPMP_LIBS="-lnatpmp" 
340         LIBNATPMP_LIBS_QT="-lnatpmp" 
341         build_bundled_natpmp="no" 
342 fi 
343 AM_CONDITIONAL([BUILD_NATPMP],[test "x$build_bundled_natpmp" = "xyes"]) 
344 AC_SUBST(LIBNATPMP_CFLAGS) 
345 AC_SUBST(LIBNATPMP_LIBS) 
346 AC_SUBST(LIBNATPMP_LIBS_QT) 
349 dnl ----------------------------------------------------------------------------
351 dnl  detection for the GTK+ client
353 AC_ARG_ENABLE([nls],
354               [AS_HELP_STRING([--enable-nls],[enable native language support])],,
355               [enable_nls=yes])
356 PKG_CHECK_EXISTS([gtk+-3.0 >= $GTK_MINIMUM
357                   glib-2.0 >= $GLIB_MINIMUM
358                   gio-2.0 >= $GIO_MINIMUM,
359                   gmodule-2.0 >= $GLIB_MINIMUM
360                   gthread-2.0 >= $GLIB_MINIMUM],
361                  [have_gtk=yes],
362                  [have_gtk=no])
363 AC_ARG_WITH([gtk], AS_HELP_STRING([--with-gtk],[with Gtk]),
364             [with_gtk=$withval],
365             [with_gtk=$have_gtk])
366 AM_CONDITIONAL([BUILD_GTK],[test "x$with_gtk" = "xyes"])
367 use_libappindicator=no
368 if test "x$with_gtk" = "xyes" ; then
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" )
372     fi
374     PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= $GTK_MINIMUM
375                               glib-2.0 >= $GLIB_MINIMUM
376                               gio-2.0 >= $GIO_MINIMUM,
377                               gmodule-2.0 >= $GLIB_MINIMUM
378                               gthread-2.0 >= $GLIB_MINIMUM])
379     PKG_CHECK_MODULES([LIBAPPINDICATOR],
380                       [appindicator3-0.1 >= $LIBAPPINDICATOR_MINIMUM],
381                       [have_libappindicator=yes],
382                       [have_libappindicator=no])
383     if test "x$have_libappindicator" = "xyes"; then
384         use_libappindicator=yes
385         AC_DEFINE([HAVE_LIBAPPINDICATOR], 1)
386     else
387         LIBAPPINDICATOR_CFLAGS=
388         LIBAPPINDICATOR_LIBS=
389     fi
392 dnl This section is only used for internationalization.
393 dnl If you don't need translations and this section gives you trouble --
394 dnl such as if you're building for a headless system --
395 dnl it's okay to tear this section out and re-build the configure script.
397 dnl Note to packagers: the bump to intltool 0.40 was made to fix
398 dnl a "make check" failure on some systems.  if upgrading to 0.40 is
399 dnl a problem and the old version was working fine for you,
400 dnl it should be safe to re-edit 0.40 back down to 0.23
402 use_nls=no
403 if test "x$enable_nls" = "xyes" ; then
404     use_nls=yes
405     m4_ifdef([IT_PROG_INTLTOOL],
406              [IT_PROG_INTLTOOL([0.35.0],[no-xml])],
407              [AC_MSG_ERROR("--enable-nls requires intltool to be installed.")])
408     AC_CHECK_HEADERS([libintl.h])
409     GETTEXT_PACKAGE=transmission-gtk
410     AC_SUBST(GETTEXT_PACKAGE)
411     AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[Gettext package])
412     AM_GLIB_GNU_GETTEXT
413     transmissionlocaledir='${prefix}/${DATADIRNAME}/locale'
414     AC_SUBST(transmissionlocaledir)
416 AC_SUBST(INTLLIBS)
419 dnl ----------------------------------------------------------------------------
421 dnl  platform-specific stuff.
423 AC_CANONICAL_HOST
424 have_darwin="no"
425 have_msw="no"
426 case $host_os in
428    *mingw32*)
429      have_msw="yes"
430      CXXFLAGS="$CXXFLAGS -mms-bitfields -mwin32 -mwindows"
431      CPPFLAGS="$CPPFLAGS -DWIN32 -D_WIN32 -DWIN32_LEAN_AND_MEAN"
432      LIBS="$LIBS -liphlpapi -lshell32 -lws2_32"
433      transmissionlocaledir="locale"
434      if test -z "$host_alias"; then
435        hostaliaswindres=
436      else
437        hostaliaswindres="$host_alias-windres";
438      fi
439      AC_CHECK_TOOL(WINDRES, windres)
440      ;;
442   *darwin*)
443     have_darwin="yes"
444     CFLAGS="-DMACOSX $CFLAGS"
445     ;;
447 esac
449 AC_ARG_ENABLE([lightweight],
450               AS_HELP_STRING([--enable-lightweight],[optimize libtransmission for low-resource systems: smaller cache size, prefer unencrypted peer connections, etc.]),
451               [enable_lightweight=${enableval}],
452               [enable_lightweight="no"])
453 if test "x$enable_lightweight" = "xyes" ; then
454   AC_DEFINE([TR_LIGHTWEIGHT],[1],[optimize libtransmission for low-resource systems])
457 AC_ARG_ENABLE([cli],
458               [AS_HELP_STRING([--enable-cli],[build command-line client])],
459               [build_cli=${enableval}],
460               [build_cli="yes"])
461 AM_CONDITIONAL([BUILD_CLI],[test "x$build_cli" = "xyes"])
463 AC_ARG_ENABLE([mac],
464               [AS_HELP_STRING([--enable-mac],[build Mac client])],
465               [build_mac=${enableval}],
466               [build_mac=${have_darwin}])
467 AM_CONDITIONAL([BUILD_MAC],[test "x$build_mac" = "xyes"])
469 AC_ARG_ENABLE([daemon],
470               [AS_HELP_STRING([--enable-daemon],[build daemon])],
471               [build_daemon=${enableval}],
472               [build_daemon="yes"])
473 AM_CONDITIONAL([BUILD_DAEMON],[test "x$build_daemon" = "xyes"])
476 if test "x$build_mac" = "xyes" ; then
477     # Make sure the proper Mac SDK is installed
478     if test ! -d /Developer/SDKs/MacOSX10.5.sdk; then
479       cat << EOF
480 You need to install the Mac OS X 10.5 SDK in order to build Transmission
481 with --enable-mac:
482   Get your Xcode CD or package
483   Restart the install
484   When it gets to "Installation Type", select "Customize"
485   Select "Mac OS X 10.5 SDK" under "Cross Development"
486   Finish the install.
488       exit 1
489     fi
491 if test "x$have_darwin" = "xyes"; then
492     AC_DEFINE([HAVE_DARWIN], 1)
493     AC_DEFINE([SYS_DARWIN], 1)
495 if test "x$have_msw" = "xyes"; then
496     AC_DEFINE([HAVE_MSW], 1)
498 AM_CONDITIONAL(WIN32, test "x$have_msw" = "xyes")
500 dnl ----------------------------------------------------------------------------
502 dnl  Generate the output
504 AC_CONFIG_FILES([Makefile
505                  transmission-gtk.spec
506                  cli/Makefile
507                  daemon/Makefile
508                  extras/Makefile
509                  libtransmission/Makefile
510                  utils/Makefile
511                  third-party/Makefile
512                  third-party/dht/Makefile
513                  third-party/libutp/Makefile
514                  third-party/libnatpmp/Makefile
515                  third-party/miniupnp/Makefile
516                  macosx/Makefile
517                  gtk/Makefile
518                  gtk/icons/Makefile
519                  qt/config.pri
520                  web/Makefile
521                  web/images/Makefile
522                  web/style/Makefile
523                  web/style/jqueryui/Makefile
524                  web/style/jqueryui/images/Makefile
525                  web/style/transmission/Makefile
526                  web/style/transmission/images/Makefile
527                  web/style/transmission/images/buttons/Makefile
528                  web/javascript/Makefile
529                  web/javascript/jquery/Makefile
530                  po/Makefile.in])
532 AC_OUTPUT
534 echo "
536 Configuration:
538    Source code location:                              ${srcdir}
539    Compiler:                                          ${CXX}
541    Build libtransmission:                             yes
542       * optimized for low-resource systems:           ${enable_lightweight}
543       * µTP enabled:                                  ${build_utp}
545    Build Command-Line client:                         ${build_cli}
547    Build GTK+ client:                                 ${with_gtk}
548       * libappindicator for an Ubuntu-style tray:     ${use_libappindicator}
550    Build Daemon:                                      ${build_daemon}
552    Build Mac client:                                  ${build_mac}