1
0
Fork 0
arangodb/m4/external.protobuf

128 lines
4.5 KiB
Plaintext

dnl -*- mode: Autoconf; -*-
dnl ----------------------------------------------------------------------------
dnl --SECTION-- PROTOBUF
dnl ----------------------------------------------------------------------------
AC_ARG_WITH(protobuf,
AS_HELP_STRING([--with-protobuf=DIR], [where the protobuf library and includes are located]),
[PROTOBUF_CPPFLAGS="-I$withval/include"
PROTOBUF_LDFLAGS="-L$withval/lib"
PROTOBUF="$withval"]
)
AC_ARG_WITH(protobuf-lib,
AS_HELP_STRING([--with-protobuf-lib=DIR], [where the protobuf library is located]),
[PROTOBUF_LDFLAGS="-L$withval"]
)
TR_STATIC_ENABLE([protobuf])
AC_MSG_NOTICE([--------------------------------------------------------------------------------])
AC_MSG_NOTICE([CHECKING FOR PROTOBUF])
AC_MSG_NOTICE([--------------------------------------------------------------------------------])
dnl ----------------------------------------------------------------------------
dnl save flags
dnl ----------------------------------------------------------------------------
SAVE_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $PROTOBUF_CPPFLAGS"
SAVE_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $PROTOBUF_LDFLAGS"
SAVE_LIBS="$LIBS"
dnl ----------------------------------------------------------------------------
dnl check for header and library
dnl ----------------------------------------------------------------------------
AC_LANG(C++)
AC_CHECK_HEADERS(google/protobuf/stubs/common.h, [tr_PROTOBUF="yes"], [tr_PROTOBUF="no"])
PROTOBUF_LIBS=""
if test "x$tr_PROTOBUF" = xyes; then
TR_FIND_CXX_LIBRARY([protobuf], [protobuf], [PROTOBUF_LIBS], [#include <google/protobuf/stubs/common.h>], [google::protobuf::ShutdownProtobufLibrary()])
tr_PROTOBUF=$tr_library_found
fi
if test "x$tr_PROTOBUF" = xyes; then
TR_STATIC_LIBRARY([protobuf], [PROTOBUF_LIBS])
else
AC_MSG_ERROR([Please install Google's protocol buffers from http://code.google.com/p/protobuf/])
fi
dnl ----------------------------------------------------------------------------
dnl check for protoc
dnl ----------------------------------------------------------------------------
AC_PATH_PROG([PROTOBUF_PROTOC], [protoc], [], [$PATH])
if test "x$PROTOBUF_PROTOC" = x; then
AC_MSG_ERROR([Please install Google's protocol buffers from http://code.google.com/p/protobuf/])
fi
dnl ----------------------------------------------------------------------------
dnl grep protobuf version number
dnl ----------------------------------------------------------------------------
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <google/protobuf/stubs/common.h>
main () {
long sdnhg36ed = GOOGLE_PROTOBUF_VERSION ;
}
_ACEOF
AC_MSG_CHECKING([PROTOBUF version])
eval "$ac_cpp conftest.$ac_ext" | fgrep "long sdnhg36ed" | awk '{m1 = int($4 / 1000000); m2 = int($4 / 1000) % 1000; m3 = ($4 % 1000); print m1 "." m2 "." m3}' > conftest.output
TRI_PROTOBUF_VERSION=`cat conftest.output`
AC_MSG_RESULT([$TRI_PROTOBUF_VERSION])
rm -f conftest*
PROTOBUF_CPPFLAGS="${PROTOBUF_CPPFLAGS} -DTRI_PROTOBUF_VERSION='\"${TRI_PROTOBUF_VERSION}\"'"
dnl ----------------------------------------------------------------------------
dnl restore flags
dnl ----------------------------------------------------------------------------
LIBS="$SAVE_LIBS"
LDFLAGS="$SAVE_LDFLAGS"
CPPFLAGS="$SAVE_CPPFLAGS"
dnl ----------------------------------------------------------------------------
dnl add substitutions
dnl ----------------------------------------------------------------------------
AC_SUBST(PROTOBUF_PROTOC)
AC_SUBST(PROTOBUF_CPPFLAGS)
AC_SUBST(PROTOBUF_LDFLAGS)
AC_SUBST(PROTOBUF_LIBS)
dnl ----------------------------------------------------------------------------
dnl informational output
dnl ----------------------------------------------------------------------------
LIB_INFO="$LIB_INFO|PROTOBUF: system version"
LIB_INFO="$LIB_INFO|PROTOBUF VERSION: ${TRI_PROTOBUF_VERSION}"
LIB_INFO="$LIB_INFO|PROTOBUF COMPILER: ${PROTOBUF_PROTOC}"
LIB_INFO="$LIB_INFO|PROTOBUF_CPPFLAGS: ${PROTOBUF_CPPFLAGS}"
LIB_INFO="$LIB_INFO|PROTOBUF_LDFLAGS: ${PROTOBUF_LDFLAGS}"
LIB_INFO="$LIB_INFO|PROTOBUF_LIBS: ${PROTOBUF_LIBS}"
LIB_INFO="$LIB_INFO|."
dnl ----------------------------------------------------------------------------
dnl --SECTION-- END-OF-FILE
dnl ----------------------------------------------------------------------------
dnl Local Variables:
dnl mode: outline-minor
dnl outline-regexp: "^\\(dnl --SECTION--\\)"
dnl End: