1## 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: 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 14# * src/google/protobuf/stubs/common.h 15# * src/Makefile.am (Update -version-info for LDFLAGS if needed) 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.) 20AC_INIT([Protocol Buffers],[3.14.0],[protobuf@googlegroups.com],[protobuf]) 21 22AM_MAINTAINER_MODE([enable]) 23 24AC_CONFIG_SRCDIR(src/google/protobuf/message.cc) 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 28AC_CONFIG_HEADERS([config.h]) 29AC_CONFIG_MACRO_DIR([m4]) 30 31AC_ARG_VAR(DIST_LANG, [language to include in the distribution package (i.e., make dist)]) 32case "$DIST_LANG" in 33 "") DIST_LANG=all ;; 34 all | cpp | csharp | java | python | javanano | objectivec | ruby | js | php) ;; 35 *) AC_MSG_FAILURE([unknown language: $DIST_LANG]) ;; 36esac 37AC_SUBST(DIST_LANG) 38 39# 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=""]) 45 46AC_CANONICAL_TARGET 47 48AM_INIT_AUTOMAKE([1.9 tar-ustar subdir-objects]) 49 50# 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 55AC_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 60AC_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 70AC_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 75AC_ARG_ENABLE([coverage], 76 [AS_HELP_STRING([--enable-coverage], 77 [generate coverage report])], 78 [coverage=yes],[coverage=no]) 79 80AM_CONDITIONAL([HAVE_COVERAGE], [test "x$coverage" == "xyes"]) 81 82# Checks for programs. 83AC_PROG_CC 84AC_PROG_CXX 85AC_PROG_CXX_FOR_BUILD 86AC_LANG([C++]) 87ACX_USE_SYSTEM_EXTENSIONS 88m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) 89AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc 90AC_PROG_OBJC 91 92# test_util.cc takes forever to compile with GCC and optimization turned on. 93AC_MSG_CHECKING([C++ compiler flags...]) 94AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],[ 95 AS_IF([test "$GCC" = "yes"],[ 96 PROTOBUF_OPT_FLAG="-O2" 97 CXXFLAGS="${CXXFLAGS} -g" 98 ]) 99 100 # Protocol Buffers contains several checks that are intended to be used only 101 # for debugging and which might hurt performance. Most users are probably 102 # end users who don't want these checks, so add -DNDEBUG by default. 103 CXXFLAGS="$CXXFLAGS -std=c++11 -DNDEBUG" 104 105 AC_MSG_RESULT([use default: $PROTOBUF_OPT_FLAG $CXXFLAGS]) 106],[ 107 AC_MSG_RESULT([use user-supplied: $CXXFLAGS]) 108]) 109 110AC_SUBST(PROTOBUF_OPT_FLAG) 111 112ACX_CHECK_SUNCC 113 114# Have to do libtool after SUNCC, other wise it "helpfully" adds Crun Cstd 115# to the link 116AC_PROG_LIBTOOL 117 118# Check whether the linker supports version scripts 119AC_MSG_CHECKING([whether the linker supports version scripts]) 120save_LDFLAGS=$LDFLAGS 121LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map" 122cat > conftest.map <<EOF 123{ 124 global: 125 main; 126 local: 127 *; 128}; 129EOF 130AC_LINK_IFELSE( 131 [AC_LANG_SOURCE([int main() { return 0; }])], 132 [have_ld_version_script=yes; AC_MSG_RESULT(yes)], 133 [have_ld_version_script=no; AC_MSG_RESULT(no)]) 134LDFLAGS=$save_LDFLAGS 135AM_CONDITIONAL([HAVE_LD_VERSION_SCRIPT], [test "$have_ld_version_script" == "yes"]) 136 137# Checks for header files. 138AC_HEADER_STDC 139AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stdlib.h unistd.h]) 140 141# Checks for library functions. 142AC_FUNC_MEMCMP 143AC_FUNC_STRTOD 144AC_CHECK_FUNCS([ftruncate memset mkdir strchr strerror strtol]) 145 146# Check for zlib. 147HAVE_ZLIB=0 148AS_IF([test "$with_zlib" != no], [ 149 AC_MSG_CHECKING([zlib version]) 150 151 # First check the zlib header version. 152 AC_COMPILE_IFELSE( 153 [AC_LANG_PROGRAM([[ 154 #include <zlib.h> 155 #if !defined(ZLIB_VERNUM) || (ZLIB_VERNUM < 0x1204) 156 # error zlib version too old 157 #endif 158 ]], [])], [ 159 AC_MSG_RESULT([ok (1.2.0.4 or later)]) 160 161 # Also need to add -lz to the linker flags and make sure this succeeds. 162 AC_SEARCH_LIBS([zlibVersion], [z], [ 163 AC_DEFINE([HAVE_ZLIB], [1], [Enable classes using zlib compression.]) 164 HAVE_ZLIB=1 165 ], [ 166 AS_IF([test "$with_zlib" != check], [ 167 AC_MSG_FAILURE([--with-zlib was given, but no working zlib library was found]) 168 ]) 169 ]) 170 ], [ 171 AS_IF([test "$with_zlib" = check], [ 172 AC_MSG_RESULT([headers missing or too old (requires 1.2.0.4)]) 173 ], [ 174 AC_MSG_FAILURE([--with-zlib was given, but zlib headers were not present or were too old (requires 1.2.0.4)]) 175 ]) 176 ]) 177]) 178AM_CONDITIONAL([HAVE_ZLIB], [test $HAVE_ZLIB = 1]) 179 180# Add -std=c++11 if necesssary. It is important for us to do this before the 181# libatomic check below, since that also depends on C++11. 182AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory]) 183 184dnl On some platforms, std::atomic needs a helper library 185AC_MSG_CHECKING(whether -latomic is needed) 186AC_LINK_IFELSE([AC_LANG_SOURCE([[ 187 #include <atomic> 188 #include <cstdint> 189 std::atomic<std::int64_t> v; 190 int main() { 191 return v; 192 } 193]])], STD_ATOMIC_NEED_LIBATOMIC=no, STD_ATOMIC_NEED_LIBATOMIC=yes) 194AC_MSG_RESULT($STD_ATOMIC_NEED_LIBATOMIC) 195if test "x$STD_ATOMIC_NEED_LIBATOMIC" = xyes; then 196 LIBATOMIC_LIBS="-latomic" 197fi 198AC_SUBST([LIBATOMIC_LIBS]) 199 200AS_IF([test "$with_protoc" != "no"], [ 201 PROTOC=$with_protoc 202 AS_IF([test "$with_protoc" = "yes"], [ 203 # No argument given. Use system protoc. 204 PROTOC=protoc 205 ]) 206 AS_IF([echo "$PROTOC" | grep -q '^@<:@^/@:>@.*/'], [ 207 # Does not start with a slash, but contains a slash. So, it's a relative 208 # path (as opposed to an absolute path or an executable in $PATH). 209 # Since it will actually be executed from the src directory, prefix with 210 # the current directory. We also insert $ac_top_build_prefix in case this 211 # is a nested package and --with-protoc was actually given on the outer 212 # package's configure script. 213 PROTOC=`pwd`/${ac_top_build_prefix}$PROTOC 214 ]) 215 AC_SUBST([PROTOC]) 216]) 217AM_CONDITIONAL([USE_EXTERNAL_PROTOC], [test "$with_protoc" != "no"]) 218 219AX_PTHREAD 220AM_CONDITIONAL([HAVE_PTHREAD], [test "x$ax_pthread_ok" = "xyes"]) 221# We still keep this for improving pbconfig.h for unsupported platforms. 222AC_CXX_STL_HASH 223 224# Enable ObjC support for conformance directory on OS X. 225OBJC_CONFORMANCE_TEST=0 226case "$target_os" in 227 darwin*) 228 OBJC_CONFORMANCE_TEST=1 229 ;; 230esac 231AM_CONDITIONAL([OBJC_CONFORMANCE_TEST], [test $OBJC_CONFORMANCE_TEST = 1]) 232 233# HACK: Make gmock's configure script pick up our copy of CFLAGS and CXXFLAGS, 234# since the flags added by ACX_CHECK_SUNCC must be used when compiling gmock 235# too. 236export CFLAGS 237export CXXFLAGS 238AC_CONFIG_SUBDIRS([third_party/googletest]) 239 240AC_CONFIG_FILES([Makefile src/Makefile benchmarks/Makefile conformance/Makefile protobuf.pc protobuf-lite.pc]) 241AC_OUTPUT 242