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