]> git.ipfire.org Git - thirdparty/gcc.git/blob - libbacktrace/configure.ac
configure.ac: Add AC_USE_SYSTEM_EXTENSIONS.
[thirdparty/gcc.git] / libbacktrace / configure.ac
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
32 AC_PREREQ(2.64)
33 AC_INIT(package-unused, version-unused,, libbacktrace)
34 AC_CONFIG_SRCDIR(backtrace.h)
35 AC_CONFIG_HEADER(config.h)
36
37 AC_CANONICAL_SYSTEM
38 target_alias=${target_alias-$host_alias}
39
40 AC_USE_SYSTEM_EXTENSIONS
41
42 libtool_VERSION=1:0:0
43 AC_SUBST(libtool_VERSION)
44
45 AM_INIT_AUTOMAKE([1.11.1 foreign no-dist no-define -Wall -Wno-portability])
46
47 AM_MAINTAINER_MODE
48
49 AC_ARG_WITH(target-subdir,
50 [ --with-target-subdir=SUBDIR Configuring in a subdirectory for target])
51
52 # We must force CC to /not/ be precious variables; otherwise
53 # the wrong, non-multilib-adjusted value will be used in multilibs.
54 # As a side effect, we have to subst CFLAGS ourselves.
55 m4_rename([_AC_ARG_VAR_PRECIOUS],[backtrace_PRECIOUS])
56 m4_define([_AC_ARG_VAR_PRECIOUS],[])
57 AC_PROG_CC
58 m4_rename_force([backtrace_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
59
60 AC_SUBST(CFLAGS)
61
62 AC_PROG_RANLIB
63
64 AC_PROG_AWK
65 case "$AWK" in
66 "") AC_MSG_ERROR([can't build without awk]) ;;
67 esac
68
69 LT_INIT([disable-shared])
70 AM_PROG_LIBTOOL
71
72 backtrace_supported=yes
73
74 if test -n "${with_target_subdir}"; then
75 # We are compiling a GCC library. We can assume that the unwind
76 # library exists.
77 AM_ENABLE_MULTILIB(, ..)
78 BACKTRACE_FILE="backtrace.lo simple.lo"
79 else
80 AC_CHECK_HEADER([unwind.h],
81 [AC_CHECK_FUNC([_Unwind_Backtrace],
82 [BACKTRACE_FILE="backtrace.lo simple.lo"],
83 [BACKTRACE_FILE="nounwind.lo"
84 backtrace_supported=no])],
85 [BACKTRACE_FILE="nounwind.lo"
86 backtrace_supported=no])
87 fi
88 AC_SUBST(BACKTRACE_FILE)
89
90 ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wstrict-prototypes \
91 -Wmissing-prototypes -Wold-style-definition \
92 -Wmissing-format-attribute -Wcast-qual],
93 [WARN_FLAGS])
94
95 if test "x$GCC" = "xyes"; then
96 WARN_FLAGS="$WARN_FLAGS -Werror"
97 fi
98
99 AC_SUBST(WARN_FLAGS)
100
101 GCC_CHECK_UNWIND_GETIPINFO
102
103 # When building as a target library, shared libraries may want to link
104 # this in. We don't want to provide another shared library to
105 # complicate dependencies. Instead, we just compile with -fPIC.
106 PIC_FLAG=
107 if test -n "${with_target_subdir}"; then
108 PIC_FLAG=-fPIC
109 fi
110 AC_SUBST(PIC_FLAG)
111
112 # Test for __sync support.
113 AC_CACHE_CHECK([__sync extensions],
114 [libbacktrace_cv_sys_sync],
115 [if test -n "${with_target_subdir}"; then
116 libbacktrace_cv_sys_sync=yes
117 else
118 AC_LINK_IFELSE(
119 [AC_LANG_PROGRAM([int i;],
120 [__sync_bool_compare_and_swap (&i, i, i);
121 __sync_lock_test_and_set (&i, 1);
122 __sync_lock_release (&i);])],
123 [libbacktrace_cv_sys_sync=yes],
124 [libbacktrace_cv_sys_sync=no])
125 fi])
126 BACKTRACE_SUPPORTS_THREADS=0
127 if test "$libbacktrace_cv_sys_sync" = "yes"; then
128 BACKTRACE_SUPPORTS_THREADS=1
129 AC_DEFINE([HAVE_SYNC_FUNCTIONS], 1,
130 [Define to 1 if you have the __sync functions])
131 fi
132 AC_SUBST(BACKTRACE_SUPPORTS_THREADS)
133
134 # The library needs to be able to read the executable itself. Compile
135 # a file to determine the executable format. The awk script
136 # filetype.awk prints out the file type.
137 AC_CACHE_CHECK([output filetype],
138 [libbacktrace_cv_sys_filetype],
139 [filetype=
140 AC_COMPILE_IFELSE(
141 [AC_LANG_PROGRAM([int i;], [int j;])],
142 [filetype=`${AWK} -f $srcdir/filetype.awk conftest.$ac_objext`],
143 [AC_MSG_FAILURE([compiler failed])])
144 libbacktrace_cv_sys_filetype=$filetype])
145
146 # Match the file type to decide what files to compile.
147 FORMAT_FILE=
148 case "$libbacktrace_cv_sys_filetype" in
149 elf*) FORMAT_FILE="elf.lo" ;;
150 *) AC_MSG_WARN([could not determine output file type])
151 FORMAT_FILE="unknown.lo"
152 backtrace_supported=no
153 ;;
154 esac
155 AC_SUBST(FORMAT_FILE)
156
157 # ELF defines.
158 elfsize=
159 case "$libbacktrace_cv_sys_filetype" in
160 elf32) elfsize=32 ;;
161 elf64) elfsize=64 ;;
162 esac
163 AC_DEFINE_UNQUOTED([BACKTRACE_ELF_SIZE], [$elfsize], [ELF size: 32 or 64])
164
165 BACKTRACE_SUPPORTED=0
166 if test "$backtrace_supported" = "yes"; then
167 BACKTRACE_SUPPORTED=1
168 fi
169 AC_SUBST(BACKTRACE_SUPPORTED)
170
171 AC_CHECK_HEADERS(sys/mman.h)
172 if test "$ac_cv_header_sys_mman_h" = "no"; then
173 have_mmap=no
174 else
175 if test -n "${with_target_subdir}"; then
176 # When built as a GCC target library, we can't do a link test. We
177 # simply assume that if we have mman.h, we have mmap.
178 have_mmap=yes
179 else
180 AC_CHECK_FUNC(mmap, [have_mmap=yes], [have_mmap=no])
181 fi
182 fi
183 if test "$have_mmap" = "no"; then
184 VIEW_FILE=read.lo
185 ALLOC_FILE=alloc.lo
186 else
187 VIEW_FILE=mmapio.lo
188 AC_PREPROC_IFELSE([
189 #include <sys/mman.h>
190 #if !defined(MAP_ANONYMOUS) && !defined(MAP_ANON)
191 #error no MAP_ANONYMOUS
192 #endif
193 ], [ALLOC_FILE=mmap.lo], [ALLOC_FILE=alloc.lo])
194 fi
195 AC_SUBST(VIEW_FILE)
196 AC_SUBST(ALLOC_FILE)
197
198 BACKTRACE_USES_MALLOC=0
199 if test "$ALLOC_FILE" = "alloc.lo"; then
200 BACKTRACE_USES_MALLOC=1
201 fi
202 AC_SUBST(BACKTRACE_USES_MALLOC)
203
204 AC_CHECK_DECLS(strnlen)
205
206 AC_CACHE_CHECK([whether tests can run],
207 [libbacktrace_cv_sys_native],
208 [AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
209 [libbacktrace_cv_sys_native=yes],
210 [libbacktrace_cv_sys_native=no],
211 [libbacktrace_cv_sys_native=no])])
212 AM_CONDITIONAL(NATIVE, test "$libbacktrace_cv_sys_native" = "yes")
213
214 if test "${multilib}" = "yes"; then
215 multilib_arg="--enable-multilib"
216 else
217 multilib_arg=
218 fi
219
220 AC_CONFIG_FILES(Makefile backtrace-supported.h)
221
222 # We need multilib support, but only if configuring for the target.
223 AC_CONFIG_COMMANDS([default],
224 [if test -n "$CONFIG_FILES"; then
225 if test -n "${with_target_subdir}"; then
226 # Multilibs need MULTISUBDIR defined correctly in certain makefiles so
227 # that multilib installs will end up installed in the correct place.
228 # The testsuite needs it for multilib-aware ABI baseline files.
229 # To work around this not being passed down from config-ml.in ->
230 # srcdir/Makefile.am -> srcdir/{src,libsupc++,...}/Makefile.am, manually
231 # append it here. Only modify Makefiles that have just been created.
232 #
233 # Also, get rid of this simulated-VPATH thing that automake does.
234 cat > vpsed << \_EOF
235 s!`test -f '$<' || echo '$(srcdir)/'`!!
236 _EOF
237 for i in $SUBDIRS; do
238 case $CONFIG_FILES in
239 *${i}/Makefile*)
240 #echo "Adding MULTISUBDIR to $i/Makefile"
241 sed -f vpsed $i/Makefile > tmp
242 grep '^MULTISUBDIR =' Makefile >> tmp
243 mv tmp $i/Makefile
244 ;;
245 esac
246 done
247 rm vpsed
248 fi
249 fi
250 ],
251 [
252 # Variables needed in config.status (file generation) which aren't already
253 # passed by autoconf.
254 SUBDIRS="$SUBDIRS"
255 ])
256
257 AC_OUTPUT