blob: b10473e5d542ad6e447e5ba3a02b5df548e82af3 [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.)
15AC_INIT([Protocol Buffers],[2.0.4-pre],[protobuf@googlegroups.com],[protobuf])
temporal40ee5512008-07-10 02:12:20 +000016
kenton@google.com42c81e12009-05-06 01:15:06 +000017# Detect whether the user specified their own compilation flags. If so then
18# we want to respect their decision, otherwise we will twiddle them later.
19AS_IF([test "$CXXFLAGS" = ""],[
20 protobuf_default_cxxflags=yes
21])
22
temporal40ee5512008-07-10 02:12:20 +000023AC_CONFIG_SRCDIR(src/google/protobuf/message.cc)
kenton@google.comc76caac2008-09-30 22:11:21 +000024AC_CONFIG_HEADERS([config.h])
kenton@google.com25bc5cd2008-12-04 20:34:50 +000025AC_CONFIG_MACRO_DIR([m4])
temporal40ee5512008-07-10 02:12:20 +000026AM_INIT_AUTOMAKE
27
kenton@google.come59427a2009-04-16 22:30:56 +000028AC_ARG_WITH([zlib],
29 [AS_HELP_STRING([--with-zlib],
30 [include classes for streaming compressed data in and out @<:@default=check@:>@])],
31 [],[with_zlib=check])
32
kenton@google.com9824eda2009-05-06 17:49:37 +000033AC_ARG_WITH([protoc],
34 [AS_HELP_STRING([--with-protoc=COMMAND],
35 [use the given protoc command instead of building a new one when building tests (useful for cross-compiling)])],
36 [],[with_protoc=no])
37
temporal40ee5512008-07-10 02:12:20 +000038# Checks for programs.
39AC_PROG_CC
40AC_PROG_CXX
kenton@google.com37ad00d2009-04-21 21:00:39 +000041AC_LANG([C++])
kenton@google.com25bc5cd2008-12-04 20:34:50 +000042ACX_USE_SYSTEM_EXTENSIONS
temporal40ee5512008-07-10 02:12:20 +000043AC_PROG_LIBTOOL
44AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc
kenton@google.com25bc5cd2008-12-04 20:34:50 +000045
kenton@google.com42c81e12009-05-06 01:15:06 +000046# autoconf's default CXXFLAGS are usually "-g -O2". These aren't necessarily
47# the best choice for libprotobuf.
48AC_MSG_CHECKING([C++ compiler flags...])
49AS_IF([test "$protobuf_default_cxxflags" = "yes"],[
50
51 # test_util.cc takes forever to compile with GCC and optimization turned on.
52 # But we cannot override anything that is part of CXXFLAGS since it is the
53 # last thing added to the command line. The automake docs insist that you
54 # should never want to override CXXFLAGS because they represent the intent of
55 # the user, and the user knows best. But if the user actually did not set
56 # any CXXFLAGS, then AC_PROG_CXX sets them to a rather arbitrary default.
57 # That's not user intent at all, but automake still treats it like it is.
58 # Grr. Anyway, getting back to the point, this hack here strips out the -O
59 # flag from autoconf's defaults and puts it into another variable so that
60 # we can override it. BTW, m4 escaping sucks.
61 PROTOBUF_OPT_FLAG=`echo "$CXXFLAGS" | grep -o '\-O@<:@0-9@:>@\?'`
62 CXXFLAGS=`echo "$CXXFLAGS" | sed -e 's/ \?-O@<:@0-9@:>@\?//g'`
63
64 # Protocol Buffers contains several checks that are intended to be used only
65 # for debugging and which might hurt performance. Most users are probably
66 # end users who don't want these checks, so add -DNDEBUG by default.
67 CXXFLAGS="$CXXFLAGS -DNDEBUG"
68
69 AC_MSG_RESULT([use default: $PROTOBUF_OPT_FLAG $CXXFLAGS])
70],[
71 PROTOBUF_OPT_FLAG=
72 AC_MSG_RESULT([use user-supplied: $CXXFLAGS])
73])
74
75AC_SUBST(PROTOBUF_OPT_FLAG)
76
kenton@google.coma8923cd2009-05-01 21:53:10 +000077ACX_CHECK_SUNCC
temporal40ee5512008-07-10 02:12:20 +000078
79# Checks for header files.
80AC_HEADER_STDC
81AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stdlib.h unistd.h])
82
83# Checks for library functions.
84AC_FUNC_MEMCMP
85AC_FUNC_STRTOD
86AC_CHECK_FUNCS([ftruncate memset mkdir strchr strerror strtol])
87
kenton@google.come59427a2009-04-16 22:30:56 +000088HAVE_ZLIB=0
89AS_IF([test "$with_zlib" != no],
90 [AC_SEARCH_LIBS([zlibVersion], [z],
91 [AC_DEFINE([HAVE_ZLIB], [1], [Enable classes using zlib compression.])
92 HAVE_ZLIB=1],
93 [if test "$with_zlib" != check; then
94 AC_MSG_FAILURE([--with-zlib was given, but test for zlib failed])
95 fi])])
96AM_CONDITIONAL([HAVE_ZLIB], [test $HAVE_ZLIB = 1])
97
kenton@google.com9824eda2009-05-06 17:49:37 +000098AS_IF([test "$with_protoc" != "no"], [
99 PROTOC=$with_protoc
100 AS_IF([test "$with_protoc" == "yes"], [
101 # No argument given. Use system protoc.
102 PROTOC=protoc
103 ])
104 AS_IF([echo "$PROTOC" | grep -q '^@<:@^/@:>@.*/'], [
105 # Does not start with a slash, but contains a slash. So, it's a relative
106 # path (as opposed to an absolute path or an executable in $PATH).
107 # Since it will actually be executed from the src directory, prefix with
108 # the current directory. We also insert $ac_top_build_prefix in case this
109 # is a nested package and --with-protoc was actually given on the outer
110 # package's configure script.
111 PROTOC=`pwd`/${ac_top_build_prefix}$PROTOC
112 ])
113 AC_SUBST([PROTOC])
114])
115AM_CONDITIONAL([USE_EXTERNAL_PROTOC], [test "$with_protoc" != "no"])
116
temporal40ee5512008-07-10 02:12:20 +0000117ACX_PTHREAD
118AC_CXX_STL_HASH
119
kenton@google.com37ad00d2009-04-21 21:00:39 +0000120AC_CONFIG_SUBDIRS([gtest])
121
kenton@google.comc76caac2008-09-30 22:11:21 +0000122AC_CONFIG_FILES([Makefile src/Makefile ])
123AC_OUTPUT