From d8d481427a05b88cdb0810c29bf400153595c423 Mon Sep 17 00:00:00 2001 From: "snappy.mirrorbot@gmail.com" Date: Tue, 3 May 2011 23:22:52 +0000 Subject: [PATCH] Fix public issue #37: Only link snappy_unittest against -lz and other autodetected libraries, not libsnappy.so (which doesn't need any such dependency). R=csilvers DELTA=20 (14 added, 0 deleted, 6 changed) Revision created by MOE tool push_codebase. MOE_MIGRATION=1710 git-svn-id: https://snappy.googlecode.com/svn/trunk@33 03e5f5b5-db94-4691-08a0-1a8bf15f6143 --- Makefile.am | 2 +- configure.ac | 24 +++++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Makefile.am b/Makefile.am index c1053e0..2da357e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -12,7 +12,7 @@ noinst_HEADERS = snappy-internal.h snappy-stubs-internal.h snappy-test.h snappy_unittest_CPPFLAGS = $(gflags_CFLAGS) $(GTEST_CPPFLAGS) snappy_unittest_SOURCES = snappy_unittest.cc snappy-test.cc snappy_unittest_LDFLAGS = $(GTEST_LDFLAGS) -snappy_unittest_LDADD = libsnappy.la $(gflags_LIBS) $(GTEST_LIBS) +snappy_unittest_LDADD = libsnappy.la $(UNITTEST_LIBS) $(gflags_LIBS) $(GTEST_LIBS) TESTS = snappy_unittest noinst_PROGRAMS = $(TESTS) diff --git a/configure.ac b/configure.ac index cf3b48c..1351b76 100644 --- a/configure.ac +++ b/configure.ac @@ -79,11 +79,25 @@ fi # Other compression libraries; the unit test can use these for comparison # if they are available. If they are not found, just ignore. -AC_CHECK_LIB([z], [zlibVersion],, [true]) -AC_CHECK_LIB([lzo2], [lzo1x_1_15_compress],, [true]) -AC_CHECK_LIB([lzf], [lzf_compress],, [true]) -AC_CHECK_LIB([fastlz], [fastlz_compress],, [true]) -AC_CHECK_LIB([quicklz], [qlz_compress],, [true]) +UNITTEST_LIBS="" +AC_DEFUN([CHECK_EXT_COMPRESSION_LIB], [ + AH_CHECK_LIB([$1]) + AC_CHECK_LIB( + [$1], + [$2], + [ + AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_LIB$1)) + UNITTEST_LIBS="-l$1 $UNITTEST_LIBS" + ], + [true] + ) +]) +CHECK_EXT_COMPRESSION_LIB([z], [zlibVersion]) +CHECK_EXT_COMPRESSION_LIB([lzo2], [lzo1x_1_15_compress]) +CHECK_EXT_COMPRESSION_LIB([lzf], [lzf_compress]) +CHECK_EXT_COMPRESSION_LIB([fastlz], [fastlz_compress]) +CHECK_EXT_COMPRESSION_LIB([quicklz], [qlz_compress]) +AC_SUBST([UNITTEST_LIBS]) # These are used by snappy-stubs-public.h.in. if test "$ac_cv_header_stdint_h" = "yes"; then