]> git.ipfire.org Git - thirdparty/gcc.git/blame - libbacktrace/configure.ac
* tree-ssa-loop-ivcanon.c (try_peel_loop): Fix typo and remove dead
[thirdparty/gcc.git] / libbacktrace / configure.ac
CommitLineData
ecd3459e 1# configure.ac -- Backtrace configure script.
8e8f6434 2# Copyright (C) 2012-2018 Free Software Foundation, Inc.
ecd3459e 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
75c399ef 9# notice, this list of conditions and the following disclaimer.
ecd3459e 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
75c399ef 14# distribution.
15
ecd3459e 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
32AC_PREREQ(2.64)
33AC_INIT(package-unused, version-unused,, libbacktrace)
34AC_CONFIG_SRCDIR(backtrace.h)
35AC_CONFIG_HEADER(config.h)
36
8df488f9 37if test -n "${with_target_subdir}"; then
38 AM_ENABLE_MULTILIB(, ..)
39fi
40
ecd3459e 41AC_CANONICAL_SYSTEM
42target_alias=${target_alias-$host_alias}
43
30bd8e8b 44AC_USE_SYSTEM_EXTENSIONS
45
ecd3459e 46libtool_VERSION=1:0:0
47AC_SUBST(libtool_VERSION)
48
451b8929 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).
58AM_INIT_AUTOMAKE([1.11.1 foreign no-dist no-define no-dependencies -Wall -Wno-portability])
ecd3459e 59
60AM_MAINTAINER_MODE
61
62AC_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.
68m4_rename([_AC_ARG_VAR_PRECIOUS],[backtrace_PRECIOUS])
69m4_define([_AC_ARG_VAR_PRECIOUS],[])
70AC_PROG_CC
71m4_rename_force([backtrace_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
72
73AC_SUBST(CFLAGS)
74
75AC_PROG_RANLIB
76
77AC_PROG_AWK
78case "$AWK" in
79"") AC_MSG_ERROR([can't build without awk]) ;;
80esac
81
d0724418 82LT_INIT
ecd3459e 83AM_PROG_LIBTOOL
84
772d73b0 85AC_SYS_LARGEFILE
86
ecd3459e 87backtrace_supported=yes
88
89if test -n "${with_target_subdir}"; then
90 # We are compiling a GCC library. We can assume that the unwind
91 # library exists.
ecd3459e 92 BACKTRACE_FILE="backtrace.lo simple.lo"
93else
94 AC_CHECK_HEADER([unwind.h],
95 [AC_CHECK_FUNC([_Unwind_Backtrace],
96 [BACKTRACE_FILE="backtrace.lo simple.lo"],
97 [BACKTRACE_FILE="nounwind.lo"
98 backtrace_supported=no])],
99 [BACKTRACE_FILE="nounwind.lo"
100 backtrace_supported=no])
101fi
102AC_SUBST(BACKTRACE_FILE)
103
536b8dd3 104EXTRA_FLAGS=
ff2fe13c 105if test -n "${with_target_subdir}"; then
a7ebc02e 106 EXTRA_FLAGS="-funwind-tables -frandom-seed=\$@"
ff2fe13c 107else
108 AC_CACHE_CHECK([for -funwind-tables option],
109 [libbacktrace_cv_c_unwind_tables],
110 [CFLAGS_hold="$CFLAGS"
111 CFLAGS="$CFLAGS -funwind-tables"
112 AC_COMPILE_IFELSE(
113 [AC_LANG_PROGRAM([static int f() { return 0; }], [return f();])],
114 [libbacktrace_cv_c_unwind_tables=yes],
115 [libbacktrace_cv_c_unwind_tables=no])
116 CFLAGS="$CFLAGS_hold"])
a7ebc02e 117 if test "$libbacktrace_cv_c_unwind_tables" = "yes"; then
118 EXTRA_FLAGS=-funwind-tables
119 fi
120 AC_CACHE_CHECK([for -frandom-seed=string option],
121 [libbacktrace_cv_c_random_seed_string],
122 [CFLAGS_hold="$CFLAGS"
123 CFLAGS="$CFLAGS -frandom-seed=conftest.lo"
124 AC_COMPILE_IFELSE(
125 [AC_LANG_PROGRAM([], [return 0;])],
126 [libbacktrace_cv_c_random_seed_string=yes],
127 [libbacktrace_cv_c_random_seed_string=no])
128 CFLAGS="$CFLAGS_hold"])
129 if test "$libbacktrace_cv_c_random_seed_string" = "yes"; then
130 EXTRA_FLAGS="$EXTRA_FLAGS -frandom-seed=\$@"
131 fi
536b8dd3 132fi
b2a9aeb7 133
134if test -n "${with_target_subdir}"; then
135 # Add CET specific flags is Intel CET is enabled.
136 GCC_CET_FLAGS(CET_FLAGS)
137 EXTRA_FLAGS="$EXTRA_FLAGS $CET_FLAGS"
138fi
536b8dd3 139AC_SUBST(EXTRA_FLAGS)
140
ecd3459e 141ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wstrict-prototypes \
142 -Wmissing-prototypes -Wold-style-definition \
143 -Wmissing-format-attribute -Wcast-qual],
144 [WARN_FLAGS])
145
47b4f489 146if test -n "${with_target_subdir}"; then
ecd3459e 147 WARN_FLAGS="$WARN_FLAGS -Werror"
148fi
149
150AC_SUBST(WARN_FLAGS)
151
837eabff 152if test -n "${with_target_subdir}"; then
153 GCC_CHECK_UNWIND_GETIPINFO
154else
a4a5a77a 155 ac_save_CFFLAGS="$CFLAGS"
156 CFLAGS="$CFLAGS -Werror-implicit-function-declaration"
157 AC_MSG_CHECKING([for _Unwind_GetIPInfo])
2ee407b0 158 AC_LINK_IFELSE(
a4a5a77a 159 [AC_LANG_PROGRAM(
160 [#include "unwind.h"
161 struct _Unwind_Context *context;
162 int ip_before_insn = 0;],
163 [return _Unwind_GetIPInfo (context, &ip_before_insn);])],
164 [have_unwind_getipinfo=yes], [have_unwind_getipinfo=no])
165 CFLAGS="$ac_save_CFLAGS"
166 AC_MSG_RESULT([$have_unwind_getipinfo])
837eabff 167 if test "$have_unwind_getipinfo" = "yes"; then
168 AC_DEFINE(HAVE_GETIPINFO, 1, [Define if _Unwind_GetIPInfo is available.])
169 fi
170fi
ecd3459e 171
d0724418 172# Enable --enable-host-shared.
2bd17377 173AC_ARG_ENABLE(host-shared,
174[AS_HELP_STRING([--enable-host-shared],
175 [build host code as shared libraries])],
d0724418 176[PIC_FLAG=-fPIC], [PIC_FLAG=])
ecd3459e 177AC_SUBST(PIC_FLAG)
178
179# Test for __sync support.
180AC_CACHE_CHECK([__sync extensions],
181[libbacktrace_cv_sys_sync],
182[if test -n "${with_target_subdir}"; then
ab861c80 183 case "${host}" in
184 hppa*-*-hpux*) libbacktrace_cv_sys_sync=no ;;
185 *) libbacktrace_cv_sys_sync=yes ;;
186 esac
ecd3459e 187 else
188 AC_LINK_IFELSE(
189 [AC_LANG_PROGRAM([int i;],
190 [__sync_bool_compare_and_swap (&i, i, i);
191 __sync_lock_test_and_set (&i, 1);
192 __sync_lock_release (&i);])],
193 [libbacktrace_cv_sys_sync=yes],
194 [libbacktrace_cv_sys_sync=no])
195 fi])
196BACKTRACE_SUPPORTS_THREADS=0
197if test "$libbacktrace_cv_sys_sync" = "yes"; then
198 BACKTRACE_SUPPORTS_THREADS=1
199 AC_DEFINE([HAVE_SYNC_FUNCTIONS], 1,
200 [Define to 1 if you have the __sync functions])
201fi
202AC_SUBST(BACKTRACE_SUPPORTS_THREADS)
203
bcafb4a8 204# Test for __atomic support.
205AC_CACHE_CHECK([__atomic extensions],
206[libbacktrace_cv_sys_atomic],
207[if test -n "${with_target_subdir}"; then
208 libbacktrace_cv_sys_atomic=yes
209 else
210 AC_LINK_IFELSE(
211 [AC_LANG_PROGRAM([int i;],
212 [__atomic_load_n (&i, __ATOMIC_ACQUIRE);
213 __atomic_store_n (&i, 1, __ATOMIC_RELEASE);])],
214 [libbacktrace_cv_sys_atomic=yes],
215 [libbacktrace_cv_sys_atomic=no])
216 fi])
217if test "$libbacktrace_cv_sys_atomic" = "yes"; then
218 AC_DEFINE([HAVE_ATOMIC_FUNCTIONS], 1,
219 [Define to 1 if you have the __atomic functions])
220fi
221
ecd3459e 222# The library needs to be able to read the executable itself. Compile
223# a file to determine the executable format. The awk script
224# filetype.awk prints out the file type.
225AC_CACHE_CHECK([output filetype],
226[libbacktrace_cv_sys_filetype],
227[filetype=
228AC_COMPILE_IFELSE(
229 [AC_LANG_PROGRAM([int i;], [int j;])],
230 [filetype=`${AWK} -f $srcdir/filetype.awk conftest.$ac_objext`],
231 [AC_MSG_FAILURE([compiler failed])])
232libbacktrace_cv_sys_filetype=$filetype])
233
234# Match the file type to decide what files to compile.
235FORMAT_FILE=
48ee217e 236backtrace_supports_data=yes
ecd3459e 237case "$libbacktrace_cv_sys_filetype" in
238elf*) FORMAT_FILE="elf.lo" ;;
48ee217e 239pecoff) FORMAT_FILE="pecoff.lo"
240 backtrace_supports_data=no
241 ;;
0a83c23a 242xcoff*) FORMAT_FILE="xcoff.lo"
243 backtrace_supports_data=no
244 ;;
ecd3459e 245*) AC_MSG_WARN([could not determine output file type])
246 FORMAT_FILE="unknown.lo"
247 backtrace_supported=no
248 ;;
249esac
250AC_SUBST(FORMAT_FILE)
251
252# ELF defines.
253elfsize=
254case "$libbacktrace_cv_sys_filetype" in
255elf32) elfsize=32 ;;
256elf64) elfsize=64 ;;
48ee217e 257*) elfsize=unused
ecd3459e 258esac
259AC_DEFINE_UNQUOTED([BACKTRACE_ELF_SIZE], [$elfsize], [ELF size: 32 or 64])
260
0a83c23a 261# XCOFF defines.
262xcoffsize=
263case "$libbacktrace_cv_sys_filetype" in
264xcoff32) xcoffsize=32 ;;
265xcoff64) xcoffsize=64 ;;
266*) xcoffsize=unused
267esac
268AC_DEFINE_UNQUOTED([BACKTRACE_XCOFF_SIZE], [$xcoffsize], [XCOFF size: 32 or 64])
269
ecd3459e 270BACKTRACE_SUPPORTED=0
271if test "$backtrace_supported" = "yes"; then
272 BACKTRACE_SUPPORTED=1
273fi
274AC_SUBST(BACKTRACE_SUPPORTED)
275
48ee217e 276BACKTRACE_SUPPORTS_DATA=0
277if test "$backtrace_supports_data" = "yes"; then
278 BACKTRACE_SUPPORTS_DATA=1
279fi
280AC_SUBST(BACKTRACE_SUPPORTS_DATA)
281
b945b61c 282GCC_HEADER_STDINT(gstdint.h)
283
ecd3459e 284AC_CHECK_HEADERS(sys/mman.h)
285if test "$ac_cv_header_sys_mman_h" = "no"; then
286 have_mmap=no
287else
288 if test -n "${with_target_subdir}"; then
289 # When built as a GCC target library, we can't do a link test. We
290 # simply assume that if we have mman.h, we have mmap.
291 have_mmap=yes
de04a87e 292 case "${host}" in
b767924b 293 spu-*-*|*-*-msdosdjgpp)
de04a87e 294 # The SPU does not have mmap, but it has a sys/mman.h header file
295 # containing "mmap_eaddr" and the mmap flags, confusing the test.
b767924b 296 # DJGPP also has sys/man.h, but no mmap
de04a87e 297 have_mmap=no ;;
298 esac
ecd3459e 299 else
300 AC_CHECK_FUNC(mmap, [have_mmap=yes], [have_mmap=no])
301 fi
302fi
303if test "$have_mmap" = "no"; then
304 VIEW_FILE=read.lo
305 ALLOC_FILE=alloc.lo
306else
307 VIEW_FILE=mmapio.lo
308 AC_PREPROC_IFELSE([
309#include <sys/mman.h>
310#if !defined(MAP_ANONYMOUS) && !defined(MAP_ANON)
311 #error no MAP_ANONYMOUS
312#endif
313], [ALLOC_FILE=mmap.lo], [ALLOC_FILE=alloc.lo])
314fi
315AC_SUBST(VIEW_FILE)
316AC_SUBST(ALLOC_FILE)
317
318BACKTRACE_USES_MALLOC=0
319if test "$ALLOC_FILE" = "alloc.lo"; then
320 BACKTRACE_USES_MALLOC=1
321fi
322AC_SUBST(BACKTRACE_USES_MALLOC)
323
1bfb5d87 324# Check for dl_iterate_phdr.
325AC_CHECK_HEADERS(link.h)
326if test "$ac_cv_header_link_h" = "no"; then
327 have_dl_iterate_phdr=no
328else
329 if test -n "${with_target_subdir}"; then
330 # When built as a GCC target library, we can't do a link test.
331 AC_EGREP_HEADER([dl_iterate_phdr], [link.h], [have_dl_iterate_phdr=yes],
332 [have_dl_iterate_phdr=no])
90de4704 333 case "${host}" in
334 *-*-solaris2.10*)
335 # Avoid dl_iterate_phdr on Solaris 10, where it is in the
336 # header file but is only in -ldl.
337 have_dl_iterate_phdr=no ;;
338 esac
1bfb5d87 339 else
340 AC_CHECK_FUNC([dl_iterate_phdr], [have_dl_iterate_phdr=yes],
341 [have_dl_iterate_phdr=no])
342 fi
343fi
344if test "$have_dl_iterate_phdr" = "yes"; then
345 AC_DEFINE(HAVE_DL_ITERATE_PHDR, 1, [Define if dl_iterate_phdr is available.])
346fi
347
0a83c23a 348# Check for loadquery.
349AC_CHECK_HEADERS(sys/ldr.h)
350if test "$ac_cv_header_sys_ldr_h" = "no"; then
351 have_loadquery=no
352else
353 if test -n "${with_target_subdir}"; then
354 # When built as a GCC target library, we can't do a link test.
355 AC_EGREP_HEADER([loadquery], [sys/ldr.h], [have_loadquery=yes],
356 [have_loadquery=no])
357 else
358 AC_CHECK_FUNC([loadquery], [have_loadquery=yes],
359 [have_loadquery=no])
360 fi
361fi
362if test "$have_loadquery" = "yes"; then
363 AC_DEFINE(HAVE_LOADQUERY, 1, [Define if AIX loadquery is available.])
364fi
365
7341e544 366# Check for the fcntl function.
367if test -n "${with_target_subdir}"; then
368 case "${host}" in
369 *-*-mingw*) have_fcntl=no ;;
b2d409ee 370 spu-*-*) have_fcntl=no ;;
7341e544 371 *) have_fcntl=yes ;;
372 esac
373else
374 AC_CHECK_FUNC(fcntl, [have_fcntl=yes], [have_fcntl=no])
375fi
376if test "$have_fcntl" = "yes"; then
377 AC_DEFINE([HAVE_FCNTL], 1,
378 [Define to 1 if you have the fcntl function])
379fi
380
5f7c240f 381AC_CHECK_DECLS(strnlen)
7b3574e4 382AC_CHECK_FUNCS(lstat readlink)
5f7c240f 383
686b3772 384# Check for getexecname function.
385if test -n "${with_target_subdir}"; then
386 case "${host}" in
387 *-*-solaris2*) have_getexecname=yes ;;
388 *) have_getexecname=no ;;
389 esac
390else
391 AC_CHECK_FUNC(getexecname, [have_getexecname=yes], [have_getexecname=no])
392fi
393if test "$have_getexecname" = "yes"; then
394 AC_DEFINE(HAVE_GETEXECNAME, 1, [Define if getexecname is available.])
395fi
396
c476d11e 397# Check for the clock_gettime function.
398AC_CHECK_FUNCS(clock_gettime)
0b986d3d 399clock_gettime_link=
400# At least for glibc, clock_gettime is in librt. But don't
401# pull that in if it still doesn't give us the function we want. This
402# test is copied from libgomp, and modified to not link in -lrt as
403# we're using this for test timing only.
404if test "$ac_cv_func_clock_gettime" = no; then
405 AC_CHECK_LIB(rt, clock_gettime,
bf821bfd 406 [CLOCK_GETTIME_LINK=-lrt
0b986d3d 407 AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
408 [Define to 1 if you have the `clock_gettime' function.])])
409fi
bf821bfd 410AC_SUBST(CLOCK_GETTIME_LINK)
c476d11e 411
3be33b09 412dnl Test whether the compiler supports the -pthread option.
413AC_CACHE_CHECK([whether -pthread is supported],
414[libgo_cv_lib_pthread],
415[CFLAGS_hold=$CFLAGS
416CFLAGS="$CFLAGS -pthread"
417AC_COMPILE_IFELSE([[int i;]],
418[libgo_cv_lib_pthread=yes],
419[libgo_cv_lib_pthread=no])
420CFLAGS=$CFLAGS_hold])
421PTHREAD_CFLAGS=
422if test "$libgo_cv_lib_pthread" = yes; then
423 PTHREAD_CFLAGS=-pthread
424fi
425AC_SUBST(PTHREAD_CFLAGS)
426
427AM_CONDITIONAL(HAVE_PTHREAD, test "$libgo_cv_lib_pthread" = yes)
428
c7e50530 429AC_CHECK_LIB([z], [compress],
430 [AC_DEFINE(HAVE_ZLIB, 1, [Define if -lz is available.])])
1fffcf69 431AM_CONDITIONAL(HAVE_ZLIB, test "$ac_cv_lib_z_compress" = yes)
432
433dnl Test whether the linker supports the --compress_debug_sections option.
434AC_CACHE_CHECK([whether --compress-debug-sections is supported],
435[libgo_cv_ld_compress],
436[LDFLAGS_hold=$LDFLAGS
437LDFLAGS="$LDFLAGS -Wl,--compress-debug-sections=zlib-gnu"
438AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
439[libgo_cv_ld_compress=yes],
440[libgo_cv_ld_compress=no])
441LDFLAGS=$LDFLAGS_hold])
442AM_CONDITIONAL(HAVE_COMPRESSED_DEBUG, test "$libgo_cv_ld_compress" = yes)
443
b919941e 444AC_ARG_VAR(OBJCOPY, [location of objcopy])
445AC_CHECK_PROG(OBJCOPY, objcopy, objcopy,)
446AC_CACHE_CHECK([whether objcopy supports debuglink],
447[libbacktrace_cv_objcopy_debuglink],
448[if test -n "${with_target_subdir}"; then
449 libbacktrace_cv_objcopy_debuglink=no
450elif ${OBJCOPY} --add-gnu-debuglink=x /bin/ls /tmp/ls$$; then
451 rm -f /tmp/ls$$
452 libbacktrace_cv_objcopy_debuglink=yes
453else
454 libbacktrace_cv_objcopy_debuglink=no
455fi])
456AM_CONDITIONAL(HAVE_OBJCOPY_DEBUGLINK, test "$libbacktrace_cv_objcopy_debuglink" = yes)
457
ecd3459e 458AC_CACHE_CHECK([whether tests can run],
459 [libbacktrace_cv_sys_native],
460 [AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
461 [libbacktrace_cv_sys_native=yes],
462 [libbacktrace_cv_sys_native=no],
463 [libbacktrace_cv_sys_native=no])])
464AM_CONDITIONAL(NATIVE, test "$libbacktrace_cv_sys_native" = "yes")
465
466if test "${multilib}" = "yes"; then
467 multilib_arg="--enable-multilib"
468else
469 multilib_arg=
470fi
471
472AC_CONFIG_FILES(Makefile backtrace-supported.h)
473
474# We need multilib support, but only if configuring for the target.
475AC_CONFIG_COMMANDS([default],
476[if test -n "$CONFIG_FILES"; then
477 if test -n "${with_target_subdir}"; then
478 # Multilibs need MULTISUBDIR defined correctly in certain makefiles so
479 # that multilib installs will end up installed in the correct place.
480 # The testsuite needs it for multilib-aware ABI baseline files.
481 # To work around this not being passed down from config-ml.in ->
482 # srcdir/Makefile.am -> srcdir/{src,libsupc++,...}/Makefile.am, manually
483 # append it here. Only modify Makefiles that have just been created.
484 #
485 # Also, get rid of this simulated-VPATH thing that automake does.
486 cat > vpsed << \_EOF
487 s!`test -f '$<' || echo '$(srcdir)/'`!!
488_EOF
489 for i in $SUBDIRS; do
490 case $CONFIG_FILES in
491 *${i}/Makefile*)
492 #echo "Adding MULTISUBDIR to $i/Makefile"
493 sed -f vpsed $i/Makefile > tmp
494 grep '^MULTISUBDIR =' Makefile >> tmp
495 mv tmp $i/Makefile
496 ;;
497 esac
498 done
499 rm vpsed
500 fi
501 fi
502],
503[
504# Variables needed in config.status (file generation) which aren't already
505# passed by autoconf.
506SUBDIRS="$SUBDIRS"
507])
508
509AC_OUTPUT