diff --git a/cli/Makefile.am b/cli/Makefile.am index 93b01ae97..3244936f6 100644 --- a/cli/Makefile.am +++ b/cli/Makefile.am @@ -1,5 +1,13 @@ AM_CPPFLAGS = -I$(top_srcdir) $(LIBEVENT_CPPFLAGS) -AM_CFLAGS = $(OPENSSL_CFLAGS) $(LIBCURL_CFLAGS) $(PTHREAD_CFLAGS) + +AM_CFLAGS = \ + $(OPENSSL_CFLAGS) \ + $(LIBCURL_CFLAGS) \ + $(ZLIB_CFLAGS) \ + $(PTHREAD_CFLAGS) + +AM_LDFLAGS = \ + $(ZLIB_LDFLAGS) bin_PROGRAMS = transmissioncli @@ -8,13 +16,14 @@ dist_man_MANS = transmissioncli.1 transmissioncli_SOURCES = cli.c transmissioncli_LDADD = \ - $(top_builddir)/libtransmission/libtransmission.a \ - $(top_builddir)/third-party/libevent/libevent.la \ - $(top_builddir)/third-party/libnatpmp/libnatpmp.a \ - $(top_builddir)/third-party/miniupnp/libminiupnp.a \ - $(INTLLIBS) \ - $(LIBCURL_LIBS) \ - $(OPENSSL_LIBS) \ - $(PTHREAD_LIBS) \ - -lm + $(top_builddir)/libtransmission/libtransmission.a \ + $(top_builddir)/third-party/libevent/libevent.la \ + $(top_builddir)/third-party/libnatpmp/libnatpmp.a \ + $(top_builddir)/third-party/miniupnp/libminiupnp.a \ + $(INTLLIBS) \ + $(LIBCURL_LIBS) \ + $(ZLIB_LIBS) \ + $(OPENSSL_LIBS) \ + $(PTHREAD_LIBS) \ + -lm diff --git a/configure.ac b/configure.ac index 1de20e736..bc592d9ac 100644 --- a/configure.ac +++ b/configure.ac @@ -58,7 +58,7 @@ AC_SEARCH_LIBS([socket], [socket net]) AC_SEARCH_LIBS([gethostbyname], [nsl bind]) PKG_CHECK_MODULES(OPENSSL, [openssl >= $OPENSSL_MINIMUM], , [CHECK_SSL()]) PKG_CHECK_MODULES(LIBCURL, [libcurl >= $CURL_MINIMUM]) -CHECK_ZLIB() +AC_PATH_ZLIB AC_SYS_LARGEFILE diff --git a/daemon/Makefile.am b/daemon/Makefile.am index ef02c55e0..381142ba5 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -1,5 +1,13 @@ AM_CPPFLAGS = -I@top_srcdir@ $(LIBEVENT_CPPFLAGS) -I$(top_srcdir)/third-party/ -DEMBEDDED -AM_CFLAGS = $(OPENSSL_CFLAGS) $(LIBCURL_CFLAGS) $(PTHREAD_CFLAGS) + +AM_CFLAGS = \ + $(OPENSSL_CFLAGS) \ + $(LIBCURL_CFLAGS) \ + $(ZLIB_CFLAGS) \ + $(PTHREAD_CFLAGS) + +AM_LDFLAGS = \ + $(ZLIB_LDFLAGS) dist_man_MANS = \ transmission-daemon.1 \ @@ -16,6 +24,7 @@ LDADD = \ $(top_builddir)/third-party/libevent/libevent.la \ $(INTLLIBS) \ $(LIBCURL_LIBS) \ + $(ZLIB_LIBS) \ $(OPENSSL_LIBS) \ $(PTHREAD_LIBS) -lm diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 96f221a80..acf4742dd 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -28,8 +28,12 @@ AM_CFLAGS = \ $(DBUS_GLIB_CFLAGS) \ $(LIBNOTIFY_CFLAGS) \ $(OPENSSL_CFLAGS) \ + $(ZLIB_CFLAGS) \ $(PTHREAD_CFLAGS) +AM_LDFLAGS = \ + $(ZLIB_LDFLAGS) + noinst_HEADERS = \ actions.h \ add-dialog.h \ @@ -101,6 +105,7 @@ transmission_LDADD = \ $(DBUS_GLIB_LIBS) \ $(OPENSSL_LIBS) \ $(LIBCURL_LIBS) \ + $(ZLIB_LIBS) \ $(PTHREAD_LIBS) -lm DESKTOP_IN_FILES=transmission.desktop.in diff --git a/libtransmission/Makefile.am b/libtransmission/Makefile.am index bc3a3ce00..395f174fb 100644 --- a/libtransmission/Makefile.am +++ b/libtransmission/Makefile.am @@ -3,7 +3,11 @@ AM_CPPFLAGS = \ -D__TRANSMISSION__ $(LIBEVENT_CPPFLAGS) \ -DPACKAGE_DATA_DIR=\""$(datadir)"\" -AM_CFLAGS = $(LIBCURL_CFLAGS) $(OPENSSL_CFLAGS) $(PTHREAD_CFLAGS) +AM_CFLAGS = \ + $(LIBCURL_CFLAGS) \ + $(OPENSSL_CFLAGS) \ + $(PTHREAD_CFLAGS) \ + $(ZLIB_CFLAGS) noinst_LIBRARIES = libtransmission.a @@ -108,6 +112,9 @@ TESTS = \ noinst_PROGRAMS = $(TESTS) +APPS_LDFLAGS = \ + $(ZLIB_LDFLAGS) + APPS_LDADD = \ ./libtransmission.a \ $(top_builddir)/third-party/miniupnp/libminiupnp.a \ @@ -117,6 +124,7 @@ APPS_LDADD = \ $(LIBCURL_LIBS) \ $(OPENSSL_LIBS) \ $(PTHREAD_LIBS) \ + $(ZLIB_LIBS) \ -lm bencode_test_SOURCES = bencode-test.c diff --git a/libtransmission/rpc-server.c b/libtransmission/rpc-server.c index 10a3d0c34..b3aad51a1 100644 --- a/libtransmission/rpc-server.c +++ b/libtransmission/rpc-server.c @@ -20,7 +20,7 @@ #include /* open */ #include /* close */ -#ifdef HAVE_LIBZ +#ifdef HAVE_ZLIB #include #endif @@ -224,7 +224,7 @@ add_response( struct evhttp_request * req, const void * content, size_t content_len ) { -#ifndef HAVE_LIBZ +#ifndef HAVE_ZLIB evbuffer_add( out, content, content_len ); #else const char * key = "Accept-Encoding"; diff --git a/m4/check-zlib.m4 b/m4/check-zlib.m4 deleted file mode 100644 index 2dc44246d..000000000 --- a/m4/check-zlib.m4 +++ /dev/null @@ -1,63 +0,0 @@ -AC_DEFUN([CHECK_ZLIB], -# -# http://autoconf-archive.cryp.to/check_zlib.html -# Handle user hints -# -[AC_MSG_CHECKING(if zlib is wanted) -AC_ARG_WITH(zlib, -[ --with-zlib=DIR root directory path of zlib installation [defaults to - /usr/local or /usr if not found in /usr/local] - --without-zlib to disable zlib usage completely], -[if test "$withval" != no ; then - AC_MSG_RESULT(yes) - if test -d "$withval" - then - ZLIB_HOME="$withval" - else - AC_MSG_WARN([Sorry, $withval does not exist, checking usual places]) - fi -else - AC_MSG_RESULT(no) -fi]) - -if test ! -f "${ZLIB_HOME}/include/zlib.h" -then - ZLIB_HOME=/usr -fi - -# -# Locate zlib, if wanted -# -if test -n "${ZLIB_HOME}" -then - ZLIB_OLD_LDFLAGS=$LDFLAGS - ZLIB_OLD_CPPFLAGS=$LDFLAGS - LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib" - CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include" - AC_LANG_SAVE - AC_LANG_C - AC_CHECK_LIB(z, inflateEnd, [zlib_cv_libz=yes], [zlib_cv_libz=no]) - AC_CHECK_HEADER(zlib.h, [zlib_cv_zlib_h=yes], [zlib_cv_zlib_h=no]) - AC_LANG_RESTORE - if test "$zlib_cv_libz" = "yes" -a "$zlib_cv_zlib_h" = "yes" - then - # - # If both library and header were found, use them - # - AC_CHECK_LIB(z, inflateEnd) - AC_MSG_CHECKING(zlib in ${ZLIB_HOME}) - AC_MSG_RESULT(ok) - else - # - # If either header or library was not found, revert and bomb - # - AC_MSG_CHECKING(zlib in ${ZLIB_HOME}) - LDFLAGS="$ZLIB_OLD_LDFLAGS" - CPPFLAGS="$ZLIB_OLD_CPPFLAGS" - AC_MSG_RESULT(failed) - AC_MSG_ERROR(either specify a valid zlib installation with --with-zlib=DIR or disable zlib usage with --without-zlib) - fi -fi - -]) - diff --git a/m4/zlib.m4 b/m4/zlib.m4 new file mode 100644 index 000000000..b9c3a55fb --- /dev/null +++ b/m4/zlib.m4 @@ -0,0 +1,80 @@ + AC_DEFUN([AC_PATH_ZLIB], [ + AC_ARG_WITH(zlib, + AC_HELP_STRING([--with-zlib=DIR], + [search for ZLIB in DIR/include and DIR/lib]), + [for dir in `echo "$withval" | tr : ' '`; do + if test -d $dir/include; then + ZLIB_CFLAGS="$ZLIB_CFLAGS -I$dir/include" + fi + if test -d $dir/lib; then + ZLIB_LDFLAGS="$ZLIB_LDFLAGS -L$dir/lib" + fi + done[]]) + + AC_ARG_WITH(zlib-includes, + AC_HELP_STRING([--with-zlib-includes=DIR], + [search for ZLIB includes in DIR]), + [for dir in `echo "$withval" | tr : ' '`; do + if test -d $dir; then + ZLIB_CFLAGS="$ZLIB_CFLAGS -I$dir" + fi + done[]]) + +ac_zlib_saved_CFLAGS="$CFLAGS" +ac_zlib_saved_LDFLAGS="$LDFLAGS" +ac_zlib_saved_LIBS="$LIBS" +CFLAGS="$CFLAGS $ZLIB_CFLAGS" +LDFLAGS="$LDFLAGS $ZLIB_LDFLAGS" +ac_have_zlibh=no +ac_have_zlib=no + touch /tmp/dummy1_zlib.h + AC_CHECK_HEADERS([/tmp/dummy1_zlib.h], [ac_have_zlibh=yes], [ac_have_zlibh=no], + [#include "zlib.h"]) + rm /tmp/dummy1_zlib.h + if test $ac_have_zlibh = yes; then + AC_SEARCH_LIBS(gzopen, [z], [ac_have_zlib=yes], [ac_have_zlib=no]) + fi +# List of places to try +testdirs="$HOME/opt/zlib $OBITINSTALL/other" +for dir in $testdirs; do + if test $ac_have_zlib = no; then + if test -f $dir/include/zlib.h; then + ZLIB_CFLAGS="-I$dir/include" + CPPFLAGS="$ac_zlib_saved_CPPFLAGS $ZLIB_CFLAGS" + ZLIB_LDFLAGS="-L$dir/lib" + LDFLAGS="$ac_zlib_saved_LDFLAGS $ZLIB_LDFLAGS" + touch /tmp/dummy3_zlib.h + AC_CHECK_HEADERS([/tmp/dummy3_zlib.h], [ac_have_zlibh=yes], [ac_have_zlibh=no], + [#include "zlib.h"]) + rm /tmp/dummy3_zlib.h + if test $ac_have_zlibh = yes; then + # Force check + ac_cv_search_gzopen=" " + AC_SEARCH_LIBS(gzopen, [z], [ac_have_zlib=yes], [ac_have_zlib=no]) + fi + if test $ac_have_zlib = yes ; then + if test $ac_have_zlibh = yes ; then + break; + fi + fi + fi + fi +done[] +if test $ac_have_zlib = no; then + AC_MSG_WARN([cannot find ZLIB library]) +fi +if test $ac_have_zlibh = no; then + AC_MSG_WARN([cannot find ZLIB headers]) + ac_have_zlib=no +fi +if test $ac_have_zlib = yes; then + AC_DEFINE(HAVE_ZLIB, 1, [Define to 1 if ZLIB is available.]) +fi +ZLIB_LIBS="$LIBS" +CFLAGS="$ac_zlib_saved_CFLAGS" +LDFLAGS="$ac_zlib_saved_LDFLAGS" +LIBS="$ac_zlib_saved_LIBS" + AC_SUBST(ZLIB_CFLAGS) + AC_SUBST(ZLIB_LDFLAGS) + AC_SUBST(ZLIB_LIBS) +])