configure.ac 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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],[3.0.0-alpha-3-pre],[protobuf@googlegroups.com],[protobuf])
  14. AM_MAINTAINER_MODE([enable])
  15. AC_CONFIG_SRCDIR(src/google/protobuf/message.cc)
  16. AC_CONFIG_HEADERS([config.h])
  17. AC_CONFIG_MACRO_DIR([m4])
  18. AC_ARG_VAR(DIST_LANG, [language to include in the distribution package (i.e., make dist)])
  19. case "$DIST_LANG" in
  20. "") DIST_LANG=all ;;
  21. all | cpp | java | python | javanano | ruby) ;;
  22. *) AC_MSG_FAILURE([unknown language: $DIST_LANG]) ;;
  23. esac
  24. AC_SUBST(DIST_LANG)
  25. # autoconf's default CXXFLAGS are usually "-g -O2". These aren't necessarily
  26. # the best choice for libprotobuf.
  27. AS_IF([test "x${ac_cv_env_CFLAGS_set}" = "x"],
  28. [CFLAGS=""])
  29. AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],
  30. [CXXFLAGS=""])
  31. AC_CANONICAL_TARGET
  32. AM_INIT_AUTOMAKE([1.9 tar-ustar subdir-objects])
  33. AC_ARG_WITH([zlib],
  34. [AS_HELP_STRING([--with-zlib],
  35. [include classes for streaming compressed data in and out @<:@default=check@:>@])],
  36. [],[with_zlib=check])
  37. AC_ARG_WITH([protoc],
  38. [AS_HELP_STRING([--with-protoc=COMMAND],
  39. [use the given protoc command instead of building a new one when building tests (useful for cross-compiling)])],
  40. [],[with_protoc=no])
  41. # Checks for programs.
  42. AC_PROG_CC
  43. AC_PROG_CXX
  44. AC_LANG([C++])
  45. ACX_USE_SYSTEM_EXTENSIONS
  46. m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
  47. AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc
  48. # test_util.cc takes forever to compile with GCC and optimization turned on.
  49. AC_MSG_CHECKING([C++ compiler flags...])
  50. AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],[
  51. AS_IF([test "$GCC" = "yes"],[
  52. PROTOBUF_OPT_FLAG="-O2"
  53. CXXFLAGS="${CXXFLAGS} -g"
  54. ])
  55. # Protocol Buffers contains several checks that are intended to be used only
  56. # for debugging and which might hurt performance. Most users are probably
  57. # end users who don't want these checks, so add -DNDEBUG by default.
  58. CXXFLAGS="$CXXFLAGS -DNDEBUG"
  59. AC_MSG_RESULT([use default: $PROTOBUF_OPT_FLAG $CXXFLAGS])
  60. ],[
  61. AC_MSG_RESULT([use user-supplied: $CXXFLAGS])
  62. ])
  63. AC_SUBST(PROTOBUF_OPT_FLAG)
  64. ACX_CHECK_SUNCC
  65. # Have to do libtool after SUNCC, other wise it "helpfully" adds Crun Cstd
  66. # to the link
  67. AC_PROG_LIBTOOL
  68. # Checks for header files.
  69. AC_HEADER_STDC
  70. AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stdlib.h unistd.h])
  71. # Checks for library functions.
  72. AC_FUNC_MEMCMP
  73. AC_FUNC_STRTOD
  74. AC_CHECK_FUNCS([ftruncate memset mkdir strchr strerror strtol])
  75. # Check for zlib.
  76. HAVE_ZLIB=0
  77. AS_IF([test "$with_zlib" != no], [
  78. AC_MSG_CHECKING([zlib version])
  79. # First check the zlib header version.
  80. AC_COMPILE_IFELSE(
  81. [AC_LANG_PROGRAM([[
  82. #include <zlib.h>
  83. #if !defined(ZLIB_VERNUM) || (ZLIB_VERNUM < 0x1204)
  84. # error zlib version too old
  85. #endif
  86. ]], [])], [
  87. AC_MSG_RESULT([ok (1.2.0.4 or later)])
  88. # Also need to add -lz to the linker flags and make sure this succeeds.
  89. AC_SEARCH_LIBS([zlibVersion], [z], [
  90. AC_DEFINE([HAVE_ZLIB], [1], [Enable classes using zlib compression.])
  91. HAVE_ZLIB=1
  92. ], [
  93. AS_IF([test "$with_zlib" != check], [
  94. AC_MSG_FAILURE([--with-zlib was given, but no working zlib library was found])
  95. ])
  96. ])
  97. ], [
  98. AS_IF([test "$with_zlib" = check], [
  99. AC_MSG_RESULT([headers missing or too old (requires 1.2.0.4)])
  100. ], [
  101. AC_MSG_FAILURE([--with-zlib was given, but zlib headers were not present or were too old (requires 1.2.0.4)])
  102. ])
  103. ])
  104. ])
  105. AM_CONDITIONAL([HAVE_ZLIB], [test $HAVE_ZLIB = 1])
  106. AS_IF([test "$with_protoc" != "no"], [
  107. PROTOC=$with_protoc
  108. AS_IF([test "$with_protoc" = "yes"], [
  109. # No argument given. Use system protoc.
  110. PROTOC=protoc
  111. ])
  112. AS_IF([echo "$PROTOC" | grep -q '^@<:@^/@:>@.*/'], [
  113. # Does not start with a slash, but contains a slash. So, it's a relative
  114. # path (as opposed to an absolute path or an executable in $PATH).
  115. # Since it will actually be executed from the src directory, prefix with
  116. # the current directory. We also insert $ac_top_build_prefix in case this
  117. # is a nested package and --with-protoc was actually given on the outer
  118. # package's configure script.
  119. PROTOC=`pwd`/${ac_top_build_prefix}$PROTOC
  120. ])
  121. AC_SUBST([PROTOC])
  122. ])
  123. AM_CONDITIONAL([USE_EXTERNAL_PROTOC], [test "$with_protoc" != "no"])
  124. ACX_PTHREAD
  125. AC_CXX_STL_HASH
  126. case "$target_os" in
  127. mingw* | cygwin* | win*)
  128. ;;
  129. *)
  130. # Need to link against rt on Solaris
  131. AC_SEARCH_LIBS([sched_yield], [rt], [], [AC_MSG_FAILURE([sched_yield was not found on your system])])
  132. ;;
  133. esac
  134. # HACK: Make gtest's configure script pick up our copy of CFLAGS and CXXFLAGS,
  135. # since the flags added by ACX_CHECK_SUNCC must be used when compiling gtest
  136. # too.
  137. export CFLAGS
  138. export CXXFLAGS
  139. AC_CONFIG_SUBDIRS([gtest])
  140. AC_CONFIG_FILES([Makefile src/Makefile conformance/Makefile protobuf.pc protobuf-lite.pc])
  141. AC_OUTPUT