blob: 7f068c31693cc76e9437507ab996817a84240c61 [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
temporal40ee5512008-07-10 02:12:20 +000033# Checks for programs.
34AC_PROG_CC
35AC_PROG_CXX
kenton@google.com37ad00d2009-04-21 21:00:39 +000036AC_LANG([C++])
kenton@google.com25bc5cd2008-12-04 20:34:50 +000037ACX_USE_SYSTEM_EXTENSIONS
temporal40ee5512008-07-10 02:12:20 +000038AC_PROG_LIBTOOL
39AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc
kenton@google.com25bc5cd2008-12-04 20:34:50 +000040
kenton@google.com42c81e12009-05-06 01:15:06 +000041# autoconf's default CXXFLAGS are usually "-g -O2". These aren't necessarily
42# the best choice for libprotobuf.
43AC_MSG_CHECKING([C++ compiler flags...])
44AS_IF([test "$protobuf_default_cxxflags" = "yes"],[
45
46 # test_util.cc takes forever to compile with GCC and optimization turned on.
47 # But we cannot override anything that is part of CXXFLAGS since it is the
48 # last thing added to the command line. The automake docs insist that you
49 # should never want to override CXXFLAGS because they represent the intent of
50 # the user, and the user knows best. But if the user actually did not set
51 # any CXXFLAGS, then AC_PROG_CXX sets them to a rather arbitrary default.
52 # That's not user intent at all, but automake still treats it like it is.
53 # Grr. Anyway, getting back to the point, this hack here strips out the -O
54 # flag from autoconf's defaults and puts it into another variable so that
55 # we can override it. BTW, m4 escaping sucks.
56 PROTOBUF_OPT_FLAG=`echo "$CXXFLAGS" | grep -o '\-O@<:@0-9@:>@\?'`
57 CXXFLAGS=`echo "$CXXFLAGS" | sed -e 's/ \?-O@<:@0-9@:>@\?//g'`
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],[
66 PROTOBUF_OPT_FLAG=
67 AC_MSG_RESULT([use user-supplied: $CXXFLAGS])
68])
69
70AC_SUBST(PROTOBUF_OPT_FLAG)
71
kenton@google.coma8923cd2009-05-01 21:53:10 +000072ACX_CHECK_SUNCC
temporal40ee5512008-07-10 02:12:20 +000073
74# Checks for header files.
75AC_HEADER_STDC
76AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stdlib.h unistd.h])
77
78# Checks for library functions.
79AC_FUNC_MEMCMP
80AC_FUNC_STRTOD
81AC_CHECK_FUNCS([ftruncate memset mkdir strchr strerror strtol])
82
kenton@google.come59427a2009-04-16 22:30:56 +000083HAVE_ZLIB=0
84AS_IF([test "$with_zlib" != no],
85 [AC_SEARCH_LIBS([zlibVersion], [z],
86 [AC_DEFINE([HAVE_ZLIB], [1], [Enable classes using zlib compression.])
87 HAVE_ZLIB=1],
88 [if test "$with_zlib" != check; then
89 AC_MSG_FAILURE([--with-zlib was given, but test for zlib failed])
90 fi])])
91AM_CONDITIONAL([HAVE_ZLIB], [test $HAVE_ZLIB = 1])
92
temporal40ee5512008-07-10 02:12:20 +000093ACX_PTHREAD
94AC_CXX_STL_HASH
95
kenton@google.com37ad00d2009-04-21 21:00:39 +000096AC_CONFIG_SUBDIRS([gtest])
97
kenton@google.comc76caac2008-09-30 22:11:21 +000098AC_CONFIG_FILES([Makefile src/Makefile ])
99AC_OUTPUT