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