Add --with-zlib=[DIR] configure option.
authorDavid Barksdale <amatus.amongus@gmail.com>
Sun, 9 Jun 2013 04:46:52 +0000 (04:46 +0000)
committerDavid Barksdale <amatus.amongus@gmail.com>
Sun, 9 Jun 2013 04:46:52 +0000 (04:46 +0000)
configure.ac
src/core/Makefile.am
src/datastore/Makefile.am
src/dht/Makefile.am
src/testbed/Makefile.am
src/util/Makefile.am

index 178fdf94ad9a7d2f8d4b30425c2b2b0e67a67152..52bc8967d02ea2c03dae6afc41fbdcc2bdf9aa2c 100644 (file)
@@ -568,14 +568,38 @@ AM_CONDITIONAL(HAVE_POSTGRES, test x$postgres = xtrue)
 AC_SUBST(POSTGRES_CPPFLAGS)
 AC_SUBST(POSTGRES_LDFLAGS)
 
-# test for libz (maybe required for linking mysql)
-zlib=1
-AC_CHECK_LIB(z, compress,,zlib=0)
-AM_CONDITIONAL(HAVE_ZLIB, test x$zlib = x1)
-if test "$zlib" != 1
-then
- AC_MSG_ERROR([GNUnet requires zlib])
-fi
+# test for zlib
+SAVE_LDFLAGS=$LDFLAGS
+SAVE_CPPFLAGS=$CPPFLAGS
+AC_ARG_WITH(zlib,
+           [  --with-zlib[[=DIR]]       use libz in DIR],
+           [AS_IF([test "$withval" = "no"],
+                  [AC_MSG_ERROR([GNUnet requires zlib])],
+                  [test "$withval" != "yes"],
+                  [
+                    Z_DIR=$withval
+                    CPPFLAGS="${CPPFLAGS} -I$withval/include"
+                    LDFLAGS="${LDFLAGS} -L$withval/lib"
+                  ])
+           ])
+AC_CHECK_HEADER(zlib.h,
+               [],
+               [AC_MSG_ERROR([GNUnet requires zlib])])
+AC_CHECK_LIB(z, compress2,
+            [
+             AC_DEFINE([HAVE_ZLIB], [], [Have compression library])
+             if test "x${Z_DIR}" != "x"; then
+                     Z_CFLAGS="-I${Z_DIR}/include"
+                     Z_LIBS="-L${Z_DIR}/lib -lz"
+             else
+                     Z_LIBS="-lz"
+             fi],
+             [AC_MSG_ERROR([GNUnet requires zlib])])
+AC_SUBST(Z_CFLAGS)
+AC_SUBST(Z_LIBS)
+
+LDFLAGS=$SAVE_LDFLAGS
+CPPFLAGS=$SAVE_CPPFLAGS
 
 # mysql & windows
 AC_CHECK_TYPES([sigset_t, off_t], [], [], [#include <sys/types.h>])
index a3ef13f5aca03827d66f1a7ccf0891d68cf43e65..7e4cd7f54284f59ee1e154df683e388834bcd9df 100644 (file)
@@ -49,7 +49,7 @@ gnunet_service_core_LDADD = \
   $(top_builddir)/src/statistics/libgnunetstatistics.la \
   $(top_builddir)/src/transport/libgnunettransport.la \
   $(top_builddir)/src/util/libgnunetutil.la \
-  $(GN_LIBINTL) -lz
+  $(GN_LIBINTL) $(Z_LIBS)
 
 
 gnunet_core_SOURCES = \
index c2acc2ffe811cf58dc3dcac4536328602911acb7..ef14175b281a839b09750d04e605e571f4dc339a 100644 (file)
@@ -124,7 +124,7 @@ libgnunet_plugin_datastore_mysql_la_SOURCES = \
 libgnunet_plugin_datastore_mysql_la_LIBADD = \
   $(top_builddir)/src/mysql/libgnunetmysql.la \
   $(top_builddir)/src/statistics/libgnunetstatistics.la \
-  $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) -lz -lmysqlclient
+  $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) $(Z_LIBS) -lmysqlclient
 libgnunet_plugin_datastore_mysql_la_LDFLAGS = \
  $(GN_PLUGIN_LDFLAGS) $(MYSQL_LDFLAGS) -lmysqlclient
 libgnunet_plugin_datastore_mysql_la_CPPFLAGS = \
index 6bbc19188cb1265c41099079936cbf593f286abb..30593172867323190a4974c3a2f99bc60ca66ce8 100644 (file)
@@ -12,10 +12,6 @@ libexecdir= $(pkglibdir)/libexec/
 pkgcfg_DATA = \
   dht.conf 
 
-if HAVE_ZLIB
- ZLIB_LNK = -lz
-endif
-
 if USE_COVERAGE
   AM_CFLAGS = --coverage -O0
   XLIB = -lgcov
index 902d8391be47e2f56bfa1452fde3243cdcf60f92..eb6d050ad02d6da0dbade0b64fa01cb986f0a9d0 100644 (file)
@@ -48,7 +48,7 @@ gnunet_service_testbed_LDADD = $(XLIB) \
  $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/testbed/libgnunettestbed.la \
  $(top_builddir)/src/arm/libgnunetarm.la \
- $(LTLIBINTL) -lz
+ $(LTLIBINTL) $(Z_LIBS)
 gnunet_service_testbed_DEPENDENCIES = \
  libgnunettestbed.la
 
@@ -71,7 +71,7 @@ gnunet_helper_testbed_LDADD = $(XLIB) \
  $(top_builddir)/src/util/libgnunetutil.la \
  $(top_builddir)/src/testing/libgnunettesting.la \
  libgnunettestbed.la \
- $(LTLIBINTL) -lz
+ $(LTLIBINTL) $(Z_LIBS)
 gnunet_helper_testbed_DEPENDENCIES = \
   gnunet-service-testbed.$(OBJEXT) \
   libgnunettestbed.la
@@ -268,7 +268,7 @@ test_gnunet_helper_testbed_SOURCES = \
 test_gnunet_helper_testbed_LDADD = \
  $(top_builddir)/src/util/libgnunetutil.la \
  libgnunettestbed.la \
- -lz
+ $(Z_LIBZ)
 
 test_testbed_api_testbed_run_topologyrandom_SOURCES = \
  test_testbed_api_testbed_run.c
index 491006a42ca987a06a4dfb67340a92910b56b3f3..06cd283c8968a3e058eb2542a7be41f4b0bd4ac1 100644 (file)
@@ -116,7 +116,7 @@ libgnunetutil_la_LIBADD = \
   $(LIBGCRYPT_LIBS) \
   $(LTLIBICONV) \
   $(LTLIBINTL) \
-  -lltdl -lz -lunistring $(XLIB) 
+  -lltdl $(Z_LIBS) -lunistring $(XLIB) 
 
 libgnunetutil_la_LDFLAGS = \
   $(GN_LIB_LDFLAGS) \