blob: b94fe1006a7f7257e9ec609c1cc7cb926a92b67b [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:
Walter Gray61c96962016-05-28 01:04:26 -07007# * 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
temporal40ee5512008-07-10 02:12:20 +000014# * src/google/protobuf/stubs/common.h
kenton@google.coma001ed02008-12-01 23:47:49 +000015# * src/Makefile.am (Update -version-info for LDFLAGS if needed)
kenton@google.com37ad00d2009-04-21 21:00:39 +000016#
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.)
Joshua Habermanf597a242020-05-12 12:49:46 -070020AC_INIT([Protocol Buffers],[3.12.0-rc-2],[protobuf@googlegroups.com],[protobuf])
temporal40ee5512008-07-10 02:12:20 +000021
liujisi@google.com26261eb2012-07-03 09:39:26 +000022AM_MAINTAINER_MODE([enable])
kenton@google.com42c81e12009-05-06 01:15:06 +000023
temporal40ee5512008-07-10 02:12:20 +000024AC_CONFIG_SRCDIR(src/google/protobuf/message.cc)
Jisi Liu78d470c2015-06-12 15:49:21 -070025# 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.comc76caac2008-09-30 22:11:21 +000028AC_CONFIG_HEADERS([config.h])
kenton@google.com25bc5cd2008-12-04 20:34:50 +000029AC_CONFIG_MACRO_DIR([m4])
kenton@google.com6be265a2009-08-06 20:47:45 +000030
Feng Xiao8f7dec82014-12-02 14:15:26 -080031AC_ARG_VAR(DIST_LANG, [language to include in the distribution package (i.e., make dist)])
32case "$DIST_LANG" in
Feng Xiao6936f172014-12-03 17:37:42 -080033 "") DIST_LANG=all ;;
Bo Yange0a6e522016-09-23 18:37:37 -070034 all | cpp | csharp | java | python | javanano | objectivec | ruby | js | php) ;;
Feng Xiao8f7dec82014-12-02 14:15:26 -080035 *) AC_MSG_FAILURE([unknown language: $DIST_LANG]) ;;
36esac
37AC_SUBST(DIST_LANG)
38
kenton@google.com6be265a2009-08-06 20:47:45 +000039# autoconf's default CXXFLAGS are usually "-g -O2". These aren't necessarily
40# the best choice for libprotobuf.
41AS_IF([test "x${ac_cv_env_CFLAGS_set}" = "x"],
42 [CFLAGS=""])
43AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],
44 [CXXFLAGS=""])
kenton@google.com445f1022009-08-06 23:01:43 +000045
kenton@google.com6be265a2009-08-06 20:47:45 +000046AC_CANONICAL_TARGET
47
Jisi Liuff35de32015-02-21 14:58:02 -080048AM_INIT_AUTOMAKE([1.9 tar-ustar subdir-objects])
temporal40ee5512008-07-10 02:12:20 +000049
Hao Nguyenf158dfe2019-06-10 16:49:58 -070050# Silent rules enabled: the output is minimal but informative.
51# In particular, the warnings from the compiler stick out very clearly.
52# To see all logs, use the --disable-silent-rules on configure or via make V=1
53AM_SILENT_RULES([yes])
54
kenton@google.come59427a2009-04-16 22:30:56 +000055AC_ARG_WITH([zlib],
56 [AS_HELP_STRING([--with-zlib],
57 [include classes for streaming compressed data in and out @<:@default=check@:>@])],
58 [],[with_zlib=check])
59
Xiaoshuang LU8ff22842017-07-25 19:28:30 +080060AC_ARG_WITH([zlib-include],
61 [AS_HELP_STRING([--with-zlib-include=PATH],
62 [zlib include directory])],
63 [CPPFLAGS="-I$withval $CPPFLAGS"])
64
65AC_ARG_WITH([zlib-lib],
66 [AS_HELP_STRING([--with-zlib-lib=PATH],
67 [zlib lib directory])],
68 [LDFLAGS="-L$withval $LDFLAGS"])
69
kenton@google.com9824eda2009-05-06 17:49:37 +000070AC_ARG_WITH([protoc],
71 [AS_HELP_STRING([--with-protoc=COMMAND],
72 [use the given protoc command instead of building a new one when building tests (useful for cross-compiling)])],
73 [],[with_protoc=no])
74
temporal40ee5512008-07-10 02:12:20 +000075# Checks for programs.
76AC_PROG_CC
77AC_PROG_CXX
Adam Cozzetteb40d3182017-01-03 13:07:21 -080078AC_PROG_CXX_FOR_BUILD
kenton@google.com37ad00d2009-04-21 21:00:39 +000079AC_LANG([C++])
kenton@google.com25bc5cd2008-12-04 20:34:50 +000080ACX_USE_SYSTEM_EXTENSIONS
Josh Habermancb3caf12015-02-17 18:23:41 -080081m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
temporal40ee5512008-07-10 02:12:20 +000082AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc
Thomas Van Lenten1745f7e2015-11-17 10:18:49 -050083AC_PROG_OBJC
kenton@google.com25bc5cd2008-12-04 20:34:50 +000084
kenton@google.com6be265a2009-08-06 20:47:45 +000085# test_util.cc takes forever to compile with GCC and optimization turned on.
kenton@google.com42c81e12009-05-06 01:15:06 +000086AC_MSG_CHECKING([C++ compiler flags...])
kenton@google.com6be265a2009-08-06 20:47:45 +000087AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],[
88 AS_IF([test "$GCC" = "yes"],[
89 PROTOBUF_OPT_FLAG="-O2"
90 CXXFLAGS="${CXXFLAGS} -g"
91 ])
kenton@google.com42c81e12009-05-06 01:15:06 +000092
93 # Protocol Buffers contains several checks that are intended to be used only
94 # for debugging and which might hurt performance. Most users are probably
95 # end users who don't want these checks, so add -DNDEBUG by default.
Adam Cozzette5f418d42018-05-31 10:07:28 -070096 CXXFLAGS="$CXXFLAGS -std=c++11 -DNDEBUG"
kenton@google.com42c81e12009-05-06 01:15:06 +000097
98 AC_MSG_RESULT([use default: $PROTOBUF_OPT_FLAG $CXXFLAGS])
99],[
kenton@google.com42c81e12009-05-06 01:15:06 +0000100 AC_MSG_RESULT([use user-supplied: $CXXFLAGS])
101])
102
103AC_SUBST(PROTOBUF_OPT_FLAG)
104
kenton@google.coma8923cd2009-05-01 21:53:10 +0000105ACX_CHECK_SUNCC
temporal40ee5512008-07-10 02:12:20 +0000106
kenton@google.com445f1022009-08-06 23:01:43 +0000107# Have to do libtool after SUNCC, other wise it "helpfully" adds Crun Cstd
kenton@google.com6be265a2009-08-06 20:47:45 +0000108# to the link
109AC_PROG_LIBTOOL
110
Alexandros Frantzis13d165d2017-03-10 14:25:27 +0200111# Check whether the linker supports version scripts
112AC_MSG_CHECKING([whether the linker supports version scripts])
113save_LDFLAGS=$LDFLAGS
114LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
115cat > conftest.map <<EOF
116{
117 global:
118 main;
119 local:
120 *;
121};
122EOF
123AC_LINK_IFELSE(
124 [AC_LANG_SOURCE([int main() { return 0; }])],
125 [have_ld_version_script=yes; AC_MSG_RESULT(yes)],
126 [have_ld_version_script=no; AC_MSG_RESULT(no)])
127LDFLAGS=$save_LDFLAGS
128AM_CONDITIONAL([HAVE_LD_VERSION_SCRIPT], [test "$have_ld_version_script" == "yes"])
129
temporal40ee5512008-07-10 02:12:20 +0000130# Checks for header files.
131AC_HEADER_STDC
132AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stdlib.h unistd.h])
133
134# Checks for library functions.
135AC_FUNC_MEMCMP
136AC_FUNC_STRTOD
137AC_CHECK_FUNCS([ftruncate memset mkdir strchr strerror strtol])
138
kenton@google.com32f330f2009-09-15 17:15:43 +0000139# Check for zlib.
kenton@google.come59427a2009-04-16 22:30:56 +0000140HAVE_ZLIB=0
kenton@google.com32f330f2009-09-15 17:15:43 +0000141AS_IF([test "$with_zlib" != no], [
142 AC_MSG_CHECKING([zlib version])
143
144 # First check the zlib header version.
145 AC_COMPILE_IFELSE(
liujisi@google.com8cc20172012-12-05 00:55:16 +0000146 [AC_LANG_PROGRAM([[
kenton@google.com32f330f2009-09-15 17:15:43 +0000147 #include <zlib.h>
148 #if !defined(ZLIB_VERNUM) || (ZLIB_VERNUM < 0x1204)
149 # error zlib version too old
150 #endif
liujisi@google.com8cc20172012-12-05 00:55:16 +0000151 ]], [])], [
kenton@google.com32f330f2009-09-15 17:15:43 +0000152 AC_MSG_RESULT([ok (1.2.0.4 or later)])
153
154 # Also need to add -lz to the linker flags and make sure this succeeds.
155 AC_SEARCH_LIBS([zlibVersion], [z], [
156 AC_DEFINE([HAVE_ZLIB], [1], [Enable classes using zlib compression.])
157 HAVE_ZLIB=1
158 ], [
159 AS_IF([test "$with_zlib" != check], [
160 AC_MSG_FAILURE([--with-zlib was given, but no working zlib library was found])
161 ])
162 ])
163 ], [
164 AS_IF([test "$with_zlib" = check], [
165 AC_MSG_RESULT([headers missing or too old (requires 1.2.0.4)])
166 ], [
167 AC_MSG_FAILURE([--with-zlib was given, but zlib headers were not present or were too old (requires 1.2.0.4)])
168 ])
169 ])
170])
kenton@google.come59427a2009-04-16 22:30:56 +0000171AM_CONDITIONAL([HAVE_ZLIB], [test $HAVE_ZLIB = 1])
172
Adam Cozzette34b64992019-03-25 11:00:19 -0700173# Add -std=c++11 if necesssary. It is important for us to do this before the
174# libatomic check below, since that also depends on C++11.
175AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory])
176
Ben Wolsieffer56b40a82018-10-04 20:25:10 -0400177dnl On some platforms, std::atomic needs a helper library
178AC_MSG_CHECKING(whether -latomic is needed)
179AC_LINK_IFELSE([AC_LANG_SOURCE([[
180 #include <atomic>
181 #include <cstdint>
182 std::atomic<std::int64_t> v;
183 int main() {
184 return v;
185 }
186]])], STD_ATOMIC_NEED_LIBATOMIC=no, STD_ATOMIC_NEED_LIBATOMIC=yes)
187AC_MSG_RESULT($STD_ATOMIC_NEED_LIBATOMIC)
188if test "x$STD_ATOMIC_NEED_LIBATOMIC" = xyes; then
189 LIBATOMIC_LIBS="-latomic"
190fi
191AC_SUBST([LIBATOMIC_LIBS])
192
kenton@google.com9824eda2009-05-06 17:49:37 +0000193AS_IF([test "$with_protoc" != "no"], [
194 PROTOC=$with_protoc
liujisi@google.com5d8d2b02010-12-06 06:20:14 +0000195 AS_IF([test "$with_protoc" = "yes"], [
kenton@google.com9824eda2009-05-06 17:49:37 +0000196 # No argument given. Use system protoc.
197 PROTOC=protoc
198 ])
199 AS_IF([echo "$PROTOC" | grep -q '^@<:@^/@:>@.*/'], [
200 # Does not start with a slash, but contains a slash. So, it's a relative
201 # path (as opposed to an absolute path or an executable in $PATH).
202 # Since it will actually be executed from the src directory, prefix with
203 # the current directory. We also insert $ac_top_build_prefix in case this
204 # is a nested package and --with-protoc was actually given on the outer
205 # package's configure script.
206 PROTOC=`pwd`/${ac_top_build_prefix}$PROTOC
207 ])
208 AC_SUBST([PROTOC])
209])
210AM_CONDITIONAL([USE_EXTERNAL_PROTOC], [test "$with_protoc" != "no"])
211
john hoodcab5eae2016-03-18 23:56:51 +0000212AX_PTHREAD
213AM_CONDITIONAL([HAVE_PTHREAD], [test "x$ax_pthread_ok" = "xyes"])
Jisi Liu78d470c2015-06-12 15:49:21 -0700214# We still keep this for improving pbconfig.h for unsupported platforms.
temporal40ee5512008-07-10 02:12:20 +0000215AC_CXX_STL_HASH
216
Thomas Van Lenten1745f7e2015-11-17 10:18:49 -0500217# Enable ObjC support for conformance directory on OS X.
218OBJC_CONFORMANCE_TEST=0
219case "$target_os" in
220 darwin*)
221 OBJC_CONFORMANCE_TEST=1
222 ;;
223esac
224AM_CONDITIONAL([OBJC_CONFORMANCE_TEST], [test $OBJC_CONFORMANCE_TEST = 1])
225
Feng Xiaoe96ff302015-06-15 18:21:48 -0700226# HACK: Make gmock's configure script pick up our copy of CFLAGS and CXXFLAGS,
227# since the flags added by ACX_CHECK_SUNCC must be used when compiling gmock
kenton@google.com45258ff2009-12-23 22:12:22 +0000228# too.
229export CFLAGS
kenton@google.com304b7312009-08-10 23:52:27 +0000230export CXXFLAGS
Carlos O'Ryan3c5442a2018-03-26 16:54:32 -0400231AC_CONFIG_SUBDIRS([third_party/googletest])
kenton@google.com37ad00d2009-04-21 21:00:39 +0000232
Josh Haberman2e831102016-04-27 18:22:22 -0700233AC_CONFIG_FILES([Makefile src/Makefile benchmarks/Makefile conformance/Makefile protobuf.pc protobuf-lite.pc])
kenton@google.comc76caac2008-09-30 22:11:21 +0000234AC_OUTPUT