configure.ac 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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. AC_PREREQ(2.64)
  30. AC_INIT(breakpad, 0.1, google-breakpad-dev@googlegroups.com)
  31. dnl Sanity check: the argument is just a file that should exist.
  32. AC_CONFIG_SRCDIR(README.md)
  33. AC_CONFIG_AUX_DIR(autotools)
  34. AC_CONFIG_MACRO_DIR([m4])
  35. AC_CANONICAL_HOST
  36. AM_INIT_AUTOMAKE(subdir-objects tar-ustar 1.11.1)
  37. AM_CONFIG_HEADER(src/config.h)
  38. AM_MAINTAINER_MODE
  39. AM_PROG_AR
  40. AM_PROG_AS
  41. AC_PROG_CC
  42. AM_PROG_CC_C_O
  43. AC_PROG_CPP
  44. AC_PROG_CXX
  45. AC_PROG_RANLIB
  46. dnl This must come before all the feature tests below.
  47. AC_ARG_ENABLE(m32,
  48. AS_HELP_STRING([--enable-m32],
  49. [Compile/build with -m32]
  50. [(default is no)]),
  51. [case "${enableval}" in
  52. yes)
  53. CFLAGS="${CFLAGS} -m32"
  54. CXXFLAGS="${CXXFLAGS} -m32"
  55. usem32=true
  56. ;;
  57. no)
  58. usem32=false
  59. ;;
  60. *)
  61. AC_MSG_ERROR(bad value ${enableval} for --enable-m32)
  62. ;;
  63. esac],
  64. [usem32=false])
  65. AC_HEADER_STDC
  66. AC_SYS_LARGEFILE
  67. AX_PTHREAD
  68. AC_CHECK_HEADERS([a.out.h sys/mman.h sys/random.h])
  69. AC_CHECK_FUNCS([arc4random getcontext getrandom memfd_create])
  70. AM_CONDITIONAL([HAVE_GETCONTEXT], [test "x$ac_cv_func_getcontext" = xyes])
  71. AM_CONDITIONAL([HAVE_MEMFD_CREATE], [test "x$ac_cv_func_memfd_create" = xyes])
  72. AX_CXX_COMPILE_STDCXX(11, noext, mandatory)
  73. dnl Test supported warning flags.
  74. WARN_CXXFLAGS=
  75. dnl This warning flag is used by clang. Its default behavior is to warn when
  76. dnl given an unknown flag rather than error out.
  77. AC_LANG_PUSH([C++])
  78. AX_CHECK_COMPILE_FLAG([-Werror=unknown-warning-option],[
  79. ax_compiler_flags_test="-Werror=unknown-warning-option"
  80. ],[
  81. ax_compiler_flags_test=""
  82. ])
  83. AX_APPEND_COMPILE_FLAGS(m4_flatten([
  84. -Wmissing-braces
  85. -Wnon-virtual-dtor
  86. -Woverloaded-virtual
  87. -Wreorder
  88. -Wsign-compare
  89. -Wunused-local-typedefs
  90. -Wunused-variable
  91. -Wvla
  92. ]), [WARN_CXXFLAGS], [${ax_compiler_flags_test}])
  93. AS_VAR_APPEND([WARN_CXXFLAGS], " -Werror")
  94. AC_LANG_POP([C++])
  95. AC_SUBST([WARN_CXXFLAGS])
  96. dnl Test support for O_CLOEXEC
  97. AX_CHECK_DEFINE([fcntl.h], [O_CLOEXEC], [],
  98. [AC_DEFINE([O_CLOEXEC], [0], [Fallback definition for old systems])])
  99. # Only build Linux client libs when compiling for Linux
  100. case $host in
  101. *-*-linux* | *-android* )
  102. LINUX_HOST=true
  103. ;;
  104. esac
  105. AM_CONDITIONAL(LINUX_HOST, test x$LINUX_HOST = xtrue)
  106. # Only use Android support headers when compiling for Android
  107. case $host in
  108. *-android*)
  109. ANDROID_HOST=true
  110. ;;
  111. esac
  112. AM_CONDITIONAL(ANDROID_HOST, test x$ANDROID_HOST = xtrue)
  113. # Some tools (like mac ones) only support x86 currently.
  114. case $host_cpu in
  115. i?86|x86_64)
  116. X86_HOST=true
  117. ;;
  118. esac
  119. AM_CONDITIONAL(X86_HOST, test x$X86_HOST = xtrue)
  120. AC_ARG_ENABLE(processor,
  121. AS_HELP_STRING([--disable-processor],
  122. [Don't build processor library]
  123. [(default is no)]),
  124. [case "${enableval}" in
  125. yes)
  126. disable_processor=false
  127. ;;
  128. no)
  129. disable_processor=true
  130. ;;
  131. *)
  132. AC_MSG_ERROR(bad value ${enableval} for --disable-processor)
  133. ;;
  134. esac],
  135. [disable_processor=false])
  136. AM_CONDITIONAL(DISABLE_PROCESSOR, test x$disable_processor = xtrue)
  137. AC_ARG_ENABLE(tools,
  138. AS_HELP_STRING([--disable-tools],
  139. [Don't build tool binaries]
  140. [(default is no)]),
  141. [case "${enableval}" in
  142. yes)
  143. disable_tools=false
  144. ;;
  145. no)
  146. disable_tools=true
  147. ;;
  148. *)
  149. AC_MSG_ERROR(bad value ${enableval} for --disable-tools)
  150. ;;
  151. esac],
  152. [disable_tools=false])
  153. AM_CONDITIONAL(DISABLE_TOOLS, test x$disable_tools = xtrue)
  154. if test x$LINUX_HOST = xfalse -a x$disable_processor = xtrue -a x$disable_tools = xtrue; then
  155. AC_MSG_ERROR([--disable-processor and --disable-tools were specified, and not building for Linux. Nothing to build!])
  156. fi
  157. AC_ARG_ENABLE(system-test-libs,
  158. AS_HELP_STRING([--enable-system-test-libs],
  159. [Use gtest/gmock/etc... from the system instead ]
  160. [of the local copies (default is local)]),
  161. [case "${enableval}" in
  162. yes)
  163. system_test_libs=true
  164. ;;
  165. no)
  166. system_test_libs=false
  167. ;;
  168. *)
  169. AC_MSG_ERROR(bad value ${enableval} for --enable-system-test-libs)
  170. ;;
  171. esac],
  172. [system_test_libs=false])
  173. AM_CONDITIONAL(SYSTEM_TEST_LIBS, test x$system_test_libs = xtrue)
  174. AC_ARG_VAR([GMOCK_CFLAGS], [Compiler flags for gmock])
  175. AC_ARG_VAR([GMOCK_LIBS], [Linker flags for gmock])
  176. AC_ARG_VAR([GTEST_CFLAGS], [Compiler flags for gtest])
  177. AC_ARG_VAR([GTEST_LIBS], [Linker flags for gtest])
  178. if test x$system_test_libs = xtrue; then
  179. : "${GMOCK_CFLAGS:=-pthread}"
  180. : "${GMOCK_LIBS:=-lgmock -lgtest -pthread -lpthread}"
  181. : "${GTEST_CFLAGS:=-pthread}"
  182. : "${GTEST_LIBS:=-lgtest -pthread -lpthread}"
  183. fi
  184. AC_ARG_ENABLE(selftest,
  185. AS_HELP_STRING([--enable-selftest],
  186. [Run extra tests with "make check" ]
  187. [(may conflict with optimizations) ]
  188. [(default is no)]),
  189. [case "${enableval}" in
  190. yes)
  191. selftest=true
  192. ;;
  193. no)
  194. selftest=false
  195. ;;
  196. *)
  197. AC_MSG_ERROR(bad value ${enableval} for --enable-selftest)
  198. ;;
  199. esac],
  200. [selftest=false])
  201. AM_CONDITIONAL(SELFTEST, test x$selftest = xtrue)
  202. AC_ARG_WITH(rust-demangle,
  203. AS_HELP_STRING([--with-rust-demangle=/path/to/rust-demangle-capi],
  204. [Link against the rust-demangle library]
  205. [to demangle Rust language symbols during]
  206. [symbol dumping (default is no)]
  207. [Pass the path to the crate root.]),
  208. [case "${withval}" in
  209. yes)
  210. AC_MSG_ERROR(You must pass the path to the rust-demangle-capi crate for --with-rust-demangle)
  211. ;;
  212. no)
  213. rust_demangle=false
  214. ;;
  215. *)
  216. if ! test -f "${withval}/Cargo.toml"; then
  217. AC_MSG_ERROR(You must pass the path to the rust-demangle-capi crate for --with-rust-demangle)
  218. fi
  219. RUST_DEMANGLE_CFLAGS="-DHAVE_RUST_DEMANGLE -I${withval}/target/include"
  220. RUST_DEMANGLE_LIBS="-L${withval}/target/release -lrust_demangle -lpthread -ldl"
  221. ;;
  222. esac],
  223. [rust_demangle=false])
  224. AC_ARG_VAR([RUST_DEMANGLE_CFLAGS], [Compiler flags for rust-demangle])
  225. AC_ARG_VAR([RUST_DEMANGLE_LIBS], [Linker flags for rust-demangle])
  226. AC_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. [case "${withval}" in
  232. yes)
  233. tests_as_root=true
  234. ;;
  235. no)
  236. tests_as_root=false
  237. ;;
  238. *)
  239. AC_MSG_ERROR(--with-tests-as-root can only be "yes" or "no")
  240. ;;
  241. esac],
  242. [tests_as_root=false])
  243. AM_CONDITIONAL(TESTS_AS_ROOT, test x$tests_as_root = xtrue)
  244. AC_CONFIG_FILES(m4_flatten([
  245. breakpad.pc
  246. breakpad-client.pc
  247. Makefile
  248. ]))
  249. AC_OUTPUT