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