configure.ac 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. # configure.ac -- Backtrace configure script.
  2. # Copyright (C) 2012-2022 Free Software Foundation, Inc.
  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. # (1) Redistributions of source code must retain the above copyright
  7. # notice, this list of conditions and the following disclaimer.
  8. # (2) Redistributions in binary form must reproduce the above copyright
  9. # notice, this list of conditions and the following disclaimer in
  10. # the documentation and/or other materials provided with the
  11. # distribution.
  12. # (3) The name of the author may not be used to
  13. # endorse or promote products derived from this software without
  14. # specific prior written permission.
  15. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  16. # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17. # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
  19. # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20. # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  21. # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  22. # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  23. # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  24. # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  25. # POSSIBILITY OF SUCH DAMAGE.
  26. AC_INIT(package-unused, version-unused,, libbacktrace)
  27. AC_CONFIG_SRCDIR(backtrace.h)
  28. AC_CONFIG_HEADER(config.h)
  29. if test -n "${with_target_subdir}"; then
  30. AM_ENABLE_MULTILIB(, ..)
  31. fi
  32. AC_CANONICAL_SYSTEM
  33. target_alias=${target_alias-$host_alias}
  34. AC_USE_SYSTEM_EXTENSIONS
  35. libtool_VERSION=1:0:0
  36. AC_SUBST(libtool_VERSION)
  37. # 1.11.1: Require that version of automake.
  38. # foreign: Don't require README, INSTALL, NEWS, etc.
  39. # no-define: Don't define PACKAGE and VERSION.
  40. # no-dependencies: Don't generate automatic dependencies.
  41. # (because it breaks when using bootstrap-lean, since some of the
  42. # headers are gone at "make install" time).
  43. # -Wall: Issue all automake warnings.
  44. # -Wno-portability: Don't warn about constructs supported by GNU make.
  45. # (because GCC requires GNU make anyhow).
  46. AM_INIT_AUTOMAKE([1.11.1 foreign no-dist no-define no-dependencies -Wall -Wno-portability])
  47. AM_MAINTAINER_MODE
  48. AC_ARG_WITH(target-subdir,
  49. [ --with-target-subdir=SUBDIR Configuring in a subdirectory for target])
  50. # We must force CC to /not/ be precious variables; otherwise
  51. # the wrong, non-multilib-adjusted value will be used in multilibs.
  52. # As a side effect, we have to subst CFLAGS ourselves.
  53. m4_rename([_AC_ARG_VAR_PRECIOUS],[backtrace_PRECIOUS])
  54. m4_define([_AC_ARG_VAR_PRECIOUS],[])
  55. AC_PROG_CC
  56. m4_rename_force([backtrace_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
  57. AC_SUBST(CFLAGS)
  58. AC_PROG_RANLIB
  59. AC_PROG_AWK
  60. case "$AWK" in
  61. "") AC_MSG_ERROR([can't build without awk]) ;;
  62. esac
  63. AC_CHECK_PROG(DWZ, dwz, dwz)
  64. AM_CONDITIONAL(HAVE_DWZ, test "$DWZ" != "")
  65. LT_INIT
  66. AM_PROG_LIBTOOL
  67. AC_SYS_LARGEFILE
  68. backtrace_supported=yes
  69. if test -n "${with_target_subdir}"; then
  70. # We are compiling a GCC library. We can assume that the unwind
  71. # library exists.
  72. BACKTRACE_FILE="backtrace.lo simple.lo"
  73. else
  74. AC_CHECK_HEADER([unwind.h],
  75. [AC_CHECK_FUNC([_Unwind_Backtrace],
  76. [BACKTRACE_FILE="backtrace.lo simple.lo"],
  77. [BACKTRACE_FILE="nounwind.lo"
  78. backtrace_supported=no])],
  79. [BACKTRACE_FILE="nounwind.lo"
  80. backtrace_supported=no])
  81. fi
  82. AC_SUBST(BACKTRACE_FILE)
  83. EXTRA_FLAGS=
  84. if test -n "${with_target_subdir}"; then
  85. EXTRA_FLAGS="-funwind-tables -frandom-seed=\$@"
  86. else
  87. AC_CACHE_CHECK([for -funwind-tables option],
  88. [libbacktrace_cv_c_unwind_tables],
  89. [CFLAGS_hold="$CFLAGS"
  90. CFLAGS="$CFLAGS -funwind-tables"
  91. AC_COMPILE_IFELSE(
  92. [AC_LANG_PROGRAM([static int f() { return 0; }], [return f();])],
  93. [libbacktrace_cv_c_unwind_tables=yes],
  94. [libbacktrace_cv_c_unwind_tables=no])
  95. CFLAGS="$CFLAGS_hold"])
  96. if test "$libbacktrace_cv_c_unwind_tables" = "yes"; then
  97. EXTRA_FLAGS=-funwind-tables
  98. fi
  99. AC_CACHE_CHECK([for -frandom-seed=string option],
  100. [libbacktrace_cv_c_random_seed_string],
  101. [CFLAGS_hold="$CFLAGS"
  102. CFLAGS="$CFLAGS -frandom-seed=conftest.lo"
  103. AC_COMPILE_IFELSE(
  104. [AC_LANG_PROGRAM([], [return 0;])],
  105. [libbacktrace_cv_c_random_seed_string=yes],
  106. [libbacktrace_cv_c_random_seed_string=no])
  107. CFLAGS="$CFLAGS_hold"])
  108. if test "$libbacktrace_cv_c_random_seed_string" = "yes"; then
  109. EXTRA_FLAGS="$EXTRA_FLAGS -frandom-seed=\$@"
  110. fi
  111. fi
  112. if test -n "${with_target_subdir}"; then
  113. # Add CET specific flags is Intel CET is enabled.
  114. GCC_CET_FLAGS(CET_FLAGS)
  115. EXTRA_FLAGS="$EXTRA_FLAGS $CET_FLAGS"
  116. fi
  117. AC_SUBST(EXTRA_FLAGS)
  118. ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wstrict-prototypes \
  119. -Wmissing-prototypes -Wold-style-definition \
  120. -Wmissing-format-attribute -Wcast-qual],
  121. [WARN_FLAGS])
  122. AC_ARG_ENABLE([werror],
  123. [AS_HELP_STRING([--disable-werror], [disable building with -Werror])])
  124. AS_IF([test "x$enable_werror" != "xno" && test -n "${with_target_subdir}"],
  125. [WARN_FLAGS="$WARN_FLAGS -Werror"])
  126. AC_SUBST(WARN_FLAGS)
  127. if test -n "${with_target_subdir}"; then
  128. GCC_CHECK_UNWIND_GETIPINFO
  129. else
  130. ac_save_CFFLAGS="$CFLAGS"
  131. CFLAGS="$CFLAGS -Werror-implicit-function-declaration"
  132. AC_MSG_CHECKING([for _Unwind_GetIPInfo])
  133. AC_LINK_IFELSE(
  134. [AC_LANG_PROGRAM(
  135. [#include "unwind.h"
  136. struct _Unwind_Context *context;
  137. int ip_before_insn = 0;],
  138. [return _Unwind_GetIPInfo (context, &ip_before_insn);])],
  139. [have_unwind_getipinfo=yes], [have_unwind_getipinfo=no])
  140. CFLAGS="$ac_save_CFLAGS"
  141. AC_MSG_RESULT([$have_unwind_getipinfo])
  142. if test "$have_unwind_getipinfo" = "yes"; then
  143. AC_DEFINE(HAVE_GETIPINFO, 1, [Define if _Unwind_GetIPInfo is available.])
  144. fi
  145. fi
  146. # Enable --enable-host-shared.
  147. AC_ARG_ENABLE(host-shared,
  148. [AS_HELP_STRING([--enable-host-shared],
  149. [build host code as shared libraries])],
  150. [PIC_FLAG=-fPIC], [PIC_FLAG=])
  151. AC_SUBST(PIC_FLAG)
  152. # Enable Intel CET on Intel CET enabled host if jit is enabled.
  153. GCC_CET_HOST_FLAGS(CET_HOST_FLAGS)
  154. case x$enable_languages in
  155. *jit*)
  156. ;;
  157. *)
  158. CET_HOST_FLAGS=
  159. ;;
  160. esac
  161. AC_SUBST(CET_HOST_FLAGS)
  162. # Test for __sync support.
  163. AC_CACHE_CHECK([__sync extensions],
  164. [libbacktrace_cv_sys_sync],
  165. [if test -n "${with_target_subdir}"; then
  166. case "${host}" in
  167. hppa*-*-hpux*) libbacktrace_cv_sys_sync=no ;;
  168. *) libbacktrace_cv_sys_sync=yes ;;
  169. esac
  170. else
  171. AC_LINK_IFELSE(
  172. [AC_LANG_PROGRAM([int i;],
  173. [__sync_bool_compare_and_swap (&i, i, i);
  174. __sync_lock_test_and_set (&i, 1);
  175. __sync_lock_release (&i);])],
  176. [libbacktrace_cv_sys_sync=yes],
  177. [libbacktrace_cv_sys_sync=no])
  178. fi])
  179. BACKTRACE_SUPPORTS_THREADS=0
  180. if test "$libbacktrace_cv_sys_sync" = "yes"; then
  181. BACKTRACE_SUPPORTS_THREADS=1
  182. AC_DEFINE([HAVE_SYNC_FUNCTIONS], 1,
  183. [Define to 1 if you have the __sync functions])
  184. fi
  185. AC_SUBST(BACKTRACE_SUPPORTS_THREADS)
  186. # Test for __atomic support.
  187. AC_CACHE_CHECK([__atomic extensions],
  188. [libbacktrace_cv_sys_atomic],
  189. [if test -n "${with_target_subdir}"; then
  190. libbacktrace_cv_sys_atomic=yes
  191. else
  192. AC_LINK_IFELSE(
  193. [AC_LANG_PROGRAM([int i;],
  194. [__atomic_load_n (&i, __ATOMIC_ACQUIRE);
  195. __atomic_store_n (&i, 1, __ATOMIC_RELEASE);])],
  196. [libbacktrace_cv_sys_atomic=yes],
  197. [libbacktrace_cv_sys_atomic=no])
  198. fi])
  199. if test "$libbacktrace_cv_sys_atomic" = "yes"; then
  200. AC_DEFINE([HAVE_ATOMIC_FUNCTIONS], 1,
  201. [Define to 1 if you have the __atomic functions])
  202. fi
  203. # The library needs to be able to read the executable itself. Compile
  204. # a file to determine the executable format. The awk script
  205. # filetype.awk prints out the file type.
  206. AC_CACHE_CHECK([output filetype],
  207. [libbacktrace_cv_sys_filetype],
  208. [filetype=
  209. AC_COMPILE_IFELSE(
  210. [AC_LANG_PROGRAM([int i;], [int j;])],
  211. [filetype=`${AWK} -f $srcdir/filetype.awk conftest.$ac_objext`],
  212. [AC_MSG_FAILURE([compiler failed])])
  213. libbacktrace_cv_sys_filetype=$filetype])
  214. # Match the file type to decide what files to compile.
  215. FORMAT_FILE=
  216. backtrace_supports_data=yes
  217. case "$libbacktrace_cv_sys_filetype" in
  218. elf*) FORMAT_FILE="elf.lo" ;;
  219. macho) FORMAT_FILE="macho.lo" ;;
  220. pecoff) FORMAT_FILE="pecoff.lo"
  221. backtrace_supports_data=no
  222. ;;
  223. xcoff*) FORMAT_FILE="xcoff.lo"
  224. backtrace_supports_data=no
  225. ;;
  226. *) AC_MSG_WARN([could not determine output file type])
  227. FORMAT_FILE="unknown.lo"
  228. backtrace_supported=no
  229. ;;
  230. esac
  231. AC_SUBST(FORMAT_FILE)
  232. # ELF defines.
  233. elfsize=
  234. case "$libbacktrace_cv_sys_filetype" in
  235. elf32) elfsize=32 ;;
  236. elf64) elfsize=64 ;;
  237. *) elfsize=unused
  238. esac
  239. AC_DEFINE_UNQUOTED([BACKTRACE_ELF_SIZE], [$elfsize], [ELF size: 32 or 64])
  240. AM_CONDITIONAL(HAVE_ELF, test "$FORMAT_FILE" = "elf.lo")
  241. # XCOFF defines.
  242. xcoffsize=
  243. case "$libbacktrace_cv_sys_filetype" in
  244. xcoff32) xcoffsize=32 ;;
  245. xcoff64) xcoffsize=64 ;;
  246. *) xcoffsize=unused
  247. esac
  248. AC_DEFINE_UNQUOTED([BACKTRACE_XCOFF_SIZE], [$xcoffsize], [XCOFF size: 32 or 64])
  249. BACKTRACE_SUPPORTED=0
  250. if test "$backtrace_supported" = "yes"; then
  251. BACKTRACE_SUPPORTED=1
  252. fi
  253. AC_SUBST(BACKTRACE_SUPPORTED)
  254. BACKTRACE_SUPPORTS_DATA=0
  255. if test "$backtrace_supports_data" = "yes"; then
  256. BACKTRACE_SUPPORTS_DATA=1
  257. fi
  258. AC_SUBST(BACKTRACE_SUPPORTS_DATA)
  259. GCC_HEADER_STDINT(gstdint.h)
  260. AC_CHECK_HEADERS(sys/mman.h)
  261. if test "$ac_cv_header_sys_mman_h" = "no"; then
  262. have_mmap=no
  263. else
  264. if test -n "${with_target_subdir}"; then
  265. # When built as a GCC target library, we can't do a link test. We
  266. # simply assume that if we have mman.h, we have mmap.
  267. have_mmap=yes
  268. case "${host}" in
  269. *-*-msdosdjgpp)
  270. # DJGPP has sys/man.h, but no mmap
  271. have_mmap=no ;;
  272. esac
  273. else
  274. AC_CHECK_FUNC(mmap, [have_mmap=yes], [have_mmap=no])
  275. fi
  276. fi
  277. if test "$have_mmap" = "no"; then
  278. VIEW_FILE=read.lo
  279. ALLOC_FILE=alloc.lo
  280. else
  281. VIEW_FILE=mmapio.lo
  282. AC_PREPROC_IFELSE([AC_LANG_SOURCE([
  283. #include <sys/mman.h>
  284. #if !defined(MAP_ANONYMOUS) && !defined(MAP_ANON)
  285. #error no MAP_ANONYMOUS
  286. #endif
  287. ])], [ALLOC_FILE=mmap.lo], [ALLOC_FILE=alloc.lo])
  288. fi
  289. AC_SUBST(VIEW_FILE)
  290. AC_SUBST(ALLOC_FILE)
  291. BACKTRACE_USES_MALLOC=0
  292. if test "$ALLOC_FILE" = "alloc.lo"; then
  293. BACKTRACE_USES_MALLOC=1
  294. fi
  295. AC_SUBST(BACKTRACE_USES_MALLOC)
  296. # Check for dl_iterate_phdr.
  297. AC_CHECK_HEADERS(link.h)
  298. if test "$ac_cv_header_link_h" = "no"; then
  299. have_dl_iterate_phdr=no
  300. else
  301. if test -n "${with_target_subdir}"; then
  302. # When built as a GCC target library, we can't do a link test.
  303. AC_EGREP_HEADER([dl_iterate_phdr], [link.h], [have_dl_iterate_phdr=yes],
  304. [have_dl_iterate_phdr=no])
  305. else
  306. AC_CHECK_FUNC([dl_iterate_phdr], [have_dl_iterate_phdr=yes],
  307. [have_dl_iterate_phdr=no])
  308. fi
  309. fi
  310. if test "$have_dl_iterate_phdr" = "yes"; then
  311. AC_DEFINE(HAVE_DL_ITERATE_PHDR, 1, [Define if dl_iterate_phdr is available.])
  312. fi
  313. # Check for header file for Mach-O image functions.
  314. AC_CHECK_HEADERS(mach-o/dyld.h)
  315. # Check for loadquery.
  316. AC_CHECK_HEADERS(sys/ldr.h)
  317. if test "$ac_cv_header_sys_ldr_h" = "no"; then
  318. have_loadquery=no
  319. else
  320. if test -n "${with_target_subdir}"; then
  321. # When built as a GCC target library, we can't do a link test.
  322. AC_EGREP_HEADER([loadquery], [sys/ldr.h], [have_loadquery=yes],
  323. [have_loadquery=no])
  324. else
  325. AC_CHECK_FUNC([loadquery], [have_loadquery=yes],
  326. [have_loadquery=no])
  327. fi
  328. fi
  329. if test "$have_loadquery" = "yes"; then
  330. AC_DEFINE(HAVE_LOADQUERY, 1, [Define if AIX loadquery is available.])
  331. fi
  332. # Check for the fcntl function.
  333. if test -n "${with_target_subdir}"; then
  334. case "${host}" in
  335. *-*-mingw*) have_fcntl=no ;;
  336. *) have_fcntl=yes ;;
  337. esac
  338. else
  339. AC_CHECK_FUNC(fcntl, [have_fcntl=yes], [have_fcntl=no])
  340. fi
  341. if test "$have_fcntl" = "yes"; then
  342. AC_DEFINE([HAVE_FCNTL], 1,
  343. [Define to 1 if you have the fcntl function])
  344. fi
  345. AC_CHECK_DECLS([strnlen, getpagesize])
  346. AC_CHECK_FUNCS(lstat readlink)
  347. # Check for getexecname function.
  348. if test -n "${with_target_subdir}"; then
  349. case "${host}" in
  350. *-*-solaris2*) have_getexecname=yes ;;
  351. *) have_getexecname=no ;;
  352. esac
  353. else
  354. AC_CHECK_FUNC(getexecname, [have_getexecname=yes], [have_getexecname=no])
  355. fi
  356. if test "$have_getexecname" = "yes"; then
  357. AC_DEFINE(HAVE_GETEXECNAME, 1, [Define if getexecname is available.])
  358. fi
  359. # Check for sysctl definitions.
  360. AC_CACHE_CHECK([for KERN_PROC],
  361. [libbacktrace_cv_proc],
  362. [AC_COMPILE_IFELSE(
  363. [AC_LANG_PROGRAM([
  364. #include <sys/types.h>
  365. #include <sys/sysctl.h>
  366. ], [int mib0 = CTL_KERN; int mib1 = KERN_PROC; int mib2 = KERN_PROC_PATHNAME;])],
  367. [libbacktrace_cv_proc=yes],
  368. [libbacktrace_cv_proc=no])])
  369. if test "$libbacktrace_cv_proc" = "yes"; then
  370. AC_DEFINE([HAVE_KERN_PROC], 1,
  371. [Define to 1 if you have KERN_PROC and KERN_PROC_PATHNAME in <sys/sysctl.h>.])
  372. fi
  373. AC_CACHE_CHECK([for KERN_PROG_ARGS],
  374. [libbacktrace_cv_procargs],
  375. [AC_COMPILE_IFELSE(
  376. [AC_LANG_PROGRAM([
  377. #include <sys/types.h>
  378. #include <sys/sysctl.h>
  379. ], [int mib0 = CTL_KERN; int mib1 = KERN_PROC_ARGS; int mib2 = KERN_PROC_PATHNAME;])],
  380. [libbacktrace_cv_procargs=yes],
  381. [libbacktrace_cv_procargs=no])])
  382. if test "$libbacktrace_cv_procargs" = "yes"; then
  383. AC_DEFINE([HAVE_KERN_PROC_ARGS], 1,
  384. [Define to 1 if you have KERN_PROCARGS and KERN_PROC_PATHNAME in <sys/sysctl.h>.])
  385. fi
  386. # Check for the clock_gettime function.
  387. AC_CHECK_FUNCS(clock_gettime)
  388. clock_gettime_link=
  389. # At least for glibc, clock_gettime is in librt. But don't
  390. # pull that in if it still doesn't give us the function we want. This
  391. # test is copied from libgomp, and modified to not link in -lrt as
  392. # we're using this for test timing only.
  393. if test "$ac_cv_func_clock_gettime" = no; then
  394. AC_CHECK_LIB(rt, clock_gettime,
  395. [CLOCK_GETTIME_LINK=-lrt
  396. AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
  397. [Define to 1 if you have the `clock_gettime' function.])])
  398. fi
  399. AC_SUBST(CLOCK_GETTIME_LINK)
  400. dnl Test whether the compiler supports the -pthread option.
  401. AC_CACHE_CHECK([whether -pthread is supported],
  402. [libgo_cv_lib_pthread],
  403. [CFLAGS_hold=$CFLAGS
  404. CFLAGS="$CFLAGS -pthread"
  405. AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
  406. [libgo_cv_lib_pthread=yes],
  407. [libgo_cv_lib_pthread=no])
  408. CFLAGS=$CFLAGS_hold])
  409. PTHREAD_CFLAGS=
  410. if test "$libgo_cv_lib_pthread" = yes; then
  411. PTHREAD_CFLAGS=-pthread
  412. fi
  413. AC_SUBST(PTHREAD_CFLAGS)
  414. AM_CONDITIONAL(HAVE_PTHREAD, test "$libgo_cv_lib_pthread" = yes)
  415. dnl Test whether the compiler and the linker support the -gdwarf-5 option.
  416. AC_CACHE_CHECK([whether -gdwarf-5 is supported],
  417. [libbacktrace_cv_lib_dwarf5],
  418. [CFLAGS_hold=$CFLAGS
  419. CFLAGS="$CFLAGS -gdwarf-5"
  420. AC_LINK_IFELSE([AC_LANG_PROGRAM([int i;], [return 0;])],
  421. [libbacktrace_cv_lib_dwarf5=yes],
  422. [libbacktrace_cv_lib_dwarf5=no])
  423. CFLAGS=$CFLAGS_hold])
  424. AM_CONDITIONAL(HAVE_DWARF5, test "$libbacktrace_cv_lib_dwarf5" = yes)
  425. AC_CHECK_LIB([z], [compress],
  426. [AC_DEFINE(HAVE_ZLIB, 1, [Define if -lz is available.])])
  427. AM_CONDITIONAL(HAVE_ZLIB, test "$ac_cv_lib_z_compress" = yes)
  428. dnl Test whether the linker supports the --compress_debug_sections option.
  429. AC_CACHE_CHECK([whether --compress-debug-sections is supported],
  430. [libgo_cv_ld_compress],
  431. [LDFLAGS_hold=$LDFLAGS
  432. LDFLAGS="$LDFLAGS -Wl,--compress-debug-sections=zlib-gnu"
  433. AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
  434. [libgo_cv_ld_compress=yes],
  435. [libgo_cv_ld_compress=no])
  436. LDFLAGS=$LDFLAGS_hold])
  437. AM_CONDITIONAL(HAVE_COMPRESSED_DEBUG, test "$libgo_cv_ld_compress" = yes)
  438. AC_ARG_VAR(OBJCOPY, [location of objcopy])
  439. AC_CHECK_PROG(OBJCOPY, objcopy, objcopy,)
  440. AC_CHECK_PROG(READELF, readelf, readelf)
  441. AC_CACHE_CHECK([whether objcopy supports debuglink],
  442. [libbacktrace_cv_objcopy_debuglink],
  443. [if test -n "${with_target_subdir}"; then
  444. libbacktrace_cv_objcopy_debuglink=no
  445. elif ! test -n "${OBJCOPY}"; then
  446. libbacktrace_cv_objcopy_debuglink=no
  447. elif ${OBJCOPY} --help | fgrep add-gnu-debuglink >/dev/null 2>&1; then
  448. libbacktrace_cv_objcopy_debuglink=yes
  449. else
  450. libbacktrace_cv_objcopy_debuglink=no
  451. fi])
  452. AM_CONDITIONAL(HAVE_OBJCOPY_DEBUGLINK, test "$libbacktrace_cv_objcopy_debuglink" = yes)
  453. AC_ARG_VAR(DSYMUTIL, [location of dsymutil])
  454. AC_CHECK_PROG(DSYMUTIL, dsymutil, dsymutil)
  455. AM_CONDITIONAL(USE_DSYMUTIL, test -n "${DSYMUTIL}" -a "$FORMAT_FILE" = "macho.lo")
  456. AC_ARG_VAR(NM, [location of nm])
  457. AC_CHECK_PROG(NM, nm, nm)
  458. AC_CHECK_PROG(XZ, xz, xz)
  459. AM_CONDITIONAL(HAVE_XZ, test "$XZ" != "")
  460. AC_CHECK_PROG(COMM, comm, comm)
  461. AM_CONDITIONAL(HAVE_COMM, test "$COMM" != "")
  462. AM_CONDITIONAL(HAVE_MINIDEBUG,
  463. test "${with_target_subdir}" = "" -a "$FORMAT_FILE" = "elf.lo" -a "${OBJCOPY}" != "" -a "${NM}" != "" -a "${XZ}" != "" -a "${COMM}" != "")
  464. AC_CHECK_LIB([lzma], [lzma_auto_decoder],
  465. [AC_DEFINE(HAVE_LIBLZMA, 1, [Define if -llzma is available.])])
  466. AM_CONDITIONAL(HAVE_LIBLZMA, test "$ac_cv_lib_lzma_lzma_auto_decoder" = yes)
  467. AC_CACHE_CHECK([whether tests can run],
  468. [libbacktrace_cv_sys_native],
  469. [AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
  470. [libbacktrace_cv_sys_native=yes],
  471. [libbacktrace_cv_sys_native=no],
  472. [libbacktrace_cv_sys_native=no])])
  473. AM_CONDITIONAL(NATIVE, test "$libbacktrace_cv_sys_native" = "yes")
  474. if test "${multilib}" = "yes"; then
  475. multilib_arg="--enable-multilib"
  476. else
  477. multilib_arg=
  478. fi
  479. AC_CONFIG_FILES(Makefile backtrace-supported.h)
  480. AC_CONFIG_FILES(install-debuginfo-for-buildid.sh, chmod +x install-debuginfo-for-buildid.sh)
  481. # We need multilib support, but only if configuring for the target.
  482. AC_CONFIG_COMMANDS([default],
  483. [if test -n "$CONFIG_FILES"; then
  484. if test -n "${with_target_subdir}"; then
  485. # Multilibs need MULTISUBDIR defined correctly in certain makefiles so
  486. # that multilib installs will end up installed in the correct place.
  487. # The testsuite needs it for multilib-aware ABI baseline files.
  488. # To work around this not being passed down from config-ml.in ->
  489. # srcdir/Makefile.am -> srcdir/{src,libsupc++,...}/Makefile.am, manually
  490. # append it here. Only modify Makefiles that have just been created.
  491. #
  492. # Also, get rid of this simulated-VPATH thing that automake does.
  493. cat > vpsed << \_EOF
  494. s!`test -f '$<' || echo '$(srcdir)/'`!!
  495. _EOF
  496. for i in $SUBDIRS; do
  497. case $CONFIG_FILES in
  498. *${i}/Makefile*)
  499. #echo "Adding MULTISUBDIR to $i/Makefile"
  500. sed -f vpsed $i/Makefile > tmp
  501. grep '^MULTISUBDIR =' Makefile >> tmp
  502. mv tmp $i/Makefile
  503. ;;
  504. esac
  505. done
  506. rm vpsed
  507. fi
  508. fi
  509. ],
  510. [
  511. # Variables needed in config.status (file generation) which aren't already
  512. # passed by autoconf.
  513. SUBDIRS="$SUBDIRS"
  514. ])
  515. AC_OUTPUT