1 # configure.ac -- Backtrace configure script.
2 # Copyright (C) 2012 Free Software Foundation, Inc.
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
8 # (1) Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
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
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.
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.
33 AC_INIT(package-unused, version-unused,, libbacktrace)
34 AC_CONFIG_SRCDIR(backtrace.h)
35 AC_CONFIG_HEADER(config.h)
38 target_alias=${target_alias-$host_alias}
40 AC_USE_SYSTEM_EXTENSIONS
43 AC_SUBST(libtool_VERSION)
45 AM_INIT_AUTOMAKE([1.11.1 foreign no-dist no-define -Wall -Wno-portability])
49 AC_ARG_WITH(target-subdir,
50 [ --with-target-subdir=SUBDIR Configuring in a subdirectory for target])
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],[])
58 m4_rename_force([backtrace_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
66 "") AC_MSG_ERROR([can't build without awk]) ;;
69 LT_INIT([disable-shared])
72 backtrace_supported=yes
74 if test -n "${with_target_subdir}"; then
75 # We are compiling a GCC library. We can assume that the unwind
77 AM_ENABLE_MULTILIB(, ..)
78 BACKTRACE_FILE="backtrace.lo simple.lo"
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])
88 AC_SUBST(BACKTRACE_FILE)
90 ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wstrict-prototypes \
91 -Wmissing-prototypes -Wold-style-definition \
92 -Wmissing-format-attribute -Wcast-qual],
95 if test "x$GCC" = "xyes"; then
96 WARN_FLAGS="$WARN_FLAGS -Werror"
101 GCC_CHECK_UNWIND_GETIPINFO
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.
107 if test -n "${with_target_subdir}"; then
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
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])
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])
132 AC_SUBST(BACKTRACE_SUPPORTS_THREADS)
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],
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])
146 # Match the file type to decide what files to compile.
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
155 AC_SUBST(FORMAT_FILE)
159 case "$libbacktrace_cv_sys_filetype" in
163 AC_DEFINE_UNQUOTED([BACKTRACE_ELF_SIZE], [$elfsize], [ELF size: 32 or 64])
165 BACKTRACE_SUPPORTED=0
166 if test "$backtrace_supported" = "yes"; then
167 BACKTRACE_SUPPORTED=1
169 AC_SUBST(BACKTRACE_SUPPORTED)
171 AC_CHECK_HEADERS(sys/mman.h)
172 if test "$ac_cv_header_sys_mman_h" = "no"; then
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.
180 AC_CHECK_FUNC(mmap, [have_mmap=yes], [have_mmap=no])
183 if test "$have_mmap" = "no"; then
189 #include <sys/mman.h>
190 #if !defined(MAP_ANONYMOUS) && !defined(MAP_ANON)
191 #error no MAP_ANONYMOUS
193 ], [ALLOC_FILE=mmap.lo], [ALLOC_FILE=alloc.lo])
198 BACKTRACE_USES_MALLOC=0
199 if test "$ALLOC_FILE" = "alloc.lo"; then
200 BACKTRACE_USES_MALLOC=1
202 AC_SUBST(BACKTRACE_USES_MALLOC)
204 AC_CHECK_DECLS(strnlen)
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")
214 if test "${multilib}" = "yes"; then
215 multilib_arg="--enable-multilib"
220 AC_CONFIG_FILES(Makefile backtrace-supported.h)
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.
233 # Also, get rid of this simulated-VPATH thing that automake does.
235 s!`test -f '$<' || echo '$(srcdir)/'`!!
237 for i in $SUBDIRS; do
238 case $CONFIG_FILES in
240 #echo "Adding MULTISUBDIR to $i/Makefile"
241 sed -f vpsed $i/Makefile > tmp
242 grep '^MULTISUBDIR =' Makefile >> tmp
252 # Variables needed in config.status (file generation) which aren't already
253 # passed by autoconf.