configure.ac 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. ## Process this file with autoconf to produce configure.
  2. ## In general, the safest way to proceed is to run ./autogen.sh
  3. AC_PREREQ(2.59)
  4. # Note: If you change the version, you must also update it in:
  5. # * java/pom.xml
  6. # * python/setup.py
  7. # * src/google/protobuf/stubs/common.h
  8. # * src/Makefile.am (Update -version-info for LDFLAGS if needed)
  9. #
  10. # In the SVN trunk, the version should always be the next anticipated release
  11. # version with the "-pre" suffix. (We used to use "-SNAPSHOT" but this pushed
  12. # the size of one file name in the dist tarfile over the 99-char limit.)
  13. AC_INIT([Protocol Buffers],[2.2.1-pre],[protobuf@googlegroups.com],[protobuf])
  14. AC_CONFIG_SRCDIR(src/google/protobuf/message.cc)
  15. AC_CONFIG_HEADERS([config.h])
  16. AC_CONFIG_MACRO_DIR([m4])
  17. # autoconf's default CXXFLAGS are usually "-g -O2". These aren't necessarily
  18. # the best choice for libprotobuf.
  19. AS_IF([test "x${ac_cv_env_CFLAGS_set}" = "x"],
  20. [CFLAGS=""])
  21. AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],
  22. [CXXFLAGS=""])
  23. AC_CANONICAL_TARGET
  24. AM_INIT_AUTOMAKE
  25. AC_ARG_WITH([zlib],
  26. [AS_HELP_STRING([--with-zlib],
  27. [include classes for streaming compressed data in and out @<:@default=check@:>@])],
  28. [],[with_zlib=check])
  29. AC_ARG_WITH([protoc],
  30. [AS_HELP_STRING([--with-protoc=COMMAND],
  31. [use the given protoc command instead of building a new one when building tests (useful for cross-compiling)])],
  32. [],[with_protoc=no])
  33. # Checks for programs.
  34. AC_PROG_CC
  35. AC_PROG_CXX
  36. AC_LANG([C++])
  37. ACX_USE_SYSTEM_EXTENSIONS
  38. AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc
  39. # test_util.cc takes forever to compile with GCC and optimization turned on.
  40. AC_MSG_CHECKING([C++ compiler flags...])
  41. AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],[
  42. AS_IF([test "$GCC" = "yes"],[
  43. PROTOBUF_OPT_FLAG="-O2"
  44. CXXFLAGS="${CXXFLAGS} -g"
  45. ])
  46. # Protocol Buffers contains several checks that are intended to be used only
  47. # for debugging and which might hurt performance. Most users are probably
  48. # end users who don't want these checks, so add -DNDEBUG by default.
  49. CXXFLAGS="$CXXFLAGS -DNDEBUG"
  50. AC_MSG_RESULT([use default: $PROTOBUF_OPT_FLAG $CXXFLAGS])
  51. ],[
  52. AC_MSG_RESULT([use user-supplied: $CXXFLAGS])
  53. ])
  54. AC_SUBST(PROTOBUF_OPT_FLAG)
  55. ACX_CHECK_SUNCC
  56. # Have to do libtool after SUNCC, other wise it "helpfully" adds Crun Cstd
  57. # to the link
  58. AC_PROG_LIBTOOL
  59. # Checks for header files.
  60. AC_HEADER_STDC
  61. AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stdlib.h unistd.h])
  62. # Checks for library functions.
  63. AC_FUNC_MEMCMP
  64. AC_FUNC_STRTOD
  65. AC_CHECK_FUNCS([ftruncate memset mkdir strchr strerror strtol])
  66. HAVE_ZLIB=0
  67. AS_IF([test "$with_zlib" != no],
  68. [AC_SEARCH_LIBS([zlibVersion], [z],
  69. [AC_DEFINE([HAVE_ZLIB], [1], [Enable classes using zlib compression.])
  70. HAVE_ZLIB=1],
  71. [if test "$with_zlib" != check; then
  72. AC_MSG_FAILURE([--with-zlib was given, but test for zlib failed])
  73. fi])])
  74. AM_CONDITIONAL([HAVE_ZLIB], [test $HAVE_ZLIB = 1])
  75. AS_IF([test "$with_protoc" != "no"], [
  76. PROTOC=$with_protoc
  77. AS_IF([test "$with_protoc" == "yes"], [
  78. # No argument given. Use system protoc.
  79. PROTOC=protoc
  80. ])
  81. AS_IF([echo "$PROTOC" | grep -q '^@<:@^/@:>@.*/'], [
  82. # Does not start with a slash, but contains a slash. So, it's a relative
  83. # path (as opposed to an absolute path or an executable in $PATH).
  84. # Since it will actually be executed from the src directory, prefix with
  85. # the current directory. We also insert $ac_top_build_prefix in case this
  86. # is a nested package and --with-protoc was actually given on the outer
  87. # package's configure script.
  88. PROTOC=`pwd`/${ac_top_build_prefix}$PROTOC
  89. ])
  90. AC_SUBST([PROTOC])
  91. ])
  92. AM_CONDITIONAL([USE_EXTERNAL_PROTOC], [test "$with_protoc" != "no"])
  93. ACX_PTHREAD
  94. AC_CXX_STL_HASH
  95. # HACK: Make gtest's configure script pick up our copy of CXXFLAGS, since the
  96. # flags added by ACX_CHECK_SUNCC must be used when compiling gtest too.
  97. export CXXFLAGS
  98. AC_CONFIG_SUBDIRS([gtest])
  99. AC_CONFIG_FILES([Makefile src/Makefile protobuf.pc protobuf-lite.pc])
  100. AC_OUTPUT