1# Copyright (c) 2006, Google Inc.
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met:
7#
8#     * Redistributions of source code must retain the above copyright
9# notice, this list of conditions and the following disclaimer.
10#     * Redistributions in binary form must reproduce the above
11# copyright notice, this list of conditions and the following disclaimer
12# in the documentation and/or other materials provided with the
13# distribution.
14#     * Neither the name of Google Inc. nor the names of its
15# contributors may be used to endorse or promote products derived from
16# this software without specific prior written permission.
17#
18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30
31AC_PREREQ(2.64)
32
33AC_INIT(breakpad, 0.1, google-breakpad-dev@googlegroups.com)
34dnl Sanity check: the argument is just a file that should exist.
35AC_CONFIG_SRCDIR(README.md)
36AC_CONFIG_AUX_DIR(autotools)
37AC_CONFIG_MACRO_DIR([m4])
38AC_CANONICAL_HOST
39
40AM_INIT_AUTOMAKE(subdir-objects tar-ustar 1.11.1)
41AM_CONFIG_HEADER(src/config.h)
42AM_MAINTAINER_MODE
43
44AM_PROG_AR
45AM_PROG_AS
46AC_PROG_CC
47AM_PROG_CC_C_O
48AC_PROG_CPP
49AC_PROG_CXX
50AC_PROG_RANLIB
51
52dnl This must come before all the feature tests below.
53AC_ARG_ENABLE(m32,
54              AS_HELP_STRING([--enable-m32],
55                             [Compile/build with -m32]
56                             [(default is no)]),
57              [case "${enableval}" in
58                 yes)
59                   CFLAGS="${CFLAGS} -m32"
60                   CXXFLAGS="${CXXFLAGS} -m32"
61                   usem32=true
62                   ;;
63                 no)
64                   usem32=false
65                   ;;
66                 *)
67                   AC_MSG_ERROR(bad value ${enableval} for --enable-m32)
68                   ;;
69               esac],
70              [usem32=false])
71
72AC_HEADER_STDC
73AC_SYS_LARGEFILE
74AX_PTHREAD
75AC_CHECK_HEADERS([a.out.h sys/random.h])
76AC_CHECK_FUNCS([arc4random getcontext getrandom])
77AM_CONDITIONAL([HAVE_GETCONTEXT], [test "x$ac_cv_func_getcontext" = xyes])
78
79AX_CXX_COMPILE_STDCXX(11, noext, mandatory)
80
81dnl Test supported warning flags.
82WARN_CXXFLAGS=
83dnl This warning flag is used by clang.  Its default behavior is to warn when
84dnl given an unknown flag rather than error out.
85AC_LANG_PUSH([C++])
86AX_CHECK_COMPILE_FLAG([-Werror=unknown-warning-option],[
87  ax_compiler_flags_test="-Werror=unknown-warning-option"
88],[
89  ax_compiler_flags_test=""
90])
91AX_APPEND_COMPILE_FLAGS(m4_flatten([
92  -Wmissing-braces
93  -Wnon-virtual-dtor
94  -Woverloaded-virtual
95  -Wreorder
96  -Wsign-compare
97  -Wunused-local-typedefs
98  -Wunused-variable
99  -Wvla
100]), [WARN_CXXFLAGS], [${ax_compiler_flags_test}])
101AS_VAR_APPEND([WARN_CXXFLAGS], " -Werror")
102AC_LANG_POP([C++])
103AC_SUBST([WARN_CXXFLAGS])
104
105dnl Test support for O_CLOEXEC
106AX_CHECK_DEFINE([fcntl.h], [O_CLOEXEC], [],
107                [AC_DEFINE([O_CLOEXEC], [0], [Fallback definition for old systems])])
108
109# Only build Linux client libs when compiling for Linux
110case $host in
111  *-*-linux* | *-android* )
112    LINUX_HOST=true
113    ;;
114esac
115AM_CONDITIONAL(LINUX_HOST, test x$LINUX_HOST = xtrue)
116
117# Only use Android support headers when compiling for Android
118case $host in
119  *-android*)
120    ANDROID_HOST=true
121    ;;
122esac
123AM_CONDITIONAL(ANDROID_HOST, test x$ANDROID_HOST = xtrue)
124
125# Some tools (like mac ones) only support x86 currently.
126case $host_cpu in
127  i?86|x86_64)
128    X86_HOST=true
129    ;;
130esac
131AM_CONDITIONAL(X86_HOST, test x$X86_HOST = xtrue)
132
133AC_ARG_ENABLE(processor,
134              AS_HELP_STRING([--disable-processor],
135                             [Don't build processor library]
136                             [(default is no)]),
137              [case "${enableval}" in
138                 yes)
139                   disable_processor=false
140                   ;;
141                 no)
142                   disable_processor=true
143                   ;;
144                 *)
145                   AC_MSG_ERROR(bad value ${enableval} for --disable-processor)
146                   ;;
147               esac],
148              [disable_processor=false])
149AM_CONDITIONAL(DISABLE_PROCESSOR, test x$disable_processor = xtrue)
150
151AC_ARG_ENABLE(tools,
152              AS_HELP_STRING([--disable-tools],
153                             [Don't build tool binaries]
154                             [(default is no)]),
155              [case "${enableval}" in
156                 yes)
157                   disable_tools=false
158                   ;;
159                 no)
160                   disable_tools=true
161                   ;;
162                 *)
163                   AC_MSG_ERROR(bad value ${enableval} for --disable-tools)
164                   ;;
165               esac],
166              [disable_tools=false])
167AM_CONDITIONAL(DISABLE_TOOLS, test x$disable_tools = xtrue)
168
169if test x$LINUX_HOST = xfalse -a x$disable_processor = xtrue -a x$disable_tools = xtrue; then
170   AC_MSG_ERROR([--disable-processor and --disable-tools were specified, and not building for Linux. Nothing to build!])
171fi
172
173AC_ARG_ENABLE(system-test-libs,
174              AS_HELP_STRING([--enable-system-test-libs],
175                             [Use gtest/gmock/etc... from the system instead ]
176                             [of the local copies (default is local)]),
177              [case "${enableval}" in
178                 yes)
179                   system_test_libs=true
180                   ;;
181                 no)
182                   system_test_libs=false
183                   ;;
184                 *)
185                   AC_MSG_ERROR(bad value ${enableval} for --enable-system-test-libs)
186                   ;;
187               esac],
188              [system_test_libs=false])
189AM_CONDITIONAL(SYSTEM_TEST_LIBS, test x$system_test_libs = xtrue)
190
191AC_ARG_VAR([GMOCK_CFLAGS], [Compiler flags for gmock])
192AC_ARG_VAR([GMOCK_LIBS], [Linker flags for gmock])
193AC_ARG_VAR([GTEST_CFLAGS], [Compiler flags for gtest])
194AC_ARG_VAR([GTEST_LIBS], [Linker flags for gtest])
195if test x$system_test_libs = xtrue; then
196  : "${GMOCK_CFLAGS:=-pthread}"
197  : "${GMOCK_LIBS:=-lgmock -lgtest -pthread -lpthread}"
198  : "${GTEST_CFLAGS:=-pthread}"
199  : "${GTEST_LIBS:=-lgtest -pthread -lpthread}"
200fi
201
202AC_ARG_ENABLE(selftest,
203              AS_HELP_STRING([--enable-selftest],
204                             [Run extra tests with "make check" ]
205                             [(may conflict with optimizations) ]
206                             [(default is no)]),
207              [case "${enableval}" in
208                 yes)
209                   selftest=true
210                   ;;
211                 no)
212                   selftest=false
213                   ;;
214                 *)
215                   AC_MSG_ERROR(bad value ${enableval} for --enable-selftest)
216                   ;;
217               esac],
218              [selftest=false])
219AM_CONDITIONAL(SELFTEST, test x$selftest = xtrue)
220
221AC_ARG_WITH(rust-demangle,
222            AS_HELP_STRING([--with-rust-demangle=/path/to/rust-demangle-capi],
223                             [Link against the rust-demangle library]
224                             [to demangle Rust language symbols during]
225                             [symbol dumping (default is no)]
226                             [Pass the path to the crate root.]),
227            [case "${withval}" in
228               yes)
229                 AC_MSG_ERROR(You must pass the path to the rust-demangle-capi crate for --with-rust-demangle)
230                 ;;
231               no)
232                 rust_demangle=false
233                 ;;
234               *)
235                 if ! test -f "${withval}/Cargo.toml"; then
236                   AC_MSG_ERROR(You must pass the path to the rust-demangle-capi crate for --with-rust-demangle)
237                 fi
238                 RUST_DEMANGLE_CFLAGS="-DHAVE_RUST_DEMANGLE -I${withval}/target/include"
239                 RUST_DEMANGLE_LIBS="-L${withval}/target/release -lrust_demangle -lpthread -ldl"
240                 ;;
241             esac],
242            [rust_demangle=false])
243AC_ARG_VAR([RUST_DEMANGLE_CFLAGS], [Compiler flags for rust-demangle])
244AC_ARG_VAR([RUST_DEMANGLE_LIBS], [Linker flags for rust-demangle])
245
246AC_ARG_WITH(tests-as-root,
247            AS_HELP_STRING([--with-tests-as-root],
248                           [Run the tests as root. Use this on platforms]
249                           [like travis-ci.org that require root privileges]
250                           [to use ptrace (default is no)]),
251            [case "${withval}" in
252               yes)
253                 tests_as_root=true
254                 ;;
255               no)
256                 tests_as_root=false
257                 ;;
258               *)
259                 AC_MSG_ERROR(--with-tests-as-root can only be "yes" or "no")
260                 ;;
261             esac],
262            [tests_as_root=false])
263AM_CONDITIONAL(TESTS_AS_ROOT, test x$tests_as_root = xtrue)
264
265AC_CONFIG_FILES(m4_flatten([
266  breakpad.pc
267  breakpad-client.pc
268  Makefile
269]))
270
271AC_OUTPUT
272