temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 1 | ## Process this file with autoconf to produce configure. |
| 2 | ## In general, the safest way to proceed is to run ./autogen.sh |
| 3 | |
| 4 | AC_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.com | a001ed0 | 2008-12-01 23:47:49 +0000 | [diff] [blame] | 10 | # * src/Makefile.am (Update -version-info for LDFLAGS if needed) |
kenton@google.com | 37ad00d | 2009-04-21 21:00:39 +0000 | [diff] [blame] | 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.) |
| 15 | AC_INIT([Protocol Buffers],[2.0.4-pre],[protobuf@googlegroups.com],[protobuf]) |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 16 | |
kenton@google.com | 42c81e1 | 2009-05-06 01:15:06 +0000 | [diff] [blame^] | 17 | # 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. |
| 19 | AS_IF([test "$CXXFLAGS" = ""],[ |
| 20 | protobuf_default_cxxflags=yes |
| 21 | ]) |
| 22 | |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 23 | AC_CONFIG_SRCDIR(src/google/protobuf/message.cc) |
kenton@google.com | c76caac | 2008-09-30 22:11:21 +0000 | [diff] [blame] | 24 | AC_CONFIG_HEADERS([config.h]) |
kenton@google.com | 25bc5cd | 2008-12-04 20:34:50 +0000 | [diff] [blame] | 25 | AC_CONFIG_MACRO_DIR([m4]) |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 26 | AM_INIT_AUTOMAKE |
| 27 | |
kenton@google.com | e59427a | 2009-04-16 22:30:56 +0000 | [diff] [blame] | 28 | AC_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 | |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 33 | # Checks for programs. |
| 34 | AC_PROG_CC |
| 35 | AC_PROG_CXX |
kenton@google.com | 37ad00d | 2009-04-21 21:00:39 +0000 | [diff] [blame] | 36 | AC_LANG([C++]) |
kenton@google.com | 25bc5cd | 2008-12-04 20:34:50 +0000 | [diff] [blame] | 37 | ACX_USE_SYSTEM_EXTENSIONS |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 38 | AC_PROG_LIBTOOL |
| 39 | AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc |
kenton@google.com | 25bc5cd | 2008-12-04 20:34:50 +0000 | [diff] [blame] | 40 | |
kenton@google.com | 42c81e1 | 2009-05-06 01:15:06 +0000 | [diff] [blame^] | 41 | # autoconf's default CXXFLAGS are usually "-g -O2". These aren't necessarily |
| 42 | # the best choice for libprotobuf. |
| 43 | AC_MSG_CHECKING([C++ compiler flags...]) |
| 44 | AS_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 | |
| 70 | AC_SUBST(PROTOBUF_OPT_FLAG) |
| 71 | |
kenton@google.com | a8923cd | 2009-05-01 21:53:10 +0000 | [diff] [blame] | 72 | ACX_CHECK_SUNCC |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 73 | |
| 74 | # Checks for header files. |
| 75 | AC_HEADER_STDC |
| 76 | AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stdlib.h unistd.h]) |
| 77 | |
| 78 | # Checks for library functions. |
| 79 | AC_FUNC_MEMCMP |
| 80 | AC_FUNC_STRTOD |
| 81 | AC_CHECK_FUNCS([ftruncate memset mkdir strchr strerror strtol]) |
| 82 | |
kenton@google.com | e59427a | 2009-04-16 22:30:56 +0000 | [diff] [blame] | 83 | HAVE_ZLIB=0 |
| 84 | AS_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])]) |
| 91 | AM_CONDITIONAL([HAVE_ZLIB], [test $HAVE_ZLIB = 1]) |
| 92 | |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 93 | ACX_PTHREAD |
| 94 | AC_CXX_STL_HASH |
| 95 | |
kenton@google.com | 37ad00d | 2009-04-21 21:00:39 +0000 | [diff] [blame] | 96 | AC_CONFIG_SUBDIRS([gtest]) |
| 97 | |
kenton@google.com | c76caac | 2008-09-30 22:11:21 +0000 | [diff] [blame] | 98 | AC_CONFIG_FILES([Makefile src/Makefile ]) |
| 99 | AC_OUTPUT |