configure.ac 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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. AC_PREREQ([2.71])
  29. AC_INIT([breakpad],[0.1],[google-breakpad-dev@googlegroups.com])
  30. dnl Sanity check: the argument is just a file that should exist.
  31. AC_CONFIG_SRCDIR(README.md)
  32. AC_CONFIG_AUX_DIR(autotools)
  33. AC_CONFIG_MACRO_DIR([m4])
  34. AC_CANONICAL_HOST
  35. AM_INIT_AUTOMAKE(subdir-objects tar-ustar 1.13)
  36. AC_CONFIG_HEADERS(src/config.h)
  37. AM_MAINTAINER_MODE
  38. AM_PROG_AR
  39. AM_PROG_AS
  40. AC_PROG_CC
  41. AM_PROG_CC_C_O
  42. AC_PROG_CPP
  43. AC_PROG_CXX
  44. AC_PROG_RANLIB
  45. dnl This must come before all the feature tests below.
  46. AC_ARG_ENABLE(m32,
  47. AS_HELP_STRING([--enable-m32],
  48. [Compile/build with -m32]
  49. [(default is no)]),,
  50. [enable_m32=no])
  51. if test "x$enable_m32" = xyes; then
  52. CFLAGS="${CFLAGS} -m32"
  53. CXXFLAGS="${CXXFLAGS} -m32"
  54. fi
  55. AC_SYS_LARGEFILE
  56. AX_PTHREAD
  57. AC_CHECK_HEADERS([a.out.h sys/mman.h sys/random.h])
  58. AC_CHECK_FUNCS([arc4random getcontext getrandom memfd_create])
  59. AM_CONDITIONAL([HAVE_GETCONTEXT], [test "x$ac_cv_func_getcontext" = xyes])
  60. AM_CONDITIONAL([HAVE_MEMFD_CREATE], [test "x$ac_cv_func_memfd_create" = xyes])
  61. AX_CXX_COMPILE_STDCXX(17, , mandatory)
  62. dnl Test supported warning flags.
  63. WARN_CXXFLAGS=
  64. dnl This warning flag is used by clang. Its default behavior is to warn when
  65. dnl given an unknown flag rather than error out.
  66. AC_LANG_PUSH([C++])
  67. AX_CHECK_COMPILE_FLAG([-Werror=unknown-warning-option],[
  68. ax_compiler_flags_test="-Werror=unknown-warning-option"
  69. ],[
  70. ax_compiler_flags_test=""
  71. ])
  72. AX_APPEND_COMPILE_FLAGS(m4_flatten([
  73. -Wmissing-braces
  74. -Wnon-virtual-dtor
  75. -Woverloaded-virtual
  76. -Wreorder
  77. -Wsign-compare
  78. -Wunused-local-typedefs
  79. -Wunused-variable
  80. -Wvla
  81. ]), [WARN_CXXFLAGS], [${ax_compiler_flags_test}])
  82. AS_VAR_APPEND([WARN_CXXFLAGS], " -Werror")
  83. AC_LANG_POP([C++])
  84. AC_SUBST([WARN_CXXFLAGS])
  85. dnl Test support for O_CLOEXEC
  86. AX_CHECK_DEFINE([fcntl.h], [O_CLOEXEC], [],
  87. [AC_DEFINE([O_CLOEXEC], [0], [Fallback definition for old systems])])
  88. # Only build Linux client libs when compiling for Linux
  89. case $host in
  90. *-*-linux* | *-android* )
  91. LINUX_HOST=true
  92. ;;
  93. esac
  94. AM_CONDITIONAL(LINUX_HOST, test x$LINUX_HOST = xtrue)
  95. # Only use Android support headers when compiling for Android
  96. case $host in
  97. *-android*)
  98. ANDROID_HOST=true
  99. ;;
  100. esac
  101. AM_CONDITIONAL(ANDROID_HOST, test x$ANDROID_HOST = xtrue)
  102. # Some tools (like mac ones) only support x86 currently.
  103. case $host_cpu in
  104. i?86|x86_64)
  105. X86_HOST=true
  106. ;;
  107. esac
  108. AM_CONDITIONAL(X86_HOST, test x$X86_HOST = xtrue)
  109. AC_ARG_ENABLE(processor,
  110. AS_HELP_STRING([--disable-processor],
  111. [Don't build processor library]
  112. [(default is no)]),,
  113. [enable_processor=yes])
  114. AM_CONDITIONAL(DISABLE_PROCESSOR, test "x$enable_processor" != xyes)
  115. AC_ARG_ENABLE(tools,
  116. AS_HELP_STRING([--disable-tools],
  117. [Don't build tool binaries]
  118. [(default is no)]),,
  119. [enable_tools=yes])
  120. AM_CONDITIONAL(DISABLE_TOOLS, test "x$enable_tools" != xyes)
  121. if test x$LINUX_HOST = xfalse -a "x$enable_processor" != xyes -a "x$enable_tools" != xyes; then
  122. AC_MSG_ERROR([--disable-processor and --disable-tools were specified, and not building for Linux. Nothing to build!])
  123. fi
  124. AC_ARG_ENABLE(system-test-libs,
  125. AS_HELP_STRING([--enable-system-test-libs],
  126. [Use gtest/gmock/etc... from the system instead ]
  127. [of the local copies (default is local)]),,
  128. [enable_system_test_libs=no])
  129. AM_CONDITIONAL(SYSTEM_TEST_LIBS, test "x$enable_system_test_libs" = xyes)
  130. AC_ARG_VAR([GMOCK_CFLAGS], [Compiler flags for gmock])
  131. AC_ARG_VAR([GMOCK_LIBS], [Linker flags for gmock])
  132. AC_ARG_VAR([GTEST_CFLAGS], [Compiler flags for gtest])
  133. AC_ARG_VAR([GTEST_LIBS], [Linker flags for gtest])
  134. if test "x$enable_system_test_libs" = xyes; then
  135. : "${GMOCK_CFLAGS:=-pthread}"
  136. : "${GMOCK_LIBS:=-lgmock -lgtest -pthread -lpthread}"
  137. : "${GTEST_CFLAGS:=-pthread}"
  138. : "${GTEST_LIBS:=-lgtest -pthread -lpthread}"
  139. fi
  140. AC_ARG_ENABLE(selftest,
  141. AS_HELP_STRING([--enable-selftest],
  142. [Run extra tests with "make check" ]
  143. [(may conflict with optimizations) ]
  144. [(default is no)]),,
  145. [enable_selftest=no])
  146. AM_CONDITIONAL(SELFTEST, test "x$enable_selftest" = xyes)
  147. AC_ARG_WITH(rustc-demangle,
  148. AS_HELP_STRING([--with-rustc-demangle=/path/to/rustc-demangle],
  149. [Link against the rustc-demangle library]
  150. [to demangle Rust language symbols during]
  151. [symbol dumping (default is no)]
  152. [Pass the path to the crate root.]),,
  153. [with_rustc_demangle=no])
  154. RUSTC_DEMANGLE_BASE_CFLAGS="-DHAVE_RUSTC_DEMANGLE"
  155. RUSTC_DEMANGLE_BASE_LIBS="-lrustc_demangle -lpthread -ldl"
  156. if test "x${with_rustc_demangle}" != xno; then
  157. if ! test -f "${with_rustc_demangle}/Cargo.toml"; then
  158. AC_MSG_ERROR(You must pass the path to the rustc-demangle crate for --with-rustc-demangle)
  159. fi
  160. RUSTC_DEMANGLE_CFLAGS="-I${with_rustc_demangle}/crates/capi/include ${RUSTC_DEMANGLE_BASE_CFLAGS}"
  161. RUSTC_DEMANGLE_LIBS="-L${with_rustc_demangle}/target/release ${RUSTC_DEMANGLE_BASE_LIBS}"
  162. fi
  163. AC_ARG_ENABLE(system-rustc-demangle,
  164. AS_HELP_STRING([--enable-system-rustc-demangle],
  165. [Link against the rustc-demangle library]
  166. [to demangle Rust language symbols during]
  167. [symbol dumping (default is no). This assumes]
  168. [that rustc-demangle is installed in your sysroot,]
  169. [and all headers from it are available in your]
  170. [standard include path]
  171. ),,
  172. [enable_system_rustc_demangle=no])
  173. if test "x${enable_system_rustc_demangle}" != xno; then
  174. if test "x${with_rustc_demangle}" != xno; then
  175. AC_MSG_ERROR([--enable-system-rustc-demangle and --with-rustc-demangle are mutually exclusive.])
  176. fi
  177. RUSTC_DEMANGLE_CFLAGS="${RUSTC_DEMANGLE_BASE_CFLAGS}"
  178. RUSTC_DEMANGLE_LIBS="${RUSTC_DEMANGLE_BASE_LIBS}"
  179. AC_CHECK_LIB([rustc_demangle], [rustc_demangle], [],
  180. [AC_MSG_ERROR(librustc_demangle.a must be present when --enable-system-rustc-demangle is specified)],
  181. [$RUSTC_DEMANGLE_LIBS])
  182. AC_CHECK_HEADERS(rustc_demangle.h, [],
  183. [AC_MSG_ERROR(rustc_demangle.h must be present when --enable-system-rustc-demangle is specified)])
  184. fi
  185. AC_ARG_VAR([RUSTC_DEMANGLE_CFLAGS], [Compiler flags for rustc-demangle])
  186. AC_ARG_VAR([RUSTC_DEMANGLE_LIBS], [Linker flags for rustc-demangle])
  187. AC_ARG_ENABLE(zstd,
  188. AS_HELP_STRING([--enable-zstd],
  189. [Enable decompression of ELF sections with zstd]),,
  190. [enable_zstd=no])
  191. if test "x${enable_zstd}" != xno; then
  192. AC_CHECK_LIB(zstd, ZSTD_decompress, [],
  193. [AC_MSG_ERROR([zstd library not found.])])
  194. AC_CHECK_HEADER(zstd.h, [],
  195. [AC_MSG_ERROR([zstd header not found.])])
  196. fi
  197. AC_ARG_WITH(tests-as-root,
  198. AS_HELP_STRING([--with-tests-as-root],
  199. [Run the tests as root. Use this on platforms]
  200. [like travis-ci.org that require root privileges]
  201. [to use ptrace (default is no)]),,
  202. [with_tests_as_root=no])
  203. AM_CONDITIONAL(TESTS_AS_ROOT, test "x$with_tests_as_root" = xyes)
  204. AC_CONFIG_FILES(m4_flatten([
  205. breakpad.pc
  206. breakpad-client.pc
  207. Makefile
  208. ]))
  209. AC_OUTPUT