temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 1 | ## Process this file with autoconf to produce configure. |
| 2 | ## In general, the safest way to proceed is to run ./autogen.sh |
| 3 | |
| 4 | AC_PREREQ(2.59) |
| 5 | |
| 6 | # Note: If you change the version, you must also update it in: |
| 7 | # * java/pom.xml |
| 8 | # * python/setup.py |
| 9 | # * src/google/protobuf/stubs/common.h |
kenton@google.com | a001ed0 | 2008-12-01 23:47:49 +0000 | [diff] [blame] | 10 | # * src/Makefile.am (Update -version-info for LDFLAGS if needed) |
kenton@google.com | 37ad00d | 2009-04-21 21:00:39 +0000 | [diff] [blame] | 11 | # |
| 12 | # In the SVN trunk, the version should always be the next anticipated release |
| 13 | # version with the "-pre" suffix. (We used to use "-SNAPSHOT" but this pushed |
| 14 | # the size of one file name in the dist tarfile over the 99-char limit.) |
jieluo@google.com | 1eba9d9 | 2014-08-25 20:17:53 +0000 | [diff] [blame] | 15 | AC_INIT([Protocol Buffers],[2.6.0],[protobuf@googlegroups.com],[protobuf]) |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 16 | |
liujisi@google.com | 26261eb | 2012-07-03 09:39:26 +0000 | [diff] [blame] | 17 | AM_MAINTAINER_MODE([enable]) |
kenton@google.com | 42c81e1 | 2009-05-06 01:15:06 +0000 | [diff] [blame] | 18 | |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 19 | AC_CONFIG_SRCDIR(src/google/protobuf/message.cc) |
kenton@google.com | c76caac | 2008-09-30 22:11:21 +0000 | [diff] [blame] | 20 | AC_CONFIG_HEADERS([config.h]) |
kenton@google.com | 25bc5cd | 2008-12-04 20:34:50 +0000 | [diff] [blame] | 21 | AC_CONFIG_MACRO_DIR([m4]) |
kenton@google.com | 6be265a | 2009-08-06 20:47:45 +0000 | [diff] [blame] | 22 | |
| 23 | # autoconf's default CXXFLAGS are usually "-g -O2". These aren't necessarily |
| 24 | # the best choice for libprotobuf. |
| 25 | AS_IF([test "x${ac_cv_env_CFLAGS_set}" = "x"], |
| 26 | [CFLAGS=""]) |
| 27 | AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"], |
| 28 | [CXXFLAGS=""]) |
kenton@google.com | 445f102 | 2009-08-06 23:01:43 +0000 | [diff] [blame] | 29 | |
kenton@google.com | 6be265a | 2009-08-06 20:47:45 +0000 | [diff] [blame] | 30 | AC_CANONICAL_TARGET |
| 31 | |
jieluo@google.com | abe61de | 2014-08-05 20:18:53 +0000 | [diff] [blame] | 32 | AM_INIT_AUTOMAKE([subdir-objects]) |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 33 | |
kenton@google.com | e59427a | 2009-04-16 22:30:56 +0000 | [diff] [blame] | 34 | AC_ARG_WITH([zlib], |
| 35 | [AS_HELP_STRING([--with-zlib], |
| 36 | [include classes for streaming compressed data in and out @<:@default=check@:>@])], |
| 37 | [],[with_zlib=check]) |
| 38 | |
kenton@google.com | 9824eda | 2009-05-06 17:49:37 +0000 | [diff] [blame] | 39 | AC_ARG_WITH([protoc], |
| 40 | [AS_HELP_STRING([--with-protoc=COMMAND], |
| 41 | [use the given protoc command instead of building a new one when building tests (useful for cross-compiling)])], |
| 42 | [],[with_protoc=no]) |
| 43 | |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 44 | # Checks for programs. |
| 45 | AC_PROG_CC |
| 46 | AC_PROG_CXX |
kenton@google.com | 37ad00d | 2009-04-21 21:00:39 +0000 | [diff] [blame] | 47 | AC_LANG([C++]) |
kenton@google.com | 25bc5cd | 2008-12-04 20:34:50 +0000 | [diff] [blame] | 48 | ACX_USE_SYSTEM_EXTENSIONS |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 49 | AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc |
kenton@google.com | 25bc5cd | 2008-12-04 20:34:50 +0000 | [diff] [blame] | 50 | |
kenton@google.com | 6be265a | 2009-08-06 20:47:45 +0000 | [diff] [blame] | 51 | # test_util.cc takes forever to compile with GCC and optimization turned on. |
kenton@google.com | 42c81e1 | 2009-05-06 01:15:06 +0000 | [diff] [blame] | 52 | AC_MSG_CHECKING([C++ compiler flags...]) |
kenton@google.com | 6be265a | 2009-08-06 20:47:45 +0000 | [diff] [blame] | 53 | AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],[ |
| 54 | AS_IF([test "$GCC" = "yes"],[ |
| 55 | PROTOBUF_OPT_FLAG="-O2" |
| 56 | CXXFLAGS="${CXXFLAGS} -g" |
| 57 | ]) |
kenton@google.com | 42c81e1 | 2009-05-06 01:15:06 +0000 | [diff] [blame] | 58 | |
| 59 | # Protocol Buffers contains several checks that are intended to be used only |
| 60 | # for debugging and which might hurt performance. Most users are probably |
| 61 | # end users who don't want these checks, so add -DNDEBUG by default. |
| 62 | CXXFLAGS="$CXXFLAGS -DNDEBUG" |
| 63 | |
| 64 | AC_MSG_RESULT([use default: $PROTOBUF_OPT_FLAG $CXXFLAGS]) |
| 65 | ],[ |
kenton@google.com | 42c81e1 | 2009-05-06 01:15:06 +0000 | [diff] [blame] | 66 | AC_MSG_RESULT([use user-supplied: $CXXFLAGS]) |
| 67 | ]) |
| 68 | |
| 69 | AC_SUBST(PROTOBUF_OPT_FLAG) |
| 70 | |
kenton@google.com | a8923cd | 2009-05-01 21:53:10 +0000 | [diff] [blame] | 71 | ACX_CHECK_SUNCC |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 72 | |
kenton@google.com | 445f102 | 2009-08-06 23:01:43 +0000 | [diff] [blame] | 73 | # Have to do libtool after SUNCC, other wise it "helpfully" adds Crun Cstd |
kenton@google.com | 6be265a | 2009-08-06 20:47:45 +0000 | [diff] [blame] | 74 | # to the link |
| 75 | AC_PROG_LIBTOOL |
| 76 | |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 77 | # Checks for header files. |
| 78 | AC_HEADER_STDC |
| 79 | AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stdlib.h unistd.h]) |
| 80 | |
| 81 | # Checks for library functions. |
| 82 | AC_FUNC_MEMCMP |
| 83 | AC_FUNC_STRTOD |
| 84 | AC_CHECK_FUNCS([ftruncate memset mkdir strchr strerror strtol]) |
| 85 | |
kenton@google.com | 32f330f | 2009-09-15 17:15:43 +0000 | [diff] [blame] | 86 | # Check for zlib. |
kenton@google.com | e59427a | 2009-04-16 22:30:56 +0000 | [diff] [blame] | 87 | HAVE_ZLIB=0 |
kenton@google.com | 32f330f | 2009-09-15 17:15:43 +0000 | [diff] [blame] | 88 | AS_IF([test "$with_zlib" != no], [ |
| 89 | AC_MSG_CHECKING([zlib version]) |
| 90 | |
| 91 | # First check the zlib header version. |
| 92 | AC_COMPILE_IFELSE( |
liujisi@google.com | 8cc2017 | 2012-12-05 00:55:16 +0000 | [diff] [blame] | 93 | [AC_LANG_PROGRAM([[ |
kenton@google.com | 32f330f | 2009-09-15 17:15:43 +0000 | [diff] [blame] | 94 | #include <zlib.h> |
| 95 | #if !defined(ZLIB_VERNUM) || (ZLIB_VERNUM < 0x1204) |
| 96 | # error zlib version too old |
| 97 | #endif |
liujisi@google.com | 8cc2017 | 2012-12-05 00:55:16 +0000 | [diff] [blame] | 98 | ]], [])], [ |
kenton@google.com | 32f330f | 2009-09-15 17:15:43 +0000 | [diff] [blame] | 99 | AC_MSG_RESULT([ok (1.2.0.4 or later)]) |
| 100 | |
| 101 | # Also need to add -lz to the linker flags and make sure this succeeds. |
| 102 | AC_SEARCH_LIBS([zlibVersion], [z], [ |
| 103 | AC_DEFINE([HAVE_ZLIB], [1], [Enable classes using zlib compression.]) |
| 104 | HAVE_ZLIB=1 |
| 105 | ], [ |
| 106 | AS_IF([test "$with_zlib" != check], [ |
| 107 | AC_MSG_FAILURE([--with-zlib was given, but no working zlib library was found]) |
| 108 | ]) |
| 109 | ]) |
| 110 | ], [ |
| 111 | AS_IF([test "$with_zlib" = check], [ |
| 112 | AC_MSG_RESULT([headers missing or too old (requires 1.2.0.4)]) |
| 113 | ], [ |
| 114 | AC_MSG_FAILURE([--with-zlib was given, but zlib headers were not present or were too old (requires 1.2.0.4)]) |
| 115 | ]) |
| 116 | ]) |
| 117 | ]) |
kenton@google.com | e59427a | 2009-04-16 22:30:56 +0000 | [diff] [blame] | 118 | AM_CONDITIONAL([HAVE_ZLIB], [test $HAVE_ZLIB = 1]) |
| 119 | |
kenton@google.com | 9824eda | 2009-05-06 17:49:37 +0000 | [diff] [blame] | 120 | AS_IF([test "$with_protoc" != "no"], [ |
| 121 | PROTOC=$with_protoc |
liujisi@google.com | 5d8d2b0 | 2010-12-06 06:20:14 +0000 | [diff] [blame] | 122 | AS_IF([test "$with_protoc" = "yes"], [ |
kenton@google.com | 9824eda | 2009-05-06 17:49:37 +0000 | [diff] [blame] | 123 | # No argument given. Use system protoc. |
| 124 | PROTOC=protoc |
| 125 | ]) |
| 126 | AS_IF([echo "$PROTOC" | grep -q '^@<:@^/@:>@.*/'], [ |
| 127 | # Does not start with a slash, but contains a slash. So, it's a relative |
| 128 | # path (as opposed to an absolute path or an executable in $PATH). |
| 129 | # Since it will actually be executed from the src directory, prefix with |
| 130 | # the current directory. We also insert $ac_top_build_prefix in case this |
| 131 | # is a nested package and --with-protoc was actually given on the outer |
| 132 | # package's configure script. |
| 133 | PROTOC=`pwd`/${ac_top_build_prefix}$PROTOC |
| 134 | ]) |
| 135 | AC_SUBST([PROTOC]) |
| 136 | ]) |
| 137 | AM_CONDITIONAL([USE_EXTERNAL_PROTOC], [test "$with_protoc" != "no"]) |
| 138 | |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 139 | ACX_PTHREAD |
| 140 | AC_CXX_STL_HASH |
| 141 | |
William Orr | 38b8494 | 2014-09-19 21:54:27 -0700 | [diff] [blame^] | 142 | # Need to link against rt on Solaris |
| 143 | AC_SEARCH_LIBS([sched_yield], [rt], [], [AC_MSG_FAILURE([sched_yield was not found on your system])]) |
| 144 | |
kenton@google.com | 45258ff | 2009-12-23 22:12:22 +0000 | [diff] [blame] | 145 | # HACK: Make gtest's configure script pick up our copy of CFLAGS and CXXFLAGS, |
| 146 | # since the flags added by ACX_CHECK_SUNCC must be used when compiling gtest |
| 147 | # too. |
| 148 | export CFLAGS |
kenton@google.com | 304b731 | 2009-08-10 23:52:27 +0000 | [diff] [blame] | 149 | export CXXFLAGS |
kenton@google.com | 37ad00d | 2009-04-21 21:00:39 +0000 | [diff] [blame] | 150 | AC_CONFIG_SUBDIRS([gtest]) |
| 151 | |
kenton@google.com | 3c66c2e | 2009-08-03 21:31:25 +0000 | [diff] [blame] | 152 | AC_CONFIG_FILES([Makefile src/Makefile protobuf.pc protobuf-lite.pc]) |
kenton@google.com | c76caac | 2008-09-30 22:11:21 +0000 | [diff] [blame] | 153 | AC_OUTPUT |