Thrift now a TLP - INFRA-3116

git-svn-id: https://svn.apache.org/repos/asf/thrift/branches/0.1.x@1028168 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/aclocal/ax_boost_base.m4 b/aclocal/ax_boost_base.m4
new file mode 100644
index 0000000..e56bb73
--- /dev/null
+++ b/aclocal/ax_boost_base.m4
@@ -0,0 +1,198 @@
+##### http://autoconf-archive.cryp.to/ax_boost_base.html
+#
+# SYNOPSIS
+#
+#   AX_BOOST_BASE([MINIMUM-VERSION])
+#
+# DESCRIPTION
+#
+#   Test for the Boost C++ libraries of a particular version (or newer)
+#
+#   If no path to the installed boost library is given the macro
+#   searchs under /usr, /usr/local, /opt and /opt/local and evaluates
+#   the $BOOST_ROOT environment variable. Further documentation is
+#   available at <http://randspringer.de/boost/index.html>.
+#
+#   This macro calls:
+#
+#     AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS)
+#
+#   And sets:
+#
+#     HAVE_BOOST
+#
+# LAST MODIFICATION
+#
+#   2007-07-28
+#
+# COPYLEFT
+#
+#   Copyright (c) 2007 Thomas Porschberg <thomas@randspringer.de>
+#
+#   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([AX_BOOST_BASE],
+[
+AC_ARG_WITH([boost],
+	AS_HELP_STRING([--with-boost@<:@=DIR@:>@], [use boost (default is yes) - it is possible to specify the root directory for boost (optional)]),
+	[
+    if test "$withval" = "no"; then
+		want_boost="no"
+    elif test "$withval" = "yes"; then
+        want_boost="yes"
+        ac_boost_path=""
+    else
+	    want_boost="yes"
+        ac_boost_path="$withval"
+	fi
+    ],
+    [want_boost="yes"])
+
+if test "x$want_boost" = "xyes"; then
+	boost_lib_version_req=ifelse([$1], ,1.20.0,$1)
+	boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
+	boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'`
+	boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
+	boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
+	if test "x$boost_lib_version_req_sub_minor" = "x" ; then
+		boost_lib_version_req_sub_minor="0"
+    	fi
+	WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+  $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor`
+	AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req)
+	succeeded=no
+
+	dnl first we check the system location for boost libraries
+	dnl this location ist chosen if boost libraries are installed with the --layout=system option
+	dnl or if you install boost with RPM
+	if test "$ac_boost_path" != ""; then
+		BOOST_LDFLAGS="-L$ac_boost_path/lib"
+		BOOST_CPPFLAGS="-I$ac_boost_path/include"
+	else
+		for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do
+			if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then
+				BOOST_LDFLAGS="-L$ac_boost_path_tmp/lib"
+				BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include"
+				break;
+			fi
+		done
+	fi
+
+	CPPFLAGS_SAVED="$CPPFLAGS"
+	CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
+	export CPPFLAGS
+
+	LDFLAGS_SAVED="$LDFLAGS"
+	LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
+	export LDFLAGS
+
+	AC_LANG_PUSH(C++)
+     	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+	@%:@include <boost/version.hpp>
+	]], [[
+	#if BOOST_VERSION >= $WANT_BOOST_VERSION
+	// Everything is okay
+	#else
+	#  error Boost version is too old
+	#endif
+	]])],[
+        AC_MSG_RESULT(yes)
+	succeeded=yes
+	found_system=yes
+       	],[
+       	])
+	AC_LANG_POP([C++])
+
+
+
+	dnl if we found no boost with system layout we search for boost libraries
+	dnl built and installed without the --layout=system option or for a staged(not installed) version
+	if test "x$succeeded" != "xyes"; then
+		_version=0
+		if test "$ac_boost_path" != ""; then
+               		BOOST_LDFLAGS="-L$ac_boost_path/lib"
+			if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
+				for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
+					_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
+					V_CHECK=`expr $_version_tmp \> $_version`
+					if test "$V_CHECK" = "1" ; then
+						_version=$_version_tmp
+					fi
+					VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
+					BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE"
+				done
+			fi
+		else
+			for ac_boost_path in /usr /usr/local /opt /opt/local ; do
+				if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
+					for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
+						_version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
+						V_CHECK=`expr $_version_tmp \> $_version`
+						if test "$V_CHECK" = "1" ; then
+							_version=$_version_tmp
+	               					best_path=$ac_boost_path
+						fi
+					done
+				fi
+			done
+
+			VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
+			BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
+			BOOST_LDFLAGS="-L$best_path/lib"
+
+	    		if test "x$BOOST_ROOT" != "x"; then
+				if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/lib" && test -r "$BOOST_ROOT/stage/lib"; then
+					version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'`
+					stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
+			        	stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'`
+					V_CHECK=`expr $stage_version_shorten \>\= $_version`
+				        if test "$V_CHECK" = "1" ; then
+						AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)
+						BOOST_CPPFLAGS="-I$BOOST_ROOT"
+						BOOST_LDFLAGS="-L$BOOST_ROOT/stage/lib"
+					fi
+				fi
+	    		fi
+		fi
+
+		CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
+		export CPPFLAGS
+		LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
+		export LDFLAGS
+
+		AC_LANG_PUSH(C++)
+	     	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+		@%:@include <boost/version.hpp>
+		]], [[
+		#if BOOST_VERSION >= $WANT_BOOST_VERSION
+		// Everything is okay
+		#else
+		#  error Boost version is too old
+		#endif
+		]])],[
+        	AC_MSG_RESULT(yes)
+		succeeded=yes
+		found_system=yes
+       		],[
+	       	])
+		AC_LANG_POP([C++])
+	fi
+
+	if test "$succeeded" != "yes" ; then
+		if test "$_version" = "0" ; then
+			AC_MSG_ERROR([[We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option.  If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation.]])
+		else
+			AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).])
+		fi
+	else
+		AC_SUBST(BOOST_CPPFLAGS)
+		AC_SUBST(BOOST_LDFLAGS)
+		AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available])
+	fi
+
+        CPPFLAGS="$CPPFLAGS_SAVED"
+       	LDFLAGS="$LDFLAGS_SAVED"
+fi
+
+])
diff --git a/aclocal/ax_javac_and_java.m4 b/aclocal/ax_javac_and_java.m4
new file mode 100644
index 0000000..3c8577f
--- /dev/null
+++ b/aclocal/ax_javac_and_java.m4
@@ -0,0 +1,84 @@
+dnl @synopsis AX_JAVAC_AND_JAVA
+dnl
+dnl Test for the presence of a JDK.
+dnl
+dnl If "JAVA" is defined in the environment, that will be the only
+dnl java command tested.  Otherwise, a hard-coded list will be used.
+dnl Similarly for "JAVAC".
+dnl
+dnl This macro does not currenly support testing for a particular
+dnl Java version, the presence of a particular class, testing for
+dnl only one of "java" and "javac", or compiling or running
+dnl user-provided Java code.
+dnl
+dnl After AX_JAVAC_AND_JAVA runs, the shell variables "success" and
+dnl "ax_javac_and_java" are set to "yes" or "no", and "JAVAC" and
+dnl "JAVA" are set to the appropriate commands.
+dnl
+dnl @category Java
+dnl @version 2009-02-09
+dnl @license AllPermissive
+dnl
+dnl Copyright (C) 2009 David Reiss
+dnl Copying and distribution of this file, with or without modification,
+dnl are permitted in any medium without royalty provided the copyright
+dnl notice and this notice are preserved.
+
+
+AC_DEFUN([AX_JAVAC_AND_JAVA],
+         [
+
+          dnl Hard-coded default commands to test.
+          JAVAC_PROGS="javac,jikes,gcj -C"
+          JAVA_PROGS="java,kaffe"
+
+          dnl Allow the user to specify an alternative.
+          if test -n "$JAVAC" ; then
+            JAVAC_PROGS="$JAVAC"
+          fi
+          if test -n "$JAVA" ; then
+            JAVA_PROGS="$JAVA"
+          fi
+
+          AC_MSG_CHECKING(for javac and java)
+
+          echo "public class configtest_ax_javac_and_java { public static void main(String args@<:@@:>@) { } }" > configtest_ax_javac_and_java.java
+          success=no
+          oIFS="$IFS"
+
+          IFS=","
+          for JAVAC in $JAVAC_PROGS ; do
+            IFS="$oIFS"
+
+            echo "Running \"$JAVAC configtest_ax_javac_and_java.java\"" >&AS_MESSAGE_LOG_FD
+            if $JAVAC configtest_ax_javac_and_java.java >&AS_MESSAGE_LOG_FD 2>&1 ; then
+
+              IFS=","
+              for JAVA in $JAVA_PROGS ; do
+                IFS="$oIFS"
+
+                echo "Running \"$JAVA configtest_ax_javac_and_java\"" >&AS_MESSAGE_LOG_FD
+                if $JAVA configtest_ax_javac_and_java >&AS_MESSAGE_LOG_FD 2>&1 ; then
+                  success=yes
+                  break 2
+                fi
+
+              done
+
+            fi
+
+          done
+
+          rm -f configtest_ax_javac_and_java.java configtest_ax_javac_and_java.class
+
+          if test "$success" != "yes" ; then
+            AC_MSG_RESULT(no)
+            JAVAC=""
+            JAVA=""
+          else
+            AC_MSG_RESULT(yes)
+          fi
+
+          ax_javac_and_java="$success"
+
+          ])
diff --git a/aclocal/ax_lib_event.m4 b/aclocal/ax_lib_event.m4
new file mode 100644
index 0000000..3a48156
--- /dev/null
+++ b/aclocal/ax_lib_event.m4
@@ -0,0 +1,173 @@
+dnl @synopsis AX_LIB_EVENT([MINIMUM-VERSION])
+dnl
+dnl Test for the libevent library of a particular version (or newer).
+dnl
+dnl If no path to the installed libevent is given, the macro will first try
+dnl using no -I or -L flags, then searches under /usr, /usr/local, /opt,
+dnl and /opt/libevent.
+dnl If these all fail, it will try the $LIBEVENT_ROOT environment variable.
+dnl
+dnl This macro requires that #include <sys/types.h> works and defines u_char.
+dnl
+dnl This macro calls:
+dnl   AC_SUBST(LIBEVENT_CPPFLAGS)
+dnl   AC_SUBST(LIBEVENT_LDFLAGS)
+dnl   AC_SUBST(LIBEVENT_LIBS)
+dnl
+dnl And (if libevent is found):
+dnl   AC_DEFINE(HAVE_LIBEVENT)
+dnl
+dnl It also leaves the shell variables "success" and "ax_have_libevent"
+dnl set to "yes" or "no".
+dnl
+dnl NOTE: This macro does not currently work for cross-compiling,
+dnl       but it can be easily modified to allow it.  (grep "cross").
+dnl
+dnl @category InstalledPackages
+dnl @category C
+dnl @version 2007-09-12
+dnl @license AllPermissive
+dnl
+dnl Copyright (C) 2009 David Reiss
+dnl Copying and distribution of this file, with or without modification,
+dnl are permitted in any medium without royalty provided the copyright
+dnl notice and this notice are preserved.
+
+dnl Input: ax_libevent_path, WANT_LIBEVENT_VERSION
+dnl Output: success=yes/no
+AC_DEFUN([AX_LIB_EVENT_DO_CHECK],
+         [
+          # Save our flags.
+          CPPFLAGS_SAVED="$CPPFLAGS"
+          LDFLAGS_SAVED="$LDFLAGS"
+          LIBS_SAVED="$LIBS"
+          LD_LIBRARY_PATH_SAVED="$LD_LIBRARY_PATH"
+
+          # Set our flags if we are checking a specific directory.
+          if test -n "$ax_libevent_path" ; then
+            LIBEVENT_CPPFLAGS="-I$ax_libevent_path/include"
+            LIBEVENT_LDFLAGS="-L$ax_libevent_path/lib"
+            LD_LIBRARY_PATH="$ax_libevent_path/lib:$LD_LIBRARY_PATH"
+          else
+            LIBEVENT_CPPFLAGS=""
+            LIBEVENT_LDFLAGS=""
+          fi
+
+          # Required flag for libevent.
+          LIBEVENT_LIBS="-levent"
+
+          # Prepare the environment for compilation.
+          CPPFLAGS="$CPPFLAGS $LIBEVENT_CPPFLAGS"
+          LDFLAGS="$LDFLAGS $LIBEVENT_LDFLAGS"
+          LIBS="$LIBS $LIBEVENT_LIBS"
+          export CPPFLAGS
+          export LDFLAGS
+          export LIBS
+          export LD_LIBRARY_PATH
+
+          success=no
+
+          # Compile, link, and run the program.  This checks:
+          # - event.h is available for including.
+          # - event_get_version() is available for linking.
+          # - The event version string is lexicographically greater
+          #   than the required version.
+          AC_LANG_PUSH([C])
+          dnl This can be changed to AC_LINK_IFELSE if you are cross-compiling,
+          dnl but then the version cannot be checked.
+          AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+          #include <sys/types.h>
+          #include <event.h>
+          ]], [[
+          const char* lib_version = event_get_version();
+          const char* wnt_version = "$WANT_LIBEVENT_VERSION";
+          for (;;) {
+            /* If we reached the end of the want version.  We have it. */
+            if (*wnt_version == '\0') {
+              return 0;
+            }
+            /* If the want version continues but the lib version does not, */
+            /* we are missing a letter.  We don't have it. */
+            if (*lib_version == '\0') {
+              return 1;
+            }
+            /* If we have greater than what we want.  We have it. */
+            if (*lib_version > *wnt_version) {
+              return 0;
+            }
+            /* If we have less, we don't. */
+            if (*lib_version < *wnt_version) {
+              return 1;
+            }
+            lib_version++;
+            wnt_version++;
+          }
+          return 0;
+          ]])], [
+          success=yes
+          ])
+          AC_LANG_POP([C])
+
+          # Restore flags.
+          CPPFLAGS="$CPPFLAGS_SAVED"
+          LDFLAGS="$LDFLAGS_SAVED"
+          LIBS="$LIBS_SAVED"
+          LD_LIBRARY_PATH="$LD_LIBRARY_PATH_SAVED"
+         ])
+
+
+AC_DEFUN([AX_LIB_EVENT],
+         [
+
+          dnl Allow search path to be overridden on the command line.
+          AC_ARG_WITH([libevent],
+                      AS_HELP_STRING([--with-libevent@<:@=DIR@:>@], [use libevent (default is yes) - it is possible to specify an alternate root directory for libevent]),
+                      [
+                       if test "x$withval" = "xno"; then
+                         want_libevent="no"
+                       elif test "x$withval" = "xyes"; then
+                         want_libevent="yes"
+                         ax_libevent_path=""
+                       else
+                         want_libevent="yes"
+                         ax_libevent_path="$withval"
+                       fi
+                       ],
+                       [ want_libevent="yes" ; ax_libevent_path="" ])
+
+
+          if test "$want_libevent" = "yes"; then
+            WANT_LIBEVENT_VERSION=ifelse([$1], ,1.2,$1)
+
+            AC_MSG_CHECKING(for libevent >= $WANT_LIBEVENT_VERSION)
+
+            # Run tests.
+            if test -n "$ax_libevent_path"; then
+              AX_LIB_EVENT_DO_CHECK
+            else
+              for ax_libevent_path in "" /usr /usr/local /opt /opt/local /opt/libevent "$LIBEVENT_ROOT" ; do
+                AX_LIB_EVENT_DO_CHECK
+                if test "$success" = "yes"; then
+                  break;
+                fi
+              done
+            fi
+
+            if test "$success" != "yes" ; then
+              AC_MSG_RESULT(no)
+              LIBEVENT_CPPFLAGS=""
+              LIBEVENT_LDFLAGS=""
+              LIBEVENT_LIBS=""
+            else
+              AC_MSG_RESULT(yes)
+              AC_DEFINE(HAVE_LIBEVENT,,[define if libevent is available])
+            fi
+
+            ax_have_libevent="$success"
+
+            AC_SUBST(LIBEVENT_CPPFLAGS)
+            AC_SUBST(LIBEVENT_LDFLAGS)
+            AC_SUBST(LIBEVENT_LIBS)
+          fi
+
+          ])
diff --git a/aclocal/ax_lib_zlib.m4 b/aclocal/ax_lib_zlib.m4
new file mode 100644
index 0000000..8c10ab4
--- /dev/null
+++ b/aclocal/ax_lib_zlib.m4
@@ -0,0 +1,173 @@
+dnl @synopsis AX_LIB_ZLIB([MINIMUM-VERSION])
+dnl
+dnl Test for the libz library of a particular version (or newer).
+dnl
+dnl If no path to the installed zlib is given, the macro will first try
+dnl using no -I or -L flags, then searches under /usr, /usr/local, /opt,
+dnl and /opt/zlib.
+dnl If these all fail, it will try the $ZLIB_ROOT environment variable.
+dnl
+dnl This macro calls:
+dnl   AC_SUBST(ZLIB_CPPFLAGS)
+dnl   AC_SUBST(ZLIB_LDFLAGS)
+dnl   AC_SUBST(ZLIB_LIBS)
+dnl
+dnl And (if zlib is found):
+dnl   AC_DEFINE(HAVE_ZLIB)
+dnl
+dnl It also leaves the shell variables "success" and "ax_have_zlib"
+dnl set to "yes" or "no".
+dnl
+dnl NOTE: This macro does not currently work for cross-compiling,
+dnl       but it can be easily modified to allow it.  (grep "cross").
+dnl
+dnl @category InstalledPackages
+dnl @category C
+dnl @version 2007-09-12
+dnl @license AllPermissive
+dnl
+dnl Copyright (C) 2009 David Reiss
+dnl Copying and distribution of this file, with or without modification,
+dnl are permitted in any medium without royalty provided the copyright
+dnl notice and this notice are preserved.
+
+dnl Input: ax_zlib_path, WANT_ZLIB_VERSION
+dnl Output: success=yes/no
+AC_DEFUN([AX_LIB_ZLIB_DO_CHECK],
+         [
+          # Save our flags.
+          CPPFLAGS_SAVED="$CPPFLAGS"
+          LDFLAGS_SAVED="$LDFLAGS"
+          LIBS_SAVED="$LIBS"
+          LD_LIBRARY_PATH_SAVED="$LD_LIBRARY_PATH"
+
+          # Set our flags if we are checking a specific directory.
+          if test -n "$ax_zlib_path" ; then
+            ZLIB_CPPFLAGS="-I$ax_zlib_path/include"
+            ZLIB_LDFLAGS="-L$ax_zlib_path/lib"
+            LD_LIBRARY_PATH="$ax_zlib_path/lib:$LD_LIBRARY_PATH"
+          else
+            ZLIB_CPPFLAGS=""
+            ZLIB_LDFLAGS=""
+          fi
+
+          # Required flag for zlib.
+          ZLIB_LIBS="-lz"
+
+          # Prepare the environment for compilation.
+          CPPFLAGS="$CPPFLAGS $ZLIB_CPPFLAGS"
+          LDFLAGS="$LDFLAGS $ZLIB_LDFLAGS"
+          LIBS="$LIBS $ZLIB_LIBS"
+          export CPPFLAGS
+          export LDFLAGS
+          export LIBS
+          export LD_LIBRARY_PATH
+
+          success=no
+
+          # Compile, link, and run the program.  This checks:
+          # - zlib.h is available for including.
+          # - zlibVersion() is available for linking.
+          # - ZLIB_VERNUM is greater than or equal to the desired version.
+          # - ZLIB_VERSION (defined in zlib.h) matches zlibVersion()
+          #   (defined in the library).
+          AC_LANG_PUSH([C])
+          dnl This can be changed to AC_LINK_IFELSE if you are cross-compiling.
+          AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+          #include <zlib.h>
+          #if ZLIB_VERNUM >= 0x$WANT_ZLIB_VERSION
+          #else
+          # error zlib is too old
+          #endif
+          ]], [[
+          const char* lib_version = zlibVersion();
+          const char* hdr_version = ZLIB_VERSION;
+          for (;;) {
+            if (*lib_version != *hdr_version) {
+              /* If this happens, your zlib header doesn't match your zlib */
+              /* library.  That is really bad. */
+              return 1;
+            }
+            if (*lib_version == '\0') {
+              break;
+            }
+            lib_version++;
+            hdr_version++;
+          }
+          return 0;
+          ]])], [
+          success=yes
+          ])
+          AC_LANG_POP([C])
+
+          # Restore flags.
+          CPPFLAGS="$CPPFLAGS_SAVED"
+          LDFLAGS="$LDFLAGS_SAVED"
+          LIBS="$LIBS_SAVED"
+          LD_LIBRARY_PATH="$LD_LIBRARY_PATH_SAVED"
+         ])
+
+
+AC_DEFUN([AX_LIB_ZLIB],
+         [
+
+          dnl Allow search path to be overridden on the command line.
+          AC_ARG_WITH([zlib],
+                      AS_HELP_STRING([--with-zlib@<:@=DIR@:>@], [use zlib (default is yes) - it is possible to specify an alternate root directory for zlib]),
+                      [
+                       if test "x$withval" = "xno"; then
+                         want_zlib="no"
+                       elif test "x$withval" = "xyes"; then
+                         want_zlib="yes"
+                         ax_zlib_path=""
+                       else
+                         want_zlib="yes"
+                         ax_zlib_path="$withval"
+                       fi
+                       ],
+                       [want_zlib="yes" ; ax_zlib_path="" ])
+
+
+          if test "$want_zlib" = "yes"; then
+            # Parse out the version.
+            zlib_version_req=ifelse([$1], ,1.2.3,$1)
+            zlib_version_req_major=`expr $zlib_version_req : '\([[0-9]]*\)'`
+            zlib_version_req_minor=`expr $zlib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
+            zlib_version_req_patch=`expr $zlib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
+            if test -z "$zlib_version_req_patch" ; then
+              zlib_version_req_patch="0"
+            fi
+            WANT_ZLIB_VERSION=`expr $zlib_version_req_major \* 1000 \+  $zlib_version_req_minor \* 100 \+ $zlib_version_req_patch \* 10`
+
+            AC_MSG_CHECKING(for zlib >= $zlib_version_req)
+
+            # Run tests.
+            if test -n "$ax_zlib_path"; then
+              AX_LIB_ZLIB_DO_CHECK
+            else
+              for ax_zlib_path in "" /usr /usr/local /opt /opt/zlib "$ZLIB_ROOT" ; do
+                AX_LIB_ZLIB_DO_CHECK
+                if test "$success" = "yes"; then
+                  break;
+                fi
+              done
+            fi
+
+            if test "$success" != "yes" ; then
+              AC_MSG_RESULT(no)
+              ZLIB_CPPFLAGS=""
+              ZLIB_LDFLAGS=""
+              ZLIB_LIBS=""
+            else
+              AC_MSG_RESULT(yes)
+              AC_DEFINE(HAVE_ZLIB,,[define if zlib is available])
+            fi
+
+            ax_have_zlib="$success"
+
+            AC_SUBST(ZLIB_CPPFLAGS)
+            AC_SUBST(ZLIB_LDFLAGS)
+            AC_SUBST(ZLIB_LIBS)
+          fi
+
+          ])
diff --git a/aclocal/ax_signed_right_shift.m4 b/aclocal/ax_signed_right_shift.m4
new file mode 100644
index 0000000..0195233
--- /dev/null
+++ b/aclocal/ax_signed_right_shift.m4
@@ -0,0 +1,127 @@
+dnl @synopsis AX_SIGNED_RIGHT_SHIFT
+dnl
+dnl Tests the behavior of a right shift on a negative signed int.
+dnl
+dnl This macro calls:
+dnl   AC_DEFINE(SIGNED_RIGHT_SHIFT_IS)
+dnl   AC_DEFINE(ARITHMETIC_RIGHT_SHIFT)
+dnl   AC_DEFINE(LOGICAL_RIGHT_SHIFT)
+dnl   AC_DEFINE(UNKNOWN_RIGHT_SHIFT)
+dnl
+dnl SIGNED_RIGHT_SHIFT_IS will be equal to one of the other macros.
+dnl It also leaves the shell variables "ax_signed_right_shift"
+dnl set to "arithmetic", "logical", or "unknown".
+dnl
+dnl NOTE: This macro does not work for cross-compiling.
+dnl
+dnl @category C
+dnl @version 2009-03-25
+dnl @license AllPermissive
+dnl
+dnl Copyright (C) 2009 David Reiss
+dnl Copying and distribution of this file, with or without modification,
+dnl are permitted in any medium without royalty provided the copyright
+dnl notice and this notice are preserved.
+
+AC_DEFUN([AX_SIGNED_RIGHT_SHIFT],
+         [
+
+          AC_MSG_CHECKING(the behavior of a signed right shift)
+
+          success_arithmetic=no
+          AC_RUN_IFELSE([AC_LANG_PROGRAM([[]], [[
+          return
+            /* 0xffffffff */
+            -1 >>  1 != -1 ||
+            -1 >>  2 != -1 ||
+            -1 >>  3 != -1 ||
+            -1 >>  4 != -1 ||
+            -1 >>  8 != -1 ||
+            -1 >> 16 != -1 ||
+            -1 >> 24 != -1 ||
+            -1 >> 31 != -1 ||
+            /* 0x80000000 */
+            (-2147483647 - 1) >>  1 != -1073741824 ||
+            (-2147483647 - 1) >>  2 != -536870912  ||
+            (-2147483647 - 1) >>  3 != -268435456  ||
+            (-2147483647 - 1) >>  4 != -134217728  ||
+            (-2147483647 - 1) >>  8 != -8388608    ||
+            (-2147483647 - 1) >> 16 != -32768      ||
+            (-2147483647 - 1) >> 24 != -128        ||
+            (-2147483647 - 1) >> 31 != -1          ||
+            /* 0x90800000 */
+            -1870659584 >>  1 != -935329792 ||
+            -1870659584 >>  2 != -467664896 ||
+            -1870659584 >>  3 != -233832448 ||
+            -1870659584 >>  4 != -116916224 ||
+            -1870659584 >>  8 != -7307264   ||
+            -1870659584 >> 16 != -28544     ||
+            -1870659584 >> 24 != -112       ||
+            -1870659584 >> 31 != -1         ||
+            0;
+          ]])], [
+          success_arithmetic=yes
+          ])
+
+
+          success_logical=no
+          AC_RUN_IFELSE([AC_LANG_PROGRAM([[]], [[
+          return
+            /* 0xffffffff */
+            -1 >>  1 != (signed)((unsigned)-1 >>  1) ||
+            -1 >>  2 != (signed)((unsigned)-1 >>  2) ||
+            -1 >>  3 != (signed)((unsigned)-1 >>  3) ||
+            -1 >>  4 != (signed)((unsigned)-1 >>  4) ||
+            -1 >>  8 != (signed)((unsigned)-1 >>  8) ||
+            -1 >> 16 != (signed)((unsigned)-1 >> 16) ||
+            -1 >> 24 != (signed)((unsigned)-1 >> 24) ||
+            -1 >> 31 != (signed)((unsigned)-1 >> 31) ||
+            /* 0x80000000 */
+            (-2147483647 - 1) >>  1 != (signed)((unsigned)(-2147483647 - 1) >>  1) ||
+            (-2147483647 - 1) >>  2 != (signed)((unsigned)(-2147483647 - 1) >>  2) ||
+            (-2147483647 - 1) >>  3 != (signed)((unsigned)(-2147483647 - 1) >>  3) ||
+            (-2147483647 - 1) >>  4 != (signed)((unsigned)(-2147483647 - 1) >>  4) ||
+            (-2147483647 - 1) >>  8 != (signed)((unsigned)(-2147483647 - 1) >>  8) ||
+            (-2147483647 - 1) >> 16 != (signed)((unsigned)(-2147483647 - 1) >> 16) ||
+            (-2147483647 - 1) >> 24 != (signed)((unsigned)(-2147483647 - 1) >> 24) ||
+            (-2147483647 - 1) >> 31 != (signed)((unsigned)(-2147483647 - 1) >> 31) ||
+            /* 0x90800000 */
+            -1870659584 >>  1 != (signed)((unsigned)-1870659584 >>  1) ||
+            -1870659584 >>  2 != (signed)((unsigned)-1870659584 >>  2) ||
+            -1870659584 >>  3 != (signed)((unsigned)-1870659584 >>  3) ||
+            -1870659584 >>  4 != (signed)((unsigned)-1870659584 >>  4) ||
+            -1870659584 >>  8 != (signed)((unsigned)-1870659584 >>  8) ||
+            -1870659584 >> 16 != (signed)((unsigned)-1870659584 >> 16) ||
+            -1870659584 >> 24 != (signed)((unsigned)-1870659584 >> 24) ||
+            -1870659584 >> 31 != (signed)((unsigned)-1870659584 >> 31) ||
+            0;
+          ]])], [
+          success_logical=yes
+          ])
+
+
+          AC_DEFINE([ARITHMETIC_RIGHT_SHIFT], 1, [Possible value for SIGNED_RIGHT_SHIFT_IS])
+          AC_DEFINE([LOGICAL_RIGHT_SHIFT], 2, [Possible value for SIGNED_RIGHT_SHIFT_IS])
+          AC_DEFINE([UNKNOWN_RIGHT_SHIFT], 3, [Possible value for SIGNED_RIGHT_SHIFT_IS])
+
+          if test "$success_arithmetic" = "yes" && test "$success_logica" = "yes" ; then
+            AC_MSG_ERROR("Right shift appears to be both arithmetic and logical!")
+          elif test "$success_arithmetic" = "yes" ; then
+            ax_signed_right_shift=arithmetic
+            AC_DEFINE([SIGNED_RIGHT_SHIFT_IS], 1,
+                      [Indicates the effect of the right shift operator
+                       on negative signed integers])
+          elif test "$success_logical" = "yes" ; then
+            ax_signed_right_shift=logical
+            AC_DEFINE([SIGNED_RIGHT_SHIFT_IS], 2,
+                      [Indicates the effect of the right shift operator
+                       on negative signed integers])
+          else
+            ax_signed_right_shift=unknown
+            AC_DEFINE([SIGNED_RIGHT_SHIFT_IS], 3,
+                      [Indicates the effect of the right shift operator
+                       on negative signed integers])
+          fi
+
+          AC_MSG_RESULT($ax_signed_right_shift)
+         ])
diff --git a/aclocal/ax_thrift_internal.m4 b/aclocal/ax_thrift_internal.m4
new file mode 100644
index 0000000..979bec6
--- /dev/null
+++ b/aclocal/ax_thrift_internal.m4
@@ -0,0 +1,39 @@
+dnl @synopsis AX_THRIFT_GEN(SHORT_LANGUAGE, LONG_LANGUAGE, DEFAULT)
+dnl @synopsis AX_THRIFT_LIB(SHORT_LANGUAGE, LONG_LANGUAGE, DEFAULT)
+dnl
+dnl Allow a particular language generator to be disabled.
+dnl Allow a particular language library to be disabled.
+dnl
+dnl These macros have poor error handling and are poorly documented.
+dnl They are intended only for internal use by the Thrift compiler.
+dnl
+dnl @version 2008-02-20
+dnl @license AllPermissive
+dnl
+dnl Copyright (C) 2009 David Reiss
+dnl Copying and distribution of this file, with or without modification,
+dnl are permitted in any medium without royalty provided the copyright
+dnl notice and this notice are preserved.
+
+AC_DEFUN([AX_THRIFT_GEN],
+         [
+          AC_ARG_ENABLE([gen-$1],
+                        AC_HELP_STRING([--enable-gen-$1], [enable the $2 compiler @<:@default=$3@:>@]),
+                        [ax_thrift_gen_$1="$enableval"],
+                        [ax_thrift_gen_$1=$3]
+                        )
+          dnl I'd like to run the AM_CONDITIONAL here, but automake likes
+          dnl all AM_CONDITIONALs to be nice and explicit in configure.ac.
+          dnl AM_CONDITIONAL([THRIFT_GEN_$1], [test "$ax_thrift_gen_$1" = "yes"])
+         ])
+
+AC_DEFUN([AX_THRIFT_LIB],
+         [
+          AC_ARG_WITH($1,
+                      AC_HELP_STRING([--with-$1], [build the $2 library @<:@default=$3@:>@]),
+                      [with_$1="$withval"],
+                      [with_$1=$3]
+                      )
+          dnl What we do here is going to vary from library to library,
+          dnl so we can't really generalize (yet!).
+         ])