AC_SUBST(LIBM)
LIBS="$save_LIBS"
+
AC_SEARCH_LIBS(floorf, m)
+dnl Specialty checks
+DETECT_BYTEORDER
+ENABLE_UTILLIB
+ENABLE_DTRACE
+SETSOCKOPT_SANITY
+ENABLE_HSIEH_HASH
+REQUIRE_POD2MAN
+PROTOCOL_BINARY_TEST
+WITH_MEMCACHED
++ENABLE_DEPRECATED
-sinclude(m4/pod2man.m4)
-sinclude(m4/debug.m4)
-sinclude(m4/dtrace.m4)
-sinclude(m4/byteorder.m4)
-sinclude(m4/64bit.m4)
-sinclude(m4/protocol_binary.m4)
-sinclude(m4/memcached.m4)
-sinclude(m4/setsockopt.m4)
-sinclude(m4/hsieh.m4)
-sinclude(m4/util.m4)
-sinclude(m4/deprecated.m4)
-
-dnl This is likely subverted by vpath builds. How do we find the original
-dnl source dir in the configure step of a vpath build?
-if test -d ".hg"
+dnl TODO: Remove this define once we are using 2.61 across the board.
+# AX_HEADER_ASSERT
+# ----------------
+# Check whether to enable assertions.
+AC_DEFUN([AX_HEADER_ASSERT],
+[
+ AC_MSG_CHECKING([whether to enable assertions])
+ AC_ARG_ENABLE([assert],
+ [AS_HELP_STRING([--disable-assert],
+ [Turn off assertions])],
+ [ac_cv_assert="no"],
+ [ac_cv_assert="yes"])
+ AC_MSG_RESULT([$ac_cv_assert])
+])
+AX_HEADER_ASSERT
+
+
+AC_ARG_WITH([debug],
+ [AS_HELP_STRING([--with-debug],
+ [Add debug code/turns off optimizations (yes|no) @<:@default=no@:>@])],
+ [with_debug=$withval],
+ [with_debug=no])
+if test "$with_debug" = "yes"
then
- building_from_hg=yes
+ # Debugging. No optimization.
+ CFLAGS="${DEBUG_CFLAGS} -DDEBUG ${CFLAGS}"
+ CXXFLAGS="${DEBUG_CXXFLAGS} -DDEBUG ${CXXFLAGS}"
else
- building_from_hg=no
+ # Optimized version. No debug
+ CFLAGS="${OPTIMIZE_CFLAGS} ${CFLAGS}"
+ CXXFLAGS="${OPTIMIZE_CXXFLAGS} ${CXXFLAGS}"
fi
+AC_ARG_ENABLE([profiling],
+ [AS_HELP_STRING([--enable-profiling],
+ [Toggle profiling @<:@default=off@:>@])],
+ [ac_profiling="$enableval"],
+ [ac_profiling="no"])
+
+AC_ARG_ENABLE([coverage],
+ [AS_HELP_STRING([--enable-coverage],
+ [Toggle coverage @<:@default=off@:>@])],
+ [ac_coverage="$enableval"],
+ [ac_coverage="no"])
-# We only support GCC and Sun's forte at the moment
if test "$GCC" = "yes"
then
- if test "$ENABLE_DEBUG" = "yes"
- then
- CFLAGS="-O0 -DHAVE_DEBUG $CFLAGS"
- CXXFLAGS="-O0 -DHAVE_DEBUG $CXXFLAGS"
- else
- CFLAGS="-O3 $CFLAGS"
- CXXFLAGS="-O3 $CXXFLAGS"
- fi
- if test "$building_from_hg" = "yes"
- then
- CFLAGS="-Werror $CFLAGS"
- CXXFLAGS="-Werror $CXXFLAGS"
- fi
-
- CFLAGS="-W -std=iso9899:1999 -Wall -Wextra -Wno-strict-aliasing -pedantic -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -ggdb3 $CFLAGS"
- CXXFLAGS="-W -Wall -Wextra -Wno-strict-aliasing -pedantic -Wundef -Woverloaded-virtual -Wnon-virtual-dtor -Wctor-dtor-privacy -Wold-style-cast -Weffc++ -Wconversion -Wmissing-declarations -Wredundant-decls -ggdb3 $CXXFLAGS"
+ AC_CACHE_CHECK([whether it is safe to use -fdiagnostics-show-option],
+ [ac_cv_safe_to_use_fdiagnostics_show_option_],
+ [save_CFLAGS="$CFLAGS"
+ CFLAGS="-fdiagnostics-show-option ${CFLAGS}"
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([],[])],
+ [ac_cv_safe_to_use_fdiagnostics_show_option_=yes],
+ [ac_cv_safe_to_use_fdiagnostics_show_option_=no])
+ CFLAGS="$save_CFLAGS"])
-fi
+ AS_IF([test "$ac_cv_safe_to_use_fdiagnostics_show_option_" = "yes"],
+ [
+ F_DIAGNOSTICS_SHOW_OPTION="-fdiagnostics-show-option"
+ ])
+
+ AC_CACHE_CHECK([whether it is safe to use -Wconversion],
+ [ac_cv_safe_to_use_wconversion_],
+ [save_CFLAGS="$CFLAGS"
+ CFLAGS="-Werror -Wconversion ${CFLAGS}"
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[
+#include <stdbool.h>
+void foo(bool a)
+{
+ (void)a;
+}
+ ]],[[
+foo(0);
+ ]])],
+ [ac_cv_safe_to_use_wconversion_=yes],
+ [ac_cv_safe_to_use_wconversion_=no])
+ CFLAGS="$save_CFLAGS"])
+
+ AS_IF([test "$ac_cv_safe_to_use_wconversion_" = "yes"],
+ [W_CONVERSION="-Wconversion"
+ AC_CACHE_CHECK([whether it is safe to use -Wconversion with htons],
+ [ac_cv_safe_to_use_Wconversion_],
+ [save_CFLAGS="$CFLAGS"
+ CFLAGS="-Werror -Wconversion ${CFLAGS}"
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[
+#include <netinet/in.h>
+ ]],[[
+uint16_t x= htons(80);
+ ]])],
+ [ac_cv_safe_to_use_Wconversion_=yes],
+ [ac_cv_safe_to_use_Wconversion_=no])
+ CFLAGS="$save_CFLAGS"])
+
+ AS_IF([test "$ac_cv_safe_to_use_Wconversion_" = "no"],
+ [
+ NO_CONVERSION="-Wno-conversion"
+ ])
+ ])
+
+ W_STRICT_ALIASING="-Wno-strict-aliasing"
+
+ AS_IF([test "$ac_profiling" = "yes"],
+ [CC_PROFILING="-pg"])
+
+ AS_IF([test "$ac_coverage" = "yes"],
+ [CC_COVERAGE="-fprofile-arcs -ftest-coverage"])
+
+ AS_IF([test "$building_from_bzr" = "yes"],
+ [W_FAIL="-Werror"])
+ BASE_WARNINGS="-pedantic -W -Wall -Wextra ${W_FAIL} -Wundef -Wshadow -Wmissing-declarations ${W_STRICT_ALIASING} ${F_DIAGNOSTICS_SHOW_OPTION} ${W_CONVERSION}"
+ CC_WARNINGS="${BASE_WARNINGS} -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wswitch-default -Wswitch-enum -Wcast-align"
+ CXX_WARNINGS="${BASE_WARNINGS} -Woverloaded-virtual -Wnon-virtual-dtor -Wctor-dtor-privacy -Wold-style-cast -Weffc++ -Wno-long-long"
+
+ AC_CACHE_CHECK([whether it is safe to use -Wlogical-op],
+ [ac_cv_safe_to_use_Wlogical_op_],
+ [save_CFLAGS="$CFLAGS"
+ CFLAGS="-Wlogical-op"
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM(
+ [[
+#include <stdio>
+ ]], [[]])
+ ],
+ [ac_cv_safe_to_use_Wlogical_op_=yes],
+ [ac_cv_safe_to_use_Wlogical_op_=no])
+ CFLAGS="$save_CFLAGS"])
+ AS_IF([test "$ac_cv_safe_to_use_Wlogical_op_" = "yes"],
+ [CC_WARNINGS="${CC_WARNINGS} -Wlogical-op"])
+
+ AC_CACHE_CHECK([whether it is safe to use -Wredundant-decls from C++],
+ [ac_cv_safe_to_use_Wredundant_decls_],
+ [AC_LANG_PUSH(C++)
+ save_CXXFLAGS="${CXXFLAGS}"
+ CXXFLAGS="${CXXFLAGS} ${W_FAIL} -Wredundant-decls"
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([
+template <typename E> struct C { void foo(); };
+template <typename E> void C<E>::foo() { }
+template <> void C<int>::foo();
+ AC_INCLUDES_DEFAULT])],
+ [ac_cv_safe_to_use_Wredundant_decls_=yes],
+ [ac_cv_safe_to_use_Wredundant_decls_=no])
+ CXXFLAGS="${save_CXXFLAGS}"
+ AC_LANG_POP()])
+ AS_IF([test "$ac_cv_safe_to_use_Wredundant_decls_" = "yes"],
+ [CXX_WARNINGS="${CXX_WARNINGS} -Wredundant-decls"],
+ [CXX_WARNINGS="${CXX_WARNINGS} -Wno-redundant-decls"])
+
+ NO_REDUNDANT_DECLS="-Wno-redundant-decls"
+fi
if test "$SUNCC" = "yes"
then
--- /dev/null
-AC_ARG_ENABLE([deprecated],
- [AS_HELP_STRING([--enable-deprecated],
- [Enable deprecated interface @<:@default=off@:>@])],
- [ac_enable_deprecated="$enableval"],
- [ac_enable_deprecated="no"])
+ dnl ---------------------------------------------------------------------------
+ dnl Macro: deprecated
+ dnl ---------------------------------------------------------------------------
-if test "x$ac_enable_deprecated" = "xyes"
-then
- DEPRECATED="#define MEMCACHED_ENABLE_DEPRECATED 1"
-fi
-
-AC_SUBST(DEPRECATED)
++AC_DEFUN([ENABLE_DEPRECATED],[
++ AC_ARG_ENABLE([deprecated],
++ [AS_HELP_STRING([--enable-deprecated],
++ [Enable deprecated interface @<:@default=off@:>@])],
++ [ac_enable_deprecated="$enableval"],
++ [ac_enable_deprecated="no"])
+
++ AS_IF([test "$ac_enable_deprecated" = "yes"],
++ [DEPRECATED="#define MEMCACHED_ENABLE_DEPRECATED 1"])
++ AC_SUBST([DEPRECATED])
++])
+ dnl ---------------------------------------------------------------------------
+ dnl End Macro: deprecated
+ dnl ---------------------------------------------------------------------------