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.) |
Jisi Liu | 40f2df3 | 2015-02-28 15:01:24 -0800 | [diff] [blame] | 15 | AC_INIT([Protocol Buffers],[3.0.0-alpha-3-pre],[protobuf@googlegroups.com],[protobuf]) |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 16 | |
liujisi@google.com | 26261eb | 2012-07-03 09:39:26 +0000 | [diff] [blame] | 17 | AM_MAINTAINER_MODE([enable]) |
kenton@google.com | 42c81e1 | 2009-05-06 01:15:06 +0000 | [diff] [blame] | 18 | |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 19 | AC_CONFIG_SRCDIR(src/google/protobuf/message.cc) |
kenton@google.com | c76caac | 2008-09-30 22:11:21 +0000 | [diff] [blame] | 20 | AC_CONFIG_HEADERS([config.h]) |
kenton@google.com | 25bc5cd | 2008-12-04 20:34:50 +0000 | [diff] [blame] | 21 | AC_CONFIG_MACRO_DIR([m4]) |
kenton@google.com | 6be265a | 2009-08-06 20:47:45 +0000 | [diff] [blame] | 22 | |
Feng Xiao | 8f7dec8 | 2014-12-02 14:15:26 -0800 | [diff] [blame] | 23 | AC_ARG_VAR(DIST_LANG, [language to include in the distribution package (i.e., make dist)]) |
| 24 | case "$DIST_LANG" in |
Feng Xiao | 6936f17 | 2014-12-03 17:37:42 -0800 | [diff] [blame] | 25 | "") DIST_LANG=all ;; |
Chris Fallin | 973f425 | 2014-11-18 14:19:58 -0800 | [diff] [blame] | 26 | all | cpp | java | python | javanano | ruby) ;; |
Feng Xiao | 8f7dec8 | 2014-12-02 14:15:26 -0800 | [diff] [blame] | 27 | *) AC_MSG_FAILURE([unknown language: $DIST_LANG]) ;; |
| 28 | esac |
| 29 | AC_SUBST(DIST_LANG) |
| 30 | |
kenton@google.com | 6be265a | 2009-08-06 20:47:45 +0000 | [diff] [blame] | 31 | # autoconf's default CXXFLAGS are usually "-g -O2". These aren't necessarily |
| 32 | # the best choice for libprotobuf. |
| 33 | AS_IF([test "x${ac_cv_env_CFLAGS_set}" = "x"], |
| 34 | [CFLAGS=""]) |
| 35 | AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"], |
| 36 | [CXXFLAGS=""]) |
kenton@google.com | 445f102 | 2009-08-06 23:01:43 +0000 | [diff] [blame] | 37 | |
kenton@google.com | 6be265a | 2009-08-06 20:47:45 +0000 | [diff] [blame] | 38 | AC_CANONICAL_TARGET |
| 39 | |
Jisi Liu | ff35de3 | 2015-02-21 14:58:02 -0800 | [diff] [blame] | 40 | AM_INIT_AUTOMAKE([1.9 tar-ustar subdir-objects]) |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 41 | |
kenton@google.com | e59427a | 2009-04-16 22:30:56 +0000 | [diff] [blame] | 42 | AC_ARG_WITH([zlib], |
| 43 | [AS_HELP_STRING([--with-zlib], |
| 44 | [include classes for streaming compressed data in and out @<:@default=check@:>@])], |
| 45 | [],[with_zlib=check]) |
| 46 | |
kenton@google.com | 9824eda | 2009-05-06 17:49:37 +0000 | [diff] [blame] | 47 | AC_ARG_WITH([protoc], |
| 48 | [AS_HELP_STRING([--with-protoc=COMMAND], |
| 49 | [use the given protoc command instead of building a new one when building tests (useful for cross-compiling)])], |
| 50 | [],[with_protoc=no]) |
| 51 | |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 52 | # Checks for programs. |
| 53 | AC_PROG_CC |
| 54 | AC_PROG_CXX |
kenton@google.com | 37ad00d | 2009-04-21 21:00:39 +0000 | [diff] [blame] | 55 | AC_LANG([C++]) |
kenton@google.com | 25bc5cd | 2008-12-04 20:34:50 +0000 | [diff] [blame] | 56 | ACX_USE_SYSTEM_EXTENSIONS |
Josh Haberman | cb3caf1 | 2015-02-17 18:23:41 -0800 | [diff] [blame] | 57 | m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 58 | 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] | 59 | |
kenton@google.com | 6be265a | 2009-08-06 20:47:45 +0000 | [diff] [blame] | 60 | # test_util.cc takes forever to compile with GCC and optimization turned on. |
kenton@google.com | 42c81e1 | 2009-05-06 01:15:06 +0000 | [diff] [blame] | 61 | AC_MSG_CHECKING([C++ compiler flags...]) |
kenton@google.com | 6be265a | 2009-08-06 20:47:45 +0000 | [diff] [blame] | 62 | AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],[ |
| 63 | AS_IF([test "$GCC" = "yes"],[ |
| 64 | PROTOBUF_OPT_FLAG="-O2" |
| 65 | CXXFLAGS="${CXXFLAGS} -g" |
| 66 | ]) |
kenton@google.com | 42c81e1 | 2009-05-06 01:15:06 +0000 | [diff] [blame] | 67 | |
| 68 | # Protocol Buffers contains several checks that are intended to be used only |
| 69 | # for debugging and which might hurt performance. Most users are probably |
| 70 | # end users who don't want these checks, so add -DNDEBUG by default. |
| 71 | CXXFLAGS="$CXXFLAGS -DNDEBUG" |
| 72 | |
| 73 | AC_MSG_RESULT([use default: $PROTOBUF_OPT_FLAG $CXXFLAGS]) |
| 74 | ],[ |
kenton@google.com | 42c81e1 | 2009-05-06 01:15:06 +0000 | [diff] [blame] | 75 | AC_MSG_RESULT([use user-supplied: $CXXFLAGS]) |
| 76 | ]) |
| 77 | |
| 78 | AC_SUBST(PROTOBUF_OPT_FLAG) |
| 79 | |
kenton@google.com | a8923cd | 2009-05-01 21:53:10 +0000 | [diff] [blame] | 80 | ACX_CHECK_SUNCC |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 81 | |
kenton@google.com | 445f102 | 2009-08-06 23:01:43 +0000 | [diff] [blame] | 82 | # Have to do libtool after SUNCC, other wise it "helpfully" adds Crun Cstd |
kenton@google.com | 6be265a | 2009-08-06 20:47:45 +0000 | [diff] [blame] | 83 | # to the link |
| 84 | AC_PROG_LIBTOOL |
| 85 | |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 86 | # Checks for header files. |
| 87 | AC_HEADER_STDC |
| 88 | AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stdlib.h unistd.h]) |
| 89 | |
| 90 | # Checks for library functions. |
| 91 | AC_FUNC_MEMCMP |
| 92 | AC_FUNC_STRTOD |
| 93 | AC_CHECK_FUNCS([ftruncate memset mkdir strchr strerror strtol]) |
| 94 | |
kenton@google.com | 32f330f | 2009-09-15 17:15:43 +0000 | [diff] [blame] | 95 | # Check for zlib. |
kenton@google.com | e59427a | 2009-04-16 22:30:56 +0000 | [diff] [blame] | 96 | HAVE_ZLIB=0 |
kenton@google.com | 32f330f | 2009-09-15 17:15:43 +0000 | [diff] [blame] | 97 | AS_IF([test "$with_zlib" != no], [ |
| 98 | AC_MSG_CHECKING([zlib version]) |
| 99 | |
| 100 | # First check the zlib header version. |
| 101 | AC_COMPILE_IFELSE( |
liujisi@google.com | 8cc2017 | 2012-12-05 00:55:16 +0000 | [diff] [blame] | 102 | [AC_LANG_PROGRAM([[ |
kenton@google.com | 32f330f | 2009-09-15 17:15:43 +0000 | [diff] [blame] | 103 | #include <zlib.h> |
| 104 | #if !defined(ZLIB_VERNUM) || (ZLIB_VERNUM < 0x1204) |
| 105 | # error zlib version too old |
| 106 | #endif |
liujisi@google.com | 8cc2017 | 2012-12-05 00:55:16 +0000 | [diff] [blame] | 107 | ]], [])], [ |
kenton@google.com | 32f330f | 2009-09-15 17:15:43 +0000 | [diff] [blame] | 108 | AC_MSG_RESULT([ok (1.2.0.4 or later)]) |
| 109 | |
| 110 | # Also need to add -lz to the linker flags and make sure this succeeds. |
| 111 | AC_SEARCH_LIBS([zlibVersion], [z], [ |
| 112 | AC_DEFINE([HAVE_ZLIB], [1], [Enable classes using zlib compression.]) |
| 113 | HAVE_ZLIB=1 |
| 114 | ], [ |
| 115 | AS_IF([test "$with_zlib" != check], [ |
| 116 | AC_MSG_FAILURE([--with-zlib was given, but no working zlib library was found]) |
| 117 | ]) |
| 118 | ]) |
| 119 | ], [ |
| 120 | AS_IF([test "$with_zlib" = check], [ |
| 121 | AC_MSG_RESULT([headers missing or too old (requires 1.2.0.4)]) |
| 122 | ], [ |
| 123 | AC_MSG_FAILURE([--with-zlib was given, but zlib headers were not present or were too old (requires 1.2.0.4)]) |
| 124 | ]) |
| 125 | ]) |
| 126 | ]) |
kenton@google.com | e59427a | 2009-04-16 22:30:56 +0000 | [diff] [blame] | 127 | AM_CONDITIONAL([HAVE_ZLIB], [test $HAVE_ZLIB = 1]) |
| 128 | |
kenton@google.com | 9824eda | 2009-05-06 17:49:37 +0000 | [diff] [blame] | 129 | AS_IF([test "$with_protoc" != "no"], [ |
| 130 | PROTOC=$with_protoc |
liujisi@google.com | 5d8d2b0 | 2010-12-06 06:20:14 +0000 | [diff] [blame] | 131 | AS_IF([test "$with_protoc" = "yes"], [ |
kenton@google.com | 9824eda | 2009-05-06 17:49:37 +0000 | [diff] [blame] | 132 | # No argument given. Use system protoc. |
| 133 | PROTOC=protoc |
| 134 | ]) |
| 135 | AS_IF([echo "$PROTOC" | grep -q '^@<:@^/@:>@.*/'], [ |
| 136 | # Does not start with a slash, but contains a slash. So, it's a relative |
| 137 | # path (as opposed to an absolute path or an executable in $PATH). |
| 138 | # Since it will actually be executed from the src directory, prefix with |
| 139 | # the current directory. We also insert $ac_top_build_prefix in case this |
| 140 | # is a nested package and --with-protoc was actually given on the outer |
| 141 | # package's configure script. |
| 142 | PROTOC=`pwd`/${ac_top_build_prefix}$PROTOC |
| 143 | ]) |
| 144 | AC_SUBST([PROTOC]) |
| 145 | ]) |
| 146 | AM_CONDITIONAL([USE_EXTERNAL_PROTOC], [test "$with_protoc" != "no"]) |
| 147 | |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 148 | ACX_PTHREAD |
| 149 | AC_CXX_STL_HASH |
| 150 | |
William Orr | 20e0a61 | 2014-10-10 22:50:39 -0700 | [diff] [blame] | 151 | case "$target_os" in |
| 152 | mingw* | cygwin* | win*) |
| 153 | ;; |
| 154 | *) |
| 155 | # Need to link against rt on Solaris |
| 156 | AC_SEARCH_LIBS([sched_yield], [rt], [], [AC_MSG_FAILURE([sched_yield was not found on your system])]) |
| 157 | ;; |
| 158 | esac |
William Orr | 38b8494 | 2014-09-19 21:54:27 -0700 | [diff] [blame] | 159 | |
kenton@google.com | 45258ff | 2009-12-23 22:12:22 +0000 | [diff] [blame] | 160 | # HACK: Make gtest's configure script pick up our copy of CFLAGS and CXXFLAGS, |
| 161 | # since the flags added by ACX_CHECK_SUNCC must be used when compiling gtest |
| 162 | # too. |
| 163 | export CFLAGS |
kenton@google.com | 304b731 | 2009-08-10 23:52:27 +0000 | [diff] [blame] | 164 | export CXXFLAGS |
kenton@google.com | 37ad00d | 2009-04-21 21:00:39 +0000 | [diff] [blame] | 165 | AC_CONFIG_SUBDIRS([gtest]) |
| 166 | |
Josh Haberman | 35a1cc7 | 2015-04-01 17:23:48 -0700 | [diff] [blame] | 167 | AC_CONFIG_FILES([Makefile src/Makefile conformance/Makefile protobuf.pc protobuf-lite.pc]) |
kenton@google.com | c76caac | 2008-09-30 22:11:21 +0000 | [diff] [blame] | 168 | AC_OUTPUT |