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