summaryrefslogtreecommitdiff
path: root/aclocal
diff options
context:
space:
mode:
authorDavid Reiss <dreiss@apache.org>2007-12-28 18:25:33 +0000
committerDavid Reiss <dreiss@apache.org>2007-12-28 18:25:33 +0000
commit832b262acab7656ce5d5541f010c29f060580693 (patch)
tree8fecf364acbfb94a60a1bcf929f8f891e5130510 /aclocal
parent65704511459cdfc0f3e7d70b5008ea4e18a6f538 (diff)
downloadthrift-832b262acab7656ce5d5541f010c29f060580693.tar.gz
Thrift: Revamp build to use a single configure.ac.
Summary: Ben Maurer suggested that it would make sense for Thrift to build as a single project, with one configure.ac and multiple Makefile.am. He was also kind enough to do the heavy lifting, and this commit is the application of his patch (with minor modifications). The most significant visible change from this diff is that in order to buidl one of the thrift sub-projects (i.e.: the compiler, the C++ library, or the Python library) you must run bootstrap.sh and configure in the Thrift root, then make in the specific project. Users who want to build and install the Python library but can't run configure because they don't have Boost can simply run setup.py directly. Reviewed By: mcslee Test Plan: Built Thrift from scratch. Revert Plan: ok git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665409 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'aclocal')
-rw-r--r--aclocal/ax_boost_base.m4186
-rw-r--r--aclocal/ax_lib_event.m4169
-rw-r--r--aclocal/ax_lib_zlib.m4169
3 files changed, 524 insertions, 0 deletions
diff --git a/aclocal/ax_boost_base.m4 b/aclocal/ax_boost_base.m4
new file mode 100644
index 000000000..f225bff44
--- /dev/null
+++ b/aclocal/ax_boost_base.m4
@@ -0,0 +1,186 @@
+dnl @synopsis AX_BOOST([MINIMUM-VERSION])
+dnl
+dnl Test for the Boost C++ libraries of a particular version (or newer)
+dnl
+dnl If no path to the installed boost library is given the macro
+dnl searchs under /usr, /usr/local, and /opt, and evaluates the
+dnl $BOOST_ROOT environment variable. Further documentation is
+dnl available at <http://randspringer.de/boost/index.html>.
+dnl
+dnl This macro calls:
+dnl
+dnl AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS)
+dnl
+dnl And sets:
+dnl
+dnl HAVE_BOOST
+dnl
+dnl @category InstalledPackages
+dnl @category Cxx
+dnl @author Thomas Porschberg <thomas@randspringer.de>
+dnl @version 2006-06-15
+dnl @license AllPermissive
+
+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 an alternate root directory for boost]),
+ [
+ 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 ; 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 ; 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_lib_event.m4 b/aclocal/ax_lib_event.m4
new file mode 100644
index 000000000..9266df4f9
--- /dev/null
+++ b/aclocal/ax_lib_event.m4
@@ -0,0 +1,169 @@
+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 @author David Reiss <dreiss@facebook.com>
+dnl @version 2007-09-12
+dnl @license AllPermissive
+
+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/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 000000000..40e96df97
--- /dev/null
+++ b/aclocal/ax_lib_zlib.m4
@@ -0,0 +1,169 @@
+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 @author David Reiss <dreiss@facebook.com>
+dnl @version 2007-09-12
+dnl @license AllPermissive
+
+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 "$withval" = "xno"; then
+ want_zlib="no"
+ elif test "$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
+
+ ])