Debian Codegraph @

libbacktrace/configure.ac

raw
1 # configure.ac -- Backtrace configure script.
2 # Copyright (C) 2012-2025 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_HEADER(config.h)
35
36 if test -n "${with_target_subdir}"; then
37 AM_ENABLE_MULTILIB(, ..)
38 fi
39
40 AC_CANONICAL_SYSTEM
41 target_alias=${target_alias-$host_alias}
42
43 AC_USE_SYSTEM_EXTENSIONS
44
45 libtool_VERSION=1:0:0
46 AC_SUBST(libtool_VERSION)
47
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).
57 AM_INIT_AUTOMAKE([1.11.1 foreign no-dist no-define no-dependencies -Wall -Wno-portability])
58
59 AM_MAINTAINER_MODE
60
61 AC_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.
67 m4_rename([_AC_ARG_VAR_PRECIOUS],[backtrace_PRECIOUS])
68 m4_define([_AC_ARG_VAR_PRECIOUS],[])
69 AC_PROG_CC
70 m4_rename_force([backtrace_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
71
72 AC_SUBST(CFLAGS)
73
74 AC_PROG_RANLIB
75
76 AC_PROG_AWK
77 case "$AWK" in
78 "") AC_MSG_ERROR([can't build without awk]) ;;
79 esac
80
81 AC_CHECK_PROG(DWZ, dwz, dwz)
82 AM_CONDITIONAL(HAVE_DWZ, test "$DWZ" != "")
83
84 LT_INIT
85 AM_PROG_LIBTOOL
86
87 AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes])
88
89 AC_SYS_LARGEFILE
90
91 backtrace_supported=yes
92
93 if test -n "${with_target_subdir}"; then
94 # We are compiling a GCC library. We can assume that the unwind
95 # library exists.
96 BACKTRACE_FILE="backtrace.lo simple.lo"
97 else
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])
105 fi
106 AC_SUBST(BACKTRACE_FILE)
107
108 EXTRA_FLAGS=
109 if test -n "${with_target_subdir}"; then
110 EXTRA_FLAGS="-funwind-tables -frandom-seed=\$@"
111 else
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"])
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
136 fi
137
138 if 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"
142 fi
143 AC_SUBST(EXTRA_FLAGS)
144
145 ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wstrict-prototypes \
146 -Wmissing-prototypes -Wold-style-definition \
147 -Wmissing-format-attribute -Wcast-qual \
148 -Wno-attributes -Wno-unknown-attributes \
149 -Wpointer-arith],
150 [WARN_FLAGS])
151
152 AC_ARG_ENABLE([werror],
153 [AS_HELP_STRING([--disable-werror], [disable building with -Werror])])
154 AS_IF([test "x$enable_werror" != "xno" && test -n "${with_target_subdir}"],
155 [WARN_FLAGS="$WARN_FLAGS -Werror"])
156 AC_SUBST(WARN_FLAGS)
157
158 if test -n "${with_target_subdir}"; then
159 GCC_CHECK_UNWIND_GETIPINFO
160 else
161 ac_save_CFFLAGS="$CFLAGS"
162 CFLAGS="$CFLAGS -Werror-implicit-function-declaration"
163 AC_MSG_CHECKING([for _Unwind_GetIPInfo])
164 AC_LINK_IFELSE(
165 [AC_LANG_PROGRAM(
166 [#include "unwind.h"
167 struct _Unwind_Context *context;
168 int ip_before_insn = 0;],
169 [return _Unwind_GetIPInfo (context, &ip_before_insn);])],
170 [have_unwind_getipinfo=yes], [have_unwind_getipinfo=no])
171 CFLAGS="$ac_save_CFLAGS"
172 AC_MSG_RESULT([$have_unwind_getipinfo])
173 if test "$have_unwind_getipinfo" = "yes"; then
174 AC_DEFINE(HAVE_GETIPINFO, 1, [Define if _Unwind_GetIPInfo is available.])
175 fi
176 fi
177
178 # Enable --enable-host-pie.
179 AC_ARG_ENABLE(host-pie,
180 [AS_HELP_STRING([--enable-host-pie],
181 [build host code as PIE])],
182 [PIC_FLAG=-fPIE], [PIC_FLAG=])
183 # Enable --enable-host-shared.
184 AC_ARG_ENABLE(host-shared,
185 [AS_HELP_STRING([--enable-host-shared],
186 [build host code as shared libraries])],
187 [PIC_FLAG=-fPIC])
188 AC_SUBST(PIC_FLAG)
189
190 # Enable Intel CET on Intel CET enabled host if jit is enabled.
191 GCC_CET_HOST_FLAGS(CET_HOST_FLAGS)
192 case x$enable_languages in
193 *jit*)
194 ;;
195 *)
196 CET_HOST_FLAGS=
197 ;;
198 esac
199 AC_SUBST(CET_HOST_FLAGS)
200
201 # Test for __sync support.
202 AC_CACHE_CHECK([__sync extensions],
203 [libbacktrace_cv_sys_sync],
204 [if test -n "${with_target_subdir}"; then
205 case "${host}" in
206 hppa*-*-hpux*) libbacktrace_cv_sys_sync=no ;;
207 arm*-*-eabi*)
208 # Older versions of the Arm architecture lack the necessary instructions
209 # for these constructs, so check whether we can use them.
210 AC_LINK_IFELSE(
211 [AC_LANG_PROGRAM([int i;],
212 [__sync_bool_compare_and_swap (&i, i, i);
213 __sync_lock_test_and_set (&i, 1);
214 __sync_lock_release (&i);])],
215 [libbacktrace_cv_sys_sync=yes],
216 [libbacktrace_cv_sys_sync=no]);;
217 *) libbacktrace_cv_sys_sync=yes ;;
218 esac
219 else
220 AC_LINK_IFELSE(
221 [AC_LANG_PROGRAM([int i;],
222 [__sync_bool_compare_and_swap (&i, i, i);
223 __sync_lock_test_and_set (&i, 1);
224 __sync_lock_release (&i);])],
225 [libbacktrace_cv_sys_sync=yes],
226 [libbacktrace_cv_sys_sync=no])
227 fi])
228 BACKTRACE_SUPPORTS_THREADS=0
229 if test "$libbacktrace_cv_sys_sync" = "yes"; then
230 BACKTRACE_SUPPORTS_THREADS=1
231 AC_DEFINE([HAVE_SYNC_FUNCTIONS], 1,
232 [Define to 1 if you have the __sync functions])
233 fi
234 AC_SUBST(BACKTRACE_SUPPORTS_THREADS)
235
236 # Test for __atomic support.
237 AC_CACHE_CHECK([__atomic extensions],
238 [libbacktrace_cv_sys_atomic],
239 [if test -n "${with_target_subdir}"; then
240 libbacktrace_cv_sys_atomic=yes
241 else
242 AC_LINK_IFELSE(
243 [AC_LANG_PROGRAM([int i;],
244 [__atomic_load_n (&i, __ATOMIC_ACQUIRE);
245 __atomic_store_n (&i, 1, __ATOMIC_RELEASE);])],
246 [libbacktrace_cv_sys_atomic=yes],
247 [libbacktrace_cv_sys_atomic=no])
248 fi])
249 if test "$libbacktrace_cv_sys_atomic" = "yes"; then
250 AC_DEFINE([HAVE_ATOMIC_FUNCTIONS], 1,
251 [Define to 1 if you have the __atomic functions])
252 fi
253
254 # The library needs to be able to read the executable itself. Compile
255 # a file to determine the executable format. The awk script
256 # filetype.awk prints out the file type.
257 AC_CACHE_CHECK([output filetype],
258 [libbacktrace_cv_sys_filetype],
259 [filetype=
260 AC_COMPILE_IFELSE(
261 [AC_LANG_PROGRAM([int i;], [int j;])],
262 [filetype=`${AWK} -f $srcdir/filetype.awk conftest.$ac_objext`],
263 [AC_MSG_FAILURE([compiler failed])])
264 libbacktrace_cv_sys_filetype=$filetype])
265
266 # Match the file type to decide what files to compile.
267 FORMAT_FILE=
268 backtrace_supports_data=yes
269 case "$libbacktrace_cv_sys_filetype" in
270 elf*) FORMAT_FILE="elf.lo" ;;
271 macho) FORMAT_FILE="macho.lo" ;;
272 pecoff) FORMAT_FILE="pecoff.lo"
273 backtrace_supports_data=no
274 ;;
275 xcoff*) FORMAT_FILE="xcoff.lo"
276 backtrace_supports_data=no
277 ;;
278 *) AC_MSG_WARN([could not determine output file type])
279 FORMAT_FILE="unknown.lo"
280 backtrace_supported=no
281 ;;
282 esac
283 AC_SUBST(FORMAT_FILE)
284
285 # ELF defines.
286 elfsize=
287 case "$libbacktrace_cv_sys_filetype" in
288 elf32) elfsize=32 ;;
289 elf64) elfsize=64 ;;
290 *) elfsize=unused
291 esac
292 AC_DEFINE_UNQUOTED([BACKTRACE_ELF_SIZE], [$elfsize], [ELF size: 32 or 64])
293 AM_CONDITIONAL(HAVE_ELF, test "$FORMAT_FILE" = "elf.lo")
294
295 # XCOFF defines.
296 xcoffsize=
297 case "$libbacktrace_cv_sys_filetype" in
298 xcoff32) xcoffsize=32 ;;
299 xcoff64) xcoffsize=64 ;;
300 *) xcoffsize=unused
301 esac
302 AC_DEFINE_UNQUOTED([BACKTRACE_XCOFF_SIZE], [$xcoffsize], [XCOFF size: 32 or 64])
303
304 BACKTRACE_SUPPORTED=0
305 if test "$backtrace_supported" = "yes"; then
306 BACKTRACE_SUPPORTED=1
307 fi
308 AC_SUBST(BACKTRACE_SUPPORTED)
309
310 BACKTRACE_SUPPORTS_DATA=0
311 if test "$backtrace_supports_data" = "yes"; then
312 BACKTRACE_SUPPORTS_DATA=1
313 fi
314 AC_SUBST(BACKTRACE_SUPPORTS_DATA)
315
316 GCC_HEADER_STDINT(gstdint.h)
317
318 AC_CHECK_HEADERS(sys/mman.h)
319 if test "$ac_cv_header_sys_mman_h" = "no"; then
320 have_mmap=no
321 else
322 if test -n "${with_target_subdir}"; then
323 # When built as a GCC target library, we can't do a link test. We
324 # simply assume that if we have mman.h, we have mmap.
325 have_mmap=yes
326 case "${host}" in
327 *-*-msdosdjgpp)
328 # DJGPP has sys/man.h, but no mmap
329 have_mmap=no ;;
330 esac
331 else
332 AC_CHECK_FUNC(mmap, [have_mmap=yes], [have_mmap=no])
333 fi
334 fi
335 if test "$have_mmap" = "no"; then
336 VIEW_FILE=read.lo
337 ALLOC_FILE=alloc.lo
338 else
339 VIEW_FILE=mmapio.lo
340 AC_PREPROC_IFELSE([AC_LANG_SOURCE([
341 #include <sys/mman.h>
342 #if !defined(MAP_ANONYMOUS) && !defined(MAP_ANON)
343 #error no MAP_ANONYMOUS
344 #endif
345 ])], [ALLOC_FILE=mmap.lo], [ALLOC_FILE=alloc.lo])
346 fi
347 AC_SUBST(VIEW_FILE)
348 AC_SUBST(ALLOC_FILE)
349
350 BACKTRACE_USES_MALLOC=0
351 if test "$ALLOC_FILE" = "alloc.lo"; then
352 BACKTRACE_USES_MALLOC=1
353 fi
354 AC_SUBST(BACKTRACE_USES_MALLOC)
355
356 # Check for dl_iterate_phdr.
357 AC_CHECK_HEADERS(link.h sys/link.h)
358 if test "$ac_cv_header_link_h" = "no" -a "$ac_cv_header_sys_link_h" = "no"; then
359 have_dl_iterate_phdr=no
360 else
361 if test -n "${with_target_subdir}"; then
362 link_h=link.h
363 if test "$ac_cv_header_link_h" = "no"; then
364 link_h=sys/link.h
365 fi
366 # When built as a GCC target library, we can't do a link test.
367 AC_EGREP_HEADER([dl_iterate_phdr], [$link_h], [have_dl_iterate_phdr=yes],
368 [have_dl_iterate_phdr=no])
369 else
370 AC_CHECK_FUNC([dl_iterate_phdr], [have_dl_iterate_phdr=yes],
371 [have_dl_iterate_phdr=no])
372 fi
373 fi
374 if test "$have_dl_iterate_phdr" = "yes"; then
375 AC_DEFINE(HAVE_DL_ITERATE_PHDR, 1, [Define if dl_iterate_phdr is available.])
376 fi
377
378 # Check for header file for Mach-O image functions.
379 AC_CHECK_HEADERS(mach-o/dyld.h)
380
381 # Check for loadquery.
382 AC_CHECK_HEADERS(sys/ldr.h)
383 if test "$ac_cv_header_sys_ldr_h" = "no"; then
384 have_loadquery=no
385 else
386 if test -n "${with_target_subdir}"; then
387 # When built as a GCC target library, we can't do a link test.
388 AC_EGREP_HEADER([loadquery], [sys/ldr.h], [have_loadquery=yes],
389 [have_loadquery=no])
390 else
391 AC_CHECK_FUNC([loadquery], [have_loadquery=yes],
392 [have_loadquery=no])
393 fi
394 fi
395 if test "$have_loadquery" = "yes"; then
396 AC_DEFINE(HAVE_LOADQUERY, 1, [Define if AIX loadquery is available.])
397 fi
398
399 AC_CHECK_HEADERS(windows.h)
400 AC_CHECK_HEADERS(tlhelp32.h, [], [],
401 [#ifdef HAVE_WINDOWS_H
402 # include <windows.h>
403 #endif])
404
405 # Check for the fcntl function.
406 if test -n "${with_target_subdir}"; then
407 case "${host}" in
408 *-*-mingw*) have_fcntl=no ;;
409 *) have_fcntl=yes ;;
410 esac
411 else
412 AC_CHECK_FUNC(fcntl, [have_fcntl=yes], [have_fcntl=no])
413 fi
414 if test "$have_fcntl" = "yes"; then
415 AC_DEFINE([HAVE_FCNTL], 1,
416 [Define to 1 if you have the fcntl function])
417 fi
418
419 AC_CHECK_DECLS([strnlen, getpagesize])
420 AC_CHECK_FUNCS(lstat readlink)
421
422 # Check for getexecname function.
423 if test -n "${with_target_subdir}"; then
424 case "${host}" in
425 *-*-solaris2*) have_getexecname=yes ;;
426 *) have_getexecname=no ;;
427 esac
428 else
429 AC_CHECK_FUNC(getexecname, [have_getexecname=yes], [have_getexecname=no])
430 fi
431 if test "$have_getexecname" = "yes"; then
432 AC_DEFINE(HAVE_GETEXECNAME, 1, [Define if getexecname is available.])
433 fi
434
435 # Check for _pgmptr variable, contains the executable filename on windows
436 AC_CHECK_DECLS([_pgmptr])
437
438 # Check for sysctl definitions.
439
440 AC_CACHE_CHECK([for KERN_PROC],
441 [libbacktrace_cv_proc],
442 [AC_COMPILE_IFELSE(
443 [AC_LANG_PROGRAM([
444 #include <sys/types.h>
445 #include <sys/sysctl.h>
446 ], [int mib0 = CTL_KERN; int mib1 = KERN_PROC; int mib2 = KERN_PROC_PATHNAME;])],
447 [libbacktrace_cv_proc=yes],
448 [libbacktrace_cv_proc=no])])
449 if test "$libbacktrace_cv_proc" = "yes"; then
450 AC_DEFINE([HAVE_KERN_PROC], 1,
451 [Define to 1 if you have KERN_PROC and KERN_PROC_PATHNAME in <sys/sysctl.h>.])
452 fi
453
454 AC_CACHE_CHECK([for KERN_PROG_ARGS],
455 [libbacktrace_cv_procargs],
456 [AC_COMPILE_IFELSE(
457 [AC_LANG_PROGRAM([
458 #include <sys/types.h>
459 #include <sys/sysctl.h>
460 ], [int mib0 = CTL_KERN; int mib1 = KERN_PROC_ARGS; int mib2 = KERN_PROC_PATHNAME;])],
461 [libbacktrace_cv_procargs=yes],
462 [libbacktrace_cv_procargs=no])])
463 if test "$libbacktrace_cv_procargs" = "yes"; then
464 AC_DEFINE([HAVE_KERN_PROC_ARGS], 1,
465 [Define to 1 if you have KERN_PROCARGS and KERN_PROC_PATHNAME in <sys/sysctl.h>.])
466 fi
467
468 # Check for the clock_gettime function.
469 AC_CHECK_FUNCS(clock_gettime)
470 clock_gettime_link=
471 # At least for glibc, clock_gettime is in librt. But don't
472 # pull that in if it still doesn't give us the function we want. This
473 # test is copied from libgomp, and modified to not link in -lrt as
474 # we're using this for test timing only.
475 if test "$ac_cv_func_clock_gettime" = no; then
476 AC_CHECK_LIB(rt, clock_gettime,
477 [CLOCK_GETTIME_LINK=-lrt
478 AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
479 [Define to 1 if you have the `clock_gettime' function.])])
480 fi
481 AC_SUBST(CLOCK_GETTIME_LINK)
482
483 dnl Test whether the compiler supports the -pthread option.
484 AC_CACHE_CHECK([whether -pthread is supported],
485 [libgo_cv_lib_pthread],
486 [CFLAGS_hold=$CFLAGS
487 CFLAGS="$CFLAGS -pthread"
488 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
489 [libgo_cv_lib_pthread=yes],
490 [libgo_cv_lib_pthread=no])
491 CFLAGS=$CFLAGS_hold])
492 PTHREAD_CFLAGS=
493 if test "$libgo_cv_lib_pthread" = yes; then
494 PTHREAD_CFLAGS=-pthread
495 fi
496 AC_SUBST(PTHREAD_CFLAGS)
497
498 AM_CONDITIONAL(HAVE_PTHREAD, test "$libgo_cv_lib_pthread" = yes)
499
500 dnl Test whether the compiler and the linker support the -gdwarf-5 option.
501 AC_CACHE_CHECK([whether -gdwarf-5 is supported],
502 [libbacktrace_cv_lib_dwarf5],
503 [CFLAGS_hold=$CFLAGS
504 CFLAGS="$CFLAGS -gdwarf-5"
505 AC_LINK_IFELSE([AC_LANG_PROGRAM([int i;], [return 0;])],
506 [libbacktrace_cv_lib_dwarf5=yes],
507 [libbacktrace_cv_lib_dwarf5=no])
508 CFLAGS=$CFLAGS_hold])
509 AM_CONDITIONAL(HAVE_DWARF5, test "$libbacktrace_cv_lib_dwarf5" = yes)
510
511 AC_CHECK_LIB([z], [compress],
512 [AC_DEFINE(HAVE_ZLIB, 1, [Define if -lz is available.])])
513 AM_CONDITIONAL(HAVE_ZLIB, test "$ac_cv_lib_z_compress" = yes)
514
515 dnl Test whether the linker supports the --build-id option.
516 AC_CACHE_CHECK([whether --build-id is supported],
517 [libbacktrace_cv_ld_buildid],
518 [LDFLAGS_hold=$LDFLAGS
519 LDFLAGS="$LDFLAGS -Wl,--build-id"
520 AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
521 [libbacktrace_cv_ld_buildid=yes],
522 [libbacktrace_cv_ld_buildid=no])
523 LDFLAGS=$LDFLAGS_hold])
524 AM_CONDITIONAL(HAVE_BUILDID, test "$libbacktrace_cv_ld_buildid" = yes)
525
526 dnl Test whether the linker supports the --compress-debug-sections=zlib-gnu
527 dnl option.
528 AC_CACHE_CHECK([whether --compress-debug-sections=zlib-gnu is supported],
529 [libgo_cv_ld_compress_zlib_gnu],
530 [LDFLAGS_hold=$LDFLAGS
531 LDFLAGS="$LDFLAGS -Wl,--compress-debug-sections=zlib-gnu"
532 AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
533 [libgo_cv_ld_compress_zlib_gnu=yes],
534 [libgo_cv_ld_compress_zlib_gnu=no])
535 LDFLAGS=$LDFLAGS_hold])
536 AM_CONDITIONAL(HAVE_COMPRESSED_DEBUG_ZLIB_GNU, test "$libgo_cv_ld_compress_zlib_gnu" = yes)
537
538 AC_CACHE_CHECK([whether --compress-debug-sections=zlib-gabi is supported],
539 [libgo_cv_ld_compress_zlib_gabi],
540 [LDFLAGS_hold=$LDFLAGS
541 LDFLAGS="$LDFLAGS -Wl,--compress-debug-sections=zlib-gabi"
542 AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
543 [libgo_cv_ld_compress_zlib_gabi=yes],
544 [libgo_cv_ld_compress_zlib_gabi=no])
545 LDFLAGS=$LDFLAGS_hold])
546 AM_CONDITIONAL(HAVE_COMPRESSED_DEBUG_ZLIB_GABI, test "$libgo_cv_ld_compress_zlib_gabi" = yes)
547
548 AC_CHECK_LIB([zstd], [ZSTD_compress],
549 [AC_DEFINE(HAVE_ZSTD, 1, [Define if -lzstd is available.])])
550 AM_CONDITIONAL(HAVE_ZSTD, test "$ac_cv_lib_zstd_ZSTD_compress" = yes)
551
552 dnl Test whether the linker supports --compress-debug-sections=zstd option.
553 AC_CACHE_CHECK([whether --compress-debug-sections=zstd is supported],
554 [libgo_cv_ld_compress_zstd],
555 [LDFLAGS_hold=$LDFLAGS
556 LDFLAGS="$LDFLAGS -Wl,--compress-debug-sections=zstd"
557 AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
558 [libgo_cv_ld_compress_zstd=yes],
559 [libgo_cv_ld_compress_zstd=no])
560 LDFLAGS=$LDFLAGS_hold])
561 AM_CONDITIONAL(HAVE_COMPRESSED_DEBUG_ZSTD, test "$libgo_cv_ld_compress_zstd" = yes)
562
563 AC_ARG_VAR(OBJCOPY, [location of objcopy])
564 AC_CHECK_PROG(OBJCOPY, objcopy, objcopy,)
565 AC_CHECK_PROG(READELF, readelf, readelf)
566 AC_CACHE_CHECK([whether objcopy supports debuglink],
567 [libbacktrace_cv_objcopy_debuglink],
568 [if test -n "${with_target_subdir}"; then
569 libbacktrace_cv_objcopy_debuglink=no
570 elif ! test -n "${OBJCOPY}"; then
571 libbacktrace_cv_objcopy_debuglink=no
572 elif ${OBJCOPY} --help | grep add-gnu-debuglink >/dev/null 2>&1; then
573 libbacktrace_cv_objcopy_debuglink=yes
574 else
575 libbacktrace_cv_objcopy_debuglink=no
576 fi])
577 AM_CONDITIONAL(HAVE_OBJCOPY_DEBUGLINK, test "$libbacktrace_cv_objcopy_debuglink" = yes)
578
579 AC_ARG_VAR(DSYMUTIL, [location of dsymutil])
580 AC_CHECK_PROG(DSYMUTIL, dsymutil, dsymutil)
581 AM_CONDITIONAL(USE_DSYMUTIL, test -n "${DSYMUTIL}" -a "$FORMAT_FILE" = "macho.lo")
582
583 AC_ARG_VAR(NM, [location of nm])
584 AC_CHECK_PROG(NM, nm, nm)
585
586 AC_CHECK_PROG(XZ, xz, xz)
587 AM_CONDITIONAL(HAVE_XZ, test "$XZ" != "")
588 AC_CHECK_PROG(COMM, comm, comm)
589 AM_CONDITIONAL(HAVE_COMM, test "$COMM" != "")
590
591 AM_CONDITIONAL(HAVE_MINIDEBUG,
592 test "${with_target_subdir}" = "" -a "$FORMAT_FILE" = "elf.lo" -a "${OBJCOPY}" != "" -a "${NM}" != "" -a "${XZ}" != "" -a "${COMM}" != "")
593
594 AC_CHECK_LIB([lzma], [lzma_auto_decoder],
595 [AC_DEFINE(HAVE_LIBLZMA, 1, [Define if -llzma is available.])])
596 AM_CONDITIONAL(HAVE_LIBLZMA, test "$ac_cv_lib_lzma_lzma_auto_decoder" = yes)
597
598 AC_CACHE_CHECK([whether tests can run],
599 [libbacktrace_cv_sys_native],
600 [AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
601 [libbacktrace_cv_sys_native=yes],
602 [libbacktrace_cv_sys_native=no],
603 [libbacktrace_cv_sys_native=no])])
604 AM_CONDITIONAL(NATIVE, test "$libbacktrace_cv_sys_native" = "yes")
605
606 if test "${multilib}" = "yes"; then
607 multilib_arg="--enable-multilib"
608 else
609 multilib_arg=
610 fi
611
612 AC_CONFIG_FILES(Makefile backtrace-supported.h)
613 AC_CONFIG_FILES(install-debuginfo-for-buildid.sh, chmod +x install-debuginfo-for-buildid.sh)
614
615 # We need multilib support, but only if configuring for the target.
616 AC_CONFIG_COMMANDS([default],
617 [if test -n "$CONFIG_FILES"; then
618 if test -n "${with_target_subdir}"; then
619 # Multilibs need MULTISUBDIR defined correctly in certain makefiles so
620 # that multilib installs will end up installed in the correct place.
621 # The testsuite needs it for multilib-aware ABI baseline files.
622 # To work around this not being passed down from config-ml.in ->
623 # srcdir/Makefile.am -> srcdir/{src,libsupc++,...}/Makefile.am, manually
624 # append it here. Only modify Makefiles that have just been created.
625 #
626 # Also, get rid of this simulated-VPATH thing that automake does.
627 cat > vpsed << \_EOF
628 s!`test -f '$<' || echo '$(srcdir)/'`!!
629 _EOF
630 for i in $SUBDIRS; do
631 case $CONFIG_FILES in
632 *${i}/Makefile*)
633 #echo "Adding MULTISUBDIR to $i/Makefile"
634 sed -f vpsed $i/Makefile > tmp
635 grep '^MULTISUBDIR =' Makefile >> tmp
636 mv tmp $i/Makefile
637 ;;
638 esac
639 done
640 rm vpsed
641 fi
642 fi
643 ],
644 [
645 # Variables needed in config.status (file generation) which aren't already
646 # passed by autoconf.
647 SUBDIRS="$SUBDIRS"
648 ])
649
650 AC_OUTPUT