]> git.ipfire.org Git - thirdparty/gcc.git/blame - libbacktrace/configure.ac
MAINTAINERS (Write After Approval): Add myself.
[thirdparty/gcc.git] / libbacktrace / configure.ac
CommitLineData
eff02e4f
ILT
1# configure.ac -- Backtrace configure script.
2# Copyright (C) 2012 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
32AC_PREREQ(2.64)
33AC_INIT(package-unused, version-unused,, libbacktrace)
34AC_CONFIG_SRCDIR(backtrace.h)
35AC_CONFIG_HEADER(config.h)
36
37AC_CANONICAL_SYSTEM
38target_alias=${target_alias-$host_alias}
39
d4c059d5
ILT
40AC_USE_SYSTEM_EXTENSIONS
41
eff02e4f
ILT
42libtool_VERSION=1:0:0
43AC_SUBST(libtool_VERSION)
44
af710874
ILT
45# 1.11.1: Require that version of automake.
46# foreign: Don't require README, INSTALL, NEWS, etc.
47# no-define: Don't define PACKAGE and VERSION.
48# no-dependencies: Don't generate automatic dependencies.
49# (because it breaks when using bootstrap-lean, since some of the
50# headers are gone at "make install" time).
51# -Wall: Issue all automake warnings.
52# -Wno-portability: Don't warn about constructs supported by GNU make.
53# (because GCC requires GNU make anyhow).
54AM_INIT_AUTOMAKE([1.11.1 foreign no-dist no-define no-dependencies -Wall -Wno-portability])
eff02e4f
ILT
55
56AM_MAINTAINER_MODE
57
58AC_ARG_WITH(target-subdir,
59[ --with-target-subdir=SUBDIR Configuring in a subdirectory for target])
60
61# We must force CC to /not/ be precious variables; otherwise
62# the wrong, non-multilib-adjusted value will be used in multilibs.
63# As a side effect, we have to subst CFLAGS ourselves.
64m4_rename([_AC_ARG_VAR_PRECIOUS],[backtrace_PRECIOUS])
65m4_define([_AC_ARG_VAR_PRECIOUS],[])
66AC_PROG_CC
67m4_rename_force([backtrace_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
68
69AC_SUBST(CFLAGS)
70
71AC_PROG_RANLIB
72
73AC_PROG_AWK
74case "$AWK" in
75"") AC_MSG_ERROR([can't build without awk]) ;;
76esac
77
78LT_INIT([disable-shared])
79AM_PROG_LIBTOOL
80
81backtrace_supported=yes
82
83if test -n "${with_target_subdir}"; then
84 # We are compiling a GCC library. We can assume that the unwind
85 # library exists.
86 AM_ENABLE_MULTILIB(, ..)
87 BACKTRACE_FILE="backtrace.lo simple.lo"
88else
89 AC_CHECK_HEADER([unwind.h],
90 [AC_CHECK_FUNC([_Unwind_Backtrace],
91 [BACKTRACE_FILE="backtrace.lo simple.lo"],
92 [BACKTRACE_FILE="nounwind.lo"
93 backtrace_supported=no])],
94 [BACKTRACE_FILE="nounwind.lo"
95 backtrace_supported=no])
96fi
97AC_SUBST(BACKTRACE_FILE)
98
56195009
UB
99EXTRA_FLAGS=
100if test "x$GCC" = "xyes"; then
101 EXTRA_FLAGS=-funwind-tables
102fi
103AC_SUBST(EXTRA_FLAGS)
104
eff02e4f
ILT
105ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wstrict-prototypes \
106 -Wmissing-prototypes -Wold-style-definition \
107 -Wmissing-format-attribute -Wcast-qual],
108 [WARN_FLAGS])
109
110if test "x$GCC" = "xyes"; then
111 WARN_FLAGS="$WARN_FLAGS -Werror"
112fi
113
114AC_SUBST(WARN_FLAGS)
115
64b89453
ILT
116if test -n "${with_target_subdir}"; then
117 GCC_CHECK_UNWIND_GETIPINFO
118else
119 AC_CHECK_FUNC(_Unwind_GetIPInfo, [have_unwind_getipinfo=yes],
120 [have_unwind_getipinfo=no])
121 if test "$have_unwind_getipinfo" = "yes"; then
122 AC_DEFINE(HAVE_GETIPINFO, 1, [Define if _Unwind_GetIPInfo is available.])
123 fi
124fi
eff02e4f
ILT
125
126# When building as a target library, shared libraries may want to link
127# this in. We don't want to provide another shared library to
128# complicate dependencies. Instead, we just compile with -fPIC.
129PIC_FLAG=
130if test -n "${with_target_subdir}"; then
131 PIC_FLAG=-fPIC
132fi
133AC_SUBST(PIC_FLAG)
134
135# Test for __sync support.
136AC_CACHE_CHECK([__sync extensions],
137[libbacktrace_cv_sys_sync],
138[if test -n "${with_target_subdir}"; then
139 libbacktrace_cv_sys_sync=yes
140 else
141 AC_LINK_IFELSE(
142 [AC_LANG_PROGRAM([int i;],
143 [__sync_bool_compare_and_swap (&i, i, i);
144 __sync_lock_test_and_set (&i, 1);
145 __sync_lock_release (&i);])],
146 [libbacktrace_cv_sys_sync=yes],
147 [libbacktrace_cv_sys_sync=no])
148 fi])
149BACKTRACE_SUPPORTS_THREADS=0
150if test "$libbacktrace_cv_sys_sync" = "yes"; then
151 BACKTRACE_SUPPORTS_THREADS=1
152 AC_DEFINE([HAVE_SYNC_FUNCTIONS], 1,
153 [Define to 1 if you have the __sync functions])
154fi
155AC_SUBST(BACKTRACE_SUPPORTS_THREADS)
156
157# The library needs to be able to read the executable itself. Compile
158# a file to determine the executable format. The awk script
159# filetype.awk prints out the file type.
160AC_CACHE_CHECK([output filetype],
161[libbacktrace_cv_sys_filetype],
162[filetype=
163AC_COMPILE_IFELSE(
164 [AC_LANG_PROGRAM([int i;], [int j;])],
165 [filetype=`${AWK} -f $srcdir/filetype.awk conftest.$ac_objext`],
166 [AC_MSG_FAILURE([compiler failed])])
167libbacktrace_cv_sys_filetype=$filetype])
168
169# Match the file type to decide what files to compile.
170FORMAT_FILE=
171case "$libbacktrace_cv_sys_filetype" in
172elf*) FORMAT_FILE="elf.lo" ;;
173*) AC_MSG_WARN([could not determine output file type])
174 FORMAT_FILE="unknown.lo"
175 backtrace_supported=no
176 ;;
177esac
178AC_SUBST(FORMAT_FILE)
179
180# ELF defines.
181elfsize=
182case "$libbacktrace_cv_sys_filetype" in
183elf32) elfsize=32 ;;
184elf64) elfsize=64 ;;
185esac
186AC_DEFINE_UNQUOTED([BACKTRACE_ELF_SIZE], [$elfsize], [ELF size: 32 or 64])
187
188BACKTRACE_SUPPORTED=0
189if test "$backtrace_supported" = "yes"; then
190 BACKTRACE_SUPPORTED=1
191fi
192AC_SUBST(BACKTRACE_SUPPORTED)
193
76850556
RO
194GCC_HEADER_STDINT(gstdint.h)
195
eff02e4f
ILT
196AC_CHECK_HEADERS(sys/mman.h)
197if test "$ac_cv_header_sys_mman_h" = "no"; then
198 have_mmap=no
199else
200 if test -n "${with_target_subdir}"; then
201 # When built as a GCC target library, we can't do a link test. We
202 # simply assume that if we have mman.h, we have mmap.
203 have_mmap=yes
204 else
205 AC_CHECK_FUNC(mmap, [have_mmap=yes], [have_mmap=no])
206 fi
207fi
208if test "$have_mmap" = "no"; then
209 VIEW_FILE=read.lo
210 ALLOC_FILE=alloc.lo
211else
212 VIEW_FILE=mmapio.lo
213 AC_PREPROC_IFELSE([
214#include <sys/mman.h>
215#if !defined(MAP_ANONYMOUS) && !defined(MAP_ANON)
216 #error no MAP_ANONYMOUS
217#endif
218], [ALLOC_FILE=mmap.lo], [ALLOC_FILE=alloc.lo])
219fi
220AC_SUBST(VIEW_FILE)
221AC_SUBST(ALLOC_FILE)
222
223BACKTRACE_USES_MALLOC=0
224if test "$ALLOC_FILE" = "alloc.lo"; then
225 BACKTRACE_USES_MALLOC=1
226fi
227AC_SUBST(BACKTRACE_USES_MALLOC)
228
e561a992
ILT
229# Check for dl_iterate_phdr.
230AC_CHECK_HEADERS(link.h)
231if test "$ac_cv_header_link_h" = "no"; then
232 have_dl_iterate_phdr=no
233else
234 if test -n "${with_target_subdir}"; then
235 # When built as a GCC target library, we can't do a link test.
236 AC_EGREP_HEADER([dl_iterate_phdr], [link.h], [have_dl_iterate_phdr=yes],
237 [have_dl_iterate_phdr=no])
5551b12c
ILT
238 case "${host}" in
239 *-*-solaris2.10*)
240 # Avoid dl_iterate_phdr on Solaris 10, where it is in the
241 # header file but is only in -ldl.
242 have_dl_iterate_phdr=no ;;
243 esac
e561a992
ILT
244 else
245 AC_CHECK_FUNC([dl_iterate_phdr], [have_dl_iterate_phdr=yes],
246 [have_dl_iterate_phdr=no])
247 fi
248fi
249if test "$have_dl_iterate_phdr" = "yes"; then
250 AC_DEFINE(HAVE_DL_ITERATE_PHDR, 1, [Define if dl_iterate_phdr is available.])
251fi
252
3319ef17
ILT
253# Check for the fcntl function.
254if test -n "${with_target_subdir}"; then
255 case "${host}" in
256 *-*-mingw*) have_fcntl=no ;;
257 *) have_fcntl=yes ;;
258 esac
259else
260 AC_CHECK_FUNC(fcntl, [have_fcntl=yes], [have_fcntl=no])
261fi
262if test "$have_fcntl" = "yes"; then
263 AC_DEFINE([HAVE_FCNTL], 1,
264 [Define to 1 if you have the fcntl function])
265fi
266
772a71a9
ILT
267AC_CHECK_DECLS(strnlen)
268
eff02e4f
ILT
269AC_CACHE_CHECK([whether tests can run],
270 [libbacktrace_cv_sys_native],
271 [AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
272 [libbacktrace_cv_sys_native=yes],
273 [libbacktrace_cv_sys_native=no],
274 [libbacktrace_cv_sys_native=no])])
275AM_CONDITIONAL(NATIVE, test "$libbacktrace_cv_sys_native" = "yes")
276
277if test "${multilib}" = "yes"; then
278 multilib_arg="--enable-multilib"
279else
280 multilib_arg=
281fi
282
283AC_CONFIG_FILES(Makefile backtrace-supported.h)
284
285# We need multilib support, but only if configuring for the target.
286AC_CONFIG_COMMANDS([default],
287[if test -n "$CONFIG_FILES"; then
288 if test -n "${with_target_subdir}"; then
289 # Multilibs need MULTISUBDIR defined correctly in certain makefiles so
290 # that multilib installs will end up installed in the correct place.
291 # The testsuite needs it for multilib-aware ABI baseline files.
292 # To work around this not being passed down from config-ml.in ->
293 # srcdir/Makefile.am -> srcdir/{src,libsupc++,...}/Makefile.am, manually
294 # append it here. Only modify Makefiles that have just been created.
295 #
296 # Also, get rid of this simulated-VPATH thing that automake does.
297 cat > vpsed << \_EOF
298 s!`test -f '$<' || echo '$(srcdir)/'`!!
299_EOF
300 for i in $SUBDIRS; do
301 case $CONFIG_FILES in
302 *${i}/Makefile*)
303 #echo "Adding MULTISUBDIR to $i/Makefile"
304 sed -f vpsed $i/Makefile > tmp
305 grep '^MULTISUBDIR =' Makefile >> tmp
306 mv tmp $i/Makefile
307 ;;
308 esac
309 done
310 rm vpsed
311 fi
312 fi
313],
314[
315# Variables needed in config.status (file generation) which aren't already
316# passed by autoconf.
317SUBDIRS="$SUBDIRS"
318])
319
320AC_OUTPUT