Cleanup around linking.
authorBrian Aker <brian@tangent.org>
Sun, 25 Nov 2012 14:12:14 +0000 (09:12 -0500)
committerBrian Aker <brian@tangent.org>
Sun, 25 Nov 2012 14:12:14 +0000 (09:12 -0500)
22 files changed:
clients/include.am
configure.ac
libhashkit/aes.cc
libhashkit/include.am
libhashkit/rijndael.cc
libmemcached/backtrace.cc
libmemcached/include.am
libmemcachedinternal/include.am
libmemcachedprotocol/include.am
libmemcachedutil/include.am
libtest/backtrace_test.cc [new file with mode: 0644]
libtest/include.am
libtest/memcached.cc
m4/ax_check_library.m4
m4/ax_harden_compiler_flags.m4
m4/ax_libevent.m4
m4/ax_sasl.m4
m4/ax_uuid.m4
m4/libgearman.m4
tests/libmemcached-1.0/include.am
util/instance.cc
util/instance.hpp

index 72fd39d4ed7a655479c56d64343a88715b3ccd54..bd38ef0420132ee9656b56bf93c34262c1527e64 100644 (file)
@@ -94,7 +94,7 @@ clients_memaslap_SOURCES+= clients/ms_thread.c
 
 clients_memaslap_SOURCES+= clients/generator.cc clients/execute.cc
 clients_memaslap_LDADD=
-clients_memaslap_LDADD+= @LIBEVENT_LDFLAGS@
+clients_memaslap_LDADD+= @LIBEVENT_LIB@
 clients_memaslap_LDADD+= $(CLIENTS_LDADDS)
 
 clients_memcapable_SOURCES=
index a8fbcafa74f201b7f302e3a9cff72e8ded9ad556..0ca87389ad09fd472c69770ed14d2f762de311c8 100644 (file)
@@ -47,6 +47,7 @@ m4_include([libhashkit/include.m4])
 LT_PREREQ([2.2])
 LT_INIT
 LT_LANG([C++])
+LT_LIB_M
 
 AX_ASSERT
 
@@ -112,6 +113,7 @@ AC_CHECK_HEADERS_ONCE([dlfcn.h])
 AC_CHECK_HEADERS_ONCE([errno.h])
 AC_CHECK_HEADERS_ONCE([execinfo.h])
 AC_CHECK_HEADERS_ONCE([fcntl.h])
+AC_CHECK_HEADERS_ONCE([fnmatch.h])
 AC_CHECK_HEADERS_ONCE([inttypes.h])
 AC_CHECK_HEADERS_ONCE([libintl.h])
 AC_CHECK_HEADERS_ONCE([limits.h])
@@ -121,6 +123,7 @@ AC_CHECK_HEADERS_ONCE([math.h])
 AC_CHECK_HEADERS_ONCE([netdb.h])
 AC_CHECK_HEADERS_ONCE([netinet/in.h])
 AC_CHECK_HEADERS_ONCE([netinet/tcp.h])
+AC_CHECK_HEADERS_ONCE([poll.h])
 AC_CHECK_HEADERS_ONCE([pthread.h])
 AC_CHECK_HEADERS_ONCE([spawn.h])
 AC_CHECK_HEADERS_ONCE([stdarg.h])
@@ -131,13 +134,14 @@ AC_CHECK_HEADERS_ONCE([sys/socket.h])
 AC_CHECK_HEADERS_ONCE([sys/sysctl.h])
 AC_CHECK_HEADERS_ONCE([sys/time.h])
 AC_CHECK_HEADERS_ONCE([sys/un.h])
+AC_CHECK_HEADERS_ONCE([sys/wait.h])
 AC_CHECK_HEADERS_ONCE([syslog.h])
 AC_CHECK_HEADERS_ONCE([time.h])
 AC_CHECK_HEADERS_ONCE([unistd.h])
 
 # Windows only
-AC_CHECK_HEADERS([winsock2.h])
-AC_CHECK_HEADERS([ws2tcpip.h])
+AC_CHECK_HEADERS_ONCE([winsock2.h])
+AC_CHECK_HEADERS_ONCE([ws2tcpip.h])
 
 # Checks for typedefs, structures, and compiler characteristics.
 
@@ -160,6 +164,7 @@ AC_CHECK_FUNCS([pipe2])
 AC_CHECK_FUNCS([putenv])
 AC_CHECK_FUNCS([select])
 AC_CHECK_FUNCS([setenv])
+AC_CHECK_FUNCS([sigignore])
 AC_CHECK_FUNCS([socket])
 AC_CHECK_FUNCS([sqrt])
 AC_CHECK_FUNCS([strcasecmp])
@@ -214,14 +219,11 @@ AC_CHECK_LIB([rt],[clock_gettime],
              [AC_DEFINE([HAVE_CLOCK_GETTIME],[0],[Have clock_gettime])])
 
 # Check for the ability to call dlopen
-AS_IF([test "x$enable_static" = "xyes"],
+AS_IF([test "x$enable_shared" = xyes],
       [AC_CHECK_LIB([dl],[dlopen],
                     [AC_SUBST([DL_LIB],[-ldl])
                     AC_DEFINE([HAVE_LIBDL],[1],[Have dlopen])])],
-                    [AC_DEFINE([HAVE_LIBDL], [0], [Have dlopen])])
-
-AC_CHECK_LIB([m],[floor])
-AC_CHECK_FUNCS([sigignore])
+                    [AC_DEFINE([HAVE_LIBDL],[0],[Have dlopen])])
 
 AC_CHECK_HEADERS([atomic.h])
 AS_IF([test "x$ac_cv_header_atomic_h" = "xyes"],
@@ -251,7 +253,6 @@ AC_CHECK_FUNCS([setppriv],
                                 build_solaris_privs=yes])
                ])
 
-AC_CHECK_HEADERS_ONCE([winsock2.h poll.h sys/wait.h fnmatch.h])
 AM_CONDITIONAL([BUILD_POLL],[test "x$ac_cv_header_poll_h" = "xno"])
 AM_CONDITIONAL([BUILD_WIN32_WRAPPERS],[test "x$ac_cv_header_winsock2_h" = "xyes"])
 AS_IF([test "x$ac_cv_header_winsock2_h" = "xyes"],
@@ -263,7 +264,6 @@ SOCKET_SEND_FLAGS
 
 AX_UUID_GENERATE_TIME_SAFE
 
-
 AC_DEFUN([CHECK_FOR_PTHREAD_AND_SASL],
          [AX_PTHREAD(, [AC_MSG_ERROR([could not find libpthread])])
          AX_PTHREAD_TIMEDJOIN_NP
@@ -279,9 +279,9 @@ AC_DEFUN([CHECK_FOR_PTHREAD_AND_SASL],
 CHECK_FOR_PTHREAD_AND_SASL
 
 
-# backtrace() does not work with static builds.
+# backtrace(), others require shared builds
 AS_IF([test "x$enable_shared" = "xyes"],
-      [AC_DEFINE([AX_ENABLE_BACKTRACE],[1],[Support for backtrace().])])
+      [AC_DEFINE([HAVE_SHARED_ENABLED],[1],[Enable code which requires shared library support. Like backtrace().])])
 AM_CONDITIONAL([SHARED_ENABLED],[test "x$enable_shared" = "xyes"])
 
 PANDORA_ENABLE_DTRACE
index 2e91e07c55fb5efd7d83411cebbf5db7668c11c6..c7083a6e4adc3c83676195b59225770ac5876997 100644 (file)
@@ -35,9 +35,9 @@
  */
 
 
-#include <libhashkit/common.h>
+#include "libhashkit/common.h"
 
-#include <libhashkit/rijndael.hpp>
+#include "libhashkit/rijndael.hpp"
 
 #include <cstring>
 
index 3124a4e0fce7b6fb6d0bef0d52f84db4ce75d208..cfbacddcdbf724a955c1d49fa23ae5fc9f3c3c27 100644 (file)
@@ -22,6 +22,7 @@ noinst_HEADERS+= libhashkit/string.h
 
 nobase_include_HEADERS+= libhashkit/hashkit.h
 
+libhashkit_libhashkit_la_LIBADD=
 libhashkit_libhashkit_la_SOURCES=
 libhashkit_libhashkit_la_CXXFLAGS=
 libhashkit_libhashkit_la_CFLAGS=
@@ -58,7 +59,6 @@ endif
 libhashkit_libhashkit_la_CXXFLAGS+= -DBUILDING_HASHKIT
 libhashkit_libhashkit_la_CFLAGS+= -DBUILDING_HASHKIT
 
-libhashkit_libhashkit_la_LIBADD=
 libhashkit_libhashkit_la_LDFLAGS= -version-info $(HASHKIT_LIBRARY_VERSION)
 
 # library used for testing
@@ -66,4 +66,4 @@ noinst_LTLIBRARIES+= libhashkit/libhashkitinc.la
 
 libhashkit_libhashkitinc_la_SOURCES= ${libhashkit_libhashkit_la_SOURCES}
 libhashkit_libhashkitinc_la_CFLAGS= ${libhashkit_libhashkit_la_CFLAGS}
-libhashkit_libhashkitinc_la_LDFLAGS=  $(LIBM)
+libhashkit_libhashkitinc_la_CXXFLAGS= ${libhashkit_libhashkit_la_CXXFLAGS}
index 24b736284e2178d5b32c2de2add6e7caec5b6d8f..93997ccb3cd5bba4408a777d7c119972fc5ebc41 100644 (file)
@@ -63,7 +63,7 @@
 #include <assert.h>
 #include <stdlib.h>
 
-#include <libhashkit/rijndael.hpp>
+#include "libhashkit/rijndael.hpp"
 
 /*
 Te0[x] = S [x].[02, 01, 01, 03];
index 98361ea55dda229bdf6cf74af2b8a4a11279af3e..782ea6a91f80d87e3cbca63cb8d62e269d2e85ba 100644 (file)
@@ -1,8 +1,8 @@
 /*  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
  * 
- *  libmcachedd client library.
+ *  Libmemcached client library.
  *
- *  Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ *  Copyright (C) 2012 Data Differential, http://datadifferential.com/
  *  All rights reserved.
  *
  *  Redistribution and use in source and binary forms, with or without
  *
  */
 
-#include <libmemcached/common.h>
+#include "mem_config.h"
 
-#ifdef AX_ENABLE_BACKTRACE
+#include "libmemcached/backtrace.hpp"
 
-#ifdef HAVE_EXECINFO_H
-# include <execinfo.h>
-#endif
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
 
-#ifdef HAVE_GCC_ABI_DEMANGLE
-# include <cxxabi.h>
-#endif
+#if defined(HAVE_SHARED_ENABLED) && HAVE_SHARED_ENABLED
 
-#ifdef HAVE_DLFCN_H
-# include <dlfcn.h>
+#ifdef HAVE_EXECINFO_H
+#include <execinfo.h>
 #endif
 
 #ifdef HAVE_GCC_ABI_DEMANGLE
+# include <cxxabi.h>
 # define USE_DEMANGLE 1
 #else
 # define USE_DEMANGLE 0
 #endif
 
+#ifdef HAVE_DLFCN_H
+# include <dlfcn.h>
+#endif   
+
 const int MAX_DEPTH= 50;
 
 void custom_backtrace(void)
 {
 #ifdef HAVE_EXECINFO_H
-  void *array[MAX_DEPTH];
-
-  int backtrace_size= backtrace(array, MAX_DEPTH);
-  fprintf(stderr, "Number of stack frames obtained: %d\n", backtrace_size);
+  void *backtrace_buffer[MAX_DEPTH +1];
 
-#ifdef HAVE_DLFCN_H
-  Dl_info dlinfo;
-#endif
+  int stack_frames= backtrace(backtrace_buffer, MAX_DEPTH);
+  if (stack_frames)
+  {
+    char **symbollist= backtrace_symbols(backtrace_buffer, stack_frames);
+    if (symbollist)
+    {
+      for (int x= 0; x < stack_frames; x++) 
+      {
+        bool was_demangled= false;
 
-  for (int x= 0; x < backtrace_size; ++x)
-  {  
+        if (USE_DEMANGLE)
+        {
 #ifdef HAVE_DLFCN_H
-    if (dladdr(array[x], &dlinfo) == 0)
-    {
-      continue;
-    }
+          Dl_info dlinfo;
+          if (dladdr(backtrace_buffer[x], &dlinfo))
+          {
+            char demangled_buffer[1024];
+            const char *called_in= "<unresolved>";
+            if (dlinfo.dli_sname)
+            {
+              size_t demangled_size= sizeof(demangled_buffer);
+              int status;
+              char* demangled;
+              if ((demangled= abi::__cxa_demangle(dlinfo.dli_sname, demangled_buffer, &demangled_size, &status)))
+              {
+                called_in= demangled;
+                fprintf(stderr, "---> demangled: %s -> %s\n", demangled_buffer, demangled);
+              }
+              else
+              {
+                called_in= dlinfo.dli_sname;
+              }
+
+              was_demangled= true;
+              fprintf(stderr, "#%d  %lp in %s at %s\n",
+                      x, backtrace_buffer[x],
+                      called_in,
+                      dlinfo.dli_fname);
+            }
+          }
 #endif
+        }
 
-    const char* symname= dlinfo.dli_sname;
-
-    int status;
-    char* demangled= abi::__cxa_demangle(symname, NULL, 0, &status);
-    if (status == 0 and demangled)
-    {
-      symname= demangled;
-    }
-
-    printf("object: %s, function: %s\n", dlinfo.dli_fname, symname);
+        if (was_demangled == false)
+        {
+          fprintf(stderr, "?%d  %lp in %s\n", x, backtrace_buffer[x], symbollist[x]);
+        }
+      }
 
-    if (demangled)
-    {
-      free(demangled);
+      ::free(symbollist);
     }
-  } 
+  }
 #endif // HAVE_EXECINFO_H
+}
+
+#else // HAVE_SHARED_ENABLED
 
-#else // AX_ENABLE_BACKTRACE
 void custom_backtrace(void)
 {
+  fprintf(stderr, "Backtrace null function called\n");
 }
 #endif // AX_ENABLE_BACKTRACE
index e230267ef49091bff28fa7ffbf22bce09338db28..2465b058c228ade522f9962458b03e7efea255f6 100644 (file)
@@ -52,8 +52,10 @@ noinst_HEADERS+= libmemcached/virtual_bucket.h
 noinst_HEADERS+= libmemcached/watchpoint.h
 
 lib_LTLIBRARIES+= libmemcached/libmemcached.la
+libmemcached_libmemcached_la_DEPENDENCIES=
+libmemcached_libmemcached_la_LIBADD=
+libmemcached_libmemcached_la_LDFLAGS=
 libmemcached_libmemcached_la_CFLAGS= -DBUILDING_LIBMEMCACHED
-
 libmemcached_libmemcached_la_CXXFLAGS= -DBUILDING_LIBMEMCACHED
 
 libmemcached_libmemcached_la_SOURCES+= libmemcached/instance.cc
@@ -110,17 +112,13 @@ libmemcached_libmemcached_la_SOURCES+= libmemcached/virtual_bucket.c
 
 libmemcached/options.cc: libmemcached/csl/parser.h
 
-
-libmemcached_libmemcached_la_DEPENDENCIES=
-libmemcached_libmemcached_la_LIBADD=
-libmemcached_libmemcached_la_LDFLAGS=
 libmemcached_libmemcached_la_LDFLAGS+= -version-info ${MEMCACHED_LIBRARY_VERSION}
-libmemcached_libmemcached_la_LDFLAGS+= @DL_LIB@
+libmemcached_libmemcached_la_LIBADD+= @DL_LIB@
 
 if HAVE_SASL
 libmemcached_libmemcached_la_CXXFLAGS+= @PTHREAD_CFLAGS@
 libmemcached_libmemcached_la_LIBADD+= @PTHREAD_LIBS@
-libmemcached_libmemcached_la_LIBADD+= @SASL_LDFLAGS@
+libmemcached_libmemcached_la_LIBADD+= @SASL_LIB@
 endif
 
 if HAVE_DTRACE
index 75e58d637b9a19f90048ea24d8c13ea881eebd54..fafef9a34151db604fb89e4a433186b26559b83b 100644 (file)
@@ -22,8 +22,6 @@ libmemcachedinternal_libmemcachedinternal_la_CXXFLAGS= \
                                                       ${AM_CXXFLAGS} \
                                                       ${NO_CONVERSION} \
                                                       -DBUILDING_LIBMEMCACHEDINTERNAL
-libmemcachedinternal_libmemcachedinternal_la_LDFLAGS=
-libmemcachedinternal_libmemcachedinternal_la_LDFLAGS+= @DL_LIB@
 libmemcachedinternal_libmemcachedinternal_la_LIBADD= $(libmemcached_libmemcached_la_LIBADD)
 libmemcachedinternal_libmemcachedinternal_la_DEPENDENCIES= $(libmemcached_libmemcached_la_DEPENDENCIES)
 endif
index dd350f5ad3ccee7ed0d61cb4a71eaa9519af25e3..6a004598ef02194ff1b6b86fe2d6828d69166ba6 100644 (file)
@@ -30,7 +30,7 @@ libmemcached_libmemcachedprotocol_la_CXXFLAGS+= -DBUILDING_LIBMEMCACHED
 libmemcached_libmemcachedprotocol_la_CXXFLAGS+= @PTHREAD_CFLAGS@
 
 libmemcached_libmemcachedprotocol_la_LIBADD=
-libmemcached_libmemcachedprotocol_la_LIBADD+= @LIBEVENT_LDFLAGS@
+libmemcached_libmemcachedprotocol_la_LIBADD+= @LIBEVENT_LIB@
 libmemcached_libmemcachedprotocol_la_LIBADD+= @PTHREAD_LIBS@
 libmemcached_libmemcachedprotocol_la_LDFLAGS= ${AM_LDFLAGS}
 libmemcached_libmemcachedprotocol_la_LDFLAGS+= -version-info ${MEMCACHED_PROTOCAL_LIBRARY_VERSION}
index 37d4846ee94f1476ceb0e98aebe517bb7196f22f..e0b1fe9597be3583328dcb55e118cd741ee584b5 100644 (file)
@@ -13,13 +13,17 @@ libmemcached_libmemcachedutil_la_SOURCES= \
                                          libmemcachedutil/ping.cc \
                                          libmemcachedutil/pool.cc \
                                          libmemcachedutil/version.cc
-libmemcached_libmemcachedutil_la_CXXFLAGS= \
+libmemcached_libmemcachedutil_la_LIBADD=
+libmemcached_libmemcachedutil_la_LDFLAGS=
+libmemcached_libmemcachedutil_la_CXXFLAGS=
+libmemcached_libmemcachedutil_la_DEPENDENCIES=
+libmemcached_libmemcachedutil_la_CXXFLAGS+= \
                                           ${AM_CXXFLAGS} \
                                           ${NO_CONVERSION} \
                                           -DBUILDING_LIBMEMCACHED
 libmemcached_libmemcachedutil_la_CXXFLAGS+= @PTHREAD_CFLAGS@
-libmemcached_libmemcachedutil_la_LIBADD= libmemcached/libmemcached.la
+libmemcached_libmemcachedutil_la_LDFLAGS+= ${AM_LDFLAGS} -version-info ${MEMCACHED_UTIL_LIBRARY_VERSION}
+libmemcached_libmemcachedutil_la_LIBADD+= libmemcached/libmemcached.la
 libmemcached_libmemcachedutil_la_LIBADD+= @PTHREAD_LIBS@
-libmemcached_libmemcachedutil_la_LDFLAGS= ${AM_LDFLAGS} -version-info ${MEMCACHED_UTIL_LIBRARY_VERSION}
-libmemcached_libmemcachedutil_la_DEPENDENCIES= libmemcached/libmemcached.la
+libmemcached_libmemcachedutil_la_DEPENDENCIES+= libmemcached/libmemcached.la
 
diff --git a/libtest/backtrace_test.cc b/libtest/backtrace_test.cc
new file mode 100644 (file)
index 0000000..d4af451
--- /dev/null
@@ -0,0 +1,123 @@
+/*  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ *  Data Differential YATL (i.e. libtest)  library
+ *
+ *  Copyright (C) 2012 Data Differential, http://datadifferential.com/
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are
+ *  met:
+ *
+ *      * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ *
+ *      * Redistributions in binary form must reproduce the above
+ *  copyright notice, this list of conditions and the following disclaimer
+ *  in the documentation and/or other materials provided with the
+ *  distribution.
+ *
+ *      * The names of its contributors may not be used to endorse or
+ *  promote products derived from this software without specific prior
+ *  written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <cerrno>
+#include <csignal>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <iostream>
+
+#include "libmemcached/backtrace.hpp"
+
+class Test {
+public:
+  Test()
+  {
+  }
+
+  void call_backtrace()
+  {
+    std::cerr << __func__ << std::endl;
+    custom_backtrace();
+  }
+};
+
+void SIGSEGV_handler(int sig_num, siginfo_t* info, void* ucontext)
+{
+  std::cerr << __func__ << std::endl;
+  (void)sig_num;
+  (void)info;
+  (void)ucontext;
+
+  custom_backtrace();
+}
+
+int raise_SIGSEGV()
+{
+  std::cerr << std::endl << "Calling backtrace()" << std::endl;
+  custom_backtrace();
+  std::cerr << std::endl << "Calling raise()" << std::endl;
+  return raise(SIGSEGV);
+}
+
+int layer4()
+{
+  return raise_SIGSEGV();
+}
+
+int layer3()
+{
+  return layer4();
+}
+
+int layer2()
+{
+  return layer3();
+}
+
+int layer1()
+{
+  return layer2();
+}
+
+int main(int, char **)
+{
+  Test t;
+
+  t.call_backtrace();
+
+  struct sigaction sigact;
+
+  sigact.sa_sigaction= SIGSEGV_handler;
+  sigact.sa_flags= SA_RESTART | SA_SIGINFO;
+
+  if (sigaction(SIGSEGV, &sigact, (struct sigaction *)NULL) != 0)
+  {
+    std::cerr << "error setting signal handler for " << strsignal(SIGSEGV) << "(" <<  SIGSEGV << ")" << std::endl;
+
+    exit(EXIT_FAILURE);
+  }
+
+  int ret= layer1();
+  if (ret)
+  {
+    std::cerr << "raise() " << strerror(errno) << std::endl;
+    exit(EXIT_FAILURE);
+  }
+
+  exit(EXIT_SUCCESS);
+}
index b09fe364536d43027a5cfeafd54853db708201d1..0e495fafc4c2836e6e7488e443dfec6754ba5b53 100644 (file)
@@ -129,13 +129,13 @@ libtest_libtest_la_SOURCES+= libtest/tmpfile.cc
 libtest_libtest_la_SOURCES+= libtest/vchar.cc
 
 libtest_libtest_la_CXXFLAGS+= -DBUILDING_LIBTEST
-libtest_libtest_la_CXXFLAGS+= $(PTHREAD_CFLAGS)
+libtest_libtest_la_CXXFLAGS+= @PTHREAD_CFLAGS@
 libtest_libtest_la_CXXFLAGS+= -DLIBTEST_TEMP="\"tmp_chroot\""
 libtest_libtest_la_CXXFLAGS+= $(CURL_CFLAGS)
 
-libtest_libtest_la_LIBADD+= $(PTHREAD_LIBS)
 libtest_libtest_la_LIBADD+= $(CURL_LIBS)
-libtest_libtest_la_LIBADD+= $(RT_LIB)
+libtest_libtest_la_LIBADD+= @PTHREAD_LIBS@
+libtest_libtest_la_LIBADD+= @RT_LIB@
 
 libtest_libtest_la_DEPENDENCIES+= libtest_tmp_dir
 libtest_libtest_la_DEPENDENCIES+=libtest/abort
@@ -190,8 +190,7 @@ libtest_unittest_DEPENDENCIES+= libgearman/libgearman.la
 libtest_unittest_DEPENDENCIES+= gearmand/gearmand
 else
 if HAVE_LIBGEARMAN
-libtest_libtest_la_DEPENDENCIES+= libgearman/libgearman.la
-libtest_libtest_la_LIBADD+= $(libgearman_LIBS)
+libtest_libtest_la_LIBADD+= @LIBGEARMAN_LDFLAGS@
 libtest_libtest_la_SOURCES+= libtest/blobslap_worker.cc
 libtest_libtest_la_SOURCES+= libtest/gearmand.cc
 libtest_libtest_la_SOURCES+= util/instance.cc
@@ -260,3 +259,15 @@ noinst_PROGRAMS+= libtest/core-count
 
 libtest_abort_SOURCES= libtest/abort.cc
 noinst_PROGRAMS+= libtest/abort
+
+libtest_backtrace_SOURCES=
+libtest_backtrace_LDADD=
+libtest_backtrace_SOURCES+= libtest/backtrace_test.cc
+libtest_backtrace_SOURCES+= libmemcached/backtrace.cc
+libtest_backtrace_LDADD+= @DL_LIB@
+noinst_PROGRAMS+= libtest/backtrace
+test-backtrace: libtest/backtrace
+       @libtest/backtrace
+
+gdb-backtrace: libtest/backtrace
+       @$(GDB_COMMAND) libtest/backtrace
index d2ce941ea54147a3cc1ea630f4c18bc5c4e91aae..c54c6b9048b68fd7344626b38da16e5f777ee09e 100644 (file)
@@ -38,9 +38,6 @@
 
 #include <libtest/common.h>
 
-#include <libmemcached-1.0/memcached.h>
-#include <libmemcachedutil-1.0/util.h>
-
 #include <cassert>
 #include <cerrno>
 #include <cstdio>
index 5998c792553253ee29987e069410d1d744046552..8177acf04696fdb31e5573058a812dd93e4ca7a3 100644 (file)
@@ -60,7 +60,7 @@
 #   modified version of the Autoconf Macro, you may extend this special
 #   exception to the GPL to apply to your modified version as well.
 
-#serial 4
+#serial 6
 
 AC_DEFUN([AX_CHECK_LIBRARY], [
   AC_ARG_VAR($1[_CPPFLAGS], [C preprocessor flags for ]$1[ headers])
@@ -89,7 +89,11 @@ AC_DEFUN([AX_CHECK_LIBRARY], [
     ])
 
   AS_IF([test "$]AS_TR_SH([ax_cv_have_]$1)[" = "yes"],
-    AC_DEFINE([HAVE_]$1, [1], [Define to 1 if ]$1[ is found])
-      m4_ifval( m4_normalize([$4]), [$4]),
-    m4_ifval( m4_normalize([$5]), [$5]))
-])
+      [AC_DEFINE([HAVE_]$1, [1], [Define to 1 if ]$1[ is found])
+      AC_SUBST($1[_CPPFLAGS])
+      AC_SUBST($1[_LDFLAGS])
+      AC_SUBST($1[_LIB],[-l]$3)
+      m4_ifval( m4_normalize([$4]), [$4]), 
+      m4_ifval( m4_normalize([$5]), [$5])])
+  AM_CONDITIONAL([HAVE_]$1,[test "$]AS_TR_SH([ax_cv_have_]$1)[" = "yes"])
+  ])
index caab7853d1fd3240e60e65203297b23d2f3a9f95..3d5eb2e3500d0fdfb26c8a88124eb2239128df7c 100644 (file)
@@ -134,14 +134,15 @@ AC_DEFUN([_HARDEN_CC_COMPILER_FLAGS],
           _APPEND_COMPILE_FLAGS_ERROR([-fwrapv])
           _APPEND_COMPILE_FLAGS_ERROR([-fmudflapt])
 
-          AS_IF([test "x$ac_cv_vcs_checkout" = xyes],
-                [_APPEND_COMPILE_FLAGS_ERROR([-fstack-check])
-                AS_IF([test "x$ac_c_gcc_recent" = xyes],
-                      [_APPEND_COMPILE_FLAGS_ERROR([-D_FORTIFY_SOURCE=2])
-                      _APPEND_COMPILE_FLAGS_ERROR([-Wstack-protector])
-                      _APPEND_COMPILE_FLAGS_ERROR([-fstack-protector])
-                      _APPEND_COMPILE_FLAGS_ERROR([-fstack-protector-all])
-                      ])])
+          AS_IF([test "x$ax_enable_debug" = xno],
+            [AS_IF([test "x$ac_cv_vcs_checkout" = xyes],
+                  [_APPEND_COMPILE_FLAGS_ERROR([-fstack-check])
+                  AS_IF([test "x$ac_c_gcc_recent" = xyes],
+                        [_APPEND_COMPILE_FLAGS_ERROR([-D_FORTIFY_SOURCE=2])
+                        _APPEND_COMPILE_FLAGS_ERROR([-Wstack-protector])
+                        _APPEND_COMPILE_FLAGS_ERROR([-fstack-protector])
+                        _APPEND_COMPILE_FLAGS_ERROR([-fstack-protector-all])
+                        ])])])
 
          AS_IF([test "x$ac_cv_vcs_checkout" = xyes],
                [_APPEND_COMPILE_FLAGS_ERROR([-fstack-check])],
@@ -210,14 +211,15 @@ AC_DEFUN([_HARDEN_CXX_COMPILER_FLAGS],
             _APPEND_COMPILE_FLAGS_ERROR([-fwrapv])
             _APPEND_COMPILE_FLAGS_ERROR([-fmudflapt])
 
-            AS_IF([test "x$ac_cv_vcs_checkout" = xyes],
+            AS_IF([test "x$ax_enable_debug" = xno],
+            [AS_IF([test "x$ac_cv_vcs_checkout" = xyes],
                   [_APPEND_COMPILE_FLAGS_ERROR([-fstack-check])
                   AS_IF([test "x$ac_c_gcc_recent" = xyes],
                         [_APPEND_COMPILE_FLAGS_ERROR([-D_FORTIFY_SOURCE=2])
                         _APPEND_COMPILE_FLAGS_ERROR([-Wstack-protector])
                         _APPEND_COMPILE_FLAGS_ERROR([-fstack-protector])
                         _APPEND_COMPILE_FLAGS_ERROR([-fstack-protector-all])
-                        ])])
+                        ])])])
 
             AS_IF([test "x$ac_cv_warnings_as_errors" = xyes],
                   [_APPEND_COMPILE_FLAGS_ERROR([-Werror])])
index 41392f9d975899178188bcf992ae0d551759be8f..686bff23aa9d5da071bd4180a2d8bc4cb9d67c04 100644 (file)
@@ -3,7 +3,9 @@
 #
 # SYNOPSIS
 #
-#   AX_LIBEVENT(), AX_LIBEVENT2(), AX_LIBEVENT2_EVHTTP()
+#   AX_LIBEVENT([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) 
+#   AX_LIBEVENT2() 
+#   AX_LIBEVENT2_EVHTTP()
 #
 # DESCRIPTION
 #
 #   and this notice are preserved. This file is offered as-is, without any
 #   warranty.
 
-#serial 2
+#serial 4
  
 AC_DEFUN([AX_LIBEVENT],
          [AC_PREREQ([2.63])dnl
          AC_CACHE_CHECK([test for a working libevent],[ax_cv_libevent],
-                        [AX_SAVE_FLAGS
-                        LIBS="-levent $LIBS"
-                        AC_LANG_PUSH([C])
-                        AC_RUN_IFELSE([
-                                      AC_LANG_PROGRAM([
+           [AX_SAVE_FLAGS
+           LIBS="-levent $LIBS"
+           AC_LANG_PUSH([C])
+           AC_RUN_IFELSE([AC_LANG_PROGRAM([
 #include <sys/types.h>
 #include <sys/time.h>
 #include <stdlib.h>
 #include <event.h>
-                                                      ],[
-                                                      struct event_base *tmp_event= event_init();
-                                                      event_base_free(tmp_event);
-                                                      ])],
-                                      [ax_cv_libevent=yes],
-                                      [ax_cv_libevent=no],
-                                      [AC_MSG_WARN([test program execution failed])])
-                        AC_LANG_POP
-                        AX_RESTORE_FLAGS
-                        ])
+               ],[
+               struct event_base *tmp_event= event_init();
+               event_base_free(tmp_event);
+               ])],
+             [ax_cv_libevent=yes],
+             [ax_cv_libevent=no],
+             [AC_MSG_WARN([test program execution failed])])
+           AC_LANG_POP
+           AX_RESTORE_FLAGS
+           ])
 
          AS_IF([test "x$ax_cv_libevent" = "xyes"],
-               [LIBEVENT_LDFLAGS="-levent"
-               AC_SUBST(LIBEVENT_LDFLAGS)
-               AC_DEFINE([HAVE_LIBEVENT],[1],[Define if event_init is present in event.h.])],
-               [AC_DEFINE([HAVE_LIBEVENT],[0],[Define if event_init is present in event.h.])])
+             [AC_SUBST([LIBEVENT_LIB],[-levent])
+             AC_DEFINE([HAVE_LIBEVENT],[1],[Define if event_init is present in event.h.])],
+             [AC_DEFINE([HAVE_LIBEVENT],[0],[Define if event_init is present in event.h.])])
 
          AM_CONDITIONAL(HAVE_LIBEVENT, test "x$ax_cv_libevent" = "xyes")
+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
+         AS_IF([test "x$ax_cv_libevent" = xyes],
+             [$1],
+             [$2])
          ])
 
-  AC_DEFUN([AX_LIBEVENT2],
-           [AC_REQUIRE([AX_LIBEVENT])
-           AC_CACHE_CHECK([test for a working libevent version 2],[ax_cv_libevent2],
-                          [AX_SAVE_FLAGS
-                          LIBS="-levent $LIBS"
-                          AC_LANG_PUSH([C])
-                          AC_RUN_IFELSE([
-                                        AC_LANG_PROGRAM([
+AC_DEFUN([AX_LIBEVENT2],
+    [AC_REQUIRE([AX_LIBEVENT])
+    AC_CACHE_CHECK([test for a working libevent version 2],[ax_cv_libevent2],
+      [AX_SAVE_FLAGS
+      LIBS="-levent $LIBS"
+      AC_LANG_PUSH([C])
+      AC_RUN_IFELSE([AC_LANG_PROGRAM([
 #include <sys/types.h>
 #include <sys/time.h>
 #include <stdlib.h>
 #include <event2/event.h>
-                                                        ],[
-                                                        struct event_base *tmp_event= event_init();
-                                                        event_base_free(tmp_event);
-                                                        ])],
-                                        [ax_cv_libevent2=yes],
-                                        [ax_cv_libevent2=no],
-                                        [AC_MSG_WARN([test program execution failed])])
-                          AC_LANG_POP
-                          AX_RESTORE_FLAGS
-                          ])
+          ],[
+          struct event_base *tmp_event= event_init();
+          event_base_free(tmp_event);
+          ])],
+        [ax_cv_libevent2=yes],
+        [ax_cv_libevent2=no],
+        [AC_MSG_WARN([test program execution failed])])
+      AC_LANG_POP([C])
+      AX_RESTORE_FLAGS
+      ])
 
-           AS_IF([test "x$ax_cv_libevent2" = xyes],
-                 [LIBEVENT2_LDFLAGS="-levent"
-                 AC_SUBST(LIBEVENT2_LDFLAGS)
-                 AC_DEFINE([HAVE_LIBEVENT2],[1],[Define if event_init is present in event2/event.h.])],
-                 [AC_DEFINE([HAVE_LIBEVENT2],[0],[Define if event_init is present in event2/event.h.])])
+    AS_IF([test "x$ax_cv_libevent2" = xyes],
+        [AC_SUBST([LIBEVENT2_LIB],[-levent])
+        AC_DEFINE([HAVE_LIBEVENT2],[1],[Define if event_init is present in event2/event.h.])],
+        [AC_DEFINE([HAVE_LIBEVENT2],[0],[Define if event_init is present in event2/event.h.])])
 
-           AM_CONDITIONAL([HAVE_LIBEVENT2], [test "x$ax_cv_libevent2" = xyes])
-           ])
+    AM_CONDITIONAL([HAVE_LIBEVENT2], [test "x$ax_cv_libevent2" = xyes])
+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
+    AS_IF([test "x$ax_cv_libevent2" = xyes],
+        [$1],
+        [$2])
+    ])dnl AX_LIBEVENT2
 
-  AC_DEFUN([AX_LIBEVENT2_EVHTTP],
-           [AC_REQUIRE([AX_LIBEVENT2])
-           AC_CACHE_CHECK([test for a working libevent2 evhttp interface], [ax_cv_libevent2_evhttp],
-                          [AX_SAVE_FLAGS
-                          LIBS="-levent $LIBS"
-                          AC_LANG_PUSH([C])
-                          AC_RUN_IFELSE([
-                                        AC_LANG_PROGRAM([
+# 
+AC_DEFUN([AX_LIBEVENT2_EVHTTP],
+    [AC_REQUIRE([AX_LIBEVENT2])
+    AC_CACHE_CHECK([test for a working libevent2 evhttp interface], [ax_cv_libevent2_evhttp],
+      [AX_SAVE_FLAGS
+      LIBS="-levent $LIBS"
+      AC_LANG_PUSH([C])
+      AC_RUN_IFELSE([AC_LANG_PROGRAM([
 #include <sys/types.h>
 #include <sys/time.h>
 #include <stdlib.h>
 #include <event2/event.h>
 #include <event2/http.h>
-                                                        ],[
-                                                        struct event_base *libbase= event_base_new();  
-                                                        struct evhttp *libsrvr= evhttp_new(libbase);
-                                                        ])],
-                                        [ax_cv_libevent2_evhttp=yes],
-                                        [ax_cv_libevent2_evhttp=no],
-                                        [AC_MSG_WARN([test program execution failed])])
-                          AC_LANG_POP
-                          AX_RESTORE_FLAGS
-                          ])
+          ],[
+          struct event_base *libbase= event_base_new();  
+          struct evhttp *libsrvr= evhttp_new(libbase);
+          ])],
+        [ax_cv_libevent2_evhttp=yes],
+        [ax_cv_libevent2_evhttp=no],
+        [AC_MSG_WARN([test program execution failed])])
+      AC_LANG_POP([C])
+      AX_RESTORE_FLAGS
+      ])
 
-           AS_IF([test "x$ax_cv_libevent2_evhttp" = "xyes"],
-                 [LIBEVENT2_LDFLAGS="-levent"
-                 AC_SUBST(LIBEVENT2_LDFLAGS)
-                 AC_DEFINE([HAVE_LIBEVENT2],[1],[Define if event_init is present in event2/event.h.])],
-                 [AC_DEFINE([HAVE_LIBEVENT2],[0],[Define if event_init is present in event2/event.h.])])
+    AS_IF([test "x$ax_cv_libevent2_evhttp" = "xyes"],
+        [AC_DEFINE([HAVE_LIBEVENT2_EVHTTP],[1],[Define if event_init is present in event2/http.h.])],
+        [AC_DEFINE([HAVE_LIBEVENT2_EVHTTP],[0],[Define if event_init is present in event2/http.h.])])
 
-           AM_CONDITIONAL([HAVE_LIBEVENT2_EVHTTP],[test "x$ax_cv_libevent2_evhttp" = xyes])
-           ])
+    AM_CONDITIONAL([HAVE_LIBEVENT2_EVHTTP],[test "x$ax_cv_libevent2_evhttp" = xyes])
+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
+    AS_IF([test "x$ax_cv_libevent2_evhttp" = xyes],
+        [$1],
+        [$2])
+    ])dnl AX_LIBEVENT2_EVHTTP
index 48b05c7474b2e505f6e8897fe852059459746ead..303fbd2bef5e1046ae6cca911a2132f6cf7cd9c3 100644 (file)
@@ -46,7 +46,7 @@ AC_DEFUN([AX_SASL_CHECK],
     [ax_sasl_check=no
     AX_CHECK_LIBRARY([LIBSASL],[sasl/sasl.h],[sasl2],
       [ax_sasl_check=yes
-      AC_SUBST([SASL_LDFLAGS],[[-lsasl2]])
+      AC_SUBST([SASL_LIB],[[-lsasl2]])
       ])
     AC_MSG_CHECKING([checking to see if sasl works])
     AC_MSG_RESULT(["$ax_sasl_check"])
index 6864b45c7170693c88f9c7fb68684207aa780ab2..93c5f89f2367791683bccd039df80f09677a045f 100644 (file)
@@ -21,7 +21,7 @@
 #   and this notice are preserved. This file is offered as-is, without any
 #   warranty.
 
-#serial 5
+#serial 6
 
 AC_DEFUN([AX_UUID],
     [AC_PREREQ([2.63])dnl
@@ -62,14 +62,14 @@ AC_DEFUN([AX_UUID],
           [ax_libuuid=yes])
       ],[ax_libuuid=no])
 
-      AS_IF([test "$ax_libuuid" = yes],
+      AS_IF([test "x$ax_libuuid" = xyes],
           [AC_DEFINE([HAVE_UUID_UUID_H],[1],[Have uuid/uuid.h])
-          AS_IF([test "$ax_cv_libuuid_is_required" = yes],[ LIBUUID_LDFLAGS='-luuid' ])],
+          AS_IF([test "x$ax_cv_libuuid_is_required" = xyes],[ LIBUUID_LIB='-luuid' ])],
           [AC_DEFINE([HAVE_UUID_UUID_H],[0],[Have uuid/uuid.h])
           ])
 
-  AC_SUBST([LIBUUID_LDFLAGS])
-  AM_CONDITIONAL([HAVE_LIBUUID],[test "$ax_libuuid" = yes])
+  AC_SUBST([LIBUUID_LIB])
+  AM_CONDITIONAL([HAVE_LIBUUID],[test "x$ax_libuuid" = xyes])
   ])
 
   AC_DEFUN([AX_UUID_GENERATE_TIME_SAFE],
@@ -78,7 +78,7 @@ AC_DEFUN([AX_UUID],
       AC_CACHE_CHECK([for uuid_generate_time_safe],
         [ax_cv_uuid_generate_time_safe],
         [AX_SAVE_FLAGS
-        LIBS="$LIBUUID_LDFLAGS $LIBS"
+        LIBS="$LIBUUID_LIB $LIBS"
         AC_LANG_PUSH([C])
         AC_RUN_IFELSE([
           AC_LANG_PROGRAM([#include <uuid/uuid.h>],[
index 0501ed3e736116fd03aaef58bf0747122efb99a3..a95c289f8575635f10194e579d28ef85f35f9b10 100644 (file)
@@ -1,10 +1,9 @@
 # serial 1
 AC_DEFUN([CHECK_FOR_LIBGEARMAND],
-    [AX_CHECK_LIBRARY([LIBGEARMAN], [libgearman/gearmand.h], [gearman], 
+    [AX_CHECK_LIBRARY([LIBGEARMAN],[libgearman/gearman.h],[gearman], 
       [ax_check_for_libgearman=yes],
       [ax_check_for_libgearman=no])
     AS_IF([test "$ax_check_for_libgearman" = xyes],
       [AC_DEFINE([HAVE_LIBGEARMAN],[1],[Enables libgearman Support])],
       [AC_DEFINE([HAVE_LIBGEARMAN],[0],[Enables libgearman Support])])
-    AM_CONDITIONAL(HAVE_LIBGEARMAN,[test "$ax_check_for_libgearman" = xyes])
     ])
index 1add550fcde17e11eea86d509adc1f08c12addf8..499123d82c508e1559f2ad416eb7ba180e92c361 100644 (file)
@@ -108,7 +108,7 @@ tests_libmemcached_1_0_testapp_DEPENDENCIES+= libtest/libtest.la
 tests_libmemcached_1_0_testapp_DEPENDENCIES+= libhashkit/libhashkit.la
 tests_libmemcached_1_0_testapp_DEPENDENCIES+= libmemcached/libmemcachedutil.la
 
-tests_libmemcached_1_0_testapp_LDADD+= @LIBUUID_LDFLAGS@
+tests_libmemcached_1_0_testapp_LDADD+= @LIBUUID_LIB@
 tests_libmemcached_1_0_testapp_LDADD+= @PTHREAD_LIBS@
 tests_libmemcached_1_0_testapp_LDADD+= libmemcached/libmemcached.la
 tests_libmemcached_1_0_testapp_LDADD+= libmemcached/libmemcachedutil.la
@@ -164,7 +164,7 @@ tests_libmemcached_1_0_testsocket_DEPENDENCIES+= libtest/libtest.la
 tests_libmemcached_1_0_testsocket_DEPENDENCIES+= libhashkit/libhashkit.la
 tests_libmemcached_1_0_testsocket_DEPENDENCIES+= libmemcached/libmemcachedutil.la
 
-tests_libmemcached_1_0_testsocket_LDADD+= @LIBUUID_LDFLAGS@
+tests_libmemcached_1_0_testsocket_LDADD+= @LIBUUID_LIB@
 tests_libmemcached_1_0_testsocket_LDADD+= @PTHREAD_LIBS@
 tests_libmemcached_1_0_testsocket_LDADD+= libmemcached/libmemcached.la
 tests_libmemcached_1_0_testsocket_LDADD+= libmemcached/libmemcachedutil.la
index a1665f36016ab0826363ff6d61d49decc7739d26..1b99739762d40e158b63a41a0c70688ca58503f9 100644 (file)
@@ -36,7 +36,7 @@
  */
 
 
-#include <mem_config.h>
+#include "mem_config.h"
 
 #include "util/instance.hpp"
 
 #include <sys/types.h>
 
 #ifdef HAVE_UNISTD_H
-#include <unistd.h>
+# include <unistd.h>
+#endif
+
+#ifndef INVALID_SOCKET
+# define INVALID_SOCKET -1
+#endif
+
+#ifndef SOCKET_ERROR
+# define SOCKET_ERROR -1
+#endif
+
+#ifndef get_socket_errno
+# define get_socket_errno() errno
+#endif
+
+#ifndef closesocket
+# define closesocket(a) close(a)
 #endif
 
 
index 1855ef8db2e592f19899f217f7529efca9f416f1..853cc00c4620b9e51fcfe52b9798b367bd545a29 100644 (file)
 
 #pragma once
 
-#include <cstdio>
-#include <cerrno>
 #include <cassert>
+#include <cerrno>
 #include <cstddef>
-#include <sys/socket.h>
+#include <cstdio>
+#include <netinet/in.h>
 #include <string>
+#include <sys/socket.h>
 
 #include "util/operation.hpp"