1 ## Process this file with autoconf to produce configure.
2 ## In general, the safest way to proceed is to run ./autogen.sh
6 # Note: If you change the version, you must also update it in:
9 # * src/google/protobuf/stubs/common.h
10 # * src/Makefile.am (Update -version-info for LDFLAGS if needed)
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.)
15 AC_INIT([Protocol Buffers],[2.6.1],[protobuf@googlegroups.com],[protobuf])
17 AM_MAINTAINER_MODE([enable])
19 AC_CONFIG_SRCDIR(src/google/protobuf/message.cc)
20 AC_CONFIG_HEADERS([config.h])
21 AC_CONFIG_MACRO_DIR([m4])
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"],
27 AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],
32 AM_INIT_AUTOMAKE([subdir-objects])
35 [AS_HELP_STRING([--with-zlib],
36 [include classes for streaming compressed data in and out @<:@default=check@:>@])],
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)])],
44 # Checks for programs.
48 ACX_USE_SYSTEM_EXTENSIONS
49 AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc
51 # test_util.cc takes forever to compile with GCC and optimization turned on.
52 AC_MSG_CHECKING([C++ compiler flags...])
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"
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"
64 AC_MSG_RESULT([use default: $PROTOBUF_OPT_FLAG $CXXFLAGS])
66 AC_MSG_RESULT([use user-supplied: $CXXFLAGS])
69 AC_SUBST(PROTOBUF_OPT_FLAG)
73 # Have to do libtool after SUNCC, other wise it "helpfully" adds Crun Cstd
77 # Checks for header files.
79 AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stdlib.h unistd.h])
81 # Checks for library functions.
84 AC_CHECK_FUNCS([ftruncate memset mkdir strchr strerror strtol])
88 AS_IF([test "$with_zlib" != no], [
89 AC_MSG_CHECKING([zlib version])
91 # First check the zlib header version.
95 #if !defined(ZLIB_VERNUM) || (ZLIB_VERNUM < 0x1204)
96 # error zlib version too old
99 AC_MSG_RESULT([ok (1.2.0.4 or later)])
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.])
106 AS_IF([test "$with_zlib" != check], [
107 AC_MSG_FAILURE([--with-zlib was given, but no working zlib library was found])
111 AS_IF([test "$with_zlib" = check], [
112 AC_MSG_RESULT([headers missing or too old (requires 1.2.0.4)])
114 AC_MSG_FAILURE([--with-zlib was given, but zlib headers were not present or were too old (requires 1.2.0.4)])
118 AM_CONDITIONAL([HAVE_ZLIB], [test $HAVE_ZLIB = 1])
120 AS_IF([test "$with_protoc" != "no"], [
122 AS_IF([test "$with_protoc" = "yes"], [
123 # No argument given. Use system protoc.
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
137 AM_CONDITIONAL([USE_EXTERNAL_PROTOC], [test "$with_protoc" != "no"])
143 mingw* | cygwin* | win*)
146 # Need to link against rt on Solaris
147 AC_SEARCH_LIBS([sched_yield], [rt], [], [AC_MSG_FAILURE([sched_yield was not found on your system])])
151 # HACK: Make gtest's configure script pick up our copy of CFLAGS and CXXFLAGS,
152 # since the flags added by ACX_CHECK_SUNCC must be used when compiling gtest
156 AC_CONFIG_SUBDIRS([gtest])
158 AC_CONFIG_FILES([Makefile src/Makefile protobuf.pc protobuf-lite.pc])