From d61195ed2a8d1db91773e1b66f6a17372f3a4838 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Tue, 9 Aug 2011 01:13:21 -0700 Subject: [PATCH] Store latest of libtest --- config/autorun.sh | 2 +- configure.ac | 2 ++ libtest/include.am | 43 ++++++++++++++++++---------- m4/ax_with_prog.m4 | 70 ++++++++++++++++++++++++++++++++++++++++++++++ m4/memcached.m4 | 39 ++++++-------------------- 5 files changed, 110 insertions(+), 46 deletions(-) create mode 100644 m4/ax_with_prog.m4 diff --git a/config/autorun.sh b/config/autorun.sh index 3b076d1a..79d6629e 100755 --- a/config/autorun.sh +++ b/config/autorun.sh @@ -1,2 +1,2 @@ #!/bin/sh -autoreconf -ivf +autoreconf -ivf -Wall diff --git a/configure.ac b/configure.ac index a71e3369..98539130 100644 --- a/configure.ac +++ b/configure.ac @@ -53,11 +53,13 @@ HASHKIT_LIBRARY_VERSION=1:0:0 AC_SUBST(HASHKIT_LIBRARY_VERSION) LT_INIT +m4_include([m4/memcached.m4]) AM_CONDITIONAL(BUILDING_LIBMEMCACHED, true) AM_CONDITIONAL(HAVE_LIBMEMCACHED, false) AM_CONDITIONAL(BUILDING_GEARMAN, false) AM_CONDITIONAL(HAVE_LIBGEARMAN, false) +AC_DEFINE([GEARMAN_BINARY], [0], [dummy variable]) AC_SEARCH_LIBS(getopt_long, gnugetopt) AC_SEARCH_LIBS(gethostbyname, nsl) diff --git a/libtest/include.am b/libtest/include.am index ab846b75..d65c4169 100644 --- a/libtest/include.am +++ b/libtest/include.am @@ -82,14 +82,6 @@ libtest_libtest_la_SOURCES= \ libtest/signal.cc \ libtest/test.cc -libtest_libtest_la_CFLAGS= ${AM_CFLAGS} -libtest_libtest_la_CFLAGS+= ${NO_CONVERSION} -libtest_libtest_la_CFLAGS+= $(PTHREAD_CFLAGS) -libtest_libtest_la_CFLAGS+= -DBUILDING_LIBTEST -libtest_libtest_la_CPPFLAGS= ${AM_CPPFLAGS} -libtest_libtest_la_CPPFLAGS+= ${NO_CONVERSION} -libtest_libtest_la_CPPFLAGS+= $(PTHREAD_LIBS) -libtest_libtest_la_CPPFLAGS+= -DBUILDING_LIBTEST libtest_libtest_la_CXXFLAGS= ${AM_CXXFLAGS} libtest_libtest_la_CXXFLAGS+= ${NO_CONVERSION} libtest_libtest_la_CXXFLAGS+= -DBUILDING_LIBTEST @@ -98,7 +90,9 @@ libtest_libtest_la_LIBADD= libtest_libtest_la_LIBADD+= $(PTHREAD_LIBS) libtest_libtest_la_DEPENDENCIES= -LIBTEST_LDADD= libtest/libtest.la +libtest_unittest_CXXFLAGS= ${AM_CXXFLAGS} +libtest_unittest_LDADD= +libtest_unittest_DEPENDENCIES= # We are either building in tree, or with if BUILDING_LIBMEMCACHED @@ -107,10 +101,19 @@ libtest_libtest_la_DEPENDENCIES+= libmemcached/libmemcachedutil.la libtest_libtest_la_LIBADD+= libmemcached/libmemcached.la libtest_libtest_la_LIBADD+= libmemcached/libmemcachedutil.la libtest_libtest_la_SOURCES+= libtest/memcached.cc -endif +libtest_libtest_la_CXXFLAGS+= -DHAVE_LIBMEMCACHED + +libtest_unittest_CXXFLAGS+= -DHAVE_LIBMEMCACHED +libtest_unittest_LDADD+= libmemcached/libmemcached.la +libtest_unittest_LDADD+= libmemcached/libmemcachedutil.la +else if HAVE_LIBMEMCACHED libtest_libtest_la_LIBADD+= $(libmemcached_LIBS) -lmemcachedutil libtest_libtest_la_SOURCES+= libtest/memcached.cc +else +libtest_libtest_la_CXXFLAGS+= -DHAVE_LIBMEMCACHED=0 +libtest_unittest_CXXFLAGS+= -DHAVE_LIBMEMCACHED=0 +endif endif if BUILDING_GEARMAN @@ -120,7 +123,14 @@ libtest_libtest_la_SOURCES+= libtest/blobslap_worker.cc libtest_libtest_la_SOURCES+= libtest/gearmand.cc libtest_libtest_la_SOURCES+= util/instance.cc libtest_libtest_la_SOURCES+= util/operation.cc -endif +libtest_libtest_la_CXXFLAGS+= -DHAVE_LIBGEARMAN +libtest_libtest_la_CXXFLAGS+= -DGEARMAND_BINARY="gearmand/gearmand" + +libtest_unittest_CXXFLAGS+= -DHAVE_LIBGEARMAN +libtest_unittest_CXXFLAGS+= -DGEARMAND_BINARY="gearmand/gearmand" +libtest_unittest_LDADD+= libgearman/libgearman.la +libtest_unittest_DEPENDENCIES+= libgearman/libgearman.la +else if HAVE_LIBGEARMAN libtest_libtest_la_DEPENDENCIES+= libgearman/libgearman.la libtest_libtest_la_LIBADD+= $(libgearman_LIBS) @@ -128,6 +138,12 @@ libtest_libtest_la_SOURCES+= libtest/blobslap_worker.cc libtest_libtest_la_SOURCES+= libtest/gearmand.cc libtest_libtest_la_SOURCES+= util/instance.cc libtest_libtest_la_SOURCES+= util/operation.cc +else +libtest_libtest_la_CXXFLAGS+= -DGEARMAND_BINARY=0 +libtest_libtest_la_CXXFLAGS+= -DHAVE_LIBGEARMAN=0 +libtest_unittest_CXXFLAGS+= -DGEARMAND_BINARY=0 +libtest_unittest_CXXFLAGS+= -DHAVE_LIBGEARMAN=0 +endif endif libtest_tmp_dir: tests/var/log tests/var/tmp tests/var/run @@ -145,9 +161,8 @@ tests/var/run: tests/var @$(mkdir_p) tests/var/run -libtest_unittest_CFLAGS= -libtest_unittest_LDADD= ${LIBTEST_LDADD} -libtest_unittest_DEPENDENCIES= ${LIBTEST_LDADD} libtest_tmp_dir +libtest_unittest_DEPENDENCIES+= libtest/libtest.la libtest_tmp_dir +libtest_unittest_LDADD+= libtest/libtest.la libtest_unittest_SOURCES= libtest/unittest.cc check_PROGRAMS+= libtest/unittest noinst_PROGRAMS+= libtest/unittest diff --git a/m4/ax_with_prog.m4 b/m4/ax_with_prog.m4 new file mode 100644 index 00000000..f337c059 --- /dev/null +++ b/m4/ax_with_prog.m4 @@ -0,0 +1,70 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_with_prog.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_WITH_PROG([VARIABLE],[program],[VALUE-IF-NOT-FOUND],[PATH]) +# +# DESCRIPTION +# +# Locates an installed program binary, placing the result in the precious +# variable VARIABLE. Accepts a present VARIABLE, then --with-program, and +# failing that searches for program in the given path (which defaults to +# the system path). If program is found, VARIABLE is set to the full path +# of the binary; if it is not found VARIABLE is set to VALUE-IF-NOT-FOUND +# if provided, unchanged otherwise. +# +# A typical example could be the following one: +# +# AX_WITH_PROG(PERL,perl) +# +# NOTE: This macro is based upon the original AX_WITH_PYTHON macro from +# Dustin J. Mitchell . +# +# LICENSE +# +# Copyright (c) 2008 Francesco Salvestrini +# Copyright (c) 2008 Dustin J. Mitchell +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 16 + +AC_DEFUN([AX_WITH_PROG],[ + AC_PREREQ([2.61]) + + pushdef([VARIABLE],$1) + pushdef([EXECUTABLE],$2) + pushdef([VALUE_IF_NOT_FOUND],$3) + pushdef([PATH_PROG],$4) + + AC_ARG_VAR(VARIABLE,Absolute path to EXECUTABLE executable) + + AS_IF(test -z "$VARIABLE",[ + AC_MSG_CHECKING(whether EXECUTABLE executable path has been provided) + AC_ARG_WITH(EXECUTABLE,AS_HELP_STRING([--with-EXECUTABLE=[[[PATH]]]],absolute path to EXECUTABLE executable), [ + AS_IF([test "$withval" != yes && test "$withval" != no],[ + VARIABLE="$withval" + AC_MSG_RESULT($VARIABLE) + ],[ + VARIABLE="" + AC_MSG_RESULT([no]) + AS_IF([test "$withval" != no], [ + AC_PATH_PROG([]VARIABLE[],[]EXECUTABLE[],[]VALUE_IF_NOT_FOUND[],[]PATH_PROG[]) + ]) + ]) + ],[ + AC_MSG_RESULT([no]) + AC_PATH_PROG([]VARIABLE[],[]EXECUTABLE[],[]VALUE_IF_NOT_FOUND[],[]PATH_PROG[]) + ]) + ]) + + popdef([PATH_PROG]) + popdef([VALUE_IF_NOT_FOUND]) + popdef([EXECUTABLE]) + popdef([VARIABLE]) +]) diff --git a/m4/memcached.m4 b/m4/memcached.m4 index 010fb429..0b8592fe 100644 --- a/m4/memcached.m4 +++ b/m4/memcached.m4 @@ -1,31 +1,8 @@ -AC_DEFUN([WITH_MEMCACHED], - [AC_ARG_WITH([memcached], - [AS_HELP_STRING([--with-memcached], - [Memcached binary to use for make test])], - [ac_cv_with_memcached="$withval"], - [ac_cv_with_memcached=memcached]) - - # just ignore the user if --without-memcached is passed.. it is - # only used by make test - AS_IF([test "x$withval" = "xno"], - [ - ac_cv_with_memcached=memcached - MEMC_BINARY=memcached - ], - [ - AS_IF([test -f "$withval"], - [ - ac_cv_with_memcached=$withval - MEMC_BINARY=$withval - ], - [ - AC_PATH_PROG([MEMC_BINARY], [$ac_cv_with_memcached], "no") - AS_IF([test "x$MEMC_BINARY" = "xno"], - AC_MSG_ERROR(["could not find memcached binary"])) - ]) - ]) - - AC_DEFINE_UNQUOTED([MEMCACHED_BINARY], "$MEMC_BINARY", - [Name of the memcached binary used in make test]) - AC_SUBST(MEMC_BINARY) -]) +AX_WITH_PROG(MEMCACHED_BINARY,memcached) +AS_IF([test -f "$ac_cv_path_MEMCACHED_BINARY"], + [ + AC_DEFINE_UNQUOTED([MEMCACHED_BINARY], "$ac_cv_path_MEMCACHED_BINARY", [Name of the memcached binary used in make test]) + ], + [ + AC_DEFINE([MEMCACHED_BINARY], [0], [Name of the memcached binary used in make test]) + ]) -- 2.30.2