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