• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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# * java/pom.xml
8# * python/setup.py
9# * src/google/protobuf/stubs/common.h
10# * src/Makefile.am (Update -version-info for LDFLAGS if needed)
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.)
15AC_INIT([Protocol Buffers],[3.0.0-beta-3],[protobuf@googlegroups.com],[protobuf])
16
17AM_MAINTAINER_MODE([enable])
18
19AC_CONFIG_SRCDIR(src/google/protobuf/message.cc)
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
23AC_CONFIG_HEADERS([config.h])
24AC_CONFIG_MACRO_DIR([m4])
25
26AC_ARG_VAR(DIST_LANG, [language to include in the distribution package (i.e., make dist)])
27case "$DIST_LANG" in
28  "") DIST_LANG=all ;;
29  all | cpp | csharp | java | python | javanano | objectivec | ruby | js) ;;
30  *) AC_MSG_FAILURE([unknown language: $DIST_LANG]) ;;
31esac
32AC_SUBST(DIST_LANG)
33
34# 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=""])
40
41AC_CANONICAL_TARGET
42
43AM_INIT_AUTOMAKE([1.9 tar-ustar subdir-objects])
44
45AC_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
50AC_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
55# Checks for programs.
56AC_PROG_CC
57AC_PROG_CXX
58AC_LANG([C++])
59ACX_USE_SYSTEM_EXTENSIONS
60m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
61AM_CONDITIONAL(GCC, test "$GCC" = yes)   # let the Makefile know if we're gcc
62AC_PROG_OBJC
63
64# test_util.cc takes forever to compile with GCC and optimization turned on.
65AC_MSG_CHECKING([C++ compiler flags...])
66AS_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  ])
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],[
79  AC_MSG_RESULT([use user-supplied: $CXXFLAGS])
80])
81
82AC_SUBST(PROTOBUF_OPT_FLAG)
83
84ACX_CHECK_SUNCC
85
86# Have to do libtool after SUNCC, other wise it "helpfully" adds Crun Cstd
87# to the link
88AC_PROG_LIBTOOL
89
90# 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
99# Check for zlib.
100HAVE_ZLIB=0
101AS_IF([test "$with_zlib" != no], [
102  AC_MSG_CHECKING([zlib version])
103
104  # First check the zlib header version.
105  AC_COMPILE_IFELSE(
106    [AC_LANG_PROGRAM([[
107        #include <zlib.h>
108        #if !defined(ZLIB_VERNUM) || (ZLIB_VERNUM < 0x1204)
109        # error zlib version too old
110        #endif
111        ]], [])], [
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])
131AM_CONDITIONAL([HAVE_ZLIB], [test $HAVE_ZLIB = 1])
132
133AS_IF([test "$with_protoc" != "no"], [
134  PROTOC=$with_protoc
135  AS_IF([test "$with_protoc" = "yes"], [
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])
150AM_CONDITIONAL([USE_EXTERNAL_PROTOC], [test "$with_protoc" != "no"])
151
152ACX_PTHREAD
153AM_CONDITIONAL([HAVE_PTHREAD], [test "x$acx_pthread_ok" = "xyes"])
154
155# We still keep this for improving pbconfig.h for unsupported platforms.
156AC_CXX_STL_HASH
157
158case "$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
166
167# 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
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
178#   too.
179export CFLAGS
180export CXXFLAGS
181AC_CONFIG_SUBDIRS([gmock])
182
183AC_CONFIG_FILES([Makefile src/Makefile benchmarks/Makefile conformance/Makefile protobuf.pc protobuf-lite.pc])
184AC_OUTPUT
185