]> git.ipfire.org Git - thirdparty/gcc.git/blame - libbacktrace/configure.ac
Update copyright years.
[thirdparty/gcc.git] / libbacktrace / configure.ac
CommitLineData
eff02e4f 1# configure.ac -- Backtrace configure script.
818ab71a 2# Copyright (C) 2012-2016 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
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
32AC_PREREQ(2.64)
33AC_INIT(package-unused, version-unused,, libbacktrace)
34AC_CONFIG_SRCDIR(backtrace.h)
35AC_CONFIG_HEADER(config.h)
36
405a6b1c
MK
37if test -n "${with_target_subdir}"; then
38 AM_ENABLE_MULTILIB(, ..)
39fi
40
eff02e4f
ILT
41AC_CANONICAL_SYSTEM
42target_alias=${target_alias-$host_alias}
43
d4c059d5
ILT
44AC_USE_SYSTEM_EXTENSIONS
45
eff02e4f
ILT
46libtool_VERSION=1:0:0
47AC_SUBST(libtool_VERSION)
48
af710874
ILT
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])
eff02e4f
ILT
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
7e5c7547 82LT_INIT
eff02e4f
ILT
83AM_PROG_LIBTOOL
84
85backtrace_supported=yes
86
87if test -n "${with_target_subdir}"; then
88 # We are compiling a GCC library. We can assume that the unwind
89 # library exists.
eff02e4f
ILT
90 BACKTRACE_FILE="backtrace.lo simple.lo"
91else
92 AC_CHECK_HEADER([unwind.h],
93 [AC_CHECK_FUNC([_Unwind_Backtrace],
94 [BACKTRACE_FILE="backtrace.lo simple.lo"],
95 [BACKTRACE_FILE="nounwind.lo"
96 backtrace_supported=no])],
97 [BACKTRACE_FILE="nounwind.lo"
98 backtrace_supported=no])
99fi
100AC_SUBST(BACKTRACE_FILE)
101
56195009 102EXTRA_FLAGS=
32061319 103if test -n "${with_target_subdir}"; then
36a58fb3 104 EXTRA_FLAGS="-funwind-tables -frandom-seed=\$@"
32061319
ILT
105else
106 AC_CACHE_CHECK([for -funwind-tables option],
107 [libbacktrace_cv_c_unwind_tables],
108 [CFLAGS_hold="$CFLAGS"
109 CFLAGS="$CFLAGS -funwind-tables"
110 AC_COMPILE_IFELSE(
111 [AC_LANG_PROGRAM([static int f() { return 0; }], [return f();])],
112 [libbacktrace_cv_c_unwind_tables=yes],
113 [libbacktrace_cv_c_unwind_tables=no])
114 CFLAGS="$CFLAGS_hold"])
36a58fb3
JJ
115 if test "$libbacktrace_cv_c_unwind_tables" = "yes"; then
116 EXTRA_FLAGS=-funwind-tables
117 fi
118 AC_CACHE_CHECK([for -frandom-seed=string option],
119 [libbacktrace_cv_c_random_seed_string],
120 [CFLAGS_hold="$CFLAGS"
121 CFLAGS="$CFLAGS -frandom-seed=conftest.lo"
122 AC_COMPILE_IFELSE(
123 [AC_LANG_PROGRAM([], [return 0;])],
124 [libbacktrace_cv_c_random_seed_string=yes],
125 [libbacktrace_cv_c_random_seed_string=no])
126 CFLAGS="$CFLAGS_hold"])
127 if test "$libbacktrace_cv_c_random_seed_string" = "yes"; then
128 EXTRA_FLAGS="$EXTRA_FLAGS -frandom-seed=\$@"
129 fi
56195009
UB
130fi
131AC_SUBST(EXTRA_FLAGS)
132
eff02e4f
ILT
133ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wstrict-prototypes \
134 -Wmissing-prototypes -Wold-style-definition \
135 -Wmissing-format-attribute -Wcast-qual],
136 [WARN_FLAGS])
137
73c3ed27 138if test -n "${with_target_subdir}"; then
eff02e4f
ILT
139 WARN_FLAGS="$WARN_FLAGS -Werror"
140fi
141
142AC_SUBST(WARN_FLAGS)
143
64b89453
ILT
144if test -n "${with_target_subdir}"; then
145 GCC_CHECK_UNWIND_GETIPINFO
146else
385710cf
JH
147 ac_save_CFFLAGS="$CFLAGS"
148 CFLAGS="$CFLAGS -Werror-implicit-function-declaration"
149 AC_MSG_CHECKING([for _Unwind_GetIPInfo])
63fefb4b 150 AC_LINK_IFELSE(
385710cf
JH
151 [AC_LANG_PROGRAM(
152 [#include "unwind.h"
153 struct _Unwind_Context *context;
154 int ip_before_insn = 0;],
155 [return _Unwind_GetIPInfo (context, &ip_before_insn);])],
156 [have_unwind_getipinfo=yes], [have_unwind_getipinfo=no])
157 CFLAGS="$ac_save_CFLAGS"
158 AC_MSG_RESULT([$have_unwind_getipinfo])
64b89453
ILT
159 if test "$have_unwind_getipinfo" = "yes"; then
160 AC_DEFINE(HAVE_GETIPINFO, 1, [Define if _Unwind_GetIPInfo is available.])
161 fi
162fi
eff02e4f 163
7e5c7547 164# Enable --enable-host-shared.
459260ec
DM
165AC_ARG_ENABLE(host-shared,
166[AS_HELP_STRING([--enable-host-shared],
167 [build host code as shared libraries])],
7e5c7547 168[PIC_FLAG=-fPIC], [PIC_FLAG=])
eff02e4f
ILT
169AC_SUBST(PIC_FLAG)
170
171# Test for __sync support.
172AC_CACHE_CHECK([__sync extensions],
173[libbacktrace_cv_sys_sync],
174[if test -n "${with_target_subdir}"; then
2f401a8f
JDA
175 case "${host}" in
176 hppa*-*-hpux*) libbacktrace_cv_sys_sync=no ;;
177 *) libbacktrace_cv_sys_sync=yes ;;
178 esac
eff02e4f
ILT
179 else
180 AC_LINK_IFELSE(
181 [AC_LANG_PROGRAM([int i;],
182 [__sync_bool_compare_and_swap (&i, i, i);
183 __sync_lock_test_and_set (&i, 1);
184 __sync_lock_release (&i);])],
185 [libbacktrace_cv_sys_sync=yes],
186 [libbacktrace_cv_sys_sync=no])
187 fi])
188BACKTRACE_SUPPORTS_THREADS=0
189if test "$libbacktrace_cv_sys_sync" = "yes"; then
190 BACKTRACE_SUPPORTS_THREADS=1
191 AC_DEFINE([HAVE_SYNC_FUNCTIONS], 1,
192 [Define to 1 if you have the __sync functions])
193fi
194AC_SUBST(BACKTRACE_SUPPORTS_THREADS)
195
49579c7e
ILT
196# Test for __atomic support.
197AC_CACHE_CHECK([__atomic extensions],
198[libbacktrace_cv_sys_atomic],
199[if test -n "${with_target_subdir}"; then
200 libbacktrace_cv_sys_atomic=yes
201 else
202 AC_LINK_IFELSE(
203 [AC_LANG_PROGRAM([int i;],
204 [__atomic_load_n (&i, __ATOMIC_ACQUIRE);
205 __atomic_store_n (&i, 1, __ATOMIC_RELEASE);])],
206 [libbacktrace_cv_sys_atomic=yes],
207 [libbacktrace_cv_sys_atomic=no])
208 fi])
209if test "$libbacktrace_cv_sys_atomic" = "yes"; then
210 AC_DEFINE([HAVE_ATOMIC_FUNCTIONS], 1,
211 [Define to 1 if you have the __atomic functions])
212fi
213
eff02e4f
ILT
214# The library needs to be able to read the executable itself. Compile
215# a file to determine the executable format. The awk script
216# filetype.awk prints out the file type.
217AC_CACHE_CHECK([output filetype],
218[libbacktrace_cv_sys_filetype],
219[filetype=
220AC_COMPILE_IFELSE(
221 [AC_LANG_PROGRAM([int i;], [int j;])],
222 [filetype=`${AWK} -f $srcdir/filetype.awk conftest.$ac_objext`],
223 [AC_MSG_FAILURE([compiler failed])])
224libbacktrace_cv_sys_filetype=$filetype])
225
226# Match the file type to decide what files to compile.
227FORMAT_FILE=
e24afc10 228backtrace_supports_data=yes
eff02e4f
ILT
229case "$libbacktrace_cv_sys_filetype" in
230elf*) FORMAT_FILE="elf.lo" ;;
e24afc10
TG
231pecoff) FORMAT_FILE="pecoff.lo"
232 backtrace_supports_data=no
233 ;;
eff02e4f
ILT
234*) AC_MSG_WARN([could not determine output file type])
235 FORMAT_FILE="unknown.lo"
236 backtrace_supported=no
237 ;;
238esac
239AC_SUBST(FORMAT_FILE)
240
241# ELF defines.
242elfsize=
243case "$libbacktrace_cv_sys_filetype" in
244elf32) elfsize=32 ;;
245elf64) elfsize=64 ;;
e24afc10 246*) elfsize=unused
eff02e4f
ILT
247esac
248AC_DEFINE_UNQUOTED([BACKTRACE_ELF_SIZE], [$elfsize], [ELF size: 32 or 64])
249
250BACKTRACE_SUPPORTED=0
251if test "$backtrace_supported" = "yes"; then
252 BACKTRACE_SUPPORTED=1
253fi
254AC_SUBST(BACKTRACE_SUPPORTED)
255
e24afc10
TG
256BACKTRACE_SUPPORTS_DATA=0
257if test "$backtrace_supports_data" = "yes"; then
258 BACKTRACE_SUPPORTS_DATA=1
259fi
260AC_SUBST(BACKTRACE_SUPPORTS_DATA)
261
76850556
RO
262GCC_HEADER_STDINT(gstdint.h)
263
eff02e4f
ILT
264AC_CHECK_HEADERS(sys/mman.h)
265if test "$ac_cv_header_sys_mman_h" = "no"; then
266 have_mmap=no
267else
268 if test -n "${with_target_subdir}"; then
269 # When built as a GCC target library, we can't do a link test. We
270 # simply assume that if we have mman.h, we have mmap.
271 have_mmap=yes
1b533361 272 case "${host}" in
5b4bbc7d 273 spu-*-*|*-*-msdosdjgpp)
1b533361
UW
274 # The SPU does not have mmap, but it has a sys/mman.h header file
275 # containing "mmap_eaddr" and the mmap flags, confusing the test.
5b4bbc7d 276 # DJGPP also has sys/man.h, but no mmap
1b533361
UW
277 have_mmap=no ;;
278 esac
eff02e4f
ILT
279 else
280 AC_CHECK_FUNC(mmap, [have_mmap=yes], [have_mmap=no])
281 fi
282fi
283if test "$have_mmap" = "no"; then
284 VIEW_FILE=read.lo
285 ALLOC_FILE=alloc.lo
286else
287 VIEW_FILE=mmapio.lo
288 AC_PREPROC_IFELSE([
289#include <sys/mman.h>
290#if !defined(MAP_ANONYMOUS) && !defined(MAP_ANON)
291 #error no MAP_ANONYMOUS
292#endif
293], [ALLOC_FILE=mmap.lo], [ALLOC_FILE=alloc.lo])
294fi
295AC_SUBST(VIEW_FILE)
296AC_SUBST(ALLOC_FILE)
297
298BACKTRACE_USES_MALLOC=0
299if test "$ALLOC_FILE" = "alloc.lo"; then
300 BACKTRACE_USES_MALLOC=1
301fi
302AC_SUBST(BACKTRACE_USES_MALLOC)
303
e561a992
ILT
304# Check for dl_iterate_phdr.
305AC_CHECK_HEADERS(link.h)
306if test "$ac_cv_header_link_h" = "no"; then
307 have_dl_iterate_phdr=no
308else
309 if test -n "${with_target_subdir}"; then
310 # When built as a GCC target library, we can't do a link test.
311 AC_EGREP_HEADER([dl_iterate_phdr], [link.h], [have_dl_iterate_phdr=yes],
312 [have_dl_iterate_phdr=no])
5551b12c
ILT
313 case "${host}" in
314 *-*-solaris2.10*)
315 # Avoid dl_iterate_phdr on Solaris 10, where it is in the
316 # header file but is only in -ldl.
317 have_dl_iterate_phdr=no ;;
318 esac
e561a992
ILT
319 else
320 AC_CHECK_FUNC([dl_iterate_phdr], [have_dl_iterate_phdr=yes],
321 [have_dl_iterate_phdr=no])
322 fi
323fi
324if test "$have_dl_iterate_phdr" = "yes"; then
325 AC_DEFINE(HAVE_DL_ITERATE_PHDR, 1, [Define if dl_iterate_phdr is available.])
326fi
327
3319ef17
ILT
328# Check for the fcntl function.
329if test -n "${with_target_subdir}"; then
330 case "${host}" in
331 *-*-mingw*) have_fcntl=no ;;
8f5027bf 332 spu-*-*) have_fcntl=no ;;
3319ef17
ILT
333 *) have_fcntl=yes ;;
334 esac
335else
336 AC_CHECK_FUNC(fcntl, [have_fcntl=yes], [have_fcntl=no])
337fi
338if test "$have_fcntl" = "yes"; then
339 AC_DEFINE([HAVE_FCNTL], 1,
340 [Define to 1 if you have the fcntl function])
341fi
342
772a71a9
ILT
343AC_CHECK_DECLS(strnlen)
344
33521509
ILT
345# Check for getexecname function.
346if test -n "${with_target_subdir}"; then
347 case "${host}" in
348 *-*-solaris2*) have_getexecname=yes ;;
349 *) have_getexecname=no ;;
350 esac
351else
352 AC_CHECK_FUNC(getexecname, [have_getexecname=yes], [have_getexecname=no])
353fi
354if test "$have_getexecname" = "yes"; then
355 AC_DEFINE(HAVE_GETEXECNAME, 1, [Define if getexecname is available.])
356fi
357
eff02e4f
ILT
358AC_CACHE_CHECK([whether tests can run],
359 [libbacktrace_cv_sys_native],
360 [AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
361 [libbacktrace_cv_sys_native=yes],
362 [libbacktrace_cv_sys_native=no],
363 [libbacktrace_cv_sys_native=no])])
364AM_CONDITIONAL(NATIVE, test "$libbacktrace_cv_sys_native" = "yes")
365
366if test "${multilib}" = "yes"; then
367 multilib_arg="--enable-multilib"
368else
369 multilib_arg=
370fi
371
372AC_CONFIG_FILES(Makefile backtrace-supported.h)
373
374# We need multilib support, but only if configuring for the target.
375AC_CONFIG_COMMANDS([default],
376[if test -n "$CONFIG_FILES"; then
377 if test -n "${with_target_subdir}"; then
378 # Multilibs need MULTISUBDIR defined correctly in certain makefiles so
379 # that multilib installs will end up installed in the correct place.
380 # The testsuite needs it for multilib-aware ABI baseline files.
381 # To work around this not being passed down from config-ml.in ->
382 # srcdir/Makefile.am -> srcdir/{src,libsupc++,...}/Makefile.am, manually
383 # append it here. Only modify Makefiles that have just been created.
384 #
385 # Also, get rid of this simulated-VPATH thing that automake does.
386 cat > vpsed << \_EOF
387 s!`test -f '$<' || echo '$(srcdir)/'`!!
388_EOF
389 for i in $SUBDIRS; do
390 case $CONFIG_FILES in
391 *${i}/Makefile*)
392 #echo "Adding MULTISUBDIR to $i/Makefile"
393 sed -f vpsed $i/Makefile > tmp
394 grep '^MULTISUBDIR =' Makefile >> tmp
395 mv tmp $i/Makefile
396 ;;
397 esac
398 done
399 rm vpsed
400 fi
401 fi
402],
403[
404# Variables needed in config.status (file generation) which aren't already
405# passed by autoconf.
406SUBDIRS="$SUBDIRS"
407])
408
409AC_OUTPUT