blob: 33a6c64d6fec03f6e3b623ce4bbe6bc19f98a8b8 [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:
7# * java/pom.xml
8# * python/setup.py
9# * src/google/protobuf/stubs/common.h
kenton@google.coma001ed02008-12-01 23:47:49 +000010# * src/Makefile.am (Update -version-info for LDFLAGS if needed)
kenton@google.com37ad00d2009-04-21 21:00:39 +000011#
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.)
Feng Xiaoaa7e17a2015-12-21 11:31:51 -080015AC_INIT([Protocol Buffers],[3.0.0-beta-2],[protobuf@googlegroups.com],[protobuf])
temporal40ee5512008-07-10 02:12:20 +000016
liujisi@google.com26261eb2012-07-03 09:39:26 +000017AM_MAINTAINER_MODE([enable])
kenton@google.com42c81e12009-05-06 01:15:06 +000018
temporal40ee5512008-07-10 02:12:20 +000019AC_CONFIG_SRCDIR(src/google/protobuf/message.cc)
Jisi Liu78d470c2015-06-12 15:49:21 -070020# 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
kenton@google.comc76caac2008-09-30 22:11:21 +000023AC_CONFIG_HEADERS([config.h])
kenton@google.com25bc5cd2008-12-04 20:34:50 +000024AC_CONFIG_MACRO_DIR([m4])
kenton@google.com6be265a2009-08-06 20:47:45 +000025
Feng Xiao8f7dec82014-12-02 14:15:26 -080026AC_ARG_VAR(DIST_LANG, [language to include in the distribution package (i.e., make dist)])
27case "$DIST_LANG" in
Feng Xiao6936f172014-12-03 17:37:42 -080028 "") DIST_LANG=all ;;
Feng Xiaob7610f12015-12-22 14:36:04 -080029 all | cpp | csharp | java | python | javanano | objectivec | ruby | js) ;;
Feng Xiao8f7dec82014-12-02 14:15:26 -080030 *) AC_MSG_FAILURE([unknown language: $DIST_LANG]) ;;
31esac
32AC_SUBST(DIST_LANG)
33
kenton@google.com6be265a2009-08-06 20:47:45 +000034# autoconf's default CXXFLAGS are usually "-g -O2". These aren't necessarily
35# the best choice for libprotobuf.
36AS_IF([test "x${ac_cv_env_CFLAGS_set}" = "x"],
37 [CFLAGS=""])
38AS_IF([test "x${ac_cv_env_CXXFLAGS_set}" = "x"],
39 [CXXFLAGS=""])
kenton@google.com445f1022009-08-06 23:01:43 +000040
kenton@google.com6be265a2009-08-06 20:47:45 +000041AC_CANONICAL_TARGET
42
Jisi Liuff35de32015-02-21 14:58:02 -080043AM_INIT_AUTOMAKE([1.9 tar-ustar subdir-objects])
temporal40ee5512008-07-10 02:12:20 +000044
kenton@google.come59427a2009-04-16 22:30:56 +000045AC_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
kenton@google.com9824eda2009-05-06 17:49:37 +000050AC_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
temporal40ee5512008-07-10 02:12:20 +000055# Checks for programs.
56AC_PROG_CC
57AC_PROG_CXX
kenton@google.com37ad00d2009-04-21 21:00:39 +000058AC_LANG([C++])
kenton@google.com25bc5cd2008-12-04 20:34:50 +000059ACX_USE_SYSTEM_EXTENSIONS
Josh Habermancb3caf12015-02-17 18:23:41 -080060m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
temporal40ee5512008-07-10 02:12:20 +000061AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc
Thomas Van Lenten1745f7e2015-11-17 10:18:49 -050062AC_PROG_OBJC
kenton@google.com25bc5cd2008-12-04 20:34:50 +000063
kenton@google.com6be265a2009-08-06 20:47:45 +000064# test_util.cc takes forever to compile with GCC and optimization turned on.
kenton@google.com42c81e12009-05-06 01:15:06 +000065AC_MSG_CHECKING([C++ compiler flags...])
kenton@google.com6be265a2009-08-06 20:47:45 +000066AS_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 ])
kenton@google.com42c81e12009-05-06 01:15:06 +000071
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],[
kenton@google.com42c81e12009-05-06 01:15:06 +000079 AC_MSG_RESULT([use user-supplied: $CXXFLAGS])
80])
81
82AC_SUBST(PROTOBUF_OPT_FLAG)
83
kenton@google.coma8923cd2009-05-01 21:53:10 +000084ACX_CHECK_SUNCC
temporal40ee5512008-07-10 02:12:20 +000085
kenton@google.com445f1022009-08-06 23:01:43 +000086# Have to do libtool after SUNCC, other wise it "helpfully" adds Crun Cstd
kenton@google.com6be265a2009-08-06 20:47:45 +000087# to the link
88AC_PROG_LIBTOOL
89
temporal40ee5512008-07-10 02:12:20 +000090# Checks for header files.
91AC_HEADER_STDC
92AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stdlib.h unistd.h])
93
94# Checks for library functions.
95AC_FUNC_MEMCMP
96AC_FUNC_STRTOD
97AC_CHECK_FUNCS([ftruncate memset mkdir strchr strerror strtol])
98
kenton@google.com32f330f2009-09-15 17:15:43 +000099# Check for zlib.
kenton@google.come59427a2009-04-16 22:30:56 +0000100HAVE_ZLIB=0
kenton@google.com32f330f2009-09-15 17:15:43 +0000101AS_IF([test "$with_zlib" != no], [
102 AC_MSG_CHECKING([zlib version])
103
104 # First check the zlib header version.
105 AC_COMPILE_IFELSE(
liujisi@google.com8cc20172012-12-05 00:55:16 +0000106 [AC_LANG_PROGRAM([[
kenton@google.com32f330f2009-09-15 17:15:43 +0000107 #include <zlib.h>
108 #if !defined(ZLIB_VERNUM) || (ZLIB_VERNUM < 0x1204)
109 # error zlib version too old
110 #endif
liujisi@google.com8cc20172012-12-05 00:55:16 +0000111 ]], [])], [
kenton@google.com32f330f2009-09-15 17:15:43 +0000112 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])
kenton@google.come59427a2009-04-16 22:30:56 +0000131AM_CONDITIONAL([HAVE_ZLIB], [test $HAVE_ZLIB = 1])
132
kenton@google.com9824eda2009-05-06 17:49:37 +0000133AS_IF([test "$with_protoc" != "no"], [
134 PROTOC=$with_protoc
liujisi@google.com5d8d2b02010-12-06 06:20:14 +0000135 AS_IF([test "$with_protoc" = "yes"], [
kenton@google.com9824eda2009-05-06 17:49:37 +0000136 # 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])
150AM_CONDITIONAL([USE_EXTERNAL_PROTOC], [test "$with_protoc" != "no"])
151
temporal40ee5512008-07-10 02:12:20 +0000152ACX_PTHREAD
Jisi Liu78d470c2015-06-12 15:49:21 -0700153AM_CONDITIONAL([HAVE_PTHREAD], [test "x$acx_pthread_ok" = "xyes"])
154
155# We still keep this for improving pbconfig.h for unsupported platforms.
temporal40ee5512008-07-10 02:12:20 +0000156AC_CXX_STL_HASH
157
William Orr20e0a612014-10-10 22:50:39 -0700158case "$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 ;;
165esac
William Orr38b84942014-09-19 21:54:27 -0700166
Thomas Van Lenten1745f7e2015-11-17 10:18:49 -0500167# Enable ObjC support for conformance directory on OS X.
168OBJC_CONFORMANCE_TEST=0
169case "$target_os" in
170 darwin*)
171 OBJC_CONFORMANCE_TEST=1
172 ;;
173esac
174AM_CONDITIONAL([OBJC_CONFORMANCE_TEST], [test $OBJC_CONFORMANCE_TEST = 1])
175
Feng Xiaoe96ff302015-06-15 18:21:48 -0700176# 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
kenton@google.com45258ff2009-12-23 22:12:22 +0000178# too.
179export CFLAGS
kenton@google.com304b7312009-08-10 23:52:27 +0000180export CXXFLAGS
Feng Xiaoe96ff302015-06-15 18:21:48 -0700181AC_CONFIG_SUBDIRS([gmock])
kenton@google.com37ad00d2009-04-21 21:00:39 +0000182
Josh Haberman35a1cc72015-04-01 17:23:48 -0700183AC_CONFIG_FILES([Makefile src/Makefile conformance/Makefile protobuf.pc protobuf-lite.pc])
kenton@google.comc76caac2008-09-30 22:11:21 +0000184AC_OUTPUT