blob: b847f3da2c363ef9d8e0f5feb48105dabd5dc2bb [file] [log] [blame]
temporal40ee5512008-07-10 02:12:20 +00001## 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
kenton@google.coma001ed02008-12-01 23:47:49 +000010# * src/Makefile.am (Update -version-info for LDFLAGS if needed)
kenton@google.com37ad00d2009-04-21 21:00:39 +000011#
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.)
kenton@google.com1fb3d392009-05-13 23:20:03 +000015AC_INIT([Protocol Buffers],[2.1.1-pre],[protobuf@googlegroups.com],[protobuf])
temporal40ee5512008-07-10 02:12:20 +000016
kenton@google.com42c81e12009-05-06 01:15:06 +000017
temporal40ee5512008-07-10 02:12:20 +000018AC_CONFIG_SRCDIR(src/google/protobuf/message.cc)
kenton@google.comc76caac2008-09-30 22:11:21 +000019AC_CONFIG_HEADERS([config.h])
kenton@google.com25bc5cd2008-12-04 20:34:50 +000020AC_CONFIG_MACRO_DIR([m4])
kenton@google.com6be265a2009-08-06 20:47:45 +000021
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
temporal40ee5512008-07-10 02:12:20 +000031AM_INIT_AUTOMAKE
32
kenton@google.come59427a2009-04-16 22:30:56 +000033AC_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
kenton@google.com9824eda2009-05-06 17:49:37 +000038AC_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
temporal40ee5512008-07-10 02:12:20 +000043# Checks for programs.
44AC_PROG_CC
45AC_PROG_CXX
kenton@google.com37ad00d2009-04-21 21:00:39 +000046AC_LANG([C++])
kenton@google.com25bc5cd2008-12-04 20:34:50 +000047ACX_USE_SYSTEM_EXTENSIONS
temporal40ee5512008-07-10 02:12:20 +000048AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc
kenton@google.com25bc5cd2008-12-04 20:34:50 +000049
kenton@google.com6be265a2009-08-06 20:47:45 +000050# test_util.cc takes forever to compile with GCC and optimization turned on.
kenton@google.com42c81e12009-05-06 01:15:06 +000051AC_MSG_CHECKING([C++ compiler flags...])
kenton@google.com6be265a2009-08-06 20:47:45 +000052AS_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 ])
kenton@google.com42c81e12009-05-06 01:15:06 +000057
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],[
kenton@google.com42c81e12009-05-06 01:15:06 +000065 AC_MSG_RESULT([use user-supplied: $CXXFLAGS])
66])
67
68AC_SUBST(PROTOBUF_OPT_FLAG)
69
kenton@google.coma8923cd2009-05-01 21:53:10 +000070ACX_CHECK_SUNCC
temporal40ee5512008-07-10 02:12:20 +000071
kenton@google.com6be265a2009-08-06 20:47:45 +000072# Have to do libtool after SUNCC, other wise it "helpfully" adds Crun Cstd
73# to the link
74AC_PROG_LIBTOOL
75
temporal40ee5512008-07-10 02:12:20 +000076# 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
kenton@google.come59427a2009-04-16 22:30:56 +000085HAVE_ZLIB=0
86AS_IF([test "$with_zlib" != no],
87 [AC_SEARCH_LIBS([zlibVersion], [z],
88 [AC_DEFINE([HAVE_ZLIB], [1], [Enable classes using zlib compression.])
89 HAVE_ZLIB=1],
90 [if test "$with_zlib" != check; then
91 AC_MSG_FAILURE([--with-zlib was given, but test for zlib failed])
92 fi])])
93AM_CONDITIONAL([HAVE_ZLIB], [test $HAVE_ZLIB = 1])
94
kenton@google.com9824eda2009-05-06 17:49:37 +000095AS_IF([test "$with_protoc" != "no"], [
96 PROTOC=$with_protoc
97 AS_IF([test "$with_protoc" == "yes"], [
98 # No argument given. Use system protoc.
99 PROTOC=protoc
100 ])
101 AS_IF([echo "$PROTOC" | grep -q '^@<:@^/@:>@.*/'], [
102 # Does not start with a slash, but contains a slash. So, it's a relative
103 # path (as opposed to an absolute path or an executable in $PATH).
104 # Since it will actually be executed from the src directory, prefix with
105 # the current directory. We also insert $ac_top_build_prefix in case this
106 # is a nested package and --with-protoc was actually given on the outer
107 # package's configure script.
108 PROTOC=`pwd`/${ac_top_build_prefix}$PROTOC
109 ])
110 AC_SUBST([PROTOC])
111])
112AM_CONDITIONAL([USE_EXTERNAL_PROTOC], [test "$with_protoc" != "no"])
113
temporal40ee5512008-07-10 02:12:20 +0000114ACX_PTHREAD
115AC_CXX_STL_HASH
116
kenton@google.com37ad00d2009-04-21 21:00:39 +0000117AC_CONFIG_SUBDIRS([gtest])
118
kenton@google.com3c66c2e2009-08-03 21:31:25 +0000119AC_CONFIG_FILES([Makefile src/Makefile protobuf.pc protobuf-lite.pc])
kenton@google.comc76caac2008-09-30 22:11:21 +0000120AC_OUTPUT