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: |
Walter Gray | 61c9696 | 2016-05-28 01:04:26 -0700 | [diff] [blame] | 7 | # * Protobuf.podspec |
| 8 | # * csharp/Google.Protobuf.Tools.nuspec |
| 9 | # * csharp/src/*/AssemblyInfo.cs |
| 10 | # * csharp/src/Google.Protobuf/Google.Protobuf.nuspec |
| 11 | # * java/*/pom.xml |
| 12 | # * python/google/protobuf/__init__.py |
| 13 | # * protoc-artifacts/pom.xml |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 14 | # * src/google/protobuf/stubs/common.h |
kenton@google.com | a001ed0 | 2008-12-01 23:47:49 +0000 | [diff] [blame] | 15 | # * src/Makefile.am (Update -version-info for LDFLAGS if needed) |
kenton@google.com | 37ad00d | 2009-04-21 21:00:39 +0000 | [diff] [blame] | 16 | # |
| 17 | # In the SVN trunk, the version should always be the next anticipated release |
| 18 | # version with the "-pre" suffix. (We used to use "-SNAPSHOT" but this pushed |
| 19 | # the size of one file name in the dist tarfile over the 99-char limit.) |
Adam Cozzette | 9e1286b | 2018-07-27 10:54:14 -0700 | [diff] [blame] | 20 | AC_INIT([Protocol Buffers],[3.6.1],[protobuf@googlegroups.com],[protobuf]) |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 21 | |
liujisi@google.com | 26261eb | 2012-07-03 09:39:26 +0000 | [diff] [blame] | 22 | AM_MAINTAINER_MODE([enable]) |
kenton@google.com | 42c81e1 | 2009-05-06 01:15:06 +0000 | [diff] [blame] | 23 | |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 24 | AC_CONFIG_SRCDIR(src/google/protobuf/message.cc) |
Jisi Liu | 78d470c | 2015-06-12 15:49:21 -0700 | [diff] [blame] | 25 | # The config file is generated but not used by the source code, since we only |
| 26 | # need very few of them, e.g. HAVE_PTHREAD and HAVE_ZLIB. Those macros are |
| 27 | # passed down in CXXFLAGS manually in src/Makefile.am |
kenton@google.com | c76caac | 2008-09-30 22:11:21 +0000 | [diff] [blame] | 28 | AC_CONFIG_HEADERS([config.h]) |
kenton@google.com | 25bc5cd | 2008-12-04 20:34:50 +0000 | [diff] [blame] | 29 | AC_CONFIG_MACRO_DIR([m4]) |
kenton@google.com | 6be265a | 2009-08-06 20:47:45 +0000 | [diff] [blame] | 30 | |
Feng Xiao | 8f7dec8 | 2014-12-02 14:15:26 -0800 | [diff] [blame] | 31 | AC_ARG_VAR(DIST_LANG, [language to include in the distribution package (i.e., make dist)]) |
| 32 | case "$DIST_LANG" in |
Feng Xiao | 6936f17 | 2014-12-03 17:37:42 -0800 | [diff] [blame] | 33 | "") DIST_LANG=all ;; |
Bo Yang | e0a6e52 | 2016-09-23 18:37:37 -0700 | [diff] [blame] | 34 | all | cpp | csharp | java | python | javanano | objectivec | ruby | js | php) ;; |
Feng Xiao | 8f7dec8 | 2014-12-02 14:15:26 -0800 | [diff] [blame] | 35 | *) AC_MSG_FAILURE([unknown language: $DIST_LANG]) ;; |
| 36 | esac |
| 37 | AC_SUBST(DIST_LANG) |
| 38 | |
kenton@google.com | 6be265a | 2009-08-06 20:47:45 +0000 | [diff] [blame] | 39 | # autoconf's default CXXFLAGS are usually "-g -O2". These aren't necessarily |
| 40 | # the best choice for libprotobuf. |
| 41 | AS_IF([test "x${ac_cv_env_CFLAGS_set}" = "x"], |
| 42 | [CFLAGS=""]) |
| 43 | AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"], |
| 44 | [CXXFLAGS=""]) |
kenton@google.com | 445f102 | 2009-08-06 23:01:43 +0000 | [diff] [blame] | 45 | |
kenton@google.com | 6be265a | 2009-08-06 20:47:45 +0000 | [diff] [blame] | 46 | AC_CANONICAL_TARGET |
| 47 | |
Jisi Liu | ff35de3 | 2015-02-21 14:58:02 -0800 | [diff] [blame] | 48 | AM_INIT_AUTOMAKE([1.9 tar-ustar subdir-objects]) |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 49 | |
kenton@google.com | e59427a | 2009-04-16 22:30:56 +0000 | [diff] [blame] | 50 | AC_ARG_WITH([zlib], |
| 51 | [AS_HELP_STRING([--with-zlib], |
| 52 | [include classes for streaming compressed data in and out @<:@default=check@:>@])], |
| 53 | [],[with_zlib=check]) |
| 54 | |
Xiaoshuang LU | 8ff2284 | 2017-07-25 19:28:30 +0800 | [diff] [blame] | 55 | AC_ARG_WITH([zlib-include], |
| 56 | [AS_HELP_STRING([--with-zlib-include=PATH], |
| 57 | [zlib include directory])], |
| 58 | [CPPFLAGS="-I$withval $CPPFLAGS"]) |
| 59 | |
| 60 | AC_ARG_WITH([zlib-lib], |
| 61 | [AS_HELP_STRING([--with-zlib-lib=PATH], |
| 62 | [zlib lib directory])], |
| 63 | [LDFLAGS="-L$withval $LDFLAGS"]) |
| 64 | |
kenton@google.com | 9824eda | 2009-05-06 17:49:37 +0000 | [diff] [blame] | 65 | AC_ARG_WITH([protoc], |
| 66 | [AS_HELP_STRING([--with-protoc=COMMAND], |
| 67 | [use the given protoc command instead of building a new one when building tests (useful for cross-compiling)])], |
| 68 | [],[with_protoc=no]) |
| 69 | |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 70 | # Checks for programs. |
| 71 | AC_PROG_CC |
| 72 | AC_PROG_CXX |
Adam Cozzette | b40d318 | 2017-01-03 13:07:21 -0800 | [diff] [blame] | 73 | AC_PROG_CXX_FOR_BUILD |
kenton@google.com | 37ad00d | 2009-04-21 21:00:39 +0000 | [diff] [blame] | 74 | AC_LANG([C++]) |
kenton@google.com | 25bc5cd | 2008-12-04 20:34:50 +0000 | [diff] [blame] | 75 | ACX_USE_SYSTEM_EXTENSIONS |
Josh Haberman | cb3caf1 | 2015-02-17 18:23:41 -0800 | [diff] [blame] | 76 | m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 77 | AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc |
Thomas Van Lenten | 1745f7e | 2015-11-17 10:18:49 -0500 | [diff] [blame] | 78 | AC_PROG_OBJC |
kenton@google.com | 25bc5cd | 2008-12-04 20:34:50 +0000 | [diff] [blame] | 79 | |
kenton@google.com | 6be265a | 2009-08-06 20:47:45 +0000 | [diff] [blame] | 80 | # 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] | 81 | AC_MSG_CHECKING([C++ compiler flags...]) |
kenton@google.com | 6be265a | 2009-08-06 20:47:45 +0000 | [diff] [blame] | 82 | AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],[ |
| 83 | AS_IF([test "$GCC" = "yes"],[ |
| 84 | PROTOBUF_OPT_FLAG="-O2" |
| 85 | CXXFLAGS="${CXXFLAGS} -g" |
| 86 | ]) |
kenton@google.com | 42c81e1 | 2009-05-06 01:15:06 +0000 | [diff] [blame] | 87 | |
| 88 | # Protocol Buffers contains several checks that are intended to be used only |
| 89 | # for debugging and which might hurt performance. Most users are probably |
| 90 | # end users who don't want these checks, so add -DNDEBUG by default. |
Adam Cozzette | 5f418d4 | 2018-05-31 10:07:28 -0700 | [diff] [blame] | 91 | CXXFLAGS="$CXXFLAGS -std=c++11 -DNDEBUG" |
kenton@google.com | 42c81e1 | 2009-05-06 01:15:06 +0000 | [diff] [blame] | 92 | |
| 93 | AC_MSG_RESULT([use default: $PROTOBUF_OPT_FLAG $CXXFLAGS]) |
| 94 | ],[ |
kenton@google.com | 42c81e1 | 2009-05-06 01:15:06 +0000 | [diff] [blame] | 95 | AC_MSG_RESULT([use user-supplied: $CXXFLAGS]) |
| 96 | ]) |
| 97 | |
| 98 | AC_SUBST(PROTOBUF_OPT_FLAG) |
| 99 | |
kenton@google.com | a8923cd | 2009-05-01 21:53:10 +0000 | [diff] [blame] | 100 | ACX_CHECK_SUNCC |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 101 | |
kenton@google.com | 445f102 | 2009-08-06 23:01:43 +0000 | [diff] [blame] | 102 | # 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] | 103 | # to the link |
| 104 | AC_PROG_LIBTOOL |
| 105 | |
Alexandros Frantzis | 13d165d | 2017-03-10 14:25:27 +0200 | [diff] [blame] | 106 | # Check whether the linker supports version scripts |
| 107 | AC_MSG_CHECKING([whether the linker supports version scripts]) |
| 108 | save_LDFLAGS=$LDFLAGS |
| 109 | LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map" |
| 110 | cat > conftest.map <<EOF |
| 111 | { |
| 112 | global: |
| 113 | main; |
| 114 | local: |
| 115 | *; |
| 116 | }; |
| 117 | EOF |
| 118 | AC_LINK_IFELSE( |
| 119 | [AC_LANG_SOURCE([int main() { return 0; }])], |
| 120 | [have_ld_version_script=yes; AC_MSG_RESULT(yes)], |
| 121 | [have_ld_version_script=no; AC_MSG_RESULT(no)]) |
| 122 | LDFLAGS=$save_LDFLAGS |
| 123 | AM_CONDITIONAL([HAVE_LD_VERSION_SCRIPT], [test "$have_ld_version_script" == "yes"]) |
| 124 | |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 125 | # Checks for header files. |
| 126 | AC_HEADER_STDC |
| 127 | AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stdlib.h unistd.h]) |
| 128 | |
| 129 | # Checks for library functions. |
| 130 | AC_FUNC_MEMCMP |
| 131 | AC_FUNC_STRTOD |
| 132 | AC_CHECK_FUNCS([ftruncate memset mkdir strchr strerror strtol]) |
| 133 | |
kenton@google.com | 32f330f | 2009-09-15 17:15:43 +0000 | [diff] [blame] | 134 | # Check for zlib. |
kenton@google.com | e59427a | 2009-04-16 22:30:56 +0000 | [diff] [blame] | 135 | HAVE_ZLIB=0 |
kenton@google.com | 32f330f | 2009-09-15 17:15:43 +0000 | [diff] [blame] | 136 | AS_IF([test "$with_zlib" != no], [ |
| 137 | AC_MSG_CHECKING([zlib version]) |
| 138 | |
| 139 | # First check the zlib header version. |
| 140 | AC_COMPILE_IFELSE( |
liujisi@google.com | 8cc2017 | 2012-12-05 00:55:16 +0000 | [diff] [blame] | 141 | [AC_LANG_PROGRAM([[ |
kenton@google.com | 32f330f | 2009-09-15 17:15:43 +0000 | [diff] [blame] | 142 | #include <zlib.h> |
| 143 | #if !defined(ZLIB_VERNUM) || (ZLIB_VERNUM < 0x1204) |
| 144 | # error zlib version too old |
| 145 | #endif |
liujisi@google.com | 8cc2017 | 2012-12-05 00:55:16 +0000 | [diff] [blame] | 146 | ]], [])], [ |
kenton@google.com | 32f330f | 2009-09-15 17:15:43 +0000 | [diff] [blame] | 147 | AC_MSG_RESULT([ok (1.2.0.4 or later)]) |
| 148 | |
| 149 | # Also need to add -lz to the linker flags and make sure this succeeds. |
| 150 | AC_SEARCH_LIBS([zlibVersion], [z], [ |
| 151 | AC_DEFINE([HAVE_ZLIB], [1], [Enable classes using zlib compression.]) |
| 152 | HAVE_ZLIB=1 |
| 153 | ], [ |
| 154 | AS_IF([test "$with_zlib" != check], [ |
| 155 | AC_MSG_FAILURE([--with-zlib was given, but no working zlib library was found]) |
| 156 | ]) |
| 157 | ]) |
| 158 | ], [ |
| 159 | AS_IF([test "$with_zlib" = check], [ |
| 160 | AC_MSG_RESULT([headers missing or too old (requires 1.2.0.4)]) |
| 161 | ], [ |
| 162 | AC_MSG_FAILURE([--with-zlib was given, but zlib headers were not present or were too old (requires 1.2.0.4)]) |
| 163 | ]) |
| 164 | ]) |
| 165 | ]) |
kenton@google.com | e59427a | 2009-04-16 22:30:56 +0000 | [diff] [blame] | 166 | AM_CONDITIONAL([HAVE_ZLIB], [test $HAVE_ZLIB = 1]) |
| 167 | |
Ben Wolsieffer | 56b40a8 | 2018-10-04 20:25:10 -0400 | [diff] [blame] | 168 | dnl On some platforms, std::atomic needs a helper library |
| 169 | AC_MSG_CHECKING(whether -latomic is needed) |
| 170 | AC_LINK_IFELSE([AC_LANG_SOURCE([[ |
| 171 | #include <atomic> |
| 172 | #include <cstdint> |
| 173 | std::atomic<std::int64_t> v; |
| 174 | int main() { |
| 175 | return v; |
| 176 | } |
| 177 | ]])], STD_ATOMIC_NEED_LIBATOMIC=no, STD_ATOMIC_NEED_LIBATOMIC=yes) |
| 178 | AC_MSG_RESULT($STD_ATOMIC_NEED_LIBATOMIC) |
| 179 | if test "x$STD_ATOMIC_NEED_LIBATOMIC" = xyes; then |
| 180 | LIBATOMIC_LIBS="-latomic" |
| 181 | fi |
| 182 | AC_SUBST([LIBATOMIC_LIBS]) |
| 183 | |
kenton@google.com | 9824eda | 2009-05-06 17:49:37 +0000 | [diff] [blame] | 184 | AS_IF([test "$with_protoc" != "no"], [ |
| 185 | PROTOC=$with_protoc |
liujisi@google.com | 5d8d2b0 | 2010-12-06 06:20:14 +0000 | [diff] [blame] | 186 | AS_IF([test "$with_protoc" = "yes"], [ |
kenton@google.com | 9824eda | 2009-05-06 17:49:37 +0000 | [diff] [blame] | 187 | # No argument given. Use system protoc. |
| 188 | PROTOC=protoc |
| 189 | ]) |
| 190 | AS_IF([echo "$PROTOC" | grep -q '^@<:@^/@:>@.*/'], [ |
| 191 | # Does not start with a slash, but contains a slash. So, it's a relative |
| 192 | # path (as opposed to an absolute path or an executable in $PATH). |
| 193 | # Since it will actually be executed from the src directory, prefix with |
| 194 | # the current directory. We also insert $ac_top_build_prefix in case this |
| 195 | # is a nested package and --with-protoc was actually given on the outer |
| 196 | # package's configure script. |
| 197 | PROTOC=`pwd`/${ac_top_build_prefix}$PROTOC |
| 198 | ]) |
| 199 | AC_SUBST([PROTOC]) |
| 200 | ]) |
| 201 | AM_CONDITIONAL([USE_EXTERNAL_PROTOC], [test "$with_protoc" != "no"]) |
| 202 | |
john hood | cab5eae | 2016-03-18 23:56:51 +0000 | [diff] [blame] | 203 | AX_PTHREAD |
| 204 | AM_CONDITIONAL([HAVE_PTHREAD], [test "x$ax_pthread_ok" = "xyes"]) |
Jisi Liu | 78d470c | 2015-06-12 15:49:21 -0700 | [diff] [blame] | 205 | # We still keep this for improving pbconfig.h for unsupported platforms. |
temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame] | 206 | AC_CXX_STL_HASH |
| 207 | |
William Orr | 20e0a61 | 2014-10-10 22:50:39 -0700 | [diff] [blame] | 208 | case "$target_os" in |
James Moore | c92b4e1 | 2018-05-16 12:08:04 -0700 | [diff] [blame] | 209 | mingw* | cygwin* | win* | aix* | *android* ) |
William Orr | 20e0a61 | 2014-10-10 22:50:39 -0700 | [diff] [blame] | 210 | ;; |
| 211 | *) |
| 212 | # Need to link against rt on Solaris |
| 213 | AC_SEARCH_LIBS([sched_yield], [rt], [], [AC_MSG_FAILURE([sched_yield was not found on your system])]) |
| 214 | ;; |
| 215 | esac |
William Orr | 38b8494 | 2014-09-19 21:54:27 -0700 | [diff] [blame] | 216 | |
Thomas Van Lenten | 1745f7e | 2015-11-17 10:18:49 -0500 | [diff] [blame] | 217 | # Enable ObjC support for conformance directory on OS X. |
| 218 | OBJC_CONFORMANCE_TEST=0 |
| 219 | case "$target_os" in |
| 220 | darwin*) |
| 221 | OBJC_CONFORMANCE_TEST=1 |
| 222 | ;; |
| 223 | esac |
| 224 | AM_CONDITIONAL([OBJC_CONFORMANCE_TEST], [test $OBJC_CONFORMANCE_TEST = 1]) |
| 225 | |
Adam Cozzette | 5f418d4 | 2018-05-31 10:07:28 -0700 | [diff] [blame] | 226 | AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory]) |
Sergio Campama | 1d91c25 | 2016-12-07 17:53:17 -0500 | [diff] [blame] | 227 | |
Feng Xiao | e96ff30 | 2015-06-15 18:21:48 -0700 | [diff] [blame] | 228 | # HACK: Make gmock's configure script pick up our copy of CFLAGS and CXXFLAGS, |
| 229 | # since the flags added by ACX_CHECK_SUNCC must be used when compiling gmock |
kenton@google.com | 45258ff | 2009-12-23 22:12:22 +0000 | [diff] [blame] | 230 | # too. |
| 231 | export CFLAGS |
kenton@google.com | 304b731 | 2009-08-10 23:52:27 +0000 | [diff] [blame] | 232 | export CXXFLAGS |
Carlos O'Ryan | 3c5442a | 2018-03-26 16:54:32 -0400 | [diff] [blame] | 233 | AC_CONFIG_SUBDIRS([third_party/googletest]) |
kenton@google.com | 37ad00d | 2009-04-21 21:00:39 +0000 | [diff] [blame] | 234 | |
Josh Haberman | 2e83110 | 2016-04-27 18:22:22 -0700 | [diff] [blame] | 235 | AC_CONFIG_FILES([Makefile src/Makefile benchmarks/Makefile conformance/Makefile protobuf.pc protobuf-lite.pc]) |
kenton@google.com | c76caac | 2008-09-30 22:11:21 +0000 | [diff] [blame] | 236 | AC_OUTPUT |