From: Monty Taylor Date: Wed, 8 Jul 2009 07:37:38 +0000 (-0700) Subject: pandora-build v0.1 X-Git-Tag: 0.31~4^2~6 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=36c6f6f7178cd69c4c0746dfee06e67f8e83cb0a;p=m6w6%2Flibmemcached pandora-build v0.1 --- diff --git a/configure.ac b/configure.ac index a336819e..ea826cc5 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ # libmemcached -# Copyright (C) 2008 Brian Aker +# Copyright (C) 2008 Brian Aker, Monty Taylor # All rights reserved. # # Use and distribution licensed under the BSD license. See @@ -12,6 +12,8 @@ AC_CONFIG_AUX_DIR(config) AM_CONFIG_HEADER([config.h]) AC_CONFIG_MACRO_DIR([m4]) +PANDORA_CANONICAL_TARGET + #shared library versioning MEMCACHED_LIBRARY_VERSION=2:0:0 # | | | @@ -28,66 +30,6 @@ AC_SUBST(MEMCACHED_LIBRARY_VERSION) MEMCACHEDUTIL_LIBRARY_VERSION=0:0:0 AC_SUBST(MEMCACHEDUTIL_LIBRARY_VERSION) -# Setting CFLAGS here prevents AC_CANONICAL_TARGET from injecting them -SAVE_CFLAGS=${CFLAGS} -SAVE_CXXFLAGS=${CXXFLAGS} -CFLAGS= -CXXFLAGS= - -AC_CANONICAL_TARGET - -CFLAGS=${SAVE_CFLAGS} -CXXFLAGS=${SAVE_CXXFLAGS} - -AM_INIT_AUTOMAKE([-Wall -Werror nostdinc subdir-objects]) - -if test "x${enable_dependency_tracking}" = "x" -then - enable_dependency_tracking=yes -fi - -if test -d "${srcdir}/.bzr" -then - building_from_bzr=yes -else - building_from_bzr=no -fi - -AC_PROG_CXX - -ACX_USE_SYSTEM_EXTENSIONS - -AC_PROG_CPP -AM_PROG_CC_C_O - -FORCE_MAC_GCC42 -dnl Once we can use a modern autoconf, we can use this -dnl AC_PROG_CC_C99 - -AC_C_BIGENDIAN -AC_C_CONST -AC_HEADER_TIME -AC_TYPE_SIZE_T -AC_FUNC_MALLOC -AC_FUNC_REALLOC - -AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"]) - -# We use libtool -AC_PROG_LIBTOOL - -AC_MSG_CHECKING("C Compiler version") -if test "$GCC" = "yes" -then - CC_VERSION=`$CC --version | sed 1q` -elif test "$SUNCC" = "yes" -then - CC_VERSION=`$CC -V 2>&1 | sed 1q` -else - CC_VERSION="" -fi -AC_MSG_RESULT("$CC_VERSION") -AC_SUBST(CC_VERSION) # libmemcached versioning when linked with GNU ld. if test "$lt_cv_prog_gnu_ld" = "yes" @@ -98,42 +40,6 @@ fi AC_SUBST(LD_VERSION_SCRIPT) AC_SUBST(LD_UTIL_VERSION_SCRIPT) -gl_VISIBILITY - -# Build optimized or debug version ? -# First check for gcc and g++ -if test "$GCC" = "yes" -then - - dnl Once we can use a modern autoconf, we can replace the std=gnu99 here - dnl with using AC_CC_STD_C99 above - CC="${CC} -std=gnu99" - - CFLAGS="-ggdb3 ${CFLAGS}" - CXXFLAGS="-ggdb3 ${CXXFLAGS}" - - DEBUG_CFLAGS="-O0" - DEBUG_CXXFLAGS="-O0" - - OPTIMIZE_CFLAGS="-O3" - OPTIMIZE_CXXFLAGS="-O3" -fi -if test "x$SUNCC" = "xyes" -then - dnl Once we can use a modern autoconf, we can replace the -xc99=all here - dnl with using AC_CC_STD_C99 above - CC="${CC} -xc99=all" - - CFLAGS="-g -mt ${CFLAGS}" - CXXFLAGS="-xlang=c99 -g -mt -compat=5 -library=stlport4 -template=no%extdef ${CXXFLAGS}" - - OPTIMIZE_FLAGS="-xO4 -xlibmil -xdepend -xbuiltin" - OPTIMIZE_CFLAGS="${OPTIMIZE_FLAGS} -Xa -xstrconst" - OPTIMIZE_CXXFLAGS="${OPTIMIZE_FLAGS}" - -fi - -ENABLE_64BIT #-------------------------------------------------------------------- # Check for libpthread @@ -168,7 +74,6 @@ AC_SEARCH_LIBS(floorf, m) dnl Specialty checks DETECT_BYTEORDER ENABLE_UTILLIB -ENABLE_DTRACE SETSOCKOPT_SANITY ENABLE_HSIEH_HASH REQUIRE_POD2MAN @@ -176,209 +81,6 @@ PROTOCOL_BINARY_TEST WITH_MEMCACHED ENABLE_DEPRECATED -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 - # Debugging. No optimization. - CFLAGS="${DEBUG_CFLAGS} -DDEBUG ${CFLAGS}" - CXXFLAGS="${DEBUG_CXXFLAGS} -DDEBUG ${CXXFLAGS}" -else - # 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"]) - -if test "$GCC" = "yes" -then - - 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"]) - - 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 -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 - ]],[[ -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" - ]) - ]) - - 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=""]) - #[W_FAIL="-Werror"]) - - BASE_WARNINGS="-pedantic -Wall -Wextra ${W_FAIL} -Wundef -Wshadow -Wmissing-declarations -Wstrict-aliasing -Wformat=2 ${F_DIAGNOSTICS_SHOW_OPTION} ${W_CONVERSION} ${CFLAG_VISIBILITY}" - 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 - ]], [[]]) - ], - [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 struct C { void foo(); }; -template void C::foo() { } -template <> void C::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_STRICT_ALIASING="-fno-strict-aliasing -Wno-strict-aliasing" - NO_REDUNDANT_DECLS="-Wno-redundant-decls" -fi -if test "$SUNCC" = "yes" -then - - AS_IF([test "$ac_profiling" = "yes"], - [CC_PROFILING="-xinstrument=datarace"]) - - AS_IF([test "$building_from_bzr" = "yes"], - [W_FAIL="-errwarn=%all"]) - - AC_CACHE_CHECK([whether E_PASTE_RESULT_NOT_TOKEN is usable], - [ac_cv_paste_result], - [ - save_CFLAGS="${CFLAGS}" - CFLAGS="-errwarn=%all -erroff=E_PASTE_RESULT_NOT_TOKEN ${CFLAGS}" - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([ - AC_INCLUDES_DEFAULT - ],[ - int x= 0;])], - [ac_cv_paste_result=yes], - [ac_cv_paste_result=no]) - CFLAGS="${save_CFLAGS}" - ]) - AS_IF([test $ac_cv_paste_result = yes], - [W_PASTE_RESULT=",E_PASTE_RESULT_NOT_TOKEN"]) - - - CC_WARNINGS="-v -errtags=yes ${W_FAIL} -erroff=E_INTEGER_OVERFLOW_DETECTED${W_PASTE_RESULT}" - CXX_WARNINGS="+w +w2 -xwe -xport64 -errtags=yes ${W_FAIL}" -fi - -AC_SUBST(NO_CONVERSION) -AC_SUBST(NO_REDUNDANT_DECLS) -AC_SUBST(NO_STRICT_ALIASING) - -AM_CPPFLAGS="-I\$(top_srcdir) -I\$(top_builddir) ${CPPFLAGS}" -AM_CFLAGS="${CC_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE} ${CFLAGS}" -AM_CXXFLAGS="${CXX_WARNING} ${CC_PROFILING} ${CC_COVERAGE} ${CXXFLAGS}" - -AC_SUBST([AM_CPPFLAGS]) -AC_SUBST([AM_CFLAGS]) -AC_SUBST([AM_CXXFLAGS]) - -dnl We've collected the flags in AM_*FLAGS now, so blank these. -CFLAGS="" -CXXFLAGS="" -CPPFLAGS="" AC_CONFIG_FILES([ Makefile @@ -404,7 +106,7 @@ echo " * Host CPU: $host_cpu" echo " * C Compiler: $CC_VERSION" echo " * Assertions enabled: $ac_cv_assert" echo " * Debug enabled: $with_debug" -echo " * Warnings as failure: $building_from_bzr" +echo " * Warnings as failure: $ac_cv_warnings_as_errors" echo "" echo "---" diff --git a/libmemcached/Makefile.am b/libmemcached/Makefile.am index 583270cf..41e8d8aa 100644 --- a/libmemcached/Makefile.am +++ b/libmemcached/Makefile.am @@ -1,17 +1,14 @@ EXTRA_DIST = libmemcached_probes.d memcached/README.txt libmemcached.ver \ memcached_configure.h.in -BUILT_SOURCES= @DTRACE_HEADER@ - EXTRA_HEADERS = -DTRACE = @DTRACE@ -DTRACEFLAGS = @DTRACEFLAGS@ +BUILT_SOURCES= noinst_HEADERS = libmemcached_probes.h \ memcached_io.h \ memcached_internal.h \ common.h \ - memcached/protocol_binary.h @DTRACE_HEADER@ + memcached/protocol_binary.h pkginclude_HEADERS= memcached.h \ memcached.hh \ @@ -26,6 +23,7 @@ pkginclude_HEADERS= memcached.h \ memcached_watchpoint.h \ visibility.h + if BUILD_LIBMEMCACHEDUTIL pkginclude_HEADERS+= memcached_util.h memcached_pool.h endif @@ -70,6 +68,7 @@ libmemcached_la_SOURCES = crc.c \ jenkins_hash.c \ memcached_allocators.c + if INCLUDE_HSIEH_SRC libmemcached_la_SOURCES += hsieh_hash.c endif @@ -78,22 +77,26 @@ if BUILD_BYTEORDER libmemcached_la_SOURCES += byteorder.c endif -libmemcached_la_DEPENDENCIES = @DTRACE_OBJ@ libmemcachedcallbacks.la -libmemcached_la_LIBADD = @DTRACE_OBJ@ $(LIBM) libmemcachedcallbacks.la +libmemcached_la_DEPENDENCIES= libmemcachedcallbacks.la +libmemcached_la_LIBADD= $(LIBM) libmemcachedcallbacks.la libmemcached_la_LDFLAGS = -version-info $(MEMCACHED_LIBRARY_VERSION) $(LD_VERSION_SCRIPT) $(LIBM) -dtrace_probes.h: libmemcached_probes.d - $(DTRACE) $(DTRACEFLAGS) -o dtrace_probes.tmp -h -s libmemcached_probes.d - sed "s/#include //g" dtrace_probes.tmp > dtrace_probes.h - rm dtrace_probes.tmp +if HAVE_DTRACE +BUILT_SOURCES+= dtrace_probes.h +noinst_HEADERS+= dtrace_probes.h +libmemcached_la_SOURCES += libmemcached_probes.d +endif + +if DTRACE_NEEDS_OBJECTS +libmemcached_la_DEPENDENCIES += libmemcached_probes.o +endif +SUFFIXES= .d -# So libtool doesn't support dtrace, but just copy one of the existing -# lo-file and replace the file name ;-) -libmemcached_probes.lo: libmemcached_probes.o - sed "s,jenkins_hash,libmemcached_probes,g" jenkins_hash.lo > libmemcached_probes.lo +dtrace_probes.h: libmemcached_probes.d + $(DTRACE) $(DTRACEFLAGS) -h -o dtrace_probes.h -s libmemcached_probes.d -libmemcached_probes.o: $(libmemcached_la_OBJECTS) - $(DTRACE) $(DTRACEFLAGS) -o .libs/libmemcached_probes.o -G -s libmemcached_probes.d `grep pic_object *.lo | cut -f 2 -d\' | grep -v non_pic_object` +libmemcached_probes.o: libmemcached_probes.d $(libmemcached_la_OBJECTS) + $(DTRACE) $(DTRACEFLAGS) -o .libs/libmemcached_probes.o -G -s libmemcached_probes.d `grep '^pic_object' *.lo | cut -f 2 -d\'` $(DTRACE) $(DTRACEFLAGS) -o libmemcached_probes.o -G -s libmemcached_probes.d `grep non_pic_object *.lo | cut -f 2 -d\' ` diff --git a/m4/64bit.m4 b/m4/64bit.m4 deleted file mode 100644 index eeecf520..00000000 --- a/m4/64bit.m4 +++ /dev/null @@ -1,36 +0,0 @@ -dnl --------------------------------------------------------------------------- -dnl Macro: ENABLE_64BIT -dnl --------------------------------------------------------------------------- -AC_DEFUN([ENABLE_64BIT],[ - - AC_CHECK_PROGS(ISAINFO, [isainfo], [no]) - AS_IF([test "x$ISAINFO" != "xno"], - [isainfo_b=`${ISAINFO} -b`], - [isainfo_b="x"]) - - AS_IF([test "$isainfo_b" != "x"], - [AC_ARG_ENABLE([64bit], - [AS_HELP_STRING([--disable-64bit], - [Build 64 bit binary @<:@default=on@:>@])], - [ac_enable_64bit="$enableval"], - [ac_enable_64bit="yes"])]) - - AS_IF([test "x$ac_enable_64bit" = "xyes"],[ - if test "x$libdir" = "x\${exec_prefix}/lib" ; then - # The user hasn't overridden the default libdir, so we'll - # the dir suffix to match solaris 32/64-bit policy - isainfo_k=`${ISAINFO} -k` - libdir="${libdir}/${isainfo_k}" - fi - CFLAGS="-m64 $CFLAGS" - CXXFLAGS="-m64 $CXXFLAGS" - if test "$target_cpu" = "sparc" -a "x$SUNCC" = "xyes" - then - CFLAGS="-xmemalign=8s $CFLAGS" - CXXFLAGS="-xmemalign=8s $CXXFLAGS" - fi - ]) -]) -dnl --------------------------------------------------------------------------- -dnl End Macro: ENABLE_64BIT -dnl --------------------------------------------------------------------------- diff --git a/m4/ac_cxx_compile_stdcxx_0x.m4 b/m4/ac_cxx_compile_stdcxx_0x.m4 new file mode 100644 index 00000000..ada41729 --- /dev/null +++ b/m4/ac_cxx_compile_stdcxx_0x.m4 @@ -0,0 +1,103 @@ +# =========================================================================== +# http://autoconf-archive.cryp.to/ac_cxx_compile_stdcxx_0x.html +# =========================================================================== +# +# SYNOPSIS +# +# AC_CXX_COMPILE_STDCXX_0X +# +# DESCRIPTION +# +# Check for baseline language coverage in the compiler for the C++0x +# standard. +# +# LICENSE +# +# Copyright (c) 2008 Benjamin Kosnik +# +# 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. + +AC_DEFUN([AC_CXX_COMPILE_STDCXX_0X], [ + AC_CACHE_CHECK(if g++ supports C++0x features without additional flags, + ac_cv_cxx_compile_cxx0x_native, + [AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_COMPILE([ + template + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + + typedef check> right_angle_brackets; + + int a; + decltype(a) b; + + typedef check check_type; + check_type c; + check_type&& cr = c;],, + ac_cv_cxx_compile_cxx0x_native=yes, ac_cv_cxx_compile_cxx0x_native=no) + AC_LANG_RESTORE + ]) + + AC_CACHE_CHECK(if g++ supports C++0x features with -std=c++0x, + ac_cv_cxx_compile_cxx0x_cxx, + [AC_LANG_SAVE + AC_LANG_CPLUSPLUS + ac_save_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS -std=c++0x" + AC_TRY_COMPILE([ + template + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + + typedef check> right_angle_brackets; + + int a; + decltype(a) b; + + typedef check check_type; + check_type c; + check_type&& cr = c;],, + ac_cv_cxx_compile_cxx0x_cxx=yes, ac_cv_cxx_compile_cxx0x_cxx=no) + CXXFLAGS="$ac_save_CXXFLAGS" + AC_LANG_RESTORE + ]) + + AC_CACHE_CHECK(if g++ supports C++0x features with -std=gnu++0x, + ac_cv_cxx_compile_cxx0x_gxx, + [AC_LANG_SAVE + AC_LANG_CPLUSPLUS + ac_save_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS -std=gnu++0x" + AC_TRY_COMPILE([ + template + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + + typedef check> right_angle_brackets; + + int a; + decltype(a) b; + + typedef check check_type; + check_type c; + check_type&& cr = c;],, + ac_cv_cxx_compile_cxx0x_gxx=yes, ac_cv_cxx_compile_cxx0x_gxx=no) + CXXFLAGS="$ac_save_CXXFLAGS" + AC_LANG_RESTORE + ]) + + if test "$ac_cv_cxx_compile_cxx0x_native" = yes || + test "$ac_cv_cxx_compile_cxx0x_cxx" = yes || + test "$ac_cv_cxx_compile_cxx0x_gxx" = yes; then + AC_DEFINE(HAVE_STDCXX_0X,,[Define if g++ supports C++0x features. ]) + fi +]) diff --git a/m4/ac_cxx_header_stdcxx_98.m4 b/m4/ac_cxx_header_stdcxx_98.m4 new file mode 100644 index 00000000..67e4c972 --- /dev/null +++ b/m4/ac_cxx_header_stdcxx_98.m4 @@ -0,0 +1,67 @@ +dnl Copyright © 2008 Benjamin Kosnik + +dnl 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. + + +AC_DEFUN([AC_CXX_HEADER_STDCXX_98], [ + AC_CACHE_CHECK(for ISO C++ 98 include files, + ac_cv_cxx_stdcxx_98, + [AC_LANG_PUSH(C++) + AC_TRY_COMPILE([ + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + ],, + ac_cv_cxx_stdcxx_98=yes, ac_cv_cxx_stdcxx_98=no) + AC_LANG_POP() + ]) + if test "$ac_cv_cxx_stdcxx_98" = yes; then + AC_DEFINE(STDCXX_98_HEADERS,,[Define if ISO C++ 1998 header files are present. ]) + fi +]) diff --git a/m4/check_gcc_version.m4 b/m4/check_gcc_version.m4 deleted file mode 100644 index e38e3000..00000000 --- a/m4/check_gcc_version.m4 +++ /dev/null @@ -1,30 +0,0 @@ -AC_DEFUN([FORCE_MAC_GCC42], - [AS_IF([test "$GCC" = "yes"],[ - dnl If you're on a Mac, and you didn't ask for a specific compiler - dnl You're gonna get 4.2. - AS_IF([test "$host_vendor" = "apple" -a "x${ac_cv_env_CC_set}" = "x"],[ - AS_IF([test -f /usr/bin/gcc-4.2], - [ - CPP="/usr/bin/gcc-4.2 -E" - CC=/usr/bin/gcc-4.2 - CXX=/usr/bin/g++-4.2 - ]) - ]) - ]) -]) - -AC_DEFUN([CHECK_GCC_VERSION],[ - AC_REQUIRE([FORCE_MAC_GCC42]) - AC_CACHE_CHECK([if GCC is recent enough], [ac_cv_gcc_recent], - [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#if !defined(__GNUC__) || (__GNUC__ < 4) || ((__GNUC__ >= 4) && (__GNUC_MINOR__ < 1)) -# error GCC is Too Old! -#endif - ]])], - [ac_cv_gcc_recent=yes], - [ac_cv_gcc_recent=no])]) - AS_IF([test "$ac_cv_gcc_recent" = "no" -a "$host_vendor" = "apple"], - AC_MSG_ERROR([Your version of GCC is too old. At least version 4.2 is required on OSX. You may need to install a version of XCode >= 3.1.2])) - AS_IF([test "$drizzle_cv_gcc_recent" = "no"], - AC_MSG_ERROR([Your version of GCC is too old. At least version 4.1 is required])) -]) diff --git a/m4/dtrace.m4 b/m4/dtrace.m4 deleted file mode 100644 index 274a6614..00000000 --- a/m4/dtrace.m4 +++ /dev/null @@ -1,40 +0,0 @@ -dnl --------------------------------------------------------------------------- -dnl Macro: ENABLE_DTRACE -dnl --------------------------------------------------------------------------- -AC_DEFUN([ENABLE_DTRACE],[ - AC_ARG_ENABLE([dtrace], - [AS_HELP_STRING([--enable-dtrace], - [Build with support for the DTRACE. @<:@default=off@:>@])], - [ac_cv_enable_dtrace="yes"], - [ac_cv_enable_dtrace="no"]) - - if test "$ac_cv_enable_dtrace" = "yes" - then - AC_PATH_PROG([DTRACE], [dtrace], "no", [/usr/sbin:$PATH]) - if test "x$DTRACE" != "xno"; then - AC_DEFINE([HAVE_DTRACE], [1], [Enables DTRACE Support]) - DTRACE_HEADER=dtrace_probes.h - - # DTrace on MacOSX does not use -G option - $DTRACE -G -o conftest.$$ -s libmemcached/libmemcached_probes.d 2>/dev/zero - if test $? -eq 0 - then - DTRACE_OBJ=libmemcached_probes.lo - rm conftest.$$ - fi - - ac_cv_enable_dtrace="yes" - AC_SUBST(HAVE_DTRACE) - else - AC_MSG_ERROR([Need dtrace binary and OS support.]) - fi - fi - - AC_SUBST(DTRACEFLAGS) - AC_SUBST(DTRACE_HEADER) - AC_SUBST(DTRACE_OBJ) - AM_CONDITIONAL([HAVE_DTRACE], [ test "$ac_cv_enable_dtrace" = "yes" ]) -]) -dnl --------------------------------------------------------------------------- -dnl End Macro: ENABLE_DTRACE -dnl --------------------------------------------------------------------------- diff --git a/m4/extensions.m4 b/m4/extensions.m4 index 2824fa09..611fcfdb 100644 --- a/m4/extensions.m4 +++ b/m4/extensions.m4 @@ -20,7 +20,7 @@ # AC_DEFINE. The goal here is to define all known feature-enabling # macros, then, if reports of conflicts are made, disable macros that # cause problems on some platforms (such as __EXTENSIONS__). -AC_DEFUN([ACX_USE_SYSTEM_EXTENSIONS], +AC_DEFUN([AC_USE_SYSTEM_EXTENSIONS], [AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl AC_BEFORE([$0], [AC_RUN_IFELSE])dnl diff --git a/m4/pandora_64bit.m4 b/m4/pandora_64bit.m4 new file mode 100644 index 00000000..06cc2b70 --- /dev/null +++ b/m4/pandora_64bit.m4 @@ -0,0 +1,42 @@ +dnl Copyright (C) 2009 Sun Microsystems +dnl This file is free software; Sun Microsystems +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl --------------------------------------------------------------------------- +dnl Macro: PANDORA_64BIT +dnl --------------------------------------------------------------------------- +AC_DEFUN([PANDORA_64BIT],[ + + AC_CHECK_PROGS(ISAINFO, [isainfo], [no]) + AS_IF([test "x$ISAINFO" != "xno"], + [isainfo_b=`${ISAINFO} -b`], + [isainfo_b="x"]) + + AS_IF([test "$isainfo_b" != "x"], + [AC_ARG_ENABLE([64bit], + [AS_HELP_STRING([--disable-64bit], + [Build 64 bit binary @<:@default=on@:>@])], + [ac_enable_64bit="$enableval"], + [ac_enable_64bit="yes"])]) + + AS_IF([test "x$ac_enable_64bit" = "xyes"],[ + if test "x$libdir" = "x\${exec_prefix}/lib" ; then + # The user hasn't overridden the default libdir, so we'll + # the dir suffix to match solaris 32/64-bit policy + isainfo_k=`${ISAINFO} -k` + libdir="${libdir}/${isainfo_k}" + fi + CPPFLAGS="-m64 ${CPPFLAGS}" + LDFLAGS="-m64 ${LDFLAGS}" + DTRACEFLAGS="${DTRACEFLAGS} -64" + if test "$target_cpu" = "sparc" -a "x$SUNCC" = "xyes" + then + AM_CFLAGS="-xmemalign=8s ${AM_CFLAGS}" + AM_CXXFLAGS="-xmemalign=8s ${AM_CXXFLAGS}" + fi + ],[DTRACEFLAGS="${DTRACEFLAGS} -32"]) +]) +dnl --------------------------------------------------------------------------- +dnl End Macro: PANDORA_64BIT +dnl --------------------------------------------------------------------------- diff --git a/m4/pandora_canonical.m4 b/m4/pandora_canonical.m4 new file mode 100644 index 00000000..9465a5c1 --- /dev/null +++ b/m4/pandora_canonical.m4 @@ -0,0 +1,133 @@ +dnl Copyright (C) 2009 Sun Microsystems +dnl This file is free software; Sun Microsystems +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Which version of the canonical setup we're using +AC_DEFUN([PANDORA_CANONICAL_VERSION],[0.1]) + +AC_DEFUN([PANDORA_FORCE_DEPEND_TRACKING],[ + dnl Force dependency tracking on for Sun Studio builds + AS_IF([test "x${enable_dependency_tracking}" = "x"],[ + enable_dependency_tracking=yes + ]) +]) + +dnl The standard setup for how we build Pandora projects +AC_DEFUN([PANDORA_CANONICAL_TARGET],[ + AC_REQUIRE([PANDORA_FORCE_DEPEND_TRACKING]) + m4_define([PCT_ALL_ARGS],[$@]) + m4_define([PCT_USE_GNULIB],[no]) + m4_define([PCT_REQUIRE_CXX],[no]) + m4_define([PCT_IGNORE_SHARED_PTR],[no]) + m4_foreach_w([pct_arg],$@,[ + m4_case(pct_arg, + [use-gnulib], [ + m4_undefine([PCT_USE_GNULIB]) + m4_define([PCT_USE_GNULIB],[yes]) + ], + [require-cxx], [ + m4_undefine([PCT_REQUIRE_CXX]) + m4_define([PCT_REQUIRE_CXX],[yes]) + ], + [ignore-shared-ptr], [ + m4_undefine([PCT_IGNORE_SHARED_PTR]) + m4_define([PCT_IGNORE_SHARED_PTR],[yes]) + ]) + ]) + + # We need to prevent canonical target + # from injecting -O2 into CFLAGS - but we won't modify anything if we have + # set CFLAGS on the command line, since that should take ultimate precedence + AS_IF([test "x${ac_cv_env_CFLAGS_set}" = "x"], + [CFLAGS=""]) + AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"], + [CXXFLAGS=""]) + + AC_CANONICAL_TARGET + + AM_INIT_AUTOMAKE(-Wall -Werror nostdinc subdir-objects) + + m4_if(PCT_USE_GNULIB,yes,[ gl_EARLY ]) + + AC_REQUIRE([AC_PROG_CC]) + + dnl Once we can use a modern autoconf, we can use this + dnl AC_PROG_CC_C99 + AC_PROG_CXX + AC_PROG_CPP + AM_PROG_CC_C_O + + gl_USE_SYSTEM_EXTENSIONS + + + PANDORA_LIBTOOL + + dnl autoconf doesn't automatically provide a fail-if-no-C++ macro + dnl so we check c++98 features and fail if we don't have them, mainly + dnl for that reason + PANDORA_CHECK_CXX_STANDARD + m4_if(PCT_REQUIRE_CXX, [yes], [ + AS_IF([test "$ac_cv_cxx_stdcxx_98" = "no"],[ + AC_MSG_ERROR([No working C++ Compiler has been found. ${PACKAGE} requires a C++ compiler that can handle C++98]) + ]) + ]) + + PANDORA_SHARED_PTR + m4_if(PCT_IGNORE_SHARED_PTR, [no], [ + AS_IF([test "$ac_cv_shared_ptr_namespace" = "missing"],[ + AC_MSG_WARN([a usable shared_ptr implementation was not found. Let someone know what your platform is.]) + ]) + ]) + + m4_if(PCT_USE_GNULIB, [yes], [gl_INIT]) + + AC_C_BIGENDIAN + AC_C_CONST + AC_C_INLINE + AC_C_VOLATILE + + AC_HEADER_TIME + AC_TYPE_SIZE_T + AC_FUNC_MALLOC + AC_FUNC_REALLOC + + + AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"]) + + AC_SYS_LARGEFILE + + AS_IF([test "$GCC" = "yes"], PANDORA_ENSURE_GCC_VERSION) + + PANDORA_CHECK_C_VERSION + PANDORA_CHECK_CXX_VERSION + + PANDORA_OPTIMIZE + PANDORA_64BIT + PANDORA_WARNINGS(PCT_ALL_ARGS) + + gl_VISIBILITY + + PANDORA_ENABLE_DTRACE + PANDORA_HEADER_ASSERT + + AC_CHECK_PROGS([DOXYGEN], [doxygen]) + AC_CHECK_PROGS([PERL], [perl]) + + AS_IF([test "x${gl_LIBOBJS}" != "x"],[ + AS_IF([test "$GCC" = "yes"],[ + AM_CPPFLAGS="-isystem \$(top_srcdir)/gnulib -isystem \$(top_builddir)/gnulib ${AM_CPPFLAGS}" + ],[ + AM_CPPFLAGS="-I\$(top_srcdir)/gnulib -I\$(top_builddir)/gnulib ${AM_CPPFLAGS}" + ]) + ]) + + AM_CPPFLAGS="-I\${top_srcdir} -I\${top_builddir} ${AM_CPPFLAGS}" + AM_CFLAGS="${AM_CFLAGS} ${CC_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}" + AM_CXXFLAGS="${AM_CXXFLAGS} ${CXX_WARNINGS} ${CC_PROFILING} ${CC_COVERAGE}" + + AC_SUBST([AM_CFLAGS]) + AC_SUBST([AM_CXXFLAGS]) + AC_SUBST([AM_CPPFLAGS]) + +]) diff --git a/m4/pandora_check_compiler_version.m4 b/m4/pandora_check_compiler_version.m4 new file mode 100644 index 00000000..ab7c6718 --- /dev/null +++ b/m4/pandora_check_compiler_version.m4 @@ -0,0 +1,37 @@ +dnl Copyright (C) 2009 Sun Microsystems +dnl This file is free software; Sun Microsystems +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + + +AC_DEFUN([PANDORA_CHECK_C_VERSION],[ + + dnl Print version of C compiler + AC_MSG_CHECKING("C Compiler version--$GCC") + AS_IF([test "$GCC" = "yes"],[ + CC_VERSION=`$CC --version | sed 1q` + ],[AS_IF([test "$SUNCC" = "yes"],[ + CC_VERSION=`$CC -V 2>&1 | sed 1q` + ],[ + CC_VERSION="" + ]) + ]) + AC_MSG_RESULT("$CC_VERSION") + AC_SUBST(CC_VERSION) +]) + + +AC_DEFUN([PANDORA_CHECK_CXX_VERSION], [ + dnl Print version of CXX compiler + AC_MSG_CHECKING("C++ Compiler version") + AS_IF([test "$GCC" = "yes"],[ + CXX_VERSION=`$CXX --version | sed 1q` + ],[AS_IF([test "$SUNCC" = "yes"],[ + CXX_VERSION=`$CXX -V 2>&1 | sed 1q` + ],[ + CXX_VERSION="" + ]) + ]) + AC_MSG_RESULT("$CXX_VERSION") + AC_SUBST(CXX_VERSION) +]) diff --git a/m4/pandora_check_cxx_standard.m4 b/m4/pandora_check_cxx_standard.m4 new file mode 100644 index 00000000..d4189ea0 --- /dev/null +++ b/m4/pandora_check_cxx_standard.m4 @@ -0,0 +1,16 @@ +dnl Copyright (C) 2009 Sun Microsystems +dnl This file is free software; Sun Microsystems +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([PANDORA_CHECK_CXX_STANDARD],[ + AC_REQUIRE([AC_CXX_COMPILE_STDCXX_0X]) + AS_IF([test "$GCC" = "yes"], + [AS_IF([test "$ac_cv_cxx_compile_cxx0x_native" = "yes"],[], + [AS_IF([test "$ac_cv_cxx_compile_cxx0x_gxx" = "yes"], + [CXXFLAGS="-std=gnu++0x ${CXXFLAGS}"], + [CXXFLAGS="-std=gnu++98"]) + ]) + ]) + AC_CXX_HEADER_STDCXX_98 +]) diff --git a/m4/pandora_enable_dtrace.m4 b/m4/pandora_enable_dtrace.m4 new file mode 100644 index 00000000..e1f82da0 --- /dev/null +++ b/m4/pandora_enable_dtrace.m4 @@ -0,0 +1,41 @@ +dnl Copyright (C) 2009 Sun Microsystems +dnl This file is free software; Sun Microsystems +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl --------------------------------------------------------------------------- +dnl Macro: PANDORA_ENABLE_DTRACE +dnl --------------------------------------------------------------------------- +AC_DEFUN([PANDORA_ENABLE_DTRACE],[ + AC_ARG_ENABLE([dtrace], + [AS_HELP_STRING([--enable-dtrace], + [Build with support for the DTRACE. @<:@default=off@:>@])], + [ac_cv_enable_dtrace="yes"], + [ac_cv_enable_dtrace="no"]) + + AS_IF([test "$ac_cv_enable_dtrace" = "yes"],[ + AC_CHECK_PROGS([DTRACE], [dtrace]) + AS_IF([test "x$ac_cv_prog_DTRACE" = "xdtrace"],[ + AC_DEFINE([HAVE_DTRACE], [1], [Enables DTRACE Support]) + dnl DTrace on MacOSX does not use -G option + cat >conftest.d <<_ACEOF +provider Example { + probe increment(int); +}; +_ACEOF + $DTRACE -G -o conftest.d.o -s conftest.d 2>/dev/zero + AS_IF([test $? -eq 0],[ac_cv_dtrace_needs_objects=yes]) + rm -f conftest.d.o conftest.d + + AC_SUBST(DTRACEFLAGS) dnl TODO: test for -G on OSX + ac_cv_have_dtrace=yes + ])]) + +AM_CONDITIONAL([HAVE_DTRACE], [test "x$ac_cv_have_dtrace" = "xyes"]) +AM_CONDITIONAL([DTRACE_NEEDS_OBJECTS], + [test "x$ac_cv_dtrace_needs_objects" = "xyes"]) + +]) +dnl --------------------------------------------------------------------------- +dnl End Macro: PANDORA_ENABLE_DTRACE +dnl --------------------------------------------------------------------------- diff --git a/m4/pandora_ensure_gcc_version.m4 b/m4/pandora_ensure_gcc_version.m4 new file mode 100644 index 00000000..608a5527 --- /dev/null +++ b/m4/pandora_ensure_gcc_version.m4 @@ -0,0 +1,36 @@ +dnl Copyright (C) 2009 Sun Microsystems +dnl This file is free software; Sun Microsystems +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl If the user is on a Mac and didn't ask for a specific compiler +dnl You're gonna get 4.2. +AC_DEFUN([PANDORA_MAC_GCC42], + [AS_IF([test "$GCC" = "yes"],[ + AS_IF([test "$host_vendor" = "apple" -a "x${ac_cv_env_CC_set}" = "x"],[ + AS_IF([test -f /usr/bin/gcc-4.2], + [ + CPP="/usr/bin/gcc-4.2 -E" + CC=/usr/bin/gcc-4.2 + CXX=/usr/bin/g++-4.2 + ]) + ]) + ]) +]) + +dnl +AC_DEFUN([PANDORA_ENSURE_GCC_VERSION],[ + AC_REQUIRE([PANDORA_MAC_GCC42]) + AC_CACHE_CHECK([if GCC is recent enough], [ac_cv_gcc_recent], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#if !defined(__GNUC__) || (__GNUC__ < 4) || ((__GNUC__ >= 4) && (__GNUC_MINOR__ < 1)) +# error GCC is Too Old! +#endif + ]])], + [ac_cv_gcc_recent=yes], + [ac_cv_gcc_recent=no])]) + AS_IF([test "$ac_cv_gcc_recent" = "no" -a "$host_vendor" = "apple"], + AC_MSG_ERROR([Your version of GCC is too old. At least version 4.2 is required on OSX. You may need to install a version of XCode >= 3.1.2])) + AS_IF([test "$ac_cv_gcc_recent" = "no"], + AC_MSG_ERROR([Your version of GCC is too old. At least version 4.1 is required])) +]) diff --git a/m4/pandora_header_assert.m4 b/m4/pandora_header_assert.m4 new file mode 100644 index 00000000..eb5d15b9 --- /dev/null +++ b/m4/pandora_header_assert.m4 @@ -0,0 +1,23 @@ +dnl Copyright (C) 2009 Sun Microsystems +dnl This file is free software; Sun Microsystems +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl PANDORA_HEADER_ASSERT +dnl ---------------- +dnl Check whether to enable assertions. +AC_DEFUN([PANDORA_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]) + + AS_IF([test "$ac_cv_assert" = "yes"], + [AC_CHECK_HEADERS(assert.h)], + [AC_DEFINE(NDEBUG, 1, [Define to 1 if assertions should be disabled.])]) +]) + diff --git a/m4/pandora_libtool.m4 b/m4/pandora_libtool.m4 new file mode 100644 index 00000000..b9e461c7 --- /dev/null +++ b/m4/pandora_libtool.m4 @@ -0,0 +1,15 @@ +dnl Copyright (C) 2009 Sun Microsystems +dnl This file is free software; Sun Microsystems +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([PANDORA_LIBTOOL],[ + AC_REQUIRE([AC_PROG_LIBTOOL]) + dnl By requiring AC_PROG_LIBTOOL, we should force the macro system to read + dnl libtool.m4, where in 2.2 AC_PROG_LIBTOOL is an alias for LT_INIT + dnl Then, if we're on 2.2, we should have LT_LANG, so we'll call it. + m4_ifdef([LT_LANG],[ + LT_LANG(C) + LT_LANG(C++) + ]) +]) diff --git a/m4/pandora_optimize.m4 b/m4/pandora_optimize.m4 new file mode 100644 index 00000000..c255f258 --- /dev/null +++ b/m4/pandora_optimize.m4 @@ -0,0 +1,64 @@ +dnl Copyright (C) 2009 Sun Microsystems +dnl This file is free software; Sun Microsystems +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([PANDORA_OPTIMIZE],[ + dnl Build optimized or debug version ? + dnl First check for gcc and g++ + AS_IF([test "$GCC" = "yes"],[ + + AC_DEFINE([_GNU_SOURCE],[1],[Fix problem with S_ISLNK() on Linux]) + + dnl The following is required for portable results of floating point + dnl calculations on PowerPC. The same must also be done for IA-64, but + dnl this options is missing in the IA-64 gcc backend. + case "$target_cpu" in + *ppc* | *powerpc*) + AM_CFLAGS="-mno-fused-madd ${AM_CFLAGS}" + AM_CXXFLAGS="-mno-fused-madd ${AM_CXXFLAGS}" + ;; + esac + + dnl Once we can use a modern autoconf, we can replace the std=gnu99 here + dnl with using AC_CC_STD_C99 above + CC="${CC} -std=gnu99" + + AM_CPPFLAGS="-ggdb3 ${AM_CPPFLAGS}" + + DEBUG_CFLAGS="-O0" + DEBUG_CXXFLAGS="-O0" + + OPTIMIZE_CFLAGS="-O3" + OPTIMIZE_CXXFLAGS="-O3" + ]) + AS_IF([test "$SUNCC" = "yes"],[ + dnl Once we can use a modern autoconf, we can replace the -xc99=all here + dnl with using AC_CC_STD_C99 above + CC="${CC} -xc99=all" + CXX="${CXX} -xlang=c99" + + AM_CFLAGS="-g -mt -xstrconst -Xa ${AM_CFLAGS}" + AM_CXXFLAGS="-g -mt -compat=5 -library=stlport4 -template=no%extdef ${AM_CXXFLAGS}" + + dnl TODO: Make a test for -xO4 usability here + OPTIMIZE_FLAGS="-xO3 -xlibmil -xdepend -xbuiltin" + OPTIMIZE_CFLAGS="${OPTIMIZE_FLAGS}" + OPTIMIZE_CXXFLAGS="${OPTIMIZE_FLAGS}" + ]) + + 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]) + AS_IF([test "$with_debug" = "yes"],[ + # Debugging. No optimization. + AM_CFLAGS="${AM_CFLAGS} ${DEBUG_CFLAGS} -DDEBUG" + AM_CXXFLAGS="${AM_CXXFLAGS} ${DEBUG_CXXFLAGS} -DDEBUG" + ],[ + # Optimized version. No debug + AM_CFLAGS="${AM_CFLAGS} ${OPTIMIZE_CFLAGS}" + AM_CXXFLAGS="${AM_CXXFLAGS} ${OPTIMIZE_CXXFLAGS}" + ]) +]) diff --git a/m4/pandora_shared_ptr.m4 b/m4/pandora_shared_ptr.m4 new file mode 100644 index 00000000..70185ade --- /dev/null +++ b/m4/pandora_shared_ptr.m4 @@ -0,0 +1,56 @@ +dnl Copyright (C) 2009 Sun Microsystems +dnl This file is free software; Sun Microsystems +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl We check two things: where is the memory include file, and in what +dnl namespace does shared_ptr reside. +dnl We include AC_COMPILE_IFELSE for all the combinations we've seen in the +dnl wild: +dnl +dnl GCC 4.3: namespace: std:: #include +dnl GCC 4.2: namespace: tr1:: #include +dnl GCC 4.2: namespace: boost:: #include +dnl +dnl We define one of HAVE_HAVE_TR1_SHARED_PTR or HAVE_BOOST_SHARED_PTR +dnl depending on location, and SHARED_PTR_NAMESPACE to be the namespace in +dnl which shared_ptr is defined. +dnl + +AC_DEFUN([PANDORA_SHARED_PTR],[ + AC_REQUIRE([PANDORA_CHECK_CXX_STANDARD]) + AC_LANG_PUSH(C++) + AC_CHECK_HEADERS(memory tr1/memory boost/shared_ptr.hpp) + AC_CACHE_CHECK([the location of shared_ptr header file], + [ac_cv_shared_ptr_h],[ + for namespace in std tr1 std::tr1 boost + do + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ +#if defined(HAVE_MEMORY) +# include +#endif +#if defined(HAVE_TR1_MEMORY) +# include +#endif +#if defined(HAVE_BOOST_SHARED_PTR_HPP) +# include +#endif +#include + +using $namespace::shared_ptr; +using namespace std; + ]],[[ +shared_ptr test_ptr(new string("test string")); + ]])], + [ + ac_cv_shared_ptr_namespace="${namespace}" + break + ],[ac_cv_shared_ptr_namespace=missing]) + done + ]) + AC_DEFINE_UNQUOTED([SHARED_PTR_NAMESPACE], + ${ac_cv_shared_ptr_namespace}, + [The namespace in which SHARED_PTR can be found]) + AC_LANG_POP() +]) diff --git a/m4/pandora_vc_build.m4 b/m4/pandora_vc_build.m4 new file mode 100644 index 00000000..ada6ccf6 --- /dev/null +++ b/m4/pandora_vc_build.m4 @@ -0,0 +1,32 @@ +dnl Copyright (C) 2009 Sun Microsystems +dnl This file is free software; Sun Microsystems +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([PANDORA_BUILDING_FROM_VC],[ + + ac_cv_building_from_vc=no + + AS_IF([test -d "${srcdir}/.bzr"],[ + ac_cv_building_from_bzr=yes + ac_cv_building_from_vc=yes + ],[ + ac_cv_building_from_bzr=no + ]) + + AS_IF([test -d "${srcdir}/.svn"],[ + ac_cv_building_from_svn=yes + ac_cv_building_from_vc=yes + ],[ + ac_cv_building_from_svn=no + ]) + + AS_IF([test -d "${srcdir}/.hg"],[ + ac_cv_building_from_hg=yes + ac_cv_building_from_vc=yes + ],[ + ac_cv_building_from_hg=no + ]) + +]) + diff --git a/m4/pandora_warnings.m4 b/m4/pandora_warnings.m4 new file mode 100644 index 00000000..55e9e0bb --- /dev/null +++ b/m4/pandora_warnings.m4 @@ -0,0 +1,239 @@ +dnl Copyright (C) 2009 Sun Microsystems +dnl This file is free software; Sun Microsystems +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl AC_PANDORA_WARNINGS([less-warnings|warnings-always-on]) +dnl less-warnings turn on a limited set of warnings +dnl warnings-always-on always set warnings=error regardless of tarball/vc + +AC_DEFUN([PANDORA_WARNINGS],[ + m4_define([PW_LESS_WARNINGS],[no]) + m4_define([PW_WARN_ALWAYS_ON],[no]) + m4_foreach_w([pw_arg],$@,[ + m4_case(pw_arg, + [less-warnings],[ + m4_undefine([PW_LESS_WARNINGS]) + m4_define([PW_LESS_WARNINGS],[yes]) + ], + [warnings-always-on],[ + m4_undefine([PW_WARN_ALWAYS_ON]) + m4_define([PW_WARN_ALWAYS_ON],[yes]) + ]) + ]) + + AC_REQUIRE([PANDORA_BUILDING_FROM_VC]) + m4_if(PW_WARN_ALWAYS_ON, [yes], + [ac_cv_warnings_as_errors=yes], + AS_IF([test "$ac_cv_building_from_vc" = "yes"], + [ac_cv_warnings_as_errors=yes], + [ac_cv_warnings_as_errors=no])) + + 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"]) + + AS_IF([test "$GCC" = "yes"],[ + + AS_IF([test "$ac_profiling" = "yes"],[ + CC_PROFILING="-pg" + save_LIBS="${LIBS}" + LIBS="" + AC_CHECK_LIB(c_p, read) + LIBC_P="${LIBS}" + LIBS="${save_LIBS}" + AC_SUBST(LIBC_P) + ],[ + CC_PROFILING=" " + ]) + + AS_IF([test "$ac_coverage" = "yes"], + [CC_COVERAGE="-fprofile-arcs -ftest-coverage"]) + + AS_IF([test "$ac_cv_warnings_as_errors" = "yes"], + [W_FAIL="-Werror"]) + + 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 ${AM_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"]) + + 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="-Wconversion ${W_FAIL} -pedantic ${AM_CFLAGS}" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ +#include +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="-Wconversion ${W_FAIL} -pedantic ${AM_CFLAGS}" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include + ]],[[ +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"]) + ]) + + NO_STRICT_ALIASING="-fno-strict-aliasing -Wno-strict-aliasing" + NO_SHADOW="-Wno-shadow" + + m4_if(PW_LESS_WARNINGS,[no],[ + BASE_WARNINGS_FULL="-Wformat=2 ${W_CONVERSION} -Wstrict-aliasing" + CC_WARNINGS_FULL="-Wswitch-default -Wswitch-enum" + CXX_WARNINGS_FULL="-Weffc++ -Wold-style-cast" + ],[ + BASE_WARNINGS_FULL="-Wformat ${NO_STRICT_ALIASING}" + ]) + + BASE_WARNINGS="${W_FAIL} -pedantic -Wall -Wextra -Wundef -Wshadow -Wstrict-aliasing ${F_DIAGNOSTICS_SHOW_OPTION} ${CFLAG_VISIBILITY} ${BASE_WARNINGS_FULL}" + CC_WARNINGS="${BASE_WARNINGS} -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wmissing-declarations -Wcast-align ${CC_WARNINGS_FULL}" + CXX_WARNINGS="${BASE_WARNINGS} -Woverloaded-virtual -Wnon-virtual-dtor -Wctor-dtor-privacy -Wno-long-long ${CXX_WARNINGS_FULL}" + + AC_CACHE_CHECK([whether it is safe to use -Wmissing-declarations from C++], + [ac_cv_safe_to_use_Wmissing_declarations_], + [AC_LANG_PUSH(C++) + save_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="-Werror -pedantic -Wmissing-declarations ${AM_CXXFLAGS}" + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM( + [[ +#include + ]], [[]]) + ], + [ac_cv_safe_to_use_Wmissing_declarations_=yes], + [ac_cv_safe_to_use_Wmissing_declarations_=no]) + CXXFLAGS="$save_CXXFLAGS" + AC_LANG_POP() + ]) + AS_IF([test "$ac_cv_safe_to_use_Wmissing_declarations_" = "yes"], + [CXX_WARNINGS="${CXX_WARNINGS} -Wmissing-declarations"]) + + AC_CACHE_CHECK([whether it is safe to use -Wlogical-op], + [ac_cv_safe_to_use_Wlogical_op_], + [save_CFLAGS="$CFLAGS" + CFLAGS="${W_FAIL} -pedantic -Wlogical-op ${AM_CFLAGS}" + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM( + [[ +#include + ]], [[]]) + ], + [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="${W_FAIL} -pedantic -Wredundant-decls ${AM_CXXFLAGS}" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([ +template struct C { void foo(); }; +template void C::foo() { } +template <> void C::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" + PROTOSKIP_WARNINGS="-Wno-effc++ -Wno-shadow" + + ]) + + AS_IF([test "$SUNCC" = "yes"],[ + + AS_IF([test "$ac_profiling" = "yes"], + [CC_PROFILING="-xinstrument=datarace"]) + + AS_IF([test "$ac_cv_warnings_as_errors" = "yes"], + [W_FAIL="-errwarn=%all"]) + + AC_CACHE_CHECK([whether E_PASTE_RESULT_NOT_TOKEN is usable], + [ac_cv_paste_result], + [ + save_CFLAGS="${CFLAGS}" + CFLAGS="-errwarn=%all -erroff=E_PASTE_RESULT_NOT_TOKEN ${CFLAGS}" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([ + AC_INCLUDES_DEFAULT + ],[ + int x= 0;])], + [ac_cv_paste_result=yes], + [ac_cv_paste_result=no]) + CFLAGS="${save_CFLAGS}" + ]) + AS_IF([test $ac_cv_paste_result = yes], + [W_PASTE_RESULT=",E_PASTE_RESULT_NOT_TOKEN"]) + + + m4_if(PW_LESS_WARNINGS, [no],[ + CC_WARNINGS_FULL="-erroff=E_INTEGER_OVERFLOW_DETECTED${W_PASTE_RESULT}" + ],[ + CC_WARNINGS_FULL="-erroff=E_ATTRIBUTE_NOT_VAR" + CXX_WARNINGS_FULL="-erroff=attrskipunsup,doubunder,reftotemp,inllargeuse,truncwarn1,signextwarn,inllargeint" + ]) + + CC_WARNINGS="-v -errtags=yes ${W_FAIL} ${CC_WARNINGS_FULL}" + CXX_WARNINGS="+w +w2 -xwe -xport64 -errtags=yes ${CXX_WARNINGS_FULL} ${W_FAIL}" + PROTOSKIP_WARNINGS="-erroff=attrskipunsup,doubunder,reftotemp,wbadinitl,identexpected,inllargeuse,truncwarn1,signextwarn" + NO_UNREACHED="-erroff=E_STATEMENT_NOT_REACHED" + + ]) + + AC_SUBST(NO_CONVERSION) + AC_SUBST(NO_REDUNDANT_DECLS) + AC_SUBST(NO_UNREACHED) + AC_SUBST(NO_SHADOW) + AC_SUBST(NO_STRICT_ALIASING) + AC_SUBST(PROTOSKIP_WARNINGS) + +])